mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 06:39:20 +01:00
parent
b099524f54
commit
e72356eb1e
@ -20,11 +20,14 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
lateinit var binding: VB
|
||||
val isBindingInitialized get() = this::binding.isInitialized
|
||||
|
||||
private var updatedTheme: Resources.Theme? = null
|
||||
|
||||
override fun attachBaseContext(newBase: Context) {
|
||||
super.attachBaseContext(LocaleHelper.createLocaleWrapper(newBase))
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
updatedTheme = null
|
||||
setThemeAndNight(preferences)
|
||||
super.onCreate(savedInstanceState)
|
||||
SecureActivityDelegate.setSecure(this)
|
||||
@ -38,6 +41,10 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun getTheme(): Resources.Theme {
|
||||
return getThemeWithExtras(super.getTheme(), preferences)
|
||||
return updatedTheme ?: run {
|
||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences)
|
||||
updatedTheme = newTheme
|
||||
newTheme
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import androidx.lifecycle.lifecycleScope
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import eu.kanade.tachiyomi.util.system.getThemeWithExtras
|
||||
import nucleus.view.NucleusAppCompatActivity
|
||||
@ -16,12 +17,15 @@ abstract class BaseRxActivity<P : BasePresenter<*>> : NucleusAppCompatActivity<P
|
||||
|
||||
val scope = lifecycleScope
|
||||
private val preferences by injectLazy<PreferencesHelper>()
|
||||
private var updatedTheme: Resources.Theme? = null
|
||||
|
||||
override fun attachBaseContext(newBase: Context) {
|
||||
super.attachBaseContext(LocaleHelper.createLocaleWrapper(newBase))
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
updatedTheme = null
|
||||
setThemeAndNight(preferences)
|
||||
super.onCreate(savedInstanceState)
|
||||
SecureActivityDelegate.setSecure(this)
|
||||
}
|
||||
@ -32,6 +36,10 @@ abstract class BaseRxActivity<P : BasePresenter<*>> : NucleusAppCompatActivity<P
|
||||
}
|
||||
|
||||
override fun getTheme(): Resources.Theme {
|
||||
return getThemeWithExtras(super.getTheme(), preferences)
|
||||
return updatedTheme ?: run {
|
||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences)
|
||||
updatedTheme = newTheme
|
||||
newTheme
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,17 +13,23 @@ import uy.kohesive.injekt.injectLazy
|
||||
abstract class BaseThemedActivity : AppCompatActivity() {
|
||||
|
||||
val preferences: PreferencesHelper by injectLazy()
|
||||
private var updatedTheme: Resources.Theme? = null
|
||||
|
||||
override fun attachBaseContext(newBase: Context) {
|
||||
super.attachBaseContext(LocaleHelper.createLocaleWrapper(newBase))
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
updatedTheme = null
|
||||
setThemeAndNight(preferences)
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun getTheme(): Resources.Theme {
|
||||
return getThemeWithExtras(super.getTheme(), preferences)
|
||||
return updatedTheme ?: run {
|
||||
val newTheme = getThemeWithExtras(super.getTheme(), preferences)
|
||||
updatedTheme = newTheme
|
||||
newTheme
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ import eu.kanade.tachiyomi.util.system.isTablet
|
||||
import eu.kanade.tachiyomi.util.system.launchIO
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||
import eu.kanade.tachiyomi.util.system.setThemeAndNight
|
||||
import eu.kanade.tachiyomi.util.system.spToPx
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.collapse
|
||||
@ -204,7 +203,6 @@ class ReaderActivity :
|
||||
* Called when the activity is created. Initializes the presenter and configuration.
|
||||
*/
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setThemeAndNight(preferences)
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ReaderActivityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
Loading…
Reference in New Issue
Block a user