Skip to content

Commit 2846ad3

Browse files
committed
Added rounded corners to CoinGecko icons for new widgets.
Fixed Crypto.com. Removed DeversiFi.
1 parent a3adfd0 commit 2846ad3

12 files changed

Lines changed: 58 additions & 38 deletions

File tree

.idea/AndroidProjectSystem.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bitcoin/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ android {
1515
applicationId = "com.brentpanther.bitcoinwidget"
1616
minSdk = 23
1717
targetSdk = 35
18-
versionCode = 339
19-
versionName = "8.6.4"
18+
versionCode = 340
19+
versionName = "8.6.5"
2020
}
2121

2222
buildFeatures {
@@ -79,6 +79,7 @@ dependencies {
7979
implementation(libs.androidx.room.runtime)
8080
implementation(libs.androidx.work)
8181
implementation(libs.coil)
82+
implementation(libs.coil.okhttp)
8283
implementation(libs.okhttp)
8384
implementation(libs.serialization)
8485

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ package com.brentpanther.bitcoinwidget
33
import android.content.Context
44
import android.graphics.Bitmap
55
import android.graphics.BitmapFactory
6+
import android.graphics.BitmapShader
7+
import android.graphics.Canvas
8+
import android.graphics.Paint
9+
import android.graphics.RectF
10+
import android.graphics.Shader.TileMode.CLAMP
611
import android.util.Log
712
import androidx.core.content.edit
13+
import androidx.core.graphics.createBitmap
814
import androidx.preference.PreferenceManager
915
import com.brentpanther.bitcoinwidget.db.Widget
1016
import com.brentpanther.bitcoinwidget.exchange.CustomExchangeData
@@ -56,7 +62,7 @@ object Repository {
5662
it.copyTo(os)
5763
os.closeQuietly()
5864
}
59-
prefs.edit().putString(LAST_MODIFIED, response.header("Last-Modified")).apply()
65+
prefs.edit{ putString(LAST_MODIFIED, response.header("Last-Modified")) }
6066
Log.d(TAG, "JSON downloaded.")
6167
}
6268
else -> Log.d(TAG, "Retrieved status code: " + response.code)
@@ -75,14 +81,22 @@ object Repository {
7581
}
7682
val id = widget.coinCustomId ?: return@let
7783
val file = File(dir, id)
78-
if (file.exists()) {
79-
return
80-
}
8184

8285
ExchangeHelper.getStream(url)?.use { stream ->
8386
ByteArrayOutputStream().use { os ->
8487
BitmapFactory.decodeStream(stream)?.let { image ->
85-
image.compress(Bitmap.CompressFormat.PNG, 100, os)
88+
var bitmap = createBitmap(image.width, image.height)
89+
90+
// apply rounded corners
91+
val canvas = Canvas(bitmap)
92+
var paint = Paint().apply {
93+
isAntiAlias = true
94+
shader = BitmapShader(image, CLAMP, CLAMP)
95+
}
96+
var rect = RectF(0f, 0f, image.width.toFloat(), image.height.toFloat())
97+
canvas.drawRoundRect(rect, 60f, 60f, paint)
98+
99+
bitmap.compress(Bitmap.CompressFormat.PNG, 100, os)
86100
file.writeBytes(os.toByteArray())
87101
}
88102
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.brentpanther.bitcoinwidget.exchange
22

33
import com.brentpanther.bitcoinwidget.Coin
4+
import com.brentpanther.bitcoinwidget.exchange.Exchange.entries
45
import com.brentpanther.bitcoinwidget.exchange.ExchangeHelper.asString
56
import com.brentpanther.bitcoinwidget.exchange.ExchangeHelper.getJsonArray
67
import com.brentpanther.bitcoinwidget.exchange.ExchangeHelper.getJsonObject
@@ -275,17 +276,10 @@ enum class Exchange(val exchangeName: String, shortName: String? = null) {
275276
CRYPTO("Crypto.com") {
276277

277278
override fun getValue(coin: String, currency: String): String? {
278-
val url = "https://api.crypto.com/v2/public/get-ticker?instrument_name=${coin}_$currency"
279+
val url = "https://api.crypto.com/exchange/v1/public/get-tickers?instrument_name=${coin}_$currency"
279280
return getJsonObject(url)["result"]?.jsonObject?.get("data")?.jsonArray?.get(0)?.jsonObject?.get("a").asString
280281
}
281282
},
282-
DEVERSIFI("DeversiFi") {
283-
284-
override fun getValue(coin: String, currency: String): String? {
285-
val url = "https://api.deversifi.com/bfx/v2/tickers?symbols=t${coin}$currency"
286-
return getJsonArray(url)[0].jsonArray[7].asString
287-
}
288-
},
289283
DIGIFINEX("Digifinex") {
290284
override fun getValue(coin: String, currency: String): String? {
291285
val url = "https://openapi.digifinex.com/v3/ticker?symbol=${coin}_$currency"

bitcoin/src/main/java/com/brentpanther/bitcoinwidget/ui/selection/CoinSelectionScreen.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.size
2020
import androidx.compose.foundation.layout.width
2121
import androidx.compose.foundation.lazy.LazyColumn
2222
import androidx.compose.foundation.lazy.items
23+
import androidx.compose.foundation.shape.RoundedCornerShape
2324
import androidx.compose.foundation.text.KeyboardActions
2425
import androidx.compose.foundation.text.KeyboardOptions
2526
import androidx.compose.material3.CircularProgressIndicator
@@ -46,6 +47,7 @@ import androidx.compose.runtime.rememberCoroutineScope
4647
import androidx.compose.runtime.setValue
4748
import androidx.compose.ui.Alignment
4849
import androidx.compose.ui.Modifier
50+
import androidx.compose.ui.draw.clip
4951
import androidx.compose.ui.input.key.onPreviewKeyEvent
5052
import androidx.compose.ui.input.nestedscroll.nestedScroll
5153
import androidx.compose.ui.platform.LocalContext
@@ -59,7 +61,7 @@ import androidx.compose.ui.unit.dp
5961
import androidx.compose.ui.unit.sp
6062
import androidx.lifecycle.viewmodel.compose.viewModel
6163
import androidx.navigation.NavController
62-
import coil.compose.AsyncImage
64+
import coil3.compose.AsyncImage
6365
import com.brentpanther.bitcoinwidget.Coin
6466
import com.brentpanther.bitcoinwidget.R
6567
import com.brentpanther.bitcoinwidget.Theme
@@ -268,7 +270,7 @@ private fun CoinRow(
268270
AsyncImage(
269271
model = item.thumb,
270272
contentDescription = null,
271-
modifier = modifier,
273+
modifier = modifier.clip(RoundedCornerShape(8.dp)),
272274
placeholder = painterResource(id = R.drawable.ic_baseline_circle_24)
273275
)
274276
} else {

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
@@ -98,7 +98,7 @@
9898
<item>ISO</item>
9999
<item>NONE</item>
100100
</string-array>
101-
<string name="json_last_modified" translatable="false">Sat, 01 Mar 2025 22:09:02 GMT</string>
101+
<string name="json_last_modified" translatable="false">Fri, 21 Mar 2025 14:01:52 GMT</string>
102102
<string name="json_url" translatable="false">https://www.brentpanther.com/cryptowidgetcoins_v2.json</string>
103103

104104
<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: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class GenerateSupportedCoinsJson {
4141
this::bitvavo, this::btcbox, this::btcmarkets, this::btcturk, this::bybit, this::cexio,
4242
this::chilebit, this::coinbase,this::coindesk, this::coingecko,
4343
this::coinjar, this::coinmate, this::coinone, this::coinpaprika, this::coinsph, this::cointree,
44-
this::cryptocom, this::deversifi, this::digifinex, this::egera, this::exmo, this::foxbit, this::gateio, this::gemini,
44+
this::cryptocom, this::digifinex, this::egera, this::exmo, this::foxbit, this::gateio, this::gemini,
4545
this::hashkey, this::hitbtc, this::huobi, this::independent_reserve, this::indodax, this::itbit,
4646
this::korbit, this::kraken, this::kucoin, this::kuna, this::lbank, this::luno,
4747
this::mercado, this::mexc, this::ndax, this::nexchange, this::okx, this::p2pb2b,
@@ -93,11 +93,16 @@ class GenerateSupportedCoinsJson {
9393
allExchangeData.exchanges.add(this)
9494
}
9595
try {
96+
var pairs = func()
97+
if (pairs.isEmpty()) {
98+
System.err.println("$exchange returned no pairs.")
99+
exchangeData.coins = listOf()
100+
continue
101+
}
96102
loadExchange(exchangeData, exchange, func(), potentialCoinAdds)
97103
} catch (e: Exception) {
98-
System.err.println("$exchange: " + e.message)
104+
System.err.println("$exchange: ${e.message}")
99105
exchangeData.coins = listOf()
100-
101106
}
102107
}
103108
allExchangeData.exchanges.sortBy { it.name }
@@ -468,13 +473,7 @@ class GenerateSupportedCoinsJson {
468473
}
469474

470475
private fun cryptocom(): List<String> {
471-
return parse("https://api.crypto.com/v2/public/get-instruments", "$.result.instruments[*].instrument_name")
472-
}
473-
474-
private fun deversifi(): List<String> {
475-
return parse("https://api.deversifi.com/bfx/v2/tickers?symbols=ALL", "$[*].[0]").map {
476-
it.removePrefix("t")
477-
}
476+
return parse("https://api.crypto.com/exchange/v1/public/get-instruments", "$.result.data[*].symbol")
478477
}
479478

480479
private fun digifinex(): List<String> {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Added rounded corners to CoinGecko icons for new widgets.
2+
Fixed Crypto.com.
3+
Removed DeversiFi.

0 commit comments

Comments
 (0)