1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 11:02:35 +01:00

moved preference key from viewmodel to settings_keys.xml

This commit is contained in:
Baji Shaik 2021-11-10 16:16:17 -05:00
parent 63291f8101
commit c35fe4f3f1
2 changed files with 5 additions and 6 deletions

View File

@ -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<Boolean>()
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,

View File

@ -14,6 +14,7 @@
<string name="saved_tabs_key" translatable="false">saved_tabs_key</string>
<!-- Key values -->
<string name="show_played_items_filter_key" translatable="false">show_played_items_preference_key</string>
<string name="download_path_video_key" translatable="false">download_path</string>
<string name="download_path_audio_key" translatable="false">download_path_audio</string>