Skip to content

Commit 0d5897c

Browse files
committed
Added CoinPaprika exchange.
Added Verus token.
1 parent d73f972 commit 0d5897c

File tree

10 files changed

+43
-20
lines changed

10 files changed

+43
-20
lines changed

.idea/kotlinc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bitcoin/build.gradle

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
id 'kotlin-android'
44
id 'com.google.devtools.ksp'
55
id 'org.jetbrains.kotlin.android'
6-
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.24'
6+
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.25'
77
}
88

99
android {
@@ -13,8 +13,8 @@ android {
1313
applicationId "com.brentpanther.bitcoinwidget"
1414
minSdk 23
1515
targetSdk 34
16-
versionCode 331
17-
versionName "8.5.6"
16+
versionCode 332
17+
versionName "8.5.7"
1818

1919
}
2020

@@ -68,13 +68,13 @@ dependencies {
6868
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3'
6969
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
7070
implementation 'androidx.preference:preference-ktx:1.2.1'
71-
implementation 'androidx.work:work-runtime:2.9.0'
72-
implementation 'androidx.activity:activity-ktx:1.9.0'
73-
implementation 'androidx.activity:activity-compose:1.9.0'
71+
implementation 'androidx.work:work-runtime:2.9.1'
72+
implementation 'androidx.activity:activity-ktx:1.9.1'
73+
implementation 'androidx.activity:activity-compose:1.9.1'
7474
implementation "androidx.compose.ui:ui"
7575
implementation "androidx.compose.ui:ui-tooling-preview"
7676
implementation 'androidx.compose.material:material'
77-
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3'
77+
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.8.4'
7878
implementation 'androidx.navigation:navigation-compose:2.7.7'
7979
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
8080
implementation 'io.coil-kt:coil-compose:2.7.0'

bitcoin/src/main/java/com/brentpanther/bitcoinwidget/Coin.kt

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ enum class Coin(val coinName: String, val coinGeckoId: String, private vararg va
141141
UMA("UMA", "uma", IconTheme(SOLID, ic_uma)),
142142
UNI("Uniswap", "uniswap", IconTheme(SOLID, ic_uni)),
143143
VET("VeChain", "vechain", IconTheme(SOLID, ic_vet)),
144+
VRSC("Verus Coin", "verus-coin", IconTheme(SOLID, ic_vrsc)),
144145
VTC("Vertcoin", "vertcoin", IconTheme(SOLID, ic_vtc)),
145146
WAVES("Waves", "waves", IconTheme(SOLID, ic_waves)),
146147
WBTC("Wrapped Bitcoin", "wrapped-bitcoin", IconTheme(SOLID, ic_wbtc)),

bitcoin/src/main/java/com/brentpanther/bitcoinwidget/exchange/Exchange.kt

+12
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,18 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
261261
return getJsonObject(url)["tickers"]?.jsonArray?.get(0)?.jsonObject?.get("last").asString
262262
}
263263
},
264+
COINPAPRIKA("Coinpaprika") {
265+
override fun getValue(coin: String, currency: String): String? {
266+
// since we can't look up by symbol, first search for id
267+
val searchUrl = "https://api.coinpaprika.com/v1/search/?q=$coin&c=currencies&modifier=symbol_search"
268+
val id = getJsonObject(searchUrl)["currencies"]?.jsonArray?.firstOrNull {
269+
it.jsonObject["symbol"].asString == coin
270+
}?.jsonObject?.get("id").asString ?: return null
271+
val url = "https://api.coinpaprika.com/v1/tickers/$id"
272+
return getJsonObject(url)["quotes"]?.jsonObject?.get(currency)?.jsonObject?.get("price").asString
273+
}
274+
275+
},
264276
COINSBIT("Coinsbit") {
265277
override fun getValue(coin: String, currency: String): String? {
266278
val coinName = if (coin == "WBTC") "wBTC" else coin
3.81 KB
Loading

bitcoin/src/main/res/raw/cryptowidgetcoins_v2.json

+1-1
Large diffs are not rendered by default.

bitcoin/src/main/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<item>ISO</item>
9797
<item>NONE</item>
9898
</string-array>
99-
<string name="json_last_modified" translatable="false">Mon, 22 Jul 2024 22:48:01 GMT</string>
99+
<string name="json_last_modified" translatable="false">Sun, 11 Aug 2024 19:22:27 GMT</string>
100100
<string name="json_url" translatable="false">https://www.brentpanther.com/cryptowidgetcoins_v2.json</string>
101101

102102
<string name="error_restricted_battery_saver">Unable to refresh, Battery Saver is on</string>

bitcoin/src/test/java/com/brentpanther/bitcoinwidget/GenerateSupportedCoinsJson.kt

+12-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class GenerateSupportedCoinsJson {
4141
this::bitpanda, this::bitpay, this::bitso, this::bitstamp, this::bittrex, this::bitrue,
4242
this::bitvavo, this::btcbox, this::btcmarkets, this::btcturk, this::bybit, this::cexio,
4343
this::chilebit, this::coinbase, this::coinbasepro, this::coindesk, this::coingecko,
44-
this::coinjar, this::coinmate, this::coinone, this::coinsbit, this::coinsph, this::cointree,
44+
this::coinjar, this::coinmate, this::coinone, this::coinpaprika, this::coinsbit, this::coinsph, this::cointree,
4545
this::cryptocom, this::deversifi, this::digifinex, this::egera, this::exmo, this::foxbit, this::gateio, this::gemini,
4646
this::hashkey, this::hitbtc, this::huobi, this::independent_reserve, this::indodax, this::itbit,
4747
this::korbit, this::kraken, this::kucoin, this::kuna, this::lbank, this::luno,
@@ -433,6 +433,13 @@ class GenerateSupportedCoinsJson {
433433
}
434434
}
435435

436+
private fun coinpaprika(): List<String> {
437+
val currencies = listOf("BTC", "ETH", "USD", "EUR", "PLN", "KRW", "GBP", "CAD", "JPY", "RUB", "TRY", "NZD", "AUD", "CHF", "UAH", "HKD", "SGD", "NGN", "PHP", "MXN", "BRL", "THB", "CLP", "CNY", "CZK", "DKK", "HUF", "IDR", "ILS", "INR", "MYR", "NOK", "PKR", "SEK", "TWD", "ZAR", "VND", "BOB", "COP", "PEN", "ARS", "ISK")
438+
val coins = parse("https://api.coinpaprika.com/v1/coins", "$[*][?(@.is_active==true)].symbol")
439+
.filterNot { it == "XBT" }
440+
return coins.flatMap { coin -> currencies.filterNot { it == coin }.map { currency -> "$coin-$currency" } }
441+
}
442+
436443
private fun coinsbit(): List<String> {
437444
return parse("https://coinsbit.io/api/v1/public/products", "$.result[*].id")
438445
}
@@ -572,8 +579,8 @@ class GenerateSupportedCoinsJson {
572579
}
573580

574581
private fun phemex(): List<String> {
575-
val list = JsonPath.read(get("https://api.phemex.com/public/products"),
576-
"$.data.products.[?(@.status == 'Listed' && @.type == 'Spot')]") as List<Map<String, *>>
582+
val path = "$.data.products.[?(@.status == 'Listed' && @.type == 'Spot')]"
583+
val list = JsonPath.read(get("https://api.phemex.com/public/products"), path) as List<Map<String, *>>
577584
return list.map { "${it["baseCurrency"]}-${it["quoteCurrency"]}" }
578585
}
579586

@@ -586,7 +593,8 @@ class GenerateSupportedCoinsJson {
586593
}
587594

588595
private fun tradeogre(): List<String> {
589-
val list = JsonPath.read(get("https://tradeogre.com/api/v1/markets"), "$[*]") as List<Map<String, *>>
596+
val path = "$[*]"
597+
val list = JsonPath.read(get("https://tradeogre.com/api/v1/markets"), path) as List<Map<String, *>>
590598
return list.map { it.keys.first().split("-").reversed().joinToString("_") }
591599
}
592600

build.gradle

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.compose_compiler_version = '1.5.14'
4+
ext.compose_compiler_version = '1.5.15'
55

6-
ext.kotlin_version = '1.9.24'
6+
ext.kotlin_version = '1.9.25'
77
repositories {
88
google()
99
mavenCentral()
1010
gradlePluginPortal()
1111
}
1212
dependencies {
13-
classpath 'com.android.tools.build:gradle:8.5.0'
14-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24"
13+
classpath 'com.android.tools.build:gradle:8.5.2'
14+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25"
1515

1616
// NOTE: Do not place your application dependencies here; they belong
1717
// in the individual module build.gradle files
1818
}
1919
}
2020

2121
plugins {
22-
id 'com.google.devtools.ksp' version '1.9.24-1.0.20' apply false
23-
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.24'
22+
id 'com.google.devtools.ksp' version '1.9.25-1.0.20' apply false
23+
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.25'
2424
}
2525

2626
allprojects {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added CoinPaprika exchange.
2+
Added Verus token.

0 commit comments

Comments
 (0)