From c35fe4f3f199b59e3763c8983ac8851e2488eefd Mon Sep 17 00:00:00 2001 From: Baji Shaik Date: Wed, 10 Nov 2021 16:16:17 -0500 Subject: [PATCH] moved preference key from viewmodel to settings_keys.xml --- .../org/schabi/newpipe/local/feed/FeedViewModel.kt | 10 ++++------ app/src/main/res/values/settings_keys.xml | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt index 5f18b6342..cea787c5a 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt @@ -12,6 +12,7 @@ import io.reactivex.rxjava3.core.Flowable import io.reactivex.rxjava3.functions.Function4 import io.reactivex.rxjava3.processors.BehaviorProcessor import io.reactivex.rxjava3.schedulers.Schedulers +import org.schabi.newpipe.R import org.schabi.newpipe.database.feed.model.FeedGroupEntity import org.schabi.newpipe.database.stream.StreamWithState import org.schabi.newpipe.local.feed.item.StreamItem @@ -25,15 +26,12 @@ import java.time.OffsetDateTime import java.util.concurrent.TimeUnit class FeedViewModel( - applicationContext: Context, + val applicationContext: Context, groupId: Long = FeedGroupEntity.GROUP_ALL_ID, initialShowPlayedItems: Boolean = true ) : ViewModel() { private var feedDatabaseManager: FeedDatabaseManager = FeedDatabaseManager(applicationContext) private var sharedPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext) - companion object { - const val SHOW_PLAYED_ITEMS_PREFERENCE = "show_played_items_preference_tag" - } private val toggleShowPlayedItems = BehaviorProcessor.create() private val streamItems = toggleShowPlayedItems @@ -88,11 +86,11 @@ class FeedViewModel( } fun savePlayedItemsToggle(showPlayedItems: Boolean) = sharedPreferences.edit { - this.putBoolean(SHOW_PLAYED_ITEMS_PREFERENCE, showPlayedItems) + this.putBoolean(applicationContext.getString(R.string.show_played_items_filter_key), showPlayedItems) this.apply() } - fun getSavedPlayedItemsToggle() = sharedPreferences.getBoolean(SHOW_PLAYED_ITEMS_PREFERENCE, true) + fun getSavedPlayedItemsToggle() = sharedPreferences.getBoolean(applicationContext.getString(R.string.show_played_items_filter_key), true) class Factory( private val context: Context, diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 1c57178b4..e60cf17c9 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -14,6 +14,7 @@ saved_tabs_key + show_played_items_preference_key download_path download_path_audio