diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index fed02381c..2dc763432 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -22,6 +22,7 @@ import io.legado.app.lib.theme.ThemeStore import io.legado.app.ui.book.read.page.ChapterProvider import io.legado.app.utils.getCompatColor import io.legado.app.utils.getPrefInt +import io.legado.app.utils.sysIsDarkMode @Suppress("DEPRECATION") class App : Application() { @@ -102,11 +103,18 @@ class App : Application() { } private fun initNightMode() { - val targetMode = if (AppConfig.isNightTheme) { - AppCompatDelegate.MODE_NIGHT_YES - } else { - AppCompatDelegate.MODE_NIGHT_NO - } + val targetMode = + if (AppConfig.autoDarkMode) { + if (sysIsDarkMode()) { + AppCompatDelegate.MODE_NIGHT_YES + } else { + AppCompatDelegate.MODE_NIGHT_NO + } + } else if (AppConfig.isNightTheme) { + AppCompatDelegate.MODE_NIGHT_YES + } else { + AppCompatDelegate.MODE_NIGHT_NO + } AppCompatDelegate.setDefaultNightMode(targetMode) }