From c1d349f17633bfa321f82e462623cd54a0981477 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 27 Jan 2020 19:40:44 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/App.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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) }