diff --git a/bitcoin/build.gradle b/bitcoin/build.gradle index 3da2d8a..56aac3f 100644 --- a/bitcoin/build.gradle +++ b/bitcoin/build.gradle @@ -12,8 +12,8 @@ android { applicationId "com.brentpanther.bitcoinwidget" minSdk 23 targetSdk 33 - versionCode 310 - versionName "8.3" + versionCode 311 + versionName "8.3.1" javaCompileOptions { annotationProcessorOptions { diff --git a/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/WidgetUpdater.kt b/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/WidgetUpdater.kt index 0198a0a..f98d712 100644 --- a/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/WidgetUpdater.kt +++ b/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/WidgetUpdater.kt @@ -14,8 +14,9 @@ object WidgetUpdater { // update display immediately to avoid looking bad for (strategy in dataStrategies) { - val widgetPresenter = RemoteWidgetPresenter(context, strategy.widget) - val displayStrategy = WidgetDisplayStrategy.getStrategy(context, strategy.widget, widgetPresenter) + val widget = strategy.widget ?: continue + val widgetPresenter = RemoteWidgetPresenter(context, widget) + val displayStrategy = WidgetDisplayStrategy.getStrategy(context, widget, widgetPresenter) displayStrategy.refresh() } @@ -27,8 +28,9 @@ object WidgetUpdater { // data may cause display to need refreshed for (strategy in dataStrategies) { - val widgetPresenter = RemoteWidgetPresenter(context, strategy.widget) - val displayStrategy = WidgetDisplayStrategy.getStrategy(context, strategy.widget, widgetPresenter) + val widget = strategy.widget ?: continue + val widgetPresenter = RemoteWidgetPresenter(context, widget) + val displayStrategy = WidgetDisplayStrategy.getStrategy(context, widget, widgetPresenter) displayStrategy.refresh() displayStrategy.save() } diff --git a/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/PriceWidgetDataStrategy.kt b/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/PriceWidgetDataStrategy.kt index 2b6ae7b..32fece9 100644 --- a/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/PriceWidgetDataStrategy.kt +++ b/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/PriceWidgetDataStrategy.kt @@ -10,6 +10,7 @@ import java.io.IOException open class PriceWidgetDataStrategy(widgetId: Int) : WidgetDataStrategy(widgetId) { override suspend fun loadData(manual: Boolean): Unit = withContext(Dispatchers.IO) { + val widget = widget ?: return@withContext val config = getConfig() if (manual) { delay(750) @@ -41,8 +42,10 @@ open class PriceWidgetDataStrategy(widgetId: Int) : WidgetDataStrategy(widgetId) } open fun setData(value: String) { - widget.lastValue = value - widget.lastUpdated = System.currentTimeMillis() + widget?.apply { + lastValue = value + lastUpdated = System.currentTimeMillis() + } } companion object { diff --git a/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/ValueWidgetDataStrategy.kt b/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/ValueWidgetDataStrategy.kt index 1ed1c58..127fb1a 100644 --- a/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/ValueWidgetDataStrategy.kt +++ b/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/ValueWidgetDataStrategy.kt @@ -3,10 +3,13 @@ package com.brentpanther.bitcoinwidget.strategy.data class ValueWidgetDataStrategy(widgetId: Int) : PriceWidgetDataStrategy(widgetId) { override fun setData(value: String) { - val valueDouble = value.toDoubleOrNull() ?: 0.0 - val amountHeld = widget.amountHeld ?: 0.0 - widget.lastValue = (valueDouble * amountHeld).toString() - widget.lastUpdated = System.currentTimeMillis() + widget?.apply { + val valueDouble = value.toDoubleOrNull() ?: 0.0 + val amountHeld = amountHeld ?: 0.0 + lastValue = (valueDouble * amountHeld).toString() + lastUpdated = System.currentTimeMillis() + } + } } \ No newline at end of file diff --git a/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/WidgetDataStrategy.kt b/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/WidgetDataStrategy.kt index b54e51d..55e4fcf 100644 --- a/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/WidgetDataStrategy.kt +++ b/bitcoin/src/main/java/com/brentpanther/bitcoinwidget/strategy/data/WidgetDataStrategy.kt @@ -11,10 +11,9 @@ abstract class WidgetDataStrategy(val widgetId: Int) { private var _widget : Widget? = null - var widget : Widget + var widget : Widget? get() { - _widget = _widget ?: dao.getByWidgetId(widgetId) ?: throw IllegalArgumentException() - return _widget!! + return _widget ?: dao.getByWidgetId(widgetId) } set(value) { _widget = value @@ -25,7 +24,7 @@ abstract class WidgetDataStrategy(val widgetId: Int) { abstract suspend fun loadData(manual: Boolean) suspend fun save() { - dao.update(widget) + widget?.let { dao.update(it) } } companion object { diff --git a/fastlane/metadata/android/en-US/changelogs/311.txt b/fastlane/metadata/android/en-US/changelogs/311.txt new file mode 100644 index 0000000..679015c --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/311.txt @@ -0,0 +1,4 @@ +New create screen with search powered by CoinGecko. Search and create a widget for any cryptocurrency. +Added themed app icon for Android 13. +New widgets will default settings to match the last created widget. +Major overhaul of UI behind the screens. \ No newline at end of file