From a692f8d8f119fe31ca55349b441c32f5d3bd784f Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 14 Jun 2024 18:43:33 +0200 Subject: [PATCH] feat: remember selected channel group across app restarts --- .../java/com/github/libretube/constants/PreferenceKeys.kt | 1 + .../github/libretube/ui/fragments/SubscriptionsFragment.kt | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt index 9b624ebe8..56fce5f7c 100644 --- a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt @@ -139,4 +139,5 @@ object PreferenceKeys { const val LAST_WATCHED_FEED_TIME = "last_watched_feed_time" const val AUTH_PREF_FILE = "auth" const val IMAGE_PROXY_URL = "image_proxy_url" + const val SELECTED_CHANNEL_GROUP = "selected_channel_group" } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt index 08b60b002..9cbc7e0ae 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt @@ -58,7 +58,10 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment() { private val viewModel: SubscriptionsViewModel by activityViewModels() private val playerModel: PlayerViewModel by activityViewModels() private val channelGroupsModel: EditChannelGroupsModel by activityViewModels() - private var selectedFilterGroup = 0 + private var selectedFilterGroup + set(value) = PreferenceHelper.putInt(PreferenceKeys.SELECTED_CHANNEL_GROUP, value) + get() = PreferenceHelper.getInt(PreferenceKeys.SELECTED_CHANNEL_GROUP, 0) + private var isCurrentTabSubChannels = false private var isAppBarFullyExpanded = true