mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Add: Dynamic theming preference
This commit is contained in:
parent
2ace49469e
commit
45161514cc
@ -219,7 +219,8 @@ object Preferences {
|
||||
|
||||
sealed class Theme(override val valueString: String) : Enumeration<Theme> {
|
||||
override val values: List<Theme>
|
||||
get() = if (Android.sdk(29)) listOf(System, AmoledSystem, Light, Dark, Amoled)
|
||||
get() = if (Android.sdk(31)) listOf(Dynamic, System, AmoledSystem, Light, Dark, Amoled)
|
||||
else if (Android.sdk(29)) listOf(System, AmoledSystem, Light, Dark, Amoled)
|
||||
else listOf(Light, Dark, Amoled)
|
||||
|
||||
abstract fun getResId(configuration: Configuration): Int
|
||||
@ -238,6 +239,12 @@ object Preferences {
|
||||
}
|
||||
}
|
||||
|
||||
object Dynamic : Theme("dynamic-system") {
|
||||
override fun getResId(configuration: Configuration): Int {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
object Light : Theme("light") {
|
||||
override fun getResId(configuration: Configuration): Int = R.style.Theme_Main_Light
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ class PrefsUserFragment : PrefsNavFragmentX() {
|
||||
is Preferences.Theme.AmoledSystem -> getString(R.string.system) + " " + getString(
|
||||
R.string.amoled
|
||||
)
|
||||
is Preferences.Theme.Dynamic -> getString(R.string.dynamic)
|
||||
is Preferences.Theme.Light -> getString(R.string.light)
|
||||
is Preferences.Theme.Dark -> getString(R.string.dark)
|
||||
is Preferences.Theme.Amoled -> getString(R.string.amoled)
|
||||
|
@ -241,6 +241,12 @@ val isBlackTheme: Boolean
|
||||
else -> false
|
||||
}
|
||||
|
||||
val isDynamicColorsTheme: Boolean
|
||||
get() = when (Preferences[Preferences.Key.Theme]) {
|
||||
is Preferences.Theme.Dynamic -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
fun Context.showBatteryOptimizationDialog() {
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(R.string.ignore_battery_optimization_title)
|
||||
|
@ -207,4 +207,5 @@
|
||||
<string name="loading_list">Loading list…</string>
|
||||
<string name="releases">Releases</string>
|
||||
<string name="no_updates_available">No versions available</string>
|
||||
<string name="dynamic">System dynamic</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user