mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 19:27:39 +00:00
Initial re-add of hide fragment
This commit is contained in:
parent
4a1e6dcc32
commit
bbae93aa16
@ -25,7 +25,7 @@ import java.io.InputStream;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class AboutActivity extends AppCompatActivity {
|
||||
public class AboutActivity extends AppCompatActivity {
|
||||
|
||||
private static final String SOURCE_CODE_URL = "https://github.com/topjohnwu/MagiskManager";
|
||||
private static final String XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3432382";
|
||||
|
172
app/src/main/java/com/topjohnwu/magisk/AutoRootFragment.java
Normal file
172
app/src/main/java/com/topjohnwu/magisk/AutoRootFragment.java
Normal file
@ -0,0 +1,172 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.app.ListFragment;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.topjohnwu.magisk.utils.ApplicationAdapter;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class AutoRootFragment extends ListFragment {
|
||||
private PackageManager packageManager = null;
|
||||
private List<ApplicationInfo> applist = null;
|
||||
private ApplicationAdapter listadaptor = null;
|
||||
public ListView listView;
|
||||
public SharedPreferences prefs;
|
||||
List<String> arrayBlackList;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
View view = inflater.inflate(R.layout.auto_root_fragment, container, false);
|
||||
int horizontalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
|
||||
int verticalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
|
||||
TypedValue tv = new TypedValue();
|
||||
int actionBarHeight = 130;
|
||||
if (getActivity().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
|
||||
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
view.setPadding(horizontalMargin, actionBarHeight, horizontalMargin, verticalMargin);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
initializeElements();
|
||||
super.onResume();
|
||||
getActivity().setTitle(R.string.auto_toggle);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initializeElements() {
|
||||
listView = getListView();
|
||||
packageManager = getActivity().getPackageManager();
|
||||
new LoadApplications().execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
Logger.dev("Click");
|
||||
super.onListItemClick(l, v, position, id);
|
||||
ApplicationInfo app = applist.get(position);
|
||||
ToggleApp(app.packageName, position, v);
|
||||
|
||||
}
|
||||
|
||||
private void ToggleApp(String appToCheck, int position, View v) {
|
||||
Logger.dev("Magisk", "AutoRootFragment: ToggleApp called for " + appToCheck);
|
||||
Set<String> blackListSet = prefs.getStringSet("auto_blacklist", null);
|
||||
assert blackListSet != null;
|
||||
arrayBlackList = new ArrayList<>(blackListSet);
|
||||
|
||||
if (!arrayBlackList.contains(appToCheck)) {
|
||||
arrayBlackList.add(appToCheck);
|
||||
|
||||
} else {
|
||||
for (int i = 0; i < arrayBlackList.size(); i++) {
|
||||
if (appToCheck.equals(arrayBlackList.get(i))) {
|
||||
arrayBlackList.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Logger.dev("Committing set, value is: " + arrayBlackList.toString());
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putStringSet("auto_blacklist", new HashSet<>(arrayBlackList));
|
||||
editor.apply();
|
||||
listadaptor.UpdateRootStatusView(position, v);
|
||||
|
||||
}
|
||||
|
||||
private List<ApplicationInfo> checkForLaunchIntent(List<ApplicationInfo> list) {
|
||||
ArrayList<ApplicationInfo> applist = new ArrayList<>();
|
||||
for (ApplicationInfo info : list) {
|
||||
try {
|
||||
if (null != packageManager.getLaunchIntentForPackage(info.packageName)) {
|
||||
if (!info.packageName.contains("magisk")) {
|
||||
applist.add(info);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Collections.sort(applist, new CustomComparator());
|
||||
|
||||
return applist;
|
||||
}
|
||||
|
||||
public class CustomComparator implements Comparator<ApplicationInfo> {
|
||||
@Override
|
||||
public int compare(ApplicationInfo o1, ApplicationInfo o2) {
|
||||
return o1.loadLabel(packageManager).toString().compareToIgnoreCase(o2.loadLabel(packageManager).toString());
|
||||
}
|
||||
}
|
||||
|
||||
private class LoadApplications extends AsyncTask<Void, Void, Void> {
|
||||
private ProgressDialog progress = null;
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
applist = checkForLaunchIntent(packageManager.getInstalledApplications(PackageManager.GET_META_DATA));
|
||||
listadaptor = new ApplicationAdapter(getActivity(),
|
||||
R.layout.list_item_app, applist);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
super.onCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
setListAdapter(listadaptor);
|
||||
progress.dismiss();
|
||||
super.onPostExecute(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progress = ProgressDialog.show(getActivity(), null,
|
||||
"Loading application info...");
|
||||
super.onPreExecute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(Void... values) {
|
||||
super.onProgressUpdate(values);
|
||||
}
|
||||
}
|
||||
}
|
153
app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java
Normal file
153
app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java
Normal file
@ -0,0 +1,153 @@
|
||||
package com.topjohnwu.magisk;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private ListPreference themePreference;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.uisettings);
|
||||
PreferenceManager.setDefaultValues(getActivity(), R.xml.uisettings, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getActivity().setTitle(R.string.settings);
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).unregisterOnSharedPreferenceChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
themePreference = (ListPreference) findPreference("theme");
|
||||
CheckBoxPreference busyboxPreference = (CheckBoxPreference) findPreference("busybox");
|
||||
CheckBoxPreference quickTilePreference = (CheckBoxPreference) findPreference("enable_quicktile");
|
||||
busyboxPreference.setChecked(Utils.commandExists("unzip"));
|
||||
PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this);
|
||||
CheckBoxPreference keepRootOffPreference = (CheckBoxPreference) findPreference("keep_root_off");
|
||||
CheckBoxPreference hideRootNotificationPreference = (CheckBoxPreference) findPreference("hide_root_notification");
|
||||
themePreference.setSummary(themePreference.getValue());
|
||||
if (MagiskFragment.magiskVersion == -1) {
|
||||
quickTilePreference.setEnabled(false);
|
||||
keepRootOffPreference.setEnabled(false);
|
||||
hideRootNotificationPreference.setEnabled(false);
|
||||
busyboxPreference.setEnabled(false);
|
||||
} else {
|
||||
quickTilePreference.setEnabled(true);
|
||||
keepRootOffPreference.setEnabled(true);
|
||||
hideRootNotificationPreference.setEnabled(true);
|
||||
busyboxPreference.setEnabled(true);
|
||||
}
|
||||
|
||||
// calculate margins
|
||||
int horizontalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
|
||||
int verticalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
|
||||
TypedValue tv = new TypedValue();
|
||||
int actionBarHeight = 130;
|
||||
if (getActivity().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
|
||||
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
view.setPadding(horizontalMargin, actionBarHeight, horizontalMargin, verticalMargin);
|
||||
|
||||
return view;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
Logger.dev("Settings: NewValue is " + key);
|
||||
|
||||
if (key.equals("theme")) {
|
||||
String pref = sharedPreferences.getString(key, "");
|
||||
|
||||
themePreference.setSummary(pref);
|
||||
if (pref.equals("Dark")) {
|
||||
getActivity().getApplication().setTheme(R.style.AppTheme_dh);
|
||||
} else {
|
||||
getActivity().getApplication().setTheme(R.style.AppTheme);
|
||||
}
|
||||
Intent intent = new Intent(getActivity(), MainActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra("Relaunch", "Settings");
|
||||
startActivity(intent);
|
||||
|
||||
Logger.dev("SettingsFragment: theme is " + pref);
|
||||
|
||||
} else if (key.equals("enable_quicktile")) {
|
||||
boolean checked = sharedPreferences.getBoolean("enable_quicktile", false);
|
||||
if (checked) {
|
||||
new AsyncTask<Void, Void, Boolean> () {
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... voids) {
|
||||
return Utils.installTile(getActivity());
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
super.onPostExecute(result);
|
||||
if (result) {
|
||||
Toast.makeText(getActivity(), "Tile installed", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), "Tile installation error", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
} else {
|
||||
new AsyncTask<Void, Void, Boolean> () {
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... voids) {
|
||||
return Utils.uninstallTile(getActivity());
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
super.onPostExecute(result);
|
||||
if (result) {
|
||||
Toast.makeText(getActivity(), "Tile uninstalled", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), "Tile uninstallation error", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
}
|
||||
} else if (key.equals("busybox")) {
|
||||
boolean checked = sharedPreferences.getBoolean("busybox", false);
|
||||
new Async.LinkBusyBox(checked).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||
} else if (key.equals("developer_logging")) {
|
||||
Logger.devLog = sharedPreferences.getBoolean("developer_logging", false);
|
||||
} else if (key.equals("shell_logging")) {
|
||||
Logger.logShell = sharedPreferences.getBoolean("shell_logging", false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.topjohnwu.magisk.services.MonitorService;
|
||||
import com.topjohnwu.magisk.utils.Async;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
@ -25,12 +26,43 @@ public class SplashActivity extends AppCompatActivity {
|
||||
Logger.devLog = prefs.getBoolean("developer_logging", false);
|
||||
Logger.logShell = prefs.getBoolean("shell_logging", false);
|
||||
|
||||
// Set up default preferences,make sure we add "extra" blacklist entries.
|
||||
if (!defaultPrefs.contains("auto_blacklist")) {
|
||||
Logger.dev("SplashActivity: Setting default preferences for application");
|
||||
SharedPreferences.Editor editor = defaultPrefs.edit();
|
||||
Set<String> 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();
|
||||
}
|
||||
|
||||
// Set up toggle states based on preferences, start services, disable root if set
|
||||
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
||||
if (!Utils.hasServicePermission(getApplicationContext())) {
|
||||
Utils.toggleAutoRoot(false, getApplicationContext());
|
||||
}
|
||||
}
|
||||
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
||||
if (!Utils.isMyServiceRunning(MonitorService.class, getApplicationContext())) {
|
||||
Intent myIntent = new Intent(getApplication(), MonitorService.class);
|
||||
getApplication().startService(myIntent);
|
||||
}
|
||||
} else if (defaultPrefs.getBoolean("keep_root_off", false)) {
|
||||
Utils.toggleRoot(false, getApplication());
|
||||
}
|
||||
|
||||
// Set up quick settings tile
|
||||
Utils.setupQuickSettingsTile(getApplicationContext());
|
||||
|
||||
// Initialize
|
||||
prefs.edit()
|
||||
.putBoolean("module_done", false)
|
||||
.putBoolean("repo_done", false)
|
||||
.putBoolean("update_check_done", false)
|
||||
.putBoolean("root", Utils.rootEnabled())
|
||||
.apply();
|
||||
|
||||
new Async.CheckUpdates(prefs).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -0,0 +1,114 @@
|
||||
package com.topjohnwu.magisk.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.topjohnwu.magisk.R;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ApplicationAdapter extends ArrayAdapter<ApplicationInfo> {
|
||||
private List<ApplicationInfo> appsList = null;
|
||||
private Context context;
|
||||
private PackageManager packageManager;
|
||||
public SharedPreferences prefs;
|
||||
|
||||
public ApplicationAdapter(Context context, int textViewResourceId,
|
||||
List<ApplicationInfo> appsList) {
|
||||
super(context, textViewResourceId, appsList);
|
||||
this.context = context;
|
||||
this.appsList = appsList;
|
||||
packageManager = context.getPackageManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return ((null != appsList) ? appsList.size() : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationInfo getItem(int position) {
|
||||
return ((null != appsList) ? appsList.get(position) : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = convertView;
|
||||
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
if (null == view) {
|
||||
LayoutInflater layoutInflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = layoutInflater.inflate(R.layout.list_item_app, null);
|
||||
}
|
||||
|
||||
ApplicationInfo applicationInfo = appsList.get(position);
|
||||
if (null != applicationInfo) {
|
||||
TextView appName = (TextView) view.findViewById(R.id.app_name);
|
||||
TextView packageName = (TextView) view.findViewById(R.id.app_paackage);
|
||||
ImageView iconview = (ImageView) view.findViewById(R.id.app_icon);
|
||||
CheckBox statusview = (CheckBox) view.findViewById(R.id.checkbox);
|
||||
appName.setText(applicationInfo.loadLabel(packageManager));
|
||||
packageName.setText(applicationInfo.packageName);
|
||||
iconview.setImageDrawable(applicationInfo.loadIcon(packageManager));
|
||||
if (CheckApp(applicationInfo.packageName)) {
|
||||
statusview.setChecked(true);
|
||||
} else {
|
||||
statusview.setChecked(false);
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
public void UpdateRootStatusView(int position, View convertView) {
|
||||
View view = convertView;
|
||||
if (null == view) {
|
||||
LayoutInflater layoutInflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = layoutInflater.inflate(R.layout.list_item_app, null);
|
||||
}
|
||||
ApplicationInfo applicationInfo = appsList.get(position);
|
||||
if (null != applicationInfo) {
|
||||
CheckBox statusview = (CheckBox) view.findViewById(R.id.checkbox);
|
||||
if (CheckApp(applicationInfo.packageName)) {
|
||||
statusview.setChecked(true);
|
||||
} else {
|
||||
statusview.setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean CheckApp(String appToCheck) {
|
||||
boolean starter = false;
|
||||
Set<String> set = prefs.getStringSet("auto_blacklist", null);
|
||||
if (set != null) {
|
||||
for (String string : set) {
|
||||
if (string.equals(appToCheck)) {
|
||||
starter = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return starter;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,10 @@ import android.widget.Toast;
|
||||
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.receivers.DownloadReceiver;
|
||||
import com.topjohnwu.magisk.receivers.PrivateBroadcastReceiver;
|
||||
import com.topjohnwu.magisk.services.MonitorService;
|
||||
import com.topjohnwu.magisk.services.TileServiceCompat;
|
||||
import com.topjohnwu.magisk.services.TileServiceNewApi;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -60,6 +64,13 @@ public class Utils {
|
||||
return commandExists("su");
|
||||
}
|
||||
|
||||
public static boolean autoToggleEnabled(Context context) {
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
Logger.dev("Utils: AutoRootEnableCheck is " + preferences.getBoolean("autoRootEnable", false));
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("autoRootEnable", false);
|
||||
|
||||
}
|
||||
|
||||
public static boolean createFile(String path) {
|
||||
String command = "touch " + path + " 2>/dev/null; if [ -f " + path + " ]; then echo true; else echo false; fi";
|
||||
return Shell.rootAccess() && Boolean.parseBoolean(Shell.su(command).get(0));
|
||||
|
4
app/src/main/res/drawable/ic_autoroot.xml
Normal file
4
app/src/main/res/drawable/ic_autoroot.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<vector android:height="24dp" android:viewportHeight="400.0"
|
||||
android:viewportWidth="400.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillAlpha="1.00" android:fillColor="#000000" android:pathData="M200.6,24.2C231.8,24.2 263,33 289.6,49.5C304.7,58.8 318.2,70.7 329.8,84.1C351.5,109.6 365.2,141.7 368.8,175C373.6,217.4 361.5,261.5 335.5,295.5C334.2,297.1 332.8,298.7 331.9,300.7C341.7,310.1 351,320 360.9,329.3C322.7,339.3 284.5,349.6 246.3,359.9C256.4,323.5 266,287 275.7,250.5C262.4,250.5 249.1,250.5 235.8,250.5C228.5,269.8 221.2,289.1 214.1,308.4C205.9,308.6 197.8,308.5 189.6,308.5C188.4,306.7 187.1,304.9 185.9,303C192.4,285.5 199.1,268 205.6,250.5C189.5,250.6 173.4,250.3 157.4,250.6C150.4,270 142.9,289.2 135.8,308.5C129.8,308.5 123.9,308.4 117.9,308.6C130.4,317.8 144,325.6 158.9,330.3C171.9,334.6 185.6,336.6 199.4,336.7C199.4,349.4 199.3,362.1 199.4,374.8C165.8,374.9 132.2,364.5 104.4,345.6C91.7,337 80.3,326.5 70.2,314.9C48.5,289.4 34.8,257.3 31.2,224C26.3,180.4 39.2,134.9 66.8,100.7C67.2,99.9 67.7,99.2 68.1,98.4C58.3,88.9 49,79 39.1,69.7C77.3,59.7 115.6,49.4 153.7,39.1C143.6,75.7 133.8,112.5 124.1,149.3C137.9,149.3 151.7,149.2 165.5,149.3C172.9,130 180.2,110.6 187.3,91.2C195.5,90.8 203.7,91 211.8,91C213,92.8 214.3,94.6 215.5,96.3C209.1,114 202.3,131.6 195.8,149.2C211.8,149.3 227.8,149.2 243.9,149.3C251.2,129.9 258.3,110.3 265.8,90.9C271.5,90.8 277.3,91.6 282.9,90.4C280.2,89.5 278.1,87.7 275.9,86.1C254,70.7 227.4,62.2 200.6,62.3C200.6,49.6 200.7,36.9 200.6,24.2M292.5,100C286.4,116.4 280.2,132.8 274,149.3C280.9,149.2 287.8,149.3 294.7,149.2C296,150.8 297.3,152.4 298.6,153.9C297.1,162.1 295.7,170.3 294.3,178.5C283.9,178.5 273.4,178.5 262.9,178.5C257.5,192.7 252.1,206.9 246.9,221.2C258.7,221.3 270.5,221.1 282.3,221.3C283.5,222.9 284.8,224.4 286.1,225.9C284.9,233.7 283.4,241.4 282.1,249.1C281.6,251 283.6,252.1 284.6,253.3C291.5,259.8 297.7,266.9 304.8,273.1C312.9,262.1 319.6,250.1 324.2,237.3C334.3,208.7 334.2,176.7 323.7,148.3C317,130.1 306.4,113.4 292.5,100M95.2,125.9C86.2,138 79,151.4 74.5,165.8C65.3,194.4 66.4,226.3 77.6,254.2C84.6,271.5 95.1,287.4 108.7,300.1C114.9,283.6 121.3,267.1 127.2,250.5C121.5,250.5 115.8,250.5 110,250.5C108.6,250.4 106.7,251 105.8,249.5C104.5,247.9 102.3,246.3 102.9,244.1C104.2,236.5 105.5,228.9 106.8,221.2C117.4,221.2 128.1,221.4 138.7,221.1C143.9,206.9 149.3,192.7 154.6,178.5C142.9,178.4 131.1,178.6 119.3,178.4C117.6,177.3 116.4,175.3 115,173.8C116.3,165.8 117.9,157.9 119,150C118.3,148.2 116.6,147.1 115.3,145.7C108.6,139.2 102.3,132.1 95.2,125.9M168.8,221.2C184.8,221.2 200.8,221.3 216.8,221.2C222.2,207 227.5,192.8 232.8,178.5C216.8,178.5 200.7,178.5 184.6,178.5C179.4,192.8 174,207 168.8,221.2Z"/>
|
||||
</vector>
|
4
app/src/main/res/drawable/ic_autoroot_white.xml
Normal file
4
app/src/main/res/drawable/ic_autoroot_white.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<vector android:height="24dp" android:viewportHeight="400.0"
|
||||
android:viewportWidth="400.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillAlpha="1.00" android:fillColor="#fff" android:pathData="M200.6,24.2C231.8,24.2 263,33 289.6,49.5C304.7,58.8 318.2,70.7 329.8,84.1C351.5,109.6 365.2,141.7 368.8,175C373.6,217.4 361.5,261.5 335.5,295.5C334.2,297.1 332.8,298.7 331.9,300.7C341.7,310.1 351,320 360.9,329.3C322.7,339.3 284.5,349.6 246.3,359.9C256.4,323.5 266,287 275.7,250.5C262.4,250.5 249.1,250.5 235.8,250.5C228.5,269.8 221.2,289.1 214.1,308.4C205.9,308.6 197.8,308.5 189.6,308.5C188.4,306.7 187.1,304.9 185.9,303C192.4,285.5 199.1,268 205.6,250.5C189.5,250.6 173.4,250.3 157.4,250.6C150.4,270 142.9,289.2 135.8,308.5C129.8,308.5 123.9,308.4 117.9,308.6C130.4,317.8 144,325.6 158.9,330.3C171.9,334.6 185.6,336.6 199.4,336.7C199.4,349.4 199.3,362.1 199.4,374.8C165.8,374.9 132.2,364.5 104.4,345.6C91.7,337 80.3,326.5 70.2,314.9C48.5,289.4 34.8,257.3 31.2,224C26.3,180.4 39.2,134.9 66.8,100.7C67.2,99.9 67.7,99.2 68.1,98.4C58.3,88.9 49,79 39.1,69.7C77.3,59.7 115.6,49.4 153.7,39.1C143.6,75.7 133.8,112.5 124.1,149.3C137.9,149.3 151.7,149.2 165.5,149.3C172.9,130 180.2,110.6 187.3,91.2C195.5,90.8 203.7,91 211.8,91C213,92.8 214.3,94.6 215.5,96.3C209.1,114 202.3,131.6 195.8,149.2C211.8,149.3 227.8,149.2 243.9,149.3C251.2,129.9 258.3,110.3 265.8,90.9C271.5,90.8 277.3,91.6 282.9,90.4C280.2,89.5 278.1,87.7 275.9,86.1C254,70.7 227.4,62.2 200.6,62.3C200.6,49.6 200.7,36.9 200.6,24.2M292.5,100C286.4,116.4 280.2,132.8 274,149.3C280.9,149.2 287.8,149.3 294.7,149.2C296,150.8 297.3,152.4 298.6,153.9C297.1,162.1 295.7,170.3 294.3,178.5C283.9,178.5 273.4,178.5 262.9,178.5C257.5,192.7 252.1,206.9 246.9,221.2C258.7,221.3 270.5,221.1 282.3,221.3C283.5,222.9 284.8,224.4 286.1,225.9C284.9,233.7 283.4,241.4 282.1,249.1C281.6,251 283.6,252.1 284.6,253.3C291.5,259.8 297.7,266.9 304.8,273.1C312.9,262.1 319.6,250.1 324.2,237.3C334.3,208.7 334.2,176.7 323.7,148.3C317,130.1 306.4,113.4 292.5,100M95.2,125.9C86.2,138 79,151.4 74.5,165.8C65.3,194.4 66.4,226.3 77.6,254.2C84.6,271.5 95.1,287.4 108.7,300.1C114.9,283.6 121.3,267.1 127.2,250.5C121.5,250.5 115.8,250.5 110,250.5C108.6,250.4 106.7,251 105.8,249.5C104.5,247.9 102.3,246.3 102.9,244.1C104.2,236.5 105.5,228.9 106.8,221.2C117.4,221.2 128.1,221.4 138.7,221.1C143.9,206.9 149.3,192.7 154.6,178.5C142.9,178.4 131.1,178.6 119.3,178.4C117.6,177.3 116.4,175.3 115,173.8C116.3,165.8 117.9,157.9 119,150C118.3,148.2 116.6,147.1 115.3,145.7C108.6,139.2 102.3,132.1 95.2,125.9M168.8,221.2C184.8,221.2 200.8,221.3 216.8,221.2C222.2,207 227.5,192.8 232.8,178.5C216.8,178.5 200.7,178.5 184.6,178.5C179.4,192.8 174,207 168.8,221.2Z"/>
|
||||
</vector>
|
14
app/src/main/res/layout/auto_root_fragment.xml
Normal file
14
app/src/main/res/layout/auto_root_fragment.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/Top">
|
||||
|
||||
<ListView android:id="@android:id/list"
|
||||
android:divider="@android:color/transparent"
|
||||
android:dividerHeight="@dimen/card_divider_space"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="6dp"/>
|
||||
|
||||
</LinearLayout>
|
89
app/src/main/res/layout/list_item_app.xml
Normal file
89
app/src/main/res/layout/list_item_app.xml
Normal file
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginBottom="@dimen/card_vertical_margin"
|
||||
android:layout_marginEnd="@dimen/card_horizontal_margin"
|
||||
android:layout_marginStart="@dimen/card_horizontal_margin"
|
||||
android:layout_marginTop="@dimen/card_vertical_margin"
|
||||
style="?attr/cardStyle"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
card_view:cardCornerRadius="@dimen/card_corner_radius"
|
||||
card_view:cardElevation="@dimen/card_elevation">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:padding="@dimen/card_layout_padding">
|
||||
|
||||
<ImageView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/app_icon"
|
||||
android:layout_width="@dimen/card_appicon_size"
|
||||
android:layout_height="@dimen/card_appicon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/textLayout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignBottom="@+id/app_icon"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingEnd="@dimen/card_appicon_size"
|
||||
android:paddingStart="65dp"
|
||||
android:weightSum="1">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="false"
|
||||
android:layout_weight="1"
|
||||
android:paddingEnd="3dp"
|
||||
android:paddingStart="3dp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_paackage"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="25dp"
|
||||
android:ellipsize="marquee"
|
||||
android:gravity="center_vertical"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="3dp"
|
||||
android:paddingStart="3dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/Linear"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:gravity="center"
|
||||
android:src="@drawable/ic_menu_overflow_material"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
android:icon="@drawable/magisk"
|
||||
android:title="@string/magisk"/>
|
||||
|
||||
|
||||
|
||||
<item
|
||||
android:id="@+id/modules"
|
||||
android:icon="@drawable/ic_extension"
|
||||
@ -21,6 +23,10 @@
|
||||
android:title="@string/downloads"/>
|
||||
|
||||
<item
|
||||
<item
|
||||
android:id="@+id/autoroot"
|
||||
android:icon="@drawable/ic_autoroot"
|
||||
android:title="@string/auto_toggle"/>
|
||||
android:id="@+id/log"
|
||||
android:icon="@drawable/ic_bug_report"
|
||||
android:title="@string/log"/>
|
||||
|
@ -11,4 +11,5 @@
|
||||
<dimen name="card_textview_width">300dip</dimen>
|
||||
<dimen name="checkbox_padding">3dp</dimen>
|
||||
<dimen name="card_imageview_margin">10dp</dimen>
|
||||
<dimen name="card_appicon_size">50dp</dimen>
|
||||
</resources>
|
@ -6,6 +6,7 @@
|
||||
<!--Welcome Activity-->
|
||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||
<string name="auto_toggle">MagiskHide</string>
|
||||
<string name="modules">Modules</string>
|
||||
<string name="downloads">Downloads</string>
|
||||
<string name="log">Log</string>
|
||||
@ -42,6 +43,7 @@
|
||||
<string name="menuSaveToSd">Save to SD</string>
|
||||
<string name="menuSend">Send</string>
|
||||
<string name="menuReload">Reload</string>
|
||||
<string name="sdcard_not_writable">SD card not found or not writable</string>
|
||||
<string name="menuClearLog">Clear log now</string>
|
||||
<string name="logs_cleared">Log successfully cleared</string>
|
||||
<string name="logs_clear_failed">Could not clear the log:</string>
|
||||
@ -53,7 +55,7 @@
|
||||
<string name="app_developers">Main developers</string>
|
||||
<string name="app_developers_"><![CDATA[App created by <a href="https://github.com/topjohnwu">topjohnwu</a> in collaboration with <a href="https://github.com/d8ahazard">Digitalhigh</a> and <a href="https://github.com/dvdandroid">Dvdandroid</a>.]]></string>
|
||||
<string name="app_changelog">App\'s changelog</string>
|
||||
<string name="translators" />
|
||||
<string name="translators"/>
|
||||
<string name="app_version">App\'s version</string>
|
||||
<string name="app_source_code">Source code</string>
|
||||
<string name="donation">Donation</string>
|
||||
@ -64,6 +66,7 @@
|
||||
<string name="permissionNotGranted">This feature will not work without permission to write external storage.</string>
|
||||
<string name="no_root_access">No root access, functionality limited</string>
|
||||
<string name="no_thanks">No thanks</string>
|
||||
<string name="accessibility_service_description">Accessibility service required for Magisk auto-unroot feature</string>
|
||||
<string name="update_title">%1$s Update!</string>
|
||||
<string name="update_msg">New version v%2$s of %1$s is available!\nChangelog:\n%3$s</string>
|
||||
<string name="repo_install_title">Install %1$s</string>
|
||||
|
11
app/src/main/res/xml/accessibilityservice.xml
Normal file
11
app/src/main/res/xml/accessibilityservice.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- These options MUST be specified here in order for the events to be received on first
|
||||
start in Android 4.1.1 -->
|
||||
<accessibility-service
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:accessibilityEventTypes="typeWindowStateChanged"
|
||||
android:accessibilityFeedbackType="feedbackGeneric"
|
||||
android:accessibilityFlags="flagIncludeNotImportantViews"
|
||||
android:description="@string/accessibility_service_description"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
tools:ignore="UnusedAttribute"/>
|
@ -31,6 +31,34 @@
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/settings_quicksettings_category">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="enable_quicktile"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/settings_enable_quicktile_title"
|
||||
android:summary="@string/settings_enable_quicktile_summary" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/settings_root_category">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="keep_root_off"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/settings_keep_root_off_title"
|
||||
android:summary="@string/settings_keep_root_off_summary" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="hide_root_notification"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/settings_hide_root_notification_title"
|
||||
android:summary="@string/settings_hide_root_notification_summary" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/settings_development_category">
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user