Skip to content

Commit 45094f6

Browse files
committed
Removed Bluetrade and TheRock exchanges.
Updated several exchange APIs.
1 parent 7791656 commit 45094f6

File tree

10 files changed

+46
-61
lines changed

10 files changed

+46
-61
lines changed

bitcoin/build.gradle

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id 'kotlin-android'
44
id 'kotlin-parcelize'
55
id 'kotlin-kapt'
6+
id 'org.jetbrains.kotlin.android'
67
}
78

89
android {
@@ -12,8 +13,8 @@ android {
1213
applicationId "com.brentpanther.bitcoinwidget"
1314
minSdk 23
1415
targetSdk 33
15-
versionCode 317
16-
versionName "8.3.7"
16+
versionCode 318
17+
versionName "8.3.8"
1718

1819
javaCompileOptions {
1920
annotationProcessorOptions {
@@ -71,26 +72,29 @@ android {
7172
}
7273

7374
dependencies {
75+
implementation platform('androidx.compose:compose-bom:2023.04.00')
76+
7477
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
7578
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
76-
implementation 'com.google.code.gson:gson:2.10'
77-
implementation 'com.google.android.material:material:1.7.0'
79+
implementation 'com.google.code.gson:gson:2.10.1'
80+
implementation 'com.google.android.material:material:1.8.0'
7881
implementation 'androidx.preference:preference-ktx:1.2.0'
79-
implementation 'androidx.work:work-runtime-ktx:2.7.1'
80-
implementation 'androidx.activity:activity-compose:1.6.1'
81-
implementation "androidx.compose.ui:ui:$compose_ui_version"
82-
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
83-
implementation 'androidx.compose.material:material:1.3.1'
84-
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1"
82+
implementation 'androidx.work:work-runtime-ktx:2.8.1'
83+
implementation 'androidx.activity:activity-compose:1.7.0'
84+
implementation "androidx.compose.ui:ui"
85+
implementation "androidx.compose.ui:ui-tooling-preview"
86+
implementation 'androidx.compose.material:material'
87+
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
8588
implementation 'androidx.navigation:navigation-compose:2.5.3'
86-
implementation "io.coil-kt:coil-compose:2.2.2"
89+
implementation "io.coil-kt:coil-compose:2.3.0"
90+
implementation 'androidx.core:core-ktx:1.9.0'
8791
testImplementation 'junit:junit:4.13.2'
88-
testImplementation 'com.jayway.jsonpath:json-path:2.7.0'
89-
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
90-
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
91-
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
92+
testImplementation 'com.jayway.jsonpath:json-path:2.8.0'
93+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:"
94+
debugImplementation "androidx.compose.ui:ui-tooling:"
95+
debugImplementation "androidx.compose.ui:ui-test-manifest:"
9296

93-
def room_version = "2.4.3"
97+
def room_version = "2.5.1"
9498

9599
implementation "androidx.room:room-runtime:$room_version"
96100
kapt "androidx.room:room-compiler:$room_version"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ open class WidgetProvider : AppWidgetProvider() {
7070
val immediateWork = OneTimeWorkRequestBuilder<WidgetUpdateWorker>().setInitialDelay(3650L, TimeUnit.DAYS).build()
7171
workManager.enqueueUniqueWork(ONETIMEWORKNAME, ExistingWorkPolicy.KEEP, immediateWork)
7272

73-
val workPolicy = if (restart) ExistingPeriodicWorkPolicy.REPLACE else ExistingPeriodicWorkPolicy.KEEP
73+
val workPolicy = if (restart) ExistingPeriodicWorkPolicy.UPDATE else ExistingPeriodicWorkPolicy.KEEP
7474
when (refresh) {
7575
5 -> (0..10 step 5).forEachIndexed { i, it -> scheduleWork(workManager, 15, it, i, workPolicy) }
7676
10 -> (0..10 step 10).forEachIndexed { i, it -> scheduleWork(workManager, 20, it, i, workPolicy) }

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

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
131131
BITPAY("BitPay") {
132132

133133
override fun getValue(coin: String, currency: String): String {
134-
val url = "https://bitpay.com/api/rates/BTC/USD"
134+
val url = "https://bitpay.com/api/rates/$coin/$currency"
135135
return getJsonObject(url).get("rate").asString
136136
}
137137
},
@@ -180,15 +180,6 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
180180
}
181181

182182
},
183-
BLEUTRADE("Bleutrade") {
184-
185-
override fun getValue(coin: String, currency: String): String {
186-
val pair = "${coin}_$currency"
187-
val url = "https://bleutrade.com/api/v3/public/getticker?market=$pair"
188-
val result = getJsonObject(url).getAsJsonArray("result").get(0).asJsonObject
189-
return result.get("Last").asString
190-
}
191-
},
192183
BTCBOX("BTC Box") {
193184

194185
override fun getValue(coin: String, currency: String): String {
@@ -277,8 +268,8 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
277268
COINONE("Coinone") {
278269

279270
override fun getValue(coin: String, currency: String): String {
280-
val url = "https://api.coinone.co.kr/ticker/?currency=$coin"
281-
return getJsonObject(url).get("last").asString
271+
val url = "https://api.coinone.co.kr/public/v2/ticker_new/$currency/$coin"
272+
return getJsonObject(url).getAsJsonArray("tickers")[0].asJsonObject.get("last").asString
282273
}
283274
},
284275
COINSBIT("Coinsbit") {
@@ -560,13 +551,6 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
560551
return getJsonObject(url).getAsJsonArray("data")[0].asJsonObject.get("last").asString
561552
}
562553
},
563-
THEROCK("TheRock") {
564-
565-
override fun getValue(coin: String, currency: String): String {
566-
val url = "https://api.therocktrading.com/v1/funds/$coin$currency/ticker"
567-
return getJsonObject(url).get("last").asString
568-
}
569-
},
570554
TRADEOGRE("TradeOgre") {
571555
override fun getValue(coin: String, currency: String): String {
572556
val url = "https://tradeogre.com/api/v1/ticker/$currency-$coin"
@@ -606,8 +590,8 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
606590
},
607591
XT("XT.com") {
608592
override fun getValue(coin: String, currency: String): String? {
609-
val url = "https://api.xt.com/data/api/v1/getTicker?market=${coin.lowercase()}_${currency.lowercase()}"
610-
return getJsonObject(url).get("price").asString
593+
val url = "https://sapi.xt.com/v4/public/ticker/price?symbol=${coin.lowercase()}_${currency.lowercase()}"
594+
return getJsonObject(url).get("result").asJsonArray[0].asJsonObject.get("p").asString
611595
}
612596

613597
},

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

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
<item>ISO</item>
9595
<item>NONE</item>
9696
</string-array>
97-
<string name="json_last_modified" translatable="false">Thu, 03 Nov 2022 11:11:24 GMT</string>
97+
<string name="json_last_modified" translatable="false">Thu, 06 Apr 2023 01:02:58 GMT</string>
9898
<string name="json_url" translatable="false">https://www.brentpanther.com/cryptowidgetcoins_v2.json</string>
9999

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

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ class GenerateSupportedCoinsJson {
3333
listOf(this::ascendex, this::bibox, this::bigone, this::binance, this::binance_us, this::bit2c,
3434
this::bitbank, this::bitcambio, this::bitclude,
3535
this::bitcoinde, this::bitfinex, this::bitflyer, this::bithumb, this::bitglobal, this::bitmart,
36-
this::bitpanda, this::bitpay, this::bitso, this::bitstamp, this::bittrex, this::bitrue, this::bitvavo, this::bleutrade,
36+
this::bitpanda, this::bitpay, this::bitso, this::bitstamp, this::bittrex, this::bitrue, this::bitvavo,
3737
this::btcbox, this::btcmarkets, this::btcturk, this::bybit, this::cexio,
3838
this::chilebit, this::coinbase, this::coinbasepro, this::coindesk, this::coingecko,
3939
this::coinjar, this::coinmate, this::coinone, this::coinsbit, this::coinsph, this::cointree,
4040
this::cryptocom, this::deversifi, this::digifinex, this::exmo, this::foxbit, this::gateio, this::gemini,
4141
this::hitbtc, this::huobi, this::independent_reserve, this::indodax, this::itbit, this::korbit, this::kraken, this::kucoin,
4242
this::kuna, this::lbank, this::liquid, this::luno, this::mercado, this::mexc, this::ndax,
4343
this::nexchange, this::okcoin, this::okx, this::p2pb2b, this::paribu, this::paymium, this::phemex,
44-
this::pocketbits, this::poloniex, this::probit, this::therock, this::tradeogre, this::uphold,
44+
this::pocketbits, this::poloniex, this::probit, this::tradeogre, this::uphold,
4545
this::vbtc, this::whitebit, this::wyre, this::xt, this::yadio, this::yobit, this::zbg, this::zonda
4646
).zip(Exchange.values())
4747

@@ -320,8 +320,10 @@ class GenerateSupportedCoinsJson {
320320
}
321321

322322
private fun bitpay(): List<String> {
323-
return parse("https://bitpay.com/currencies", "$.data[*].code").flatMap {
324-
listOf("BTC_$it", "BCH_$it")
323+
val coins = parse("https://bitpay.com/currencies", "$.data[?(@.chain)].code").filterNot { it == "PAX" }
324+
val currencies = parse("https://bitpay.com/currencies", "$.data[*].code")
325+
return coins.flatMap { coin ->
326+
currencies.map { currency -> "${coin}_$currency"}
325327
}
326328
}
327329

@@ -346,10 +348,6 @@ class GenerateSupportedCoinsJson {
346348
return parse("https://api.bitvavo.com/v2/markets", "$[*].market")
347349
}
348350

349-
private fun bleutrade(): List<String> {
350-
return parse("https://bleutrade.com/api/v3/public/getmarkets", "$.result[*].MarketName")
351-
}
352-
353351
private fun btcbox(): List<String> {
354352
return parseKeys("https://www.btcbox.co.jp/api/v1/tickers", "$")
355353
}
@@ -411,8 +409,10 @@ class GenerateSupportedCoinsJson {
411409
}
412410

413411
private fun coinone(): List<String> {
414-
return parse("https://tb.coinone.co.kr/api/v1/tradepair/", "$.tradepairs[*].target_coin_symbol").map {
415-
it + "_KRW"
412+
val currencies = listOf("KRW")
413+
return currencies.flatMap { currency ->
414+
val list = parse("https://api.coinone.co.kr/public/v2/markets/$currency", "$.markets[*].target_currency")
415+
list.map { "${it}_$currency" }
416416
}
417417
}
418418

@@ -572,10 +572,6 @@ class GenerateSupportedCoinsJson {
572572
return parse("https://api.probit.com/api/exchange/v1/market", "$.data[*].id")
573573
}
574574

575-
private fun therock(): List<String> {
576-
return parse("https://api.therocktrading.com/v1/funds/tickers", "$.tickers[*].fund_id")
577-
}
578-
579575
private fun tradeogre(): List<String> {
580576
val list = JsonPath.read(get("https://tradeogre.com/api/v1/markets"), "$[*]") as List<Map<String, *>>
581577
return list.map { it.keys.first().split("-").reversed().joinToString("_") }
@@ -604,7 +600,7 @@ class GenerateSupportedCoinsJson {
604600
}
605601

606602
private fun xt(): List<String> {
607-
return parseKeys("https://api.xt.com/data/api/v1/getTickers", "$")
603+
return parse("https://sapi.xt.com/v4/public/symbol", "$.result.symbols[*].symbol")
608604
}
609605

610606
private fun yadio(): List<String> {

build.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
buildscript {
44
ext {
5-
compose_ui_version = '1.3.2'
6-
compose_compiler_version = '1.3.1'
5+
compose_compiler_version = '1.4.3'
76
}
8-
ext.kotlin_version = '1.7.10'
7+
ext.kotlin_version = '1.8.10'
98
repositories {
109
google()
1110
mavenCentral()
1211
}
1312
dependencies {
14-
classpath 'com.android.tools.build:gradle:7.3.1'
15-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13+
classpath 'com.android.tools.build:gradle:7.4.2'
14+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10"
1615

1716
// NOTE: Do not place your application dependencies here; they belong
1817
// in the individual module build.gradle files
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed Bluetrade and TheRock exchanges.

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
org.gradle.jvmargs=-Xmx2048M -XX:+UseParallelGC
1515
android.useAndroidX=true
1616
android.enableJetifier=true
17+
org.gradle.unsafe.configuration-cache=true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)