mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-10 19:18:56 +01:00
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:
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user