Improved settings
This commit is contained in:
parent
b067105660
commit
c3c155a1ed
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -83,8 +83,8 @@
|
||||
|
||||
<!--Settings Activity -->
|
||||
<string name="settings_general_category">عام</string>
|
||||
<string name="settings_theme_title">السمة</string>
|
||||
<string name="settings_theme_summary">أختر سمة</string>
|
||||
<string name="settings_dark_theme_title">السمة</string>
|
||||
<string name="settings_dark_theme_summary">أختر سمة</string>
|
||||
<string name="theme_default">إفتراضي</string>
|
||||
<string name="theme_dark">غامق</string>
|
||||
|
||||
|
@ -113,8 +113,8 @@
|
||||
|
||||
<!--Settings Activity -->
|
||||
<string name="settings_general_category">Allgemein</string>
|
||||
<string name="settings_theme_title">Thema</string>
|
||||
<string name="settings_theme_summary">Wähle ein Thema</string>
|
||||
<string name="settings_dark_theme_title">Thema</string>
|
||||
<string name="settings_dark_theme_summary">Wähle ein Thema</string>
|
||||
<string name="theme_default">Standard</string>
|
||||
<string name="theme_dark">Dunkel</string>
|
||||
<string name="settings_clear_cache_title">Repo-Cache löschen</string>
|
||||
|
@ -80,8 +80,8 @@
|
||||
|
||||
<!--Settings Activity -->
|
||||
<string name="settings_general_category">General</string>
|
||||
<string name="settings_theme_title">Tema</string>
|
||||
<string name="settings_theme_summary">Selecciona un tema</string>
|
||||
<string name="settings_dark_theme_title">Tema</string>
|
||||
<string name="settings_dark_theme_summary">Selecciona un tema</string>
|
||||
<string name="theme_default">Por defecto</string>
|
||||
<string name="theme_dark">Oscuro</string>
|
||||
|
||||
|
@ -78,8 +78,8 @@
|
||||
|
||||
<!--Settings Fragment -->
|
||||
<string name="settings_general_category">Generali</string>
|
||||
<string name="settings_theme_title">Tema</string>
|
||||
<string name="settings_theme_summary">Scegli un tema</string>
|
||||
<string name="settings_dark_theme_title">Tema</string>
|
||||
<string name="settings_dark_theme_summary">Scegli un tema</string>
|
||||
<string name="theme_default">Default</string>
|
||||
<string name="theme_dark">Scuro</string>
|
||||
|
||||
|
@ -78,8 +78,8 @@
|
||||
|
||||
<!--Settings Fragment -->
|
||||
<string name="settings_general_category">Algemeen</string>
|
||||
<string name="settings_theme_title">Thema</string>
|
||||
<string name="settings_theme_summary">Selecteer een thema</string>
|
||||
<string name="settings_dark_theme_title">Thema</string>
|
||||
<string name="settings_dark_theme_summary">Selecteer een thema</string>
|
||||
<string name="theme_default">Standaard</string>
|
||||
<string name="theme_dark">Donker</string>
|
||||
|
||||
|
@ -107,8 +107,8 @@
|
||||
|
||||
<!--Settings Fragment -->
|
||||
<string name="settings_general_category">Geral</string>
|
||||
<string name="settings_theme_title">Tema</string>
|
||||
<string name="settings_theme_summary">Escolha um tema</string>
|
||||
<string name="settings_dark_theme_title">Tema</string>
|
||||
<string name="settings_dark_theme_summary">Escolha um tema</string>
|
||||
<string name="theme_default">Padrão</string>
|
||||
<string name="theme_dark">Escuro</string>
|
||||
|
||||
|
@ -104,8 +104,8 @@
|
||||
|
||||
<!--Settings Activity -->
|
||||
<string name="settings_general_category">常规</string>
|
||||
<string name="settings_theme_title">主题</string>
|
||||
<string name="settings_theme_summary">选择一个主题</string>
|
||||
<string name="settings_dark_theme_title">主题</string>
|
||||
<string name="settings_dark_theme_summary">选择一个主题</string>
|
||||
<string name="theme_default">默认</string>
|
||||
<string name="theme_dark">深色</string>
|
||||
|
||||
|
@ -121,8 +121,8 @@
|
||||
|
||||
<!--Settings Activity -->
|
||||
<string name="settings_general_category">General</string>
|
||||
<string name="settings_theme_title">Theme</string>
|
||||
<string name="settings_theme_summary">Select a theme</string>
|
||||
<string name="settings_dark_theme_title">Dark Theme</string>
|
||||
<string name="settings_dark_theme_summary">Toggle dark theme</string>
|
||||
<string name="theme_default">Default</string>
|
||||
<string name="theme_dark">Dark</string>
|
||||
<string name="settings_clear_cache_title">Clear Repo Cache</string>
|
||||
|
@ -4,13 +4,11 @@
|
||||
<PreferenceCategory
|
||||
android:title="@string/settings_general_category">
|
||||
|
||||
<ListPreference
|
||||
android:key="theme"
|
||||
android:title="@string/settings_theme_title"
|
||||
android:summary="@string/settings_theme_summary"
|
||||
android:defaultValue="@string/theme_default_value"
|
||||
android:entries="@array/themes"
|
||||
android:entryValues="@array/themes_values"/>
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:title="@string/settings_dark_theme_title"
|
||||
android:summary="@string/settings_dark_theme_summary"
|
||||
android:key="dark_theme" />
|
||||
|
||||
<Preference
|
||||
android:key="clear"
|
||||
@ -34,7 +32,7 @@
|
||||
android:title="@string/settings_busybox_title"
|
||||
android:summary="@string/settings_busybox_summary" />
|
||||
|
||||
<CheckBoxPreference
|
||||
<SwitchPreference
|
||||
android:key="hosts"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/settings_hosts_title"
|
||||
|
Loading…
Reference in New Issue
Block a user