fix black theme

This commit is contained in:
Bnyro 2022-08-25 11:26:10 +02:00
parent 44175b35c5
commit d949b38789
4 changed files with 30 additions and 73 deletions

View File

@ -23,7 +23,7 @@
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Purple.Pure" android:theme="@style/StartupTheme"
tools:targetApi="n"> tools:targetApi="n">
<activity <activity

View File

@ -1,5 +1,6 @@
package com.github.libretube.util package com.github.libretube.util
import android.app.Activity
import android.app.NotificationManager import android.app.NotificationManager
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context
@ -22,10 +23,10 @@ object ThemeHelper {
*/ */
fun updateTheme(activity: AppCompatActivity) { fun updateTheme(activity: AppCompatActivity) {
val themeMode = PreferenceHelper.getString(PreferenceKeys.THEME_MODE, "A") val themeMode = PreferenceHelper.getString(PreferenceKeys.THEME_MODE, "A")
val pureThemeEnabled = PreferenceHelper.getBoolean(PreferenceKeys.PURE_THEME, false)
updateAccentColor(activity, pureThemeEnabled) updateAccentColor(activity)
applyDynamicColorsIfEnabled(activity) applyDynamicColorsIfEnabled(activity)
applyPureThemeIfEnabled(activity)
updateThemeMode(themeMode) updateThemeMode(themeMode)
} }
@ -33,8 +34,7 @@ object ThemeHelper {
* Update the accent color of the app * Update the accent color of the app
*/ */
private fun updateAccentColor( private fun updateAccentColor(
activity: AppCompatActivity, activity: AppCompatActivity
pureThemeEnabled: Boolean
) { ) {
val theme = when ( val theme = when (
PreferenceHelper.getString( PreferenceHelper.getString(
@ -43,13 +43,13 @@ object ThemeHelper {
) )
) { ) {
// set the accent color, use the pure black/white theme if enabled // set the accent color, use the pure black/white theme if enabled
"my" -> if (pureThemeEnabled) R.style.BaseTheme_Pure else R.style.BaseTheme "my" -> R.style.BaseTheme
"red" -> if (pureThemeEnabled) R.style.Theme_Red_Pure else R.style.Theme_Red "red" -> R.style.Theme_Red
"blue" -> if (pureThemeEnabled) R.style.Theme_Blue_Pure else R.style.Theme_Blue "blue" -> R.style.Theme_Blue
"yellow" -> if (pureThemeEnabled) R.style.Theme_Yellow_Pure else R.style.Theme_Yellow "yellow" -> R.style.Theme_Yellow
"green" -> if (pureThemeEnabled) R.style.Theme_Green_Pure else R.style.Theme_Green "green" -> R.style.Theme_Green
"purple" -> if (pureThemeEnabled) R.style.Theme_Purple_Pure else R.style.Theme_Purple "purple" -> R.style.Theme_Purple
else -> if (pureThemeEnabled) R.style.Theme_Purple_Pure else R.style.Theme_Purple else -> R.style.Theme_Purple
} }
activity.setTheme(theme) activity.setTheme(theme)
} }
@ -63,7 +63,20 @@ object ThemeHelper {
PreferenceKeys.ACCENT_COLOR, PreferenceKeys.ACCENT_COLOR,
"purple" "purple"
) == "my" ) == "my"
) DynamicColors.applyToActivityIfAvailable(activity) ) {
DynamicColors.applyToActivityIfAvailable(activity)
}
}
/**
* apply the pure black/white theme
*/
private fun applyPureThemeIfEnabled(activity: Activity) {
val pureThemeEnabled = PreferenceHelper.getBoolean(
PreferenceKeys.PURE_THEME,
false
)
if (pureThemeEnabled) activity.theme.applyStyle(R.style.Pure, true)
} }
/** /**

View File

@ -8,7 +8,7 @@
</style> </style>
<style name="BaseTheme.Pure" parent="BaseTheme"> <style name="StartupTheme" parent="BaseTheme">
<item name="android:colorBackground">@android:color/black</item> <item name="android:colorBackground">@android:color/black</item>
<item name="colorSurface">@android:color/black</item> <item name="colorSurface">@android:color/black</item>
@ -29,13 +29,6 @@
</style> </style>
<style name="Theme.Red.Pure" parent="Theme.Red">
<item name="android:colorBackground">@android:color/black</item>
<item name="colorSurface">@android:color/black</item>
</style>
<style name="Theme.Blue" parent="BaseTheme"> <style name="Theme.Blue" parent="BaseTheme">
<item name="colorPrimary">@color/blue_dark_accentLight</item> <item name="colorPrimary">@color/blue_dark_accentLight</item>
@ -50,13 +43,6 @@
</style> </style>
<style name="Theme.Blue.Pure" parent="Theme.Blue">
<item name="android:colorBackground">@android:color/black</item>
<item name="colorSurface">@android:color/black</item>
</style>
<style name="Theme.Yellow" parent="BaseTheme"> <style name="Theme.Yellow" parent="BaseTheme">
<item name="colorPrimary">@color/yellow_dark_accentLight</item> <item name="colorPrimary">@color/yellow_dark_accentLight</item>
@ -71,13 +57,6 @@
</style> </style>
<style name="Theme.Yellow.Pure" parent="Theme.Yellow">
<item name="android:colorBackground">@android:color/black</item>
<item name="colorSurface">@android:color/black</item>
</style>
<style name="Theme.Green" parent="BaseTheme"> <style name="Theme.Green" parent="BaseTheme">
<item name="colorPrimary">@color/green_dark_accentLight</item> <item name="colorPrimary">@color/green_dark_accentLight</item>
@ -92,13 +71,6 @@
</style> </style>
<style name="Theme.Green.Pure" parent="Theme.Green">
<item name="android:colorBackground">@android:color/black</item>
<item name="colorSurface">@android:color/black</item>
</style>
<style name="Theme.Purple" parent="BaseTheme"> <style name="Theme.Purple" parent="BaseTheme">
<item name="colorPrimary">@color/purple_dark_accentLight</item> <item name="colorPrimary">@color/purple_dark_accentLight</item>
@ -113,7 +85,7 @@
</style> </style>
<style name="Theme.Purple.Pure" parent="Theme.Purple"> <style name="Pure">
<item name="android:colorBackground">@android:color/black</item> <item name="android:colorBackground">@android:color/black</item>
<item name="colorSurface">@android:color/black</item> <item name="colorSurface">@android:color/black</item>

View File

@ -8,7 +8,7 @@
</style> </style>
<style name="Theme.BaseTheme.Pure" parent="BaseTheme"> <style name="StartupTheme" parent="BaseTheme">
<item name="android:colorBackground">@android:color/white</item> <item name="android:colorBackground">@android:color/white</item>
<item name="colorSurface">@android:color/white</item> <item name="colorSurface">@android:color/white</item>
@ -30,13 +30,6 @@
</style> </style>
<style name="Theme.Red.Pure" parent="Theme.Red">
<item name="android:colorBackground">@android:color/white</item>
<item name="colorSurface">@android:color/white</item>
</style>
<style name="Theme.Blue" parent="BaseTheme"> <style name="Theme.Blue" parent="BaseTheme">
<item name="colorPrimary">@color/blue_light_accentLight</item> <item name="colorPrimary">@color/blue_light_accentLight</item>
@ -52,13 +45,6 @@
</style> </style>
<style name="Theme.Blue.Pure" parent="Theme.Blue">
<item name="android:colorBackground">@android:color/white</item>
<item name="colorSurface">@android:color/white</item>
</style>
<style name="Theme.Yellow" parent="BaseTheme"> <style name="Theme.Yellow" parent="BaseTheme">
<item name="colorPrimary">@color/yellow_light_accentLight</item> <item name="colorPrimary">@color/yellow_light_accentLight</item>
@ -74,13 +60,6 @@
</style> </style>
<style name="Theme.Yellow.Pure" parent="Theme.Yellow">
<item name="android:colorBackground">@android:color/white</item>
<item name="colorSurface">@android:color/white</item>
</style>
<style name="Theme.Green" parent="BaseTheme"> <style name="Theme.Green" parent="BaseTheme">
<item name="colorPrimary">@color/green_light_accentLight</item> <item name="colorPrimary">@color/green_light_accentLight</item>
@ -96,13 +75,6 @@
</style> </style>
<style name="Theme.Green.Pure" parent="Theme.Green">
<item name="android:colorBackground">@android:color/white</item>
<item name="colorSurface">@android:color/white</item>
</style>
<style name="Theme.Purple" parent="BaseTheme"> <style name="Theme.Purple" parent="BaseTheme">
<item name="colorPrimary">@color/purple_light_accentLight</item> <item name="colorPrimary">@color/purple_light_accentLight</item>
@ -118,7 +90,7 @@
</style> </style>
<style name="Theme.Purple.Pure" parent="Theme.Purple"> <style name="Pure">
<item name="android:colorBackground">@android:color/white</item> <item name="android:colorBackground">@android:color/white</item>
<item name="colorSurface">@android:color/white</item> <item name="colorSurface">@android:color/white</item>