Compare commits
47 Commits
2f7a94b5de
...
1.1-a
Author | SHA1 | Date | |
---|---|---|---|
580c5b6611 | |||
8f0ffb7041 | |||
0494efc2ad | |||
09871e8727 | |||
d220a03a89 | |||
95b2c1e70b | |||
4005a39696
|
|||
407a5d32a5 | |||
81ab379e0e
|
|||
5a4d30b9f8
|
|||
5c92f74ceb
|
|||
0906b95273
|
|||
4c9c7a3aa4 | |||
07ad6cb59d | |||
fcd27175ac | |||
a9c5282bdc | |||
52386c1987 | |||
fb59407f8b | |||
1261b80346 | |||
a1b7569ef0 | |||
d1bc545a07
|
|||
9c184c08a8
|
|||
186f1e693c
|
|||
3e6e44c4b3
|
|||
da80ba3abd
|
|||
f05f4fbbad
|
|||
91a8b0380b
|
|||
3b196de1d8
|
|||
b4beaf4f94
|
|||
85c9bd50cd | |||
e6e9d7e082
|
|||
d3d7bd391b | |||
3142cd79f6
|
|||
e6d8a5b7aa | |||
821162964b
|
|||
fa0905486a | |||
c0d5908a6e
|
|||
d0598853bd | |||
3a62d99c40
|
|||
9dfdd328db | |||
286109dc38
|
|||
fd77fbd97e | |||
69d8ae9d7a
|
|||
08bdb6f481 | |||
fc9f054dec
|
|||
f33906b965 | |||
be208912b7
|
@ -1,22 +1,40 @@
|
||||
name: Gitea Actions Demo
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions
|
||||
name: Gitea Android Builder
|
||||
run-name: ${{ gitea.actor }} is building an Android application
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- pipeline-test
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
runs-on: ubuntu-22.04
|
||||
Build:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||
- run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||
- run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
- name: Check out repository code
|
||||
- name: Checkout the repo
|
||||
uses: actions/checkout@v4
|
||||
- run: echo "The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||
- run: echo "The workflow is now ready to test your code on the runner."
|
||||
- name: List files in the repository
|
||||
run: |
|
||||
ls ${{ gitea.workspace }}
|
||||
- run: echo "This job's status is ${{ job.status }}."
|
||||
- name: Set up JDK 23
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '23'
|
||||
distribution: 'temurin'
|
||||
- name: Set up Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Cache Gradle packages
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
- name: Build with Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: assembleDebug
|
||||
- name: Upload .apk Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: android-app-apk
|
||||
path: app/build/outputs/apk/debug/*.apk
|
||||
- name: Status
|
||||
run: echo "This job's status is ${{ job.status }}."
|
||||
|
40
.gitea/workflows/debug.yaml
Normal file
@ -0,0 +1,40 @@
|
||||
name: Gitea Android Builder
|
||||
run-name: ${{ gitea.actor }} is building an Android application
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
Build:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout the repo
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up JDK 23
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '23'
|
||||
distribution: 'temurin'
|
||||
- name: Set up Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Cache Gradle packages
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
- name: Build with Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: assembleDebug
|
||||
- name: Upload .apk Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: android-app-apk
|
||||
path: app/build/outputs/apk/debug/*.apk
|
||||
- name: Status
|
||||
run: echo "This job's status is ${{ job.status }}."
|
7
.gitignore
vendored
@ -1,12 +1,7 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
/.idea
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
|
1
.idea/gradle.xml
generated
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
|
1
.idea/misc.xml
generated
@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||
|
@ -56,4 +56,11 @@ dependencies {
|
||||
androidTestImplementation(libs.androidx.ui.test.junit4)
|
||||
debugImplementation(libs.androidx.ui.tooling)
|
||||
debugImplementation(libs.androidx.ui.test.manifest)
|
||||
|
||||
implementation(libs.retrofit)
|
||||
implementation(libs.converter.gson)
|
||||
implementation(libs.kotlinx.coroutines.android)
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
implementation(libs.vico.compose.m3)
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
|
BIN
app/src/main/ic_launcher-playstore.png
Normal file
After Width: | Height: | Size: 36 KiB |
@ -0,0 +1,22 @@
|
||||
package ru.vendetti.bitcoin_summarizer
|
||||
|
||||
import retrofit2.Response
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Query
|
||||
|
||||
// Retrofit-API-интерфейс
|
||||
interface CryptoApiService {
|
||||
// Получение индекса страха и жадности (по умолчанию за 30 дней)
|
||||
@GET("fng/")
|
||||
suspend fun getFearAndGreedIndex(
|
||||
@Query("limit") limit: Int = 30
|
||||
): Response<FearAndGreedResponse>
|
||||
|
||||
// Получение глобальной информации
|
||||
@GET("v1/global/")
|
||||
suspend fun getGlobalData(): Response<GlobalResponse>
|
||||
|
||||
// Получение данных Bitcoin
|
||||
@GET("v1/ticker/bitcoin/")
|
||||
suspend fun getBitcoinTicker(): Response<TickerResponse>
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package ru.vendetti.bitcoin_summarizer
|
||||
|
||||
//Репозиторий для обработки запросов
|
||||
class CryptoRepository(private val apiService: CryptoApiService) {
|
||||
/**
|
||||
* Запрашивает данные для Bitcoin-тикера
|
||||
*/
|
||||
suspend fun fetchBitcoinTicker(): TickerResponse? {
|
||||
return try {
|
||||
val response = apiService.getBitcoinTicker()
|
||||
if (response.isSuccessful) {
|
||||
response.body()
|
||||
} else {
|
||||
println("Ошибка запроса Bitcoin Ticker: ${response.code()}")
|
||||
null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
println("Exception при получении Bitcoin Ticker: ${e.localizedMessage}")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Запрашивает глобальные данные крипторынка
|
||||
*/
|
||||
suspend fun fetchGlobalData(): GlobalResponse? {
|
||||
return try {
|
||||
val response = apiService.getGlobalData()
|
||||
if (response.isSuccessful) {
|
||||
response.body()
|
||||
} else {
|
||||
println("Ошибка запроса Global Data: ${response.code()}")
|
||||
null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
println("Exception при получении Global Data: ${e.localizedMessage}")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Запрашивает индекс страха и жадности за указанный период (по умолчанию 30 дней)
|
||||
*/
|
||||
suspend fun fetchFearAndGreedData(limit: Int = 30): FearAndGreedResponse? {
|
||||
return try {
|
||||
val response = apiService.getFearAndGreedIndex(limit)
|
||||
if (response.isSuccessful) {
|
||||
response.body()
|
||||
} else {
|
||||
println("Ошибка запроса Fear & Greed Index: ${response.code()}")
|
||||
null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
println("Exception при получении Fear & Greed Index: ${e.localizedMessage}")
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package ru.vendetti.bitcoin_summarizer
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
// Обёртка для данных (тут вложенность есть и это API v2, а не v1, поэтому чуть сложнее структура, чем в GlobalResponse.kt)
|
||||
data class FearAndGreedResponse(
|
||||
@SerializedName("name")
|
||||
val name: String,
|
||||
@SerializedName("data")
|
||||
val dataList: List<FearAndGreedData>
|
||||
)
|
||||
|
||||
// Сами данные
|
||||
data class FearAndGreedData(
|
||||
@SerializedName("value")
|
||||
val value: String,
|
||||
@SerializedName("value_classification")
|
||||
val valueClassification: String,
|
||||
@SerializedName("timestamp")
|
||||
val timestamp: String,
|
||||
@SerializedName("time_until_update")
|
||||
val timeUntilUpdate: String
|
||||
)
|
@ -0,0 +1,11 @@
|
||||
package ru.vendetti.bitcoin_summarizer
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
// Данные
|
||||
data class GlobalResponse(
|
||||
@SerializedName("active_currencies") val activeCryptocurrencies: String = "",
|
||||
@SerializedName("total_market_cap_usd") val totalMarketCapUsd: String = "",
|
||||
@SerializedName("total_24h_volume_usd") val total24hVolumeUsd: String = "",
|
||||
@SerializedName("bitcoin_percentage_of_market_cap") val bitcoinPercentageOfMarketCap: String = "0.0"
|
||||
)
|
@ -1,47 +1,309 @@
|
||||
package ru.vendetti.bitcoin_summarizer
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.magnifier
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material.icons.filled.MoreVert
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.MediumTopAppBar
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.rememberTopAppBarState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.TextUnit
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.patrykandpatrick.vico.compose.cartesian.CartesianChartHost
|
||||
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberAxisLabelComponent
|
||||
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberAxisLineComponent
|
||||
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberBottom
|
||||
import com.patrykandpatrick.vico.compose.cartesian.axis.rememberStart
|
||||
import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLine
|
||||
import com.patrykandpatrick.vico.compose.cartesian.layer.rememberLineCartesianLayer
|
||||
import com.patrykandpatrick.vico.compose.cartesian.rememberCartesianChart
|
||||
import com.patrykandpatrick.vico.compose.cartesian.rememberVicoZoomState
|
||||
import com.patrykandpatrick.vico.compose.common.component.rememberLineComponent
|
||||
import com.patrykandpatrick.vico.compose.common.component.rememberTextComponent
|
||||
import com.patrykandpatrick.vico.compose.common.component.shapeComponent
|
||||
import com.patrykandpatrick.vico.compose.common.fill
|
||||
import com.patrykandpatrick.vico.compose.common.shape.rounded
|
||||
import com.patrykandpatrick.vico.compose.common.vicoTheme
|
||||
import com.patrykandpatrick.vico.core.cartesian.Zoom
|
||||
import com.patrykandpatrick.vico.core.cartesian.axis.BaseAxis
|
||||
import com.patrykandpatrick.vico.core.cartesian.axis.HorizontalAxis
|
||||
import com.patrykandpatrick.vico.core.cartesian.axis.VerticalAxis
|
||||
import com.patrykandpatrick.vico.core.cartesian.data.CartesianChartModelProducer
|
||||
import com.patrykandpatrick.vico.core.cartesian.data.CartesianLayerRangeProvider
|
||||
import com.patrykandpatrick.vico.core.cartesian.data.lineSeries
|
||||
import com.patrykandpatrick.vico.core.cartesian.decoration.HorizontalLine
|
||||
import com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer
|
||||
import com.patrykandpatrick.vico.core.common.Position
|
||||
import com.patrykandpatrick.vico.core.common.component.LineComponent
|
||||
import com.patrykandpatrick.vico.core.common.component.TextComponent
|
||||
import com.patrykandpatrick.vico.core.common.shape.CorneredShape
|
||||
import ru.vendetti.bitcoin_summarizer.ui.theme.BitcoinSummarizerTheme
|
||||
import ru.vendetti.bitcoin_summarizer.ui.theme.EnglishViolet
|
||||
import ru.vendetti.bitcoin_summarizer.ui.theme.Flame
|
||||
import ru.vendetti.bitcoin_summarizer.ui.theme.Green2
|
||||
import java.text.DateFormat
|
||||
import java.text.DecimalFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.Date
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
setContent {
|
||||
BitcoinSummarizerTheme {
|
||||
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
|
||||
Greeting(
|
||||
name = "Android",
|
||||
modifier = Modifier.padding(innerPadding)
|
||||
)
|
||||
}
|
||||
CryptoScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MutableCollectionMutableState", "SimpleDateFormat")
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Preview
|
||||
@Composable
|
||||
fun Greeting(name: String, modifier: Modifier = Modifier) {
|
||||
fun CryptoScreen() {
|
||||
// Создаем репозиторий для работы с API
|
||||
val cryptoRepository = remember { CryptoRepository(RetrofitClient.apiService) }
|
||||
// Состояния для хранения результатов запросов
|
||||
var bitcoinTicker by remember { mutableStateOf(TickerData()) }
|
||||
var globalData by remember { mutableStateOf(GlobalResponse()) }
|
||||
var fearGreedDataList by remember { mutableStateOf(ArrayList<FearAndGreedData>()) }
|
||||
|
||||
var fearGreedIndexDaysCount by remember { mutableIntStateOf(30) }
|
||||
|
||||
// Запускаем корутину для выполнения сетевых запросов
|
||||
LaunchedEffect(fearGreedIndexDaysCount) {
|
||||
// Запрос Bitcoin Ticker
|
||||
val tickerResponse = cryptoRepository.fetchBitcoinTicker()
|
||||
bitcoinTicker = tickerResponse!!.first()
|
||||
|
||||
// Запрос глобальных данных
|
||||
val globalResponse = cryptoRepository.fetchGlobalData()
|
||||
globalData = globalResponse!!
|
||||
|
||||
// Запрос индекса страха и жадности
|
||||
val fearResponse = cryptoRepository.fetchFearAndGreedData(fearGreedIndexDaysCount)
|
||||
fearGreedDataList = fearResponse?.dataList as ArrayList<FearAndGreedData>
|
||||
}
|
||||
|
||||
val modelProducer = remember { CartesianChartModelProducer() }
|
||||
|
||||
LaunchedEffect(fearGreedDataList) {
|
||||
modelProducer.runTransaction {
|
||||
var numberValues = Array<Int>(fearGreedDataList.count()) {
|
||||
index ->
|
||||
fearGreedDataList[fearGreedDataList.count() - index - 1]
|
||||
.value.toInt()
|
||||
}
|
||||
|
||||
if(numberValues.isEmpty())
|
||||
numberValues = Array<Int>(1) {0}
|
||||
|
||||
lineSeries { series(numberValues.toList()) }
|
||||
}
|
||||
}
|
||||
|
||||
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
|
||||
val zoomState = rememberVicoZoomState(
|
||||
zoomEnabled = false,
|
||||
initialZoom = Zoom.x(fearGreedIndexDaysCount.toDouble()))
|
||||
|
||||
// Отображаем результаты на странице
|
||||
Scaffold (
|
||||
modifier = Modifier
|
||||
.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
|
||||
topBar = {
|
||||
MediumTopAppBar(
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
scrolledContainerColor = MaterialTheme.colorScheme.primary,
|
||||
titleContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||
navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||
actionIconContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||
),
|
||||
title = {
|
||||
Text(
|
||||
text = "Hello $name!",
|
||||
modifier = modifier
|
||||
"Bitcoin Summarizer!",
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = {}) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Menu,
|
||||
contentDescription = "Navigation hamburger menu"
|
||||
)
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
IconButton(onClick = {}) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.MoreVert,
|
||||
contentDescription = "Actions"
|
||||
)
|
||||
}
|
||||
},
|
||||
scrollBehavior = scrollBehavior
|
||||
)
|
||||
},
|
||||
)
|
||||
{ innerPadding ->
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.background(Color.Transparent)
|
||||
.padding(innerPadding)
|
||||
.verticalScroll(rememberScrollState())
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(16.dp, 16.dp, 16.dp, 36.dp)
|
||||
) {
|
||||
/* Fear Greed Chart Start */
|
||||
CartesianChartHost(
|
||||
zoomState = zoomState,
|
||||
chart = rememberCartesianChart(
|
||||
rememberLineCartesianLayer(
|
||||
lineProvider = LineCartesianLayer.LineProvider.series(
|
||||
vicoTheme.lineCartesianLayerColors.map{
|
||||
_ ->
|
||||
LineCartesianLayer
|
||||
.rememberLine(
|
||||
LineCartesianLayer.LineFill.single(
|
||||
fill(MaterialTheme.colorScheme.onPrimary)
|
||||
)
|
||||
)
|
||||
}
|
||||
),
|
||||
rangeProvider = remember { CartesianLayerRangeProvider.fixed(minY = 0.0, maxY = 100.0)}
|
||||
),
|
||||
startAxis = VerticalAxis.rememberStart(
|
||||
title = "FGI",
|
||||
titleComponent = rememberTextComponent(MaterialTheme.colorScheme.onPrimary),
|
||||
line = rememberAxisLineComponent(fill(MaterialTheme.colorScheme.onPrimary)),
|
||||
label = rememberAxisLabelComponent(MaterialTheme.colorScheme.onPrimary)
|
||||
),
|
||||
bottomAxis = HorizontalAxis.rememberBottom(
|
||||
title = "last $fearGreedIndexDaysCount days",
|
||||
titleComponent = rememberTextComponent(MaterialTheme.colorScheme.onPrimary),
|
||||
line = rememberAxisLineComponent(fill(MaterialTheme.colorScheme.onPrimary)),
|
||||
label = rememberAxisLabelComponent(MaterialTheme.colorScheme.onPrimary)
|
||||
),
|
||||
decorations = listOf(
|
||||
remember {
|
||||
HorizontalLine(
|
||||
y = { 25.toDouble() },
|
||||
line = LineComponent(fill(Flame), 2f),
|
||||
labelComponent = TextComponent(
|
||||
background =
|
||||
shapeComponent(
|
||||
fill(Flame),
|
||||
CorneredShape.rounded(
|
||||
topLeft = 4.dp,
|
||||
topRight = 4.dp
|
||||
)
|
||||
),
|
||||
),
|
||||
label = { "Fear" },
|
||||
verticalLabelPosition = Position.Vertical.Top
|
||||
)
|
||||
},
|
||||
remember {
|
||||
HorizontalLine(
|
||||
y = { 70.toDouble() },
|
||||
line = LineComponent(fill(Green2), 2f),
|
||||
labelComponent = TextComponent(
|
||||
background =
|
||||
shapeComponent(
|
||||
fill(Green2),
|
||||
CorneredShape.rounded(
|
||||
bottomLeft = 4.dp,
|
||||
bottomRight = 4.dp
|
||||
)
|
||||
),
|
||||
),
|
||||
label = { "Greed" },
|
||||
verticalLabelPosition = Position.Vertical.Bottom
|
||||
)
|
||||
}
|
||||
),
|
||||
),
|
||||
modelProducer = modelProducer,
|
||||
)
|
||||
/* Fear Greed Chart End */
|
||||
HorizontalDivider(thickness = 2.dp)
|
||||
Text(
|
||||
"Данные о Биткойне",
|
||||
modifier = Modifier
|
||||
.align(alignment = Alignment.CenterHorizontally),
|
||||
fontSize = 24.sp
|
||||
)
|
||||
val formatter = DecimalFormat("0.00")
|
||||
Text("Текущая цена: \n \$ ${formatter.format(bitcoinTicker.priceUsd.toFloat())}\n")
|
||||
Text("Суточный оборот: \n \$ ${bitcoinTicker.volume24hUsd}\n")
|
||||
Text("Капитализация: \n \$ ${bitcoinTicker.marketCapUsd}\n")
|
||||
Text(
|
||||
"Изменение курса за: " +
|
||||
"\n Сутки: ${formatter.format(bitcoinTicker.percentChange24h.toFloat())}% " +
|
||||
"\n Неделю: ${formatter.format(bitcoinTicker.percentChange7d.toFloat())}%\n"
|
||||
)
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun GreetingPreview() {
|
||||
BitcoinSummarizerTheme {
|
||||
Greeting("Android")
|
||||
var humanDate = ""
|
||||
|
||||
if(bitcoinTicker.lastUpdated.isNotEmpty())
|
||||
humanDate = DateTimeFormatter.ISO_INSTANT
|
||||
.format(java.time.Instant.ofEpochSecond(bitcoinTicker.lastUpdated.toLong()))
|
||||
|
||||
Text("Дата последнего обновления: \n ${humanDate}\n")
|
||||
|
||||
HorizontalDivider(thickness = 2.dp)
|
||||
Text(
|
||||
"Глобальные данные",
|
||||
modifier = Modifier
|
||||
.align(alignment = Alignment.CenterHorizontally),
|
||||
fontSize = 24.sp
|
||||
)
|
||||
Text("Общая капитализация крипторынка: \n \$ ${globalData.totalMarketCapUsd}\n")
|
||||
Text("Всего видов криптовалют: \n ${globalData.activeCryptocurrencies}\n")
|
||||
Text("Суточный оборот других криптовалют: \n \$ ${globalData.total24hVolumeUsd}\n")
|
||||
Text("Процент доминации Биткоина: \n ${formatter.format(globalData.bitcoinPercentageOfMarketCap.toFloat())}%\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package ru.vendetti.bitcoin_summarizer
|
||||
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
|
||||
object RetrofitClient {
|
||||
private const val BASE_URL = "https://api.alternative.me/"
|
||||
|
||||
val apiService: CryptoApiService by lazy {
|
||||
Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build()
|
||||
.create(CryptoApiService::class.java)
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package ru.vendetti.bitcoin_summarizer
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
// Обёртка для данных (тут json-массив с одним элементом, поэтому выглядит так)
|
||||
typealias TickerResponse = List<TickerData>
|
||||
|
||||
// Сами данные
|
||||
data class TickerData(
|
||||
val id: String = "",
|
||||
val name: String = "",
|
||||
val symbol: String = "",
|
||||
val rank: String = "",
|
||||
@SerializedName("price_usd") val priceUsd: String = "0.0",
|
||||
@SerializedName("price_btc") val priceBtc: String = "0.0",
|
||||
@SerializedName("24h_volume_usd") val volume24hUsd: String = "0",
|
||||
@SerializedName("market_cap_usd") val marketCapUsd: String = "0",
|
||||
@SerializedName("available_supply") val availableSupply: String = "0",
|
||||
@SerializedName("total_supply") val totalSupply: String = "0",
|
||||
@SerializedName("max_supply") val maxSupply: String? = "0",
|
||||
@SerializedName("percent_change_1h") val percentChange1h: String = "0",
|
||||
@SerializedName("percent_change_24h") val percentChange24h: String = "0.0",
|
||||
@SerializedName("percent_change_7d") val percentChange7d: String = "0.0",
|
||||
@SerializedName("last_updated") val lastUpdated: String = ""
|
||||
)
|
@ -9,3 +9,11 @@ val Pink80 = Color(0xFFEFB8C8)
|
||||
val Purple40 = Color(0xFF6650a4)
|
||||
val PurpleGrey40 = Color(0xFF625b71)
|
||||
val Pink40 = Color(0xFF7D5260)
|
||||
|
||||
val EnglishViolet = Color(0xFF44355B)
|
||||
val DarkPurple = Color(0xFF31263E)
|
||||
val RaisinBlack = Color(0xFF221E22)
|
||||
val HunyadiYellow = Color(0xFFECA72C)
|
||||
val Flame = Color(0xFFEE5622)
|
||||
|
||||
val Green2 = Color(0xFFB1E434)
|
@ -9,43 +9,45 @@ import androidx.compose.material3.dynamicDarkColorScheme
|
||||
import androidx.compose.material3.dynamicLightColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
primary = Purple80,
|
||||
secondary = PurpleGrey80,
|
||||
tertiary = Pink80
|
||||
primary = RaisinBlack,
|
||||
secondary = DarkPurple,
|
||||
tertiary = EnglishViolet,
|
||||
|
||||
// Other default colors to override
|
||||
background = DarkPurple,
|
||||
surface = Color(0xFFFFFBFE),
|
||||
onPrimary = HunyadiYellow,
|
||||
onSecondary = HunyadiYellow,
|
||||
onTertiary = HunyadiYellow,
|
||||
onBackground = HunyadiYellow,
|
||||
onSurface = Color(0xFF1C1B1F),
|
||||
)
|
||||
|
||||
private val LightColorScheme = lightColorScheme(
|
||||
primary = Purple40,
|
||||
secondary = PurpleGrey40,
|
||||
tertiary = Pink40
|
||||
primary = HunyadiYellow,
|
||||
secondary = Flame,
|
||||
tertiary = EnglishViolet,
|
||||
|
||||
/* Other default colors to override
|
||||
background = Color(0xFFFFFBFE),
|
||||
// Other default colors to override
|
||||
background = Color.White,
|
||||
surface = Color(0xFFFFFBFE),
|
||||
onPrimary = Color.White,
|
||||
onPrimary = RaisinBlack,
|
||||
onSecondary = Color.White,
|
||||
onTertiary = Color.White,
|
||||
onBackground = Color(0xFF1C1B1F),
|
||||
onBackground = RaisinBlack,
|
||||
onSurface = Color(0xFF1C1B1F),
|
||||
*/
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun BitcoinSummarizerTheme(
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
// Dynamic color is available on Android 12+
|
||||
dynamicColor: Boolean = true,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
val colorScheme = when {
|
||||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||
val context = LocalContext.current
|
||||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||
}
|
||||
|
||||
darkTheme -> DarkColorScheme
|
||||
else -> LightColorScheme
|
||||
}
|
||||
|
6
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<monochrome android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
6
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
<monochrome android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.5 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp
Normal file
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 982 B After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp
Normal file
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 3.0 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp
Normal file
After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 4.6 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp
Normal file
After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 6.1 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp
Normal file
After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 11 KiB |
4
app/src/main/res/values/ic_launcher_background.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#FFFFFF</color>
|
||||
</resources>
|
@ -21,3 +21,5 @@ kotlin.code.style=official
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
@ -1,16 +1,22 @@
|
||||
[versions]
|
||||
agp = "8.8.1"
|
||||
agp = "8.8.2"
|
||||
converterGson = "2.9.0"
|
||||
kotlin = "2.0.0"
|
||||
coreKtx = "1.10.1"
|
||||
coreKtx = "1.15.0"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.1.5"
|
||||
espressoCore = "3.5.1"
|
||||
lifecycleRuntimeKtx = "2.6.1"
|
||||
activityCompose = "1.8.0"
|
||||
composeBom = "2024.04.01"
|
||||
junitVersion = "1.2.1"
|
||||
espressoCore = "3.6.1"
|
||||
kotlinxCoroutinesAndroid = "1.7.3"
|
||||
kotlinxCoroutinesCore = "1.7.3"
|
||||
lifecycleRuntimeKtx = "2.8.7"
|
||||
activityCompose = "1.10.1"
|
||||
composeBom = "2025.02.00"
|
||||
retrofit = "2.9.0"
|
||||
vico = "2.0.2"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "converterGson" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
@ -24,6 +30,10 @@ androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-toolin
|
||||
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinxCoroutinesAndroid" }
|
||||
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutinesCore" }
|
||||
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
|
||||
vico-compose-m3 = { group = "com.patrykandpatrick.vico", name = "compose-m3", version.ref = "vico" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|