From 27fb0474d503b5ca2557a0ff24233498950af9b8 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Sun, 20 Oct 2019 17:27:39 +0200 Subject: [PATCH] Added more standard night-mode system --- app/src/main/java/com/topjohnwu/magisk/Config.kt | 7 +++++++ .../main/java/com/topjohnwu/magisk/base/BaseActivity.kt | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/Config.kt b/app/src/main/java/com/topjohnwu/magisk/Config.kt index 932467dd7..09c28fb45 100644 --- a/app/src/main/java/com/topjohnwu/magisk/Config.kt +++ b/app/src/main/java/com/topjohnwu/magisk/Config.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.SharedPreferences import android.os.Environment import android.util.Xml +import androidx.appcompat.app.AppCompatDelegate import androidx.core.content.edit import com.topjohnwu.magisk.data.database.SettingsDao import com.topjohnwu.magisk.data.database.StringDao @@ -45,6 +46,7 @@ object Config : PreferenceModel, DBConfig { const val CUSTOM_CHANNEL = "custom_channel" const val LOCALE = "locale" const val DARK_THEME = "dark_theme" + const val DARK_THEME_EXTENDED = "dark_theme_extended" const val REPO_ORDER = "repo_order" const val SHOW_SYSTEM_APP = "show_system" const val DOWNLOAD_PATH = "download_path" @@ -110,7 +112,12 @@ object Config : PreferenceModel, DBConfig { var updateChannel by preferenceStrInt(Key.UPDATE_CHANNEL, defaultChannel) var redesign by preference(Key.REDESIGN, false) + @Deprecated("Use extended dark theme") var darkTheme by preference(Key.DARK_THEME, true) + var darkThemeExtended by preference( + Key.DARK_THEME_EXTENDED, + AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM + ) var suReAuth by preference(Key.SU_REAUTH, false) var checkUpdate by preference(Key.CHECK_UPDATES, true) var magiskHide by preference(Key.MAGISKHIDE, true) diff --git a/app/src/main/java/com/topjohnwu/magisk/base/BaseActivity.kt b/app/src/main/java/com/topjohnwu/magisk/base/BaseActivity.kt index fd32472c5..9c7b22081 100644 --- a/app/src/main/java/com/topjohnwu/magisk/base/BaseActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/base/BaseActivity.kt @@ -39,10 +39,13 @@ abstract class BaseActivity() } init { - val theme = if (Config.darkTheme) { - AppCompatDelegate.MODE_NIGHT_YES + val theme = if (Config.redesign) { + Config.darkThemeExtended } else { - AppCompatDelegate.MODE_NIGHT_NO + when { + Config.darkTheme -> AppCompatDelegate.MODE_NIGHT_YES + else -> AppCompatDelegate.MODE_NIGHT_NO + } } AppCompatDelegate.setDefaultNightMode(theme) }