Use enums for other PreferenceValues

This commit is contained in:
arkon
2020-05-25 14:07:12 -04:00
parent 0af81c7d05
commit a0f5633094
4 changed files with 40 additions and 34 deletions

View File

@@ -5,16 +5,22 @@ package eu.kanade.tachiyomi.data.preference
*/
object PreferenceValues {
const val THEME_MODE_LIGHT = "light"
const val THEME_MODE_DARK = "dark"
const val THEME_MODE_SYSTEM = "system"
enum class ThemeMode(val value: String) {
LIGHT("light"),
DARK("dark"),
SYSTEM("system"),
}
const val THEME_LIGHT_DEFAULT = "default"
const val THEME_LIGHT_BLUE = "blue"
enum class LightThemeVariant(val value: String) {
DEFAULT("default"),
BLUE("blue"),
}
const val THEME_DARK_DEFAULT = "default"
const val THEME_DARK_BLUE = "blue"
const val THEME_DARK_AMOLED = "amoled"
enum class DarkThemeVariant(val value: String) {
DEFAULT("default"),
BLUE("blue"),
AMOLED("amoled"),
}
enum class DisplayMode(val value: Int) {
COMPACT_GRID(0),

View File

@@ -69,11 +69,11 @@ class PreferencesHelper(val context: Context) {
fun clear() = prefs.edit().clear().apply()
fun themeMode() = flowPrefs.getString(Keys.themeMode, Values.THEME_MODE_SYSTEM)
fun themeMode() = flowPrefs.getString(Keys.themeMode, Values.ThemeMode.SYSTEM.value)
fun themeLight() = flowPrefs.getString(Keys.themeLight, Values.THEME_LIGHT_DEFAULT)
fun themeLight() = flowPrefs.getString(Keys.themeLight, Values.LightThemeVariant.DEFAULT.value)
fun themeDark() = flowPrefs.getString(Keys.themeDark, Values.THEME_DARK_DEFAULT)
fun themeDark() = flowPrefs.getString(Keys.themeDark, Values.DarkThemeVariant.DEFAULT.value)
fun rotation() = flowPrefs.getInt(Keys.rotation, 1)