Rename and move methods

This commit is contained in:
topjohnwu
2018-07-31 17:41:54 +08:00
parent 7c74be2790
commit f900189f90
36 changed files with 182 additions and 180 deletions
@@ -109,7 +109,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
findPreference("clear").setOnPreferenceClickListener((pref) -> {
prefs.edit().remove(Const.Key.ETAG_KEY).apply();
mm.repoDB.clearRepo();
Global.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT);
Utils.toast(R.string.repo_cache_cleared, Toast.LENGTH_SHORT);
return true;
});
@@ -124,8 +124,8 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
SwitchPreference fingerprint = (SwitchPreference) findPreference(Const.Key.SU_FINGERPRINT);
updateChannel.setOnPreferenceChangeListener((pref, o) -> {
Global.updateChannel = Integer.parseInt((String) o);
if (Global.updateChannel == Const.Value.CUSTOM_CHANNEL) {
Data.updateChannel = Integer.parseInt((String) o);
if (Data.updateChannel == Const.Value.CUSTOM_CHANNEL) {
View v = LayoutInflater.from(getActivity()).inflate(R.layout.custom_channel_dialog, null);
EditText url = v.findViewById(R.id.custom_url);
url.setText(mm.prefs.getString(Const.Key.CUSTOM_CHANNEL, ""));
@@ -160,7 +160,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
fingerprint.setSummary(R.string.disable_fingerprint);
}
if (Global.magiskVersionCode >= Const.MAGISK_VER.MANAGER_HIDE) {
if (Data.magiskVersionCode >= Const.MAGISK_VER.MANAGER_HIDE) {
if (mm.getPackageName().equals(Const.ORIG_PKG_NAME)) {
hideManager.setOnPreferenceClickListener((pref) -> {
new HideManager(getActivity()).exec();
@@ -174,7 +174,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
getActivity(), new DownloadReceiver() {
@Override
public void onDownloadDone(Context context, Uri uri) {
Global.exportPrefs();
Data.exportPrefs();
Shell.su("cp " + uri.getPath() + " /data/local/tmp/manager.apk").exec();
if (ShellUtils.fastCmdResult("pm install /data/local/tmp/manager.apk")) {
Shell.su("rm -f /data/local/tmp/manager.apk").exec();
@@ -184,8 +184,8 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
Shell.su("rm -f /data/local/tmp/manager.apk").exec();
}
},
Global.managerLink,
Utils.fmt("MagiskManager-v%s.apk", Global.remoteManagerVersionString)
Data.managerLink,
Utils.fmt("MagiskManager-v%s.apk", Data.remoteManagerVersionString)
);
return true;
});
@@ -200,14 +200,14 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
}
if (!Shell.rootAccess() || (Const.USER_ID > 0 &&
Global.multiuserMode == Const.Value.MULTIUSER_MODE_OWNER_MANAGED)) {
Data.multiuserMode == Const.Value.MULTIUSER_MODE_OWNER_MANAGED)) {
prefScreen.removePreference(suCategory);
}
if (!Shell.rootAccess()) {
prefScreen.removePreference(magiskCategory);
generalCatagory.removePreference(hideManager);
} else if (Global.magiskVersionCode < Const.MAGISK_VER.UNIFIED) {
} else if (Data.magiskVersionCode < Const.MAGISK_VER.UNIFIED) {
prefScreen.removePreference(magiskCategory);
}
}
@@ -246,7 +246,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
switch (key) {
case Const.Key.DARK_THEME:
Global.isDarkTheme = prefs.getBoolean(key, false);
Data.isDarkTheme = prefs.getBoolean(key, false);
mm.reloadActivity.publish(false);
return;
case Const.Key.COREONLY:
@@ -293,25 +293,25 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
Utils.setupUpdateCheck();
break;
}
Global.loadConfig();
Data.loadConfig();
setSummary();
}
private void setSummary() {
updateChannel.setSummary(getResources()
.getStringArray(R.array.update_channel)[Global.updateChannel]);
.getStringArray(R.array.update_channel)[Data.updateChannel]);
suAccess.setSummary(getResources()
.getStringArray(R.array.su_access)[Global.suAccessState]);
.getStringArray(R.array.su_access)[Data.suAccessState]);
autoRes.setSummary(getResources()
.getStringArray(R.array.auto_response)[Global.suResponseType]);
.getStringArray(R.array.auto_response)[Data.suResponseType]);
suNotification.setSummary(getResources()
.getStringArray(R.array.su_notification)[Global.suNotificationType]);
.getStringArray(R.array.su_notification)[Data.suNotificationType]);
requestTimeout.setSummary(
getString(R.string.request_timeout_summary, prefs.getString(Const.Key.SU_REQUEST_TIMEOUT, "10")));
multiuserMode.setSummary(getResources()
.getStringArray(R.array.multiuser_summary)[Global.multiuserMode]);
.getStringArray(R.array.multiuser_summary)[Data.multiuserMode]);
namespaceMode.setSummary(getResources()
.getStringArray(R.array.namespace_summary)[Global.suNamespaceMode]);
.getStringArray(R.array.namespace_summary)[Data.suNamespaceMode]);
}
@Override