diff --git a/android/app/src/main/java/io/bluewallet/bluewallet/BitcoinPriceWidget.kt b/android/app/src/main/java/io/bluewallet/bluewallet/BitcoinPriceWidget.kt index b55ac67c6..d27bc4434 100644 --- a/android/app/src/main/java/io/bluewallet/bluewallet/BitcoinPriceWidget.kt +++ b/android/app/src/main/java/io/bluewallet/bluewallet/BitcoinPriceWidget.kt @@ -12,7 +12,6 @@ class BitcoinPriceWidget : AppWidgetProvider() { companion object { private const val TAG = "BitcoinPriceWidget" private const val SHARED_PREF_NAME = "group.io.bluewallet.bluewallet" - private const val WIDGET_COUNT_KEY = "widget_count" } override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) { @@ -25,16 +24,12 @@ class BitcoinPriceWidget : AppWidgetProvider() { override fun onEnabled(context: Context) { super.onEnabled(context) - val sharedPref = context.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE) - val widgetCount = sharedPref.getInt(WIDGET_COUNT_KEY, 0) - sharedPref.edit().putInt(WIDGET_COUNT_KEY, widgetCount + 1).apply() Log.d(TAG, "onEnabled called") WidgetUpdateWorker.scheduleWork(context) } override fun onDisabled(context: Context) { super.onDisabled(context) - clearWidgetCount(context) Log.d(TAG, "onDisabled called") clearCache(context) WorkManager.getInstance(context).cancelUniqueWork(WidgetUpdateWorker.WORK_NAME) @@ -42,19 +37,9 @@ class BitcoinPriceWidget : AppWidgetProvider() { override fun onDeleted(context: Context, appWidgetIds: IntArray) { super.onDeleted(context, appWidgetIds) - val sharedPref = context.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE) - val widgetCount = sharedPref.getInt(WIDGET_COUNT_KEY, 1) - val newCount = widgetCount - appWidgetIds.size - sharedPref.edit().putInt(WIDGET_COUNT_KEY, if (newCount >= 0) newCount else 0).apply() Log.d(TAG, "onDeleted called for widgets: ${appWidgetIds.joinToString()}") } - private fun clearWidgetCount(context: Context) { - val sharedPref = context.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE) - sharedPref.edit().putInt(WIDGET_COUNT_KEY, 0).apply() - Log.d(TAG, "Widget count reset to 0") - } - private fun clearCache(context: Context) { val sharedPref = context.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE) sharedPref.edit().clear().apply()