Skip to content

Commit

Permalink
Fix coin and currency overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
hwki committed Oct 16, 2021
1 parent 439fcb0 commit 73b9e5d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bitcoin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.brentpanther.bitcoinwidget"
minSdk 23
targetSdk 31
versionCode 283
versionName "8.1.3"
versionCode 284
versionName "8.1.4"

javaCompileOptions {
annotationProcessorOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ data class Widget(
) {
fun toCoinEntry() = CoinEntry(coinCustomId ?: coin.coinName, coinName(), coin.name, coin, customIcon)

fun coinName() = coinCustomName ?: coin.coinName
fun coinName() = if (coinCustomId != null) coinCustomName ?: coin.coinName else coin.coinName

fun isOld(refresh: Int) = System.currentTimeMillis() - lastUpdated > (60000 * refresh * 1.5)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ open class PriceWidgetDataStrategy(context: Context, widgetId: Int) : WidgetData
}
try {
val currency = widget.currencyCustomName ?: widget.currency
val coin = widget.coinCustomId ?: widget.coin.name
val coin = widget.coinCustomId ?: widget.coinCustomName ?: widget.coin.name
val value = widget.exchange.getValue(coin, currency)
widget.state = WidgetState.CURRENT
if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ abstract class SettingsFragment : PreferenceFragmentCompat() {
val updatePrice = when(key) {
"currency" -> {
widget.currency = value ?: widget.currency
widget.currencyCustomName = data.getExchangeCurrencyName(widget.exchange.name, widget.currency)
updateExchangeValues()
updateCurrencyUnits()
true
Expand All @@ -245,6 +246,8 @@ abstract class SettingsFragment : PreferenceFragmentCompat() {
}
"exchange" -> {
widget.exchange = Exchange.valueOf(value ?: Exchange.COINGECKO.name)
widget.coinCustomName = data.getExchangeCoinName(widget.exchange.name)
widget.currencyCustomName = data.getExchangeCurrencyName(widget.exchange.name, widget.currency)
true
}
"units_coin" -> {
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/284.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug causing some coin/currency/exchange combinations to not load correctly.

0 comments on commit 73b9e5d

Please sign in to comment.