fix material you

This commit is contained in:
Bnyro 2022-08-25 11:11:31 +02:00
parent 47a4187d52
commit 44175b35c5

View File

@ -25,6 +25,7 @@ object ThemeHelper {
val pureThemeEnabled = PreferenceHelper.getBoolean(PreferenceKeys.PURE_THEME, false) val pureThemeEnabled = PreferenceHelper.getBoolean(PreferenceKeys.PURE_THEME, false)
updateAccentColor(activity, pureThemeEnabled) updateAccentColor(activity, pureThemeEnabled)
applyDynamicColorsIfEnabled(activity)
updateThemeMode(themeMode) updateThemeMode(themeMode)
} }
@ -41,15 +42,8 @@ object ThemeHelper {
"purple" "purple"
) )
) { ) {
"my" -> { // set the accent color, use the pure black/white theme if enabled
applyDynamicColors(activity) "my" -> if (pureThemeEnabled) R.style.BaseTheme_Pure else R.style.BaseTheme
if (pureThemeEnabled) {
R.style.BaseTheme_Pure
} else {
R.style.BaseTheme
}
}
// set the theme, use the pure theme if enabled
"red" -> if (pureThemeEnabled) R.style.Theme_Red_Pure else R.style.Theme_Red "red" -> if (pureThemeEnabled) R.style.Theme_Red_Pure else R.style.Theme_Red
"blue" -> if (pureThemeEnabled) R.style.Theme_Blue_Pure else R.style.Theme_Blue "blue" -> if (pureThemeEnabled) R.style.Theme_Blue_Pure else R.style.Theme_Blue
"yellow" -> if (pureThemeEnabled) R.style.Theme_Yellow_Pure else R.style.Theme_Yellow "yellow" -> if (pureThemeEnabled) R.style.Theme_Yellow_Pure else R.style.Theme_Yellow
@ -63,8 +57,13 @@ object ThemeHelper {
/** /**
* apply dynamic colors to the activity * apply dynamic colors to the activity
*/ */
private fun applyDynamicColors(activity: AppCompatActivity) { private fun applyDynamicColorsIfEnabled(activity: AppCompatActivity) {
DynamicColors.applyToActivityIfAvailable(activity) if (
PreferenceHelper.getString(
PreferenceKeys.ACCENT_COLOR,
"purple"
) == "my"
) DynamicColors.applyToActivityIfAvailable(activity)
} }
/** /**