Skip to content

Commit c35fe4f

Browse files
committed
moved preference key from viewmodel to settings_keys.xml
1 parent 63291f8 commit c35fe4f

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import io.reactivex.rxjava3.core.Flowable
1212
import io.reactivex.rxjava3.functions.Function4
1313
import io.reactivex.rxjava3.processors.BehaviorProcessor
1414
import io.reactivex.rxjava3.schedulers.Schedulers
15+
import org.schabi.newpipe.R
1516
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
1617
import org.schabi.newpipe.database.stream.StreamWithState
1718
import org.schabi.newpipe.local.feed.item.StreamItem
@@ -25,15 +26,12 @@ import java.time.OffsetDateTime
2526
import java.util.concurrent.TimeUnit
2627

2728
class FeedViewModel(
28-
applicationContext: Context,
29+
val applicationContext: Context,
2930
groupId: Long = FeedGroupEntity.GROUP_ALL_ID,
3031
initialShowPlayedItems: Boolean = true
3132
) : ViewModel() {
3233
private var feedDatabaseManager: FeedDatabaseManager = FeedDatabaseManager(applicationContext)
3334
private var sharedPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext)
34-
companion object {
35-
const val SHOW_PLAYED_ITEMS_PREFERENCE = "show_played_items_preference_tag"
36-
}
3735

3836
private val toggleShowPlayedItems = BehaviorProcessor.create<Boolean>()
3937
private val streamItems = toggleShowPlayedItems
@@ -88,11 +86,11 @@ class FeedViewModel(
8886
}
8987

9088
fun savePlayedItemsToggle(showPlayedItems: Boolean) = sharedPreferences.edit {
91-
this.putBoolean(SHOW_PLAYED_ITEMS_PREFERENCE, showPlayedItems)
89+
this.putBoolean(applicationContext.getString(R.string.show_played_items_filter_key), showPlayedItems)
9290
this.apply()
9391
}
9492

95-
fun getSavedPlayedItemsToggle() = sharedPreferences.getBoolean(SHOW_PLAYED_ITEMS_PREFERENCE, true)
93+
fun getSavedPlayedItemsToggle() = sharedPreferences.getBoolean(applicationContext.getString(R.string.show_played_items_filter_key), true)
9694

9795
class Factory(
9896
private val context: Context,

app/src/main/res/values/settings_keys.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<string name="saved_tabs_key" translatable="false">saved_tabs_key</string>
1515

1616
<!-- Key values -->
17+
<string name="show_played_items_filter_key" translatable="false">show_played_items_preference_key</string>
1718
<string name="download_path_video_key" translatable="false">download_path</string>
1819
<string name="download_path_audio_key" translatable="false">download_path_audio</string>
1920

0 commit comments

Comments
 (0)