diff --git a/app/src/main/java/com/smartpack/kernelprofiler/MainActivity.java b/app/src/main/java/com/smartpack/kernelprofiler/MainActivity.java index 85ac23c..83c687b 100644 --- a/app/src/main/java/com/smartpack/kernelprofiler/MainActivity.java +++ b/app/src/main/java/com/smartpack/kernelprofiler/MainActivity.java @@ -153,8 +153,13 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { private void settingsMenu() { PopupMenu popupMenu = new PopupMenu(this, mSettings); Menu menu = popupMenu.getMenu(); - menu.add(Menu.NONE, 1, Menu.NONE, getString(R.string.dark_theme)).setCheckable(true).setChecked( - Prefs.getBoolean("dark_theme", true, this)); + SubMenu appTheme = menu.addSubMenu(Menu.NONE, 0, Menu.NONE, getString(R.string.dark_theme)); + appTheme.add(Menu.NONE, 21, Menu.NONE, getString(R.string.dark_theme_auto)).setCheckable(true) + .setChecked(Prefs.getBoolean("theme_auto", true, this)); + appTheme.add(Menu.NONE, 1, Menu.NONE, getString(R.string.dark_theme_enable)).setCheckable(true) + .setChecked(Prefs.getBoolean("dark_theme", false, this)); + appTheme.add(Menu.NONE, 20, Menu.NONE, getString(R.string.dark_theme_disable)).setCheckable(true) + .setChecked(Prefs.getBoolean("light_theme", false, this)); if (KP.supported() && KP.isCustomSettingsAvailable()) { SubMenu kernel = menu.addSubMenu(Menu.NONE, 0, Menu.NONE, getString(R.string.kernel_about)); if (KP.getSupport() != null && !KP.getSupport().isEmpty()) { @@ -196,12 +201,12 @@ private void settingsMenu() { case 0: break; case 1: - if (Prefs.getBoolean("dark_theme", true, this)) { - Prefs.saveBoolean("dark_theme", false, this); - } else { + if (!Prefs.getBoolean("dark_theme", false, this)) { Prefs.saveBoolean("dark_theme", true, this); + Prefs.saveBoolean("light_theme", false, this); + Prefs.saveBoolean("theme_auto", false, this); + restartApp(); } - restartApp(); break; case 2: launchURL(KP.getSupport()); @@ -289,6 +294,22 @@ private void settingsMenu() { restartApp(); } break; + case 20: + if (!Prefs.getBoolean("light_theme", false, this)) { + Prefs.saveBoolean("dark_theme", false, this); + Prefs.saveBoolean("light_theme", true, this); + Prefs.saveBoolean("theme_auto", false, this); + restartApp(); + } + break; + case 21: + if (!Prefs.getBoolean("theme_auto", true, this)) { + Prefs.saveBoolean("dark_theme", false, this); + Prefs.saveBoolean("light_theme", false, this); + Prefs.saveBoolean("theme_auto", true, this); + restartApp(); + } + break; } return false; }); diff --git a/app/src/main/java/com/smartpack/kernelprofiler/utils/Utils.java b/app/src/main/java/com/smartpack/kernelprofiler/utils/Utils.java index 8ed542d..4b7f7d9 100644 --- a/app/src/main/java/com/smartpack/kernelprofiler/utils/Utils.java +++ b/app/src/main/java/com/smartpack/kernelprofiler/utils/Utils.java @@ -55,12 +55,15 @@ public static boolean isNotDonated(Context context) { } public static void initializeAppTheme(Context context) { - if (Prefs.getBoolean("dark_theme", true, context)) { + if (Prefs.getBoolean("dark_theme", false, context)) { AppCompatDelegate.setDefaultNightMode( AppCompatDelegate.MODE_NIGHT_YES); - } else { + } else if (Prefs.getBoolean("light_theme", false, context)) { AppCompatDelegate.setDefaultNightMode( AppCompatDelegate.MODE_NIGHT_NO); + } else { + AppCompatDelegate.setDefaultNightMode( + AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d30fe6e..ad38c37 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,6 +15,9 @@ Credits Grarak: KernelAdiutor (Code base)\ntopjohnwu: libsu\nLennoard Silva: Code Contributions, App Icon, & Portuguese (Brazilian) Translation\ntsiflimagas: Greek translations Dark Theme + Auto + Disable + Enable The changes you made on this page will be lost! Are you sure? Description Add a short description about your kernel here (single line)!