Add Dynamic theme for Android 12 (#5569)

* Add Dynamic theme for Android 12

* Also theme text colors
This commit is contained in:
Ivan Iskandar
2021-07-19 00:01:58 +07:00
committed by GitHub
parent 8bfc5f0450
commit b2d58e04d2
13 changed files with 79 additions and 3 deletions

View File

@ -23,6 +23,7 @@ object PreferenceValues {
enum class AppTheme(val titleResId: Int?) {
DEFAULT(R.string.theme_default),
MONET(R.string.theme_monet),
BLUE(R.string.theme_blue),
GREEN_APPLE(R.string.theme_greenapple),
MIDNIGHT_DUSK(R.string.theme_midnightdusk),

View File

@ -40,6 +40,9 @@ abstract class BaseThemedActivity : AppCompatActivity() {
fun AppCompatActivity.applyThemePreferences(preferences: PreferencesHelper) {
val resIds = mutableListOf<Int>()
when (preferences.appTheme().get()) {
PreferenceValues.AppTheme.MONET -> {
resIds += R.style.Theme_Tachiyomi_Monet
}
PreferenceValues.AppTheme.BLUE -> {
resIds += R.style.Theme_Tachiyomi_Blue
resIds += R.style.ThemeOverlay_Tachiyomi_ColoredBars

View File

@ -122,7 +122,14 @@ class SettingsGeneralController : SettingsController() {
key = Keys.appTheme
titleRes = R.string.pref_app_theme
val appThemes = Values.AppTheme.values().filter { it.titleResId != null }
val appThemes = Values.AppTheme.values().filter {
val monetFilter = if (it == Values.AppTheme.MONET) {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
} else {
true
}
it.titleResId != null && monetFilter
}
entriesRes = appThemes.map { it.titleResId!! }.toTypedArray()
entryValues = appThemes.map { it.name }.toTypedArray()
defaultValue = appThemes[0].name