From 0bc2a8b6d4b65454528dd22e5048546513711cc3 Mon Sep 17 00:00:00 2001 From: Quentin Hibon Date: Sun, 1 Aug 2021 18:13:40 +0200 Subject: [PATCH] Handle target widget type in stacked widget Fixes #965. --- .../java/org/isoron/uhabits/widgets/StackWidgetService.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/uhabits-android/src/main/java/org/isoron/uhabits/widgets/StackWidgetService.kt b/uhabits-android/src/main/java/org/isoron/uhabits/widgets/StackWidgetService.kt index e73f20259..75018cead 100644 --- a/uhabits-android/src/main/java/org/isoron/uhabits/widgets/StackWidgetService.kt +++ b/uhabits-android/src/main/java/org/isoron/uhabits/widgets/StackWidgetService.kt @@ -53,7 +53,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int AppWidgetManager.INVALID_APPWIDGET_ID ) private val habitIds: LongArray - private val widgetType: StackWidgetType? + private val widgetType: StackWidgetType private var remoteViews = ArrayList() override fun onCreate() {} override fun onDestroy() {} @@ -105,7 +105,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int StackWidgetType.SCORE -> ScoreWidget(context, widgetId, habit, true) StackWidgetType.HISTORY -> HistoryWidget(context, widgetId, habit, true) StackWidgetType.STREAKS -> StreakWidget(context, widgetId, habit, true) - else -> throw IllegalStateException() + StackWidgetType.TARGET -> TargetWidget(context, widgetId, habit, true) } } @@ -157,6 +157,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int if (widgetTypeValue < 0) throw RuntimeException("invalid widget type") if (habitIdsStr == null) throw RuntimeException("habitIdsStr is null") widgetType = StackWidgetType.getWidgetTypeFromValue(widgetTypeValue) + ?: throw RuntimeException("unknown widget type value: $widgetTypeValue") habitIds = splitLongs(habitIdsStr) } }