mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 03:19:18 +01:00
Fix amoled theme resetting on relaunch for older devices/system light theme
This commit is contained in:
parent
1f11faaffd
commit
f1e4669e5c
@ -41,10 +41,8 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun getTheme(): Resources.Theme {
|
||||
return updatedTheme ?: run {
|
||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences)
|
||||
updatedTheme = newTheme
|
||||
newTheme
|
||||
}
|
||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences, updatedTheme)
|
||||
updatedTheme = newTheme
|
||||
return newTheme
|
||||
}
|
||||
}
|
||||
|
@ -36,10 +36,8 @@ abstract class BaseRxActivity<P : BasePresenter<*>> : NucleusAppCompatActivity<P
|
||||
}
|
||||
|
||||
override fun getTheme(): Resources.Theme {
|
||||
return updatedTheme ?: run {
|
||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences)
|
||||
updatedTheme = newTheme
|
||||
newTheme
|
||||
}
|
||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences, updatedTheme)
|
||||
updatedTheme = newTheme
|
||||
return newTheme
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,8 @@ abstract class BaseThemedActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun getTheme(): Resources.Theme {
|
||||
return updatedTheme ?: run {
|
||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences)
|
||||
updatedTheme = newTheme
|
||||
newTheme
|
||||
}
|
||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences, updatedTheme)
|
||||
updatedTheme = newTheme
|
||||
return newTheme
|
||||
}
|
||||
}
|
||||
|
@ -98,12 +98,17 @@ fun AppCompatActivity.setThemeAndNight(preferences: PreferencesHelper) {
|
||||
setTheme(theme.styleRes)
|
||||
}
|
||||
|
||||
fun AppCompatActivity.getThemeWithExtras(theme: Resources.Theme, preferences: PreferencesHelper): Resources.Theme {
|
||||
val prefTheme = getPrefTheme(preferences)
|
||||
if ((isInNightMode() || preferences.nightMode().get() == AppCompatDelegate.MODE_NIGHT_YES) &&
|
||||
fun AppCompatActivity.getThemeWithExtras(theme: Resources.Theme, preferences: PreferencesHelper, oldTheme: Resources.Theme?): Resources.Theme {
|
||||
val useAmoled = (isInNightMode() || preferences.nightMode().get() == AppCompatDelegate.MODE_NIGHT_YES) &&
|
||||
preferences.themeDarkAmoled().get()
|
||||
) {
|
||||
if (oldTheme != null) {
|
||||
val array = oldTheme.obtainStyledAttributes(intArrayOf(android.R.attr.colorBackground))
|
||||
val bg = array.getColor(0, 0)
|
||||
if (bg == Color.BLACK && useAmoled) { return oldTheme }
|
||||
}
|
||||
if (useAmoled) {
|
||||
theme.applyStyle(R.style.ThemeOverlay_Tachiyomi_Amoled, true)
|
||||
val prefTheme = getPrefTheme(preferences)
|
||||
if (ThemeUtil.isColoredTheme(prefTheme)) {
|
||||
theme.applyStyle(R.style.ThemeOverlay_Tachiyomi_AllBlue, true)
|
||||
}
|
||||
|
@ -6,18 +6,6 @@
|
||||
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
|
||||
</style>
|
||||
|
||||
<!--== AMOLED theme overlay ==-->
|
||||
<style name="ThemeOverlay.Tachiyomi.Amoled" parent="">
|
||||
<item name="colorSecondary">@color/colorAmoledPrimary</item>
|
||||
<item name="colorPrimaryVariant">@color/colorAmoledPrimary</item>
|
||||
<item name="colorOnPrimary">@color/colorAmoledPrimary</item>
|
||||
<item name="android:colorBackground">@color/colorAmoledPrimary</item>
|
||||
<item name="readerBackground">@color/colorAmoledPrimary</item>
|
||||
|
||||
<!-- Material Dialog colors -->
|
||||
<item name="md_background_color">@color/colorAmoledPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tachiyomi.Strawberries">
|
||||
<item name="colorPrimary">@color/primaryRed</item>
|
||||
<item name="colorAccent">@color/holo_red</item>
|
||||
|
@ -80,7 +80,17 @@
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
|
||||
</style>
|
||||
<style name="ThemeOverlay.Tachiyomi.Amoled" parent=""/>
|
||||
|
||||
<style name="ThemeOverlay.Tachiyomi.Amoled" parent="">
|
||||
<item name="colorSecondary">@color/md_black_1000</item>
|
||||
<item name="colorPrimaryVariant">@color/md_black_1000</item>
|
||||
<item name="colorOnPrimary">@color/md_black_1000</item>
|
||||
<item name="android:colorBackground">@color/md_black_1000</item>
|
||||
<item name="readerBackground">@color/md_black_1000</item>
|
||||
|
||||
<!-- Material Dialog colors -->
|
||||
<item name="md_background_color">@color/md_black_1000</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tachiyomi.FlatLime"/>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user