Update settings

This commit is contained in:
topjohnwu 2017-01-28 22:02:33 +08:00
parent cd4dfc9861
commit 9bc0b7f183
6 changed files with 46 additions and 15 deletions

View File

@ -20,7 +20,7 @@ android {
}
compileOptions {
incremental false
incremental true
}
buildTypes {
@ -34,7 +34,7 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
preDexLibraries = false
preDexLibraries = true
}
externalNativeBuild {
cmake {

View File

@ -69,6 +69,7 @@ public class Global {
initSuConfigs(context);
// Initialize prefs
prefs.edit()
.putBoolean("dark_theme", Configs.isDarkTheme)
.putBoolean("magiskhide", Utils.itemExist(false, "/magisk/.core/magiskhide/enable"))
.putBoolean("busybox", Utils.commandExists("busybox"))
.putBoolean("hosts", Utils.itemExist(false, "/magisk/.core/hosts"))

View File

@ -3,7 +3,9 @@ package com.topjohnwu.magisk;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
@ -79,25 +81,42 @@ public class SettingsActivity extends AppCompatActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.app_settings);
PreferenceManager.setDefaultValues(getActivity(), R.xml.app_settings, false);
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
prefScreen = getPreferenceScreen();
PreferenceCategory magiskCategory = (PreferenceCategory) findPreference("magisk");
PreferenceCategory suCategory = (PreferenceCategory) findPreference("superuser");
ListPreference suAccess = (ListPreference) findPreference("su_access");
ListPreference autoRes = (ListPreference) findPreference("su_auto_response");
ListPreference requestTimeout = (ListPreference) findPreference("su_request_timeout");
ListPreference suNotification = (ListPreference) findPreference("su_notification");
suAccess.setSummary(getResources()
.getStringArray(R.array.su_access)[Utils.getPrefsInt(prefs, "su_access", 3)]);
autoRes.setSummary(getResources()
.getStringArray(R.array.auto_response)[Utils.getPrefsInt(prefs, "su_auto_response", 0)]);
suNotification.setSummary(getResources()
.getStringArray(R.array.su_notification)[Utils.getPrefsInt(prefs, "su_notification", 1)]);
requestTimeout.setSummary(
getString(R.string.request_timeout_summary, prefs.getString("su_request_timeout", "10")));
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
CheckBoxPreference magiskhidePreference = (CheckBoxPreference) findPreference("magiskhide");
SwitchPreference hostsPreference = (SwitchPreference) findPreference("hosts");
Preference clear = findPreference("clear");
clear.setOnPreferenceClickListener((pref) -> {
findPreference("clear").setOnPreferenceClickListener((pref) -> {
ModuleHelper.clearRepoCache(getActivity());
return true;
});
if (!Shell.rootAccess()) {
busyboxPreference.setEnabled(false);
magiskhidePreference.setEnabled(false);
hostsPreference.setEnabled(false);
prefScreen.removePreference(magiskCategory);
prefScreen.removePreference(suCategory);
} else {
if (!Global.Info.isSuClient) {
prefScreen.removePreference(suCategory);
}
if (Global.Info.magiskVersion < 9) {
hostsPreference.setEnabled(false);
busyboxPreference.setEnabled(false);

View File

@ -130,8 +130,8 @@
<string name="settings_magiskhide_summary">Hide Magisk from various detections\nRequires reboot</string>
<string name="settings_busybox_title">Enable BusyBox</string>
<string name="settings_busybox_summary">Bind mount Magisk\'s built-in busybox to xbin\nRequires reboot</string>
<string name="settings_hosts_title">Enable systemless hosts</string>
<string name="settings_hosts_summary">Systemless support for Adblock apps</string>
<string name="settings_hosts_title">Systemless hosts</string>
<string name="settings_hosts_summary">Systemless hosts support for Adblock apps</string>
<string name="settings_su_app_adb">Apps and ADB</string>
<string name="settings_su_app">Apps only</string>
@ -141,6 +141,11 @@
<string name="settings_su_request_20">20 seconds</string>
<string name="settings_su_request_30">30 seconds</string>
<string name="settings_su_request_60">60 seconds</string>
<string name="superuser_access">Superuser Access</string>
<string name="auto_response">Automatic Response</string>
<string name="request_timeout">Request Timeout</string>
<string name="superuser_notification">Superuser Notification</string>
<string name="request_timeout_summary">%1$s seconds</string>
<string name="settings_development_category">App Development</string>
<string name="settings_developer_logging_title">Enable advanced debug logging</string>

View File

@ -18,6 +18,7 @@
</PreferenceCategory>
<PreferenceCategory
android:key="magisk"
android:title="@string/magisk">
<CheckBoxPreference
@ -41,29 +42,30 @@
</PreferenceCategory>
<PreferenceCategory
android:key="superuser"
android:title="@string/superuser">
<ListPreference
android:key="su_access"
android:title="Superuser Access"
android:title="@string/superuser_access"
android:entries="@array/su_access"
android:entryValues="@array/value_array" />
<ListPreference
android:key="su_auto_response"
android:title="Automatic Response"
android:title="@string/auto_response"
android:entries="@array/auto_response"
android:entryValues="@array/value_array" />
<ListPreference
android:key="su_request_timeout"
android:title="Request Timeout"
android:title="@string/request_timeout"
android:entries="@array/request_timeout"
android:entryValues="@array/request_timeout_value" />
<ListPreference
android:key="su_notification"
android:title="Superuser Notification"
android:title="@string/superuser_notification"
android:entries="@array/su_notification"
android:entryValues="@array/value_array" />

View File

@ -16,3 +16,7 @@ org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryErr
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true
# When set to true the Gradle daemon is used to run the build. For local developer builds this is our favorite property.
# The developer environment is optimized for speed and feedback so we nearly always run Gradle jobs with the daemon.
org.gradle.daemon=true