优化
Some checks failed
Test Build / prepare (push) Has been cancelled
Test Build / build (app, release) (push) Has been cancelled
Test Build / build (app, releaseA) (push) Has been cancelled
Test Build / prerelease (push) Has been cancelled
Test Build / lanzou (push) Has been cancelled
Test Build / test_Branch (push) Has been cancelled
Test Build / telegram (push) Has been cancelled
closeStaleIssue / stale (push) Has been cancelled

This commit is contained in:
Horis
2025-04-30 19:35:32 +08:00
parent 830e44bda5
commit 9f7ce9d6f2
2 changed files with 8 additions and 3 deletions

View File

@@ -28,7 +28,7 @@ import io.legado.app.help.RuleBigDataHelp
import io.legado.app.help.book.BookHelp
import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.ThemeConfig.applyDayNight
import io.legado.app.help.config.ThemeConfig.initNightMode
import io.legado.app.help.config.ThemeConfig.applyDayNightInit
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.help.http.Cronet
import io.legado.app.help.http.ObsoleteUrlFactory
@@ -60,7 +60,7 @@ class App : Application() {
ThreadUtils.setThreadAssertsDisabledForTesting(true)
}
oldConfig = Configuration(resources.configuration)
initNightMode()
applyDayNightInit(this)
registerActivityLifecycleCallbacks(LifecycleHelp)
defaultSharedPreferences.registerOnSharedPreferenceChangeListener(AppConfig)
Coroutine.async {

View File

@@ -57,7 +57,12 @@ object ThemeConfig {
postEvent(EventBus.RECREATE, "")
}
fun initNightMode() {
fun applyDayNightInit(context: Context) {
applyTheme(context)
initNightMode()
}
private fun initNightMode() {
val targetMode =
if (AppConfig.isNightTheme) {
AppCompatDelegate.MODE_NIGHT_YES