Make Cached playlist optional (#11)

This commit is contained in:
vfsfitvnm
2022-07-13 19:24:22 +02:00
parent fe95805f98
commit 48e8055f21
3 changed files with 51 additions and 32 deletions

View File

@@ -321,6 +321,7 @@ fun HomeScreen() {
}
}
if (preferences.isCachedPlaylistShown) {
item {
Box(
modifier = Modifier
@@ -356,6 +357,7 @@ fun HomeScreen() {
)
}
}
}
items(
items = playlistPreviews,

View File

@@ -96,6 +96,17 @@ fun AppearanceSettingsScreen() {
preferences.thumbnailRoundness = it
}
)
SettingsEntryGroupText(title = "OTHER")
SwitchSettingEntry(
title = "Cached playlist",
text = "Display a playlist whose songs can be played offline",
isChecked = preferences.isCachedPlaylistShown,
onCheckedChange = {
preferences.isCachedPlaylistShown = it
}
)
}
}
}

View File

@@ -26,6 +26,7 @@ class Preferences(
initialVolumeNormalization: Boolean,
initialPersistentQueue: Boolean,
initialIsInvincibilityEnabled: Boolean,
initialIsCachedPlaylistShown: Boolean,
) {
constructor(preferences: SharedPreferences) : this(
edit = { action: SharedPreferences.Editor.() -> Unit ->
@@ -44,6 +45,7 @@ class Preferences(
initialVolumeNormalization = preferences.getBoolean(Keys.volumeNormalization, false),
initialPersistentQueue = preferences.getBoolean(Keys.persistentQueue, false),
initialIsInvincibilityEnabled = preferences.getBoolean(Keys.isInvincibilityEnabled, false),
initialIsCachedPlaylistShown = preferences.getBoolean(Keys.isCachedPlaylistShown, false),
)
var isFirstLaunch = initialIsFirstLaunch
@@ -85,6 +87,9 @@ class Preferences(
var isInvincibilityEnabled = initialIsInvincibilityEnabled
set(value) = edit { putBoolean(Keys.isInvincibilityEnabled, value) }
var isCachedPlaylistShown = initialIsCachedPlaylistShown
set(value) = edit { putBoolean(Keys.isCachedPlaylistShown, value) }
object Keys {
const val isFirstLaunch = "isFirstLaunch"
const val songSortOrder = "songSortOrder"
@@ -99,6 +104,7 @@ class Preferences(
const val volumeNormalization = "volumeNormalization"
const val persistentQueue = "persistentQueue"
const val isInvincibilityEnabled = "isInvincibilityEnabled"
const val isCachedPlaylistShown = "isCachedPlaylistShown"
}
companion object {