mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 06:59:18 +01:00
Refactor amoled theme configuration
Because I'm tired of being flashed and the double fingerprint popup and other issues Fixes #924
This commit is contained in:
parent
ef166dd712
commit
f56fe25010
@ -1,6 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.ui.base.activity
|
package eu.kanade.tachiyomi.ui.base.activity
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.Resources
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.viewbinding.ViewBinding
|
import androidx.viewbinding.ViewBinding
|
||||||
@ -9,6 +10,7 @@ import eu.kanade.tachiyomi.ui.main.SearchActivity
|
|||||||
import eu.kanade.tachiyomi.ui.security.BiometricActivity
|
import eu.kanade.tachiyomi.ui.security.BiometricActivity
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
|
import eu.kanade.tachiyomi.util.system.getThemeWithExtras
|
||||||
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
@ -34,4 +36,8 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||||||
SecureActivityDelegate.promptLockIfNeeded(this)
|
SecureActivityDelegate.promptLockIfNeeded(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getTheme(): Resources.Theme {
|
||||||
|
return getThemeWithExtras(super.getTheme(), preferences)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package eu.kanade.tachiyomi.ui.base.activity
|
package eu.kanade.tachiyomi.ui.base.activity
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.Resources
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
|
import eu.kanade.tachiyomi.util.system.getThemeWithExtras
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
abstract class BaseThemedActivity : AppCompatActivity() {
|
abstract class BaseThemedActivity : AppCompatActivity() {
|
||||||
@ -20,4 +22,8 @@ abstract class BaseThemedActivity : AppCompatActivity() {
|
|||||||
setThemeAndNight(preferences)
|
setThemeAndNight(preferences)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getTheme(): Resources.Theme {
|
||||||
|
return getThemeWithExtras(super.getTheme(), preferences)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package eu.kanade.tachiyomi.util.system
|
package eu.kanade.tachiyomi.util.system
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.Resources
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.lifecycle.coroutineScope
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
@ -59,22 +59,22 @@ fun AppCompatActivity.setThemeAndNight(preferences: PreferencesHelper) {
|
|||||||
if (preferences.nightMode().isNotSet()) {
|
if (preferences.nightMode().isNotSet()) {
|
||||||
ThemeUtil.convertTheme(preferences, preferences.oldTheme())
|
ThemeUtil.convertTheme(preferences, preferences.oldTheme())
|
||||||
}
|
}
|
||||||
|
if (AppCompatDelegate.getDefaultNightMode() != preferences.nightMode().get()) {
|
||||||
|
AppCompatDelegate.setDefaultNightMode(preferences.nightMode().get())
|
||||||
|
}
|
||||||
val theme = getPrefTheme(preferences)
|
val theme = getPrefTheme(preferences)
|
||||||
setTheme(theme.styleRes)
|
setTheme(theme.styleRes)
|
||||||
|
}
|
||||||
|
|
||||||
if (theme.isDarkTheme && preferences.themeDarkAmoled().get()) {
|
fun AppCompatActivity.getThemeWithExtras(theme: Resources.Theme, preferences: PreferencesHelper): Resources.Theme {
|
||||||
setTheme(R.style.ThemeOverlay_Tachiyomi_Amoled)
|
val prefTheme = getPrefTheme(preferences)
|
||||||
if (ThemeUtil.isColoredTheme(theme)) {
|
if (prefTheme.isDarkTheme && preferences.themeDarkAmoled().get()) {
|
||||||
setTheme(R.style.ThemeOverlay_Tachiyomi_AllBlue)
|
theme.applyStyle(R.style.ThemeOverlay_Tachiyomi_Amoled, true)
|
||||||
}
|
if (ThemeUtil.isColoredTheme(prefTheme)) {
|
||||||
if (!isInNightMode()) {
|
theme.applyStyle(R.style.ThemeOverlay_Tachiyomi_AllBlue, true)
|
||||||
lifecycle.coroutineScope.launchWhenCreated {
|
|
||||||
AppCompatDelegate.setDefaultNightMode(preferences.nightMode().get())
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppCompatDelegate.setDefaultNightMode(preferences.nightMode().get())
|
return theme
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getPrefTheme(preferences: PreferencesHelper): Themes {
|
fun Context.getPrefTheme(preferences: PreferencesHelper): Themes {
|
||||||
|
Loading…
Reference in New Issue
Block a user