diff --git a/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java b/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java index 6bf831cc7..65d4e4e71 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java @@ -29,9 +29,8 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); - - // Load the preferences from an XML resource addPreferencesFromResource(R.xml.uisettings); + PreferenceManager.setDefaultValues(getActivity(), R.xml.uisettings, false); } @Override diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java index 84ea06023..02b428fca 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -21,27 +21,28 @@ public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { - SharedPreferences defaultPrefs = PreferenceManager.getDefaultSharedPreferences(getApplication()); + super.onCreate(savedInstanceState); + SharedPreferences defaultPrefs = PreferenceManager.getDefaultSharedPreferences(getApplication()); if (defaultPrefs.getString("theme","").equals("Dark")) { setTheme(R.style.AppTheme_dh); } - super.onCreate(savedInstanceState); - //setups go here // Set up default preferences,make sure we add "extra" blacklist entries. - PreferenceManager.setDefaultValues(this, R.xml.defaultpref, false); + if (!defaultPrefs.contains("auto_blacklist")) { - Logger.dh("AutoRootFragment: Setting default preferences for application"); + Logger.dh("SplashActivity: Setting default preferences for application"); SharedPreferences.Editor editor = defaultPrefs.edit(); Set set = new HashSet<>(); set.add("com.google.android.apps.walletnfcrel"); set.add("com.google.android.gms"); set.add("com.google.commerce.tapandpay"); editor.putStringSet("auto_blacklist", set); + editor.putBoolean("autoRootEnable",false); + editor.putBoolean("root",Utils.rootEnabled()); editor.apply(); } diff --git a/app/src/main/res/xml/defaultpref.xml b/app/src/main/res/xml/defaultpref.xml deleted file mode 100644 index 3094a2b2e..000000000 --- a/app/src/main/res/xml/defaultpref.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/xml/uisettings.xml b/app/src/main/res/xml/uisettings.xml index 0a06e6f78..a524e3cf6 100644 --- a/app/src/main/res/xml/uisettings.xml +++ b/app/src/main/res/xml/uisettings.xml @@ -8,6 +8,7 @@ android:key="theme" android:title="Theme" android:summary="Select a theme" + android:defaultValue="Default" android:entries="@array/themes" android:entryValues="@array/themes"/> @@ -16,6 +17,7 @@ @@ -24,6 +26,7 @@ android:title="@string/settings_root_category"> @@ -39,6 +42,7 @@