diff --git a/app/src/main/java/com/topjohnwu/magisk/Global.java b/app/src/main/java/com/topjohnwu/magisk/Global.java
index 63257f0e0..00a1162f7 100644
--- a/app/src/main/java/com/topjohnwu/magisk/Global.java
+++ b/app/src/main/java/com/topjohnwu/magisk/Global.java
@@ -45,7 +45,7 @@ public class Global {
public static void init(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- isDarkTheme = prefs.getString("theme", context.getString(R.string.theme_default_value)).equalsIgnoreCase(context.getString(R.string.theme_dark_value));
+ isDarkTheme = prefs.getBoolean("dark_theme", false);
devLogging = prefs.getBoolean("developer_logging", false);
shellLogging = prefs.getBoolean("shell_logging", false);
}
diff --git a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
index bdd6976c4..0093155a5 100644
--- a/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
+++ b/app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
@@ -7,6 +7,7 @@ import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
+import android.preference.SwitchPreference;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
@@ -73,7 +74,6 @@ public class SettingsActivity extends AppCompatActivity {
public static class SettingsFragment extends PreferenceFragment
implements SharedPreferences.OnSharedPreferenceChangeListener {
- private ListPreference themePreference;
private SharedPreferences prefs;
@Override
@@ -83,36 +83,28 @@ public class SettingsActivity extends AppCompatActivity {
PreferenceManager.setDefaultValues(getActivity(), R.xml.app_settings, false);
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
- themePreference = (ListPreference) findPreference("theme");
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide");
- CheckBoxPreference hostsPreference = (CheckBoxPreference) findPreference("hosts");
+ SwitchPreference hostsPreference = (SwitchPreference) findPreference("hosts");
Preference clear = findPreference("clear");
clear.setOnPreferenceClickListener((pref) -> {
- ModuleHelper.clearRepoCache(getActivity());
+ ModuleHelper.clearRepoCache(getActivity());
return true;
});
- if (Global.Configs.isDarkTheme) {
- themePreference.setSummary(R.string.theme_dark);
- } else {
- themePreference.setSummary(R.string.theme_default);
- }
-
- if (Global.Info.magiskVersion < 9) {
- hostsPreference.setEnabled(false);
- busyboxPreference.setEnabled(false);
- } else if (Global.Info.magiskVersion < 8) {
- magiskhidePreference.setEnabled(false);
- } else if (! Shell.rootAccess()) {
+ if (!Shell.rootAccess()) {
busyboxPreference.setEnabled(false);
magiskhidePreference.setEnabled(false);
hostsPreference.setEnabled(false);
} else {
- busyboxPreference.setEnabled(true);
- magiskhidePreference.setEnabled(true);
- hostsPreference.setEnabled(true);
+ if (Global.Info.magiskVersion < 9) {
+ hostsPreference.setEnabled(false);
+ busyboxPreference.setEnabled(false);
+ }
+ if (Global.Info.magiskVersion < 8) {
+ magiskhidePreference.setEnabled(false);
+ }
}
}
@@ -123,9 +115,9 @@ public class SettingsActivity extends AppCompatActivity {
}
@Override
- public void onDestroy() {
+ public void onStop() {
+ super.onStop();
prefs.unregisterOnSharedPreferenceChangeListener(this);
- super.onDestroy();
}
@Override
@@ -134,10 +126,10 @@ public class SettingsActivity extends AppCompatActivity {
boolean checked;
switch (key) {
- case "theme":
- String theme = prefs.getString("theme", getString(R.string.theme_default_value));
- if (Global.Configs.isDarkTheme != theme.equalsIgnoreCase(getString(R.string.theme_dark_value))) {
- Global.Configs.isDarkTheme = !Global.Configs.isDarkTheme;
+ case "dark_theme":
+ checked = prefs.getBoolean("dark_theme", false);
+ if (Global.Configs.isDarkTheme != checked) {
+ Global.Configs.isDarkTheme = checked;
getActivity().recreate();
Global.Events.reloadMainActivity.trigger();
}
diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml
index 1772b6ed3..983daa749 100644
--- a/app/src/main/res/values-ar/strings.xml
+++ b/app/src/main/res/values-ar/strings.xml
@@ -83,8 +83,8 @@
عام
- السمة
- أختر سمة
+ السمة
+ أختر سمة
إفتراضي
غامق
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 60e48b625..863e346aa 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -113,8 +113,8 @@
Allgemein
- Thema
- Wähle ein Thema
+ Thema
+ Wähle ein Thema
Standard
Dunkel
Repo-Cache löschen
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 6e480e864..80f226e69 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -80,8 +80,8 @@
General
- Tema
- Selecciona un tema
+ Tema
+ Selecciona un tema
Por defecto
Oscuro
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index caf55a025..895dbb1eb 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -78,8 +78,8 @@
Generali
- Tema
- Scegli un tema
+ Tema
+ Scegli un tema
Default
Scuro
diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml
index 97cc29800..02006a6f0 100644
--- a/app/src/main/res/values-nl/strings.xml
+++ b/app/src/main/res/values-nl/strings.xml
@@ -78,8 +78,8 @@
Algemeen
- Thema
- Selecteer een thema
+ Thema
+ Selecteer een thema
Standaard
Donker
diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml
index fcae5ec73..24f656bee 100644
--- a/app/src/main/res/values-pt/strings.xml
+++ b/app/src/main/res/values-pt/strings.xml
@@ -107,8 +107,8 @@
Geral
- Tema
- Escolha um tema
+ Tema
+ Escolha um tema
Padrão
Escuro
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index c99cf5576..4dac93e5a 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -104,8 +104,8 @@
常规
- 主题
- 选择一个主题
+ 主题
+ 选择一个主题
默认
深色
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 52ba65777..ed84bb702 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -121,8 +121,8 @@
General
- Theme
- Select a theme
+ Dark Theme
+ Toggle dark theme
Default
Dark
Clear Repo Cache
diff --git a/app/src/main/res/xml/app_settings.xml b/app/src/main/res/xml/app_settings.xml
index 8f382eb75..f5d4dc8fe 100644
--- a/app/src/main/res/xml/app_settings.xml
+++ b/app/src/main/res/xml/app_settings.xml
@@ -4,13 +4,11 @@
-
+
-