Support follow system theme[Android 10] (#2603)

* Support follow system theme

* Show [follow system theme] only on Oreo and newer

* Update preference values of theme

* Refine theme preference
This commit is contained in:
onlymash
2020-02-19 10:58:52 +08:00
committed by GitHub
parent ef533b4c87
commit 02b5c3da71
6 changed files with 100 additions and 19 deletions

View File

@@ -5,7 +5,9 @@ package eu.kanade.tachiyomi.data.preference
*/
object PreferenceKeys {
const val theme = "pref_theme_key"
const val themeMode = "pref_theme_mode_key"
const val themeDark = "pref_theme_dark_key"
const val rotation = "pref_rotation_type_key"

View File

@@ -0,0 +1,19 @@
package eu.kanade.tachiyomi.data.preference
/**
* This class stores the values for the preferences in the application.
*/
object PreferenceValues {
const val THEME_MODE_LIGHT = "light"
const val THEME_MODE_DARK = "dark"
const val THEME_MODE_SYSTEM = "system"
const val THEME_DARK_DEFAULT = "default"
const val THEME_DARK_AMOLED = "amoled"
const val THEME_DARK_BLUE = "blue"
}

View File

@@ -15,6 +15,7 @@ import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.Locale
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
fun <T> Preference<T>.getOrDefault(): T = get() ?: defaultValue()!!
@@ -53,7 +54,9 @@ class PreferencesHelper(val context: Context) {
fun clear() = prefs.edit().clear().apply()
fun theme() = prefs.getInt(Keys.theme, 1)
fun themeMode() = prefs.getString(Keys.themeMode, Values.THEME_MODE_LIGHT)
fun themeDark() = prefs.getString(Keys.themeDark, Values.THEME_DARK_DEFAULT)
fun rotation() = rxPrefs.getInteger(Keys.rotation, 1)