mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 05:19:16 +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 {
|
override fun getTheme(): Resources.Theme {
|
||||||
return updatedTheme ?: run {
|
val newTheme = getThemeWithExtras(super.getTheme(), preferences, updatedTheme)
|
||||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences)
|
|
||||||
updatedTheme = newTheme
|
updatedTheme = newTheme
|
||||||
newTheme
|
return newTheme
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,8 @@ abstract class BaseRxActivity<P : BasePresenter<*>> : NucleusAppCompatActivity<P
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getTheme(): Resources.Theme {
|
override fun getTheme(): Resources.Theme {
|
||||||
return updatedTheme ?: run {
|
val newTheme = getThemeWithExtras(super.getTheme(), preferences, updatedTheme)
|
||||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences)
|
|
||||||
updatedTheme = newTheme
|
updatedTheme = newTheme
|
||||||
newTheme
|
return newTheme
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,8 @@ abstract class BaseThemedActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getTheme(): Resources.Theme {
|
override fun getTheme(): Resources.Theme {
|
||||||
return updatedTheme ?: run {
|
val newTheme = getThemeWithExtras(super.getTheme(), preferences, updatedTheme)
|
||||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences)
|
|
||||||
updatedTheme = newTheme
|
updatedTheme = newTheme
|
||||||
newTheme
|
return newTheme
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,12 +98,17 @@ fun AppCompatActivity.setThemeAndNight(preferences: PreferencesHelper) {
|
|||||||
setTheme(theme.styleRes)
|
setTheme(theme.styleRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AppCompatActivity.getThemeWithExtras(theme: Resources.Theme, preferences: PreferencesHelper): Resources.Theme {
|
fun AppCompatActivity.getThemeWithExtras(theme: Resources.Theme, preferences: PreferencesHelper, oldTheme: Resources.Theme?): Resources.Theme {
|
||||||
val prefTheme = getPrefTheme(preferences)
|
val useAmoled = (isInNightMode() || preferences.nightMode().get() == AppCompatDelegate.MODE_NIGHT_YES) &&
|
||||||
if ((isInNightMode() || preferences.nightMode().get() == AppCompatDelegate.MODE_NIGHT_YES) &&
|
|
||||||
preferences.themeDarkAmoled().get()
|
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)
|
theme.applyStyle(R.style.ThemeOverlay_Tachiyomi_Amoled, true)
|
||||||
|
val prefTheme = getPrefTheme(preferences)
|
||||||
if (ThemeUtil.isColoredTheme(prefTheme)) {
|
if (ThemeUtil.isColoredTheme(prefTheme)) {
|
||||||
theme.applyStyle(R.style.ThemeOverlay_Tachiyomi_AllBlue, true)
|
theme.applyStyle(R.style.ThemeOverlay_Tachiyomi_AllBlue, true)
|
||||||
}
|
}
|
||||||
|
@ -6,18 +6,6 @@
|
|||||||
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
|
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
|
||||||
</style>
|
</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">
|
<style name="Theme.Tachiyomi.Strawberries">
|
||||||
<item name="colorPrimary">@color/primaryRed</item>
|
<item name="colorPrimary">@color/primaryRed</item>
|
||||||
<item name="colorAccent">@color/holo_red</item>
|
<item name="colorAccent">@color/holo_red</item>
|
||||||
|
@ -80,7 +80,17 @@
|
|||||||
<item name="android:windowLightStatusBar">false</item>
|
<item name="android:windowLightStatusBar">false</item>
|
||||||
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
|
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
|
||||||
</style>
|
</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"/>
|
<style name="Theme.Tachiyomi.FlatLime"/>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user