Whoop whoop

This commit is contained in:
d8ahazard 2016-09-21 16:55:20 -05:00
parent 5d8f9f1a5a
commit 41a5639711
22 changed files with 574 additions and 62 deletions

View File

@ -32,9 +32,9 @@ repositories {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.github.d8ahazard:BroadcastTileSupportUpdate:master'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.github.michalis-vitos:aFileChooser:master'

View File

@ -107,12 +107,9 @@
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<receiver android:name=".RootFragment.mYourBroadcastReceiner">
<intent-filter>
<action android:name="com.magisk.UPDATEUI"/>
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -1,5 +1,6 @@
package com.topjohnwu.magisk;
import android.app.ListFragment;
import android.app.ProgressDialog;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
@ -8,7 +9,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -41,7 +42,7 @@ public class AutoRootFragment extends ListFragment {
super.onActivityCreated(savedInstanceState);
listView = getListView();
packageManager = getActivity().getPackageManager();
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
if (!prefs.contains("auto_blacklist")) {
SharedPreferences.Editor editor = prefs.edit();
Set<String> set = new HashSet<>();

View File

@ -6,13 +6,14 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@ -132,7 +133,9 @@ public class LogFragment extends Fragment {
@SuppressLint("DefaultLocale")
private File save() {
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
}
return null;
}

View File

@ -1,10 +1,11 @@
package com.topjohnwu.magisk;
import android.app.Fragment;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;

View File

@ -1,12 +1,13 @@
package com.topjohnwu.magisk;
import android.app.Fragment;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;

View File

@ -5,7 +5,7 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;

View File

@ -12,7 +12,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.LayoutInflater;
@ -97,7 +97,7 @@ public class RootFragment extends Fragment implements Receiver{
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.root_fragment, container, false);
ButterKnife.bind(this, view);
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
if (prefs.contains("autoRootEnable")) {
autoRootStatus = prefs.getBoolean("autoRootEnable", false);
@ -125,22 +125,22 @@ public class RootFragment extends Fragment implements Receiver{
new updateUI().execute();
});
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mYourBroadcastReceiver,
new IntentFilter("com.magisk.UPDATEUI"));
// LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mYourBroadcastReceiver,
// new IntentFilter("com.magisk.UPDATEUI"));
return view;
}
private final BroadcastReceiver mYourBroadcastReceiver = new RootFragmentReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("Magisk", "RootFragment: UpdateRF called and fired");
new updateUI().execute();
}
};
// private final BroadcastReceiver mYourBroadcastReceiver = new RootFragmentReceiver(Re) {
// @Override
// public void onReceive(Context context, Intent intent) {
//
// Log.d("Magisk", "RootFragment: UpdateRF called and fired");
// new updateUI().execute();
// }
//
//
// };
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

View File

@ -0,0 +1,95 @@
package com.topjohnwu.magisk;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
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.Utils;
import butterknife.ButterKnife;
public class SettingsFragment extends PreferenceFragment {
private CheckBoxPreference quickTilePreference;
private CheckBoxPreference devLogPreference;
private CheckBoxPreference keepRootOffPreference;
private CheckBoxPreference hideRootNotificationPreference;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.uisettings);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
ButterKnife.bind(this, view);
quickTilePreference = (CheckBoxPreference) findPreference("enable_quicktile");
devLogPreference = (CheckBoxPreference) findPreference("developer_logging");
keepRootOffPreference = (CheckBoxPreference) findPreference("keep_root_off");
hideRootNotificationPreference = (CheckBoxPreference) findPreference("hide_root_notification");
if (Utils.magiskVersion == -1) {
quickTilePreference.setEnabled(false);
keepRootOffPreference.setEnabled(false);
hideRootNotificationPreference.setEnabled(false);
} else {
quickTilePreference.setEnabled(true);
keepRootOffPreference.setEnabled(true);
hideRootNotificationPreference.setEnabled(true);
}
Preference.OnPreferenceClickListener preferenceClickListener = preference -> {
if (preference == quickTilePreference) {
boolean isChecked = quickTilePreference.isChecked();
if (isChecked) {
Utils.installTile(getActivity());
} else {
Utils.uninstallTile(getActivity());
}
}
if (preference == devLogPreference) {
boolean isChecked = devLogPreference.isChecked();
}
if (preference == keepRootOffPreference) {
boolean isChecked = devLogPreference.isChecked();
}
if (preference == hideRootNotificationPreference) {
boolean isChecked = devLogPreference.isChecked();
}
return false;
};
quickTilePreference.setOnPreferenceClickListener(preferenceClickListener);
// 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;
}
}

View File

@ -1,6 +1,7 @@
package com.topjohnwu.magisk;
import android.Manifest;
import android.app.Fragment;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
@ -12,9 +13,9 @@ import android.preference.PreferenceManager;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
@ -175,14 +176,19 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
tag = "log";
navFragment = new LogFragment();
break;
case R.id.settings:
setTitle(R.string.settings);
tag = "settings";
navFragment = new SettingsFragment();
break;
case R.id.app_about:
startActivity(new Intent(this, AboutActivity.class));
return;
}
if (navFragment != null) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out);
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
try {
toolbar.setElevation(navFragment instanceof ModulesFragment ? 0 : 10);

View File

@ -6,6 +6,7 @@ import android.content.Intent;
import android.util.Log;
import com.topjohnwu.magisk.services.MonitorService;
import com.topjohnwu.magisk.utils.PrefHelper;
import com.topjohnwu.magisk.utils.Utils;
public class AutoStartReceiver extends BroadcastReceiver {
@ -14,7 +15,13 @@ public class AutoStartReceiver extends BroadcastReceiver {
Log.d("Magisk", "Received Boot call, attempting to start service");
Intent myIntent = new Intent(context, MonitorService.class);
context.startService(myIntent);
Utils.SetupQuickSettingsTile(context);
if (PrefHelper.CheckBool("keep_root_off")) {
Utils.toggleRoot(false);
}
if (PrefHelper.CheckBool("enable_quicktile")) {
Utils.SetupQuickSettingsTile(context);
}
}
}

View File

@ -0,0 +1,25 @@
package com.topjohnwu.magisk.receivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.topjohnwu.magisk.services.TileService;
public class TileReceiver extends BroadcastReceiver {
private static final String TAG = "MainReceiver";
public TileReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG,"RECEIVED");
String action = intent.getAction();
if (action.equals(Intent.ACTION_BOOT_COMPLETED) || action.equals(Intent.ACTION_USER_PRESENT) || action.equals(Intent.ACTION_SCREEN_ON)) {
context.startService(new Intent(context,TileService.class));
}
}
}

View File

@ -18,6 +18,7 @@ import android.view.accessibility.AccessibilityEvent;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.WelcomeActivity;
import com.topjohnwu.magisk.utils.PrefHelper;
import com.topjohnwu.magisk.utils.Utils;
import java.util.Set;
@ -125,32 +126,33 @@ public class MonitorService extends AccessibilityService {
private void ShowNotification(boolean rootAction, String packageName) {
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder;
if (!PrefHelper.CheckBool("hide_root_notification")) {
if (rootAction) {
if (rootAction) {
Intent intent = new Intent(getApplication(), WelcomeActivity.class);
intent.putExtra("relaunch", "relaunch");
String rootMessage;
PendingIntent pendingIntent = PendingIntent.getActivity(
getApplicationContext(),
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT);
if (packageName.equals("")) {
rootMessage = "Root has been disabled";
Intent intent = new Intent(getApplication(), WelcomeActivity.class);
intent.putExtra("relaunch", "relaunch");
String rootMessage;
PendingIntent pendingIntent = PendingIntent.getActivity(
getApplicationContext(),
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT);
if (packageName.equals("")) {
rootMessage = "Root has been disabled";
} else {
rootMessage = "Root has been disabled for " + packageName;
}
mBuilder =
new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(disableroot ? R.drawable.ic_stat_notification_autoroot_off : R.drawable.ic_stat_notification_autoroot_on)
.setContentIntent(pendingIntent)
.setContentTitle("Auto-root status changed")
.setContentText(rootMessage);
int mNotificationId = 1;
mNotifyMgr.notify(mNotificationId, mBuilder.build());
} else {
rootMessage = "Root has been disabled for " + packageName;
mNotifyMgr.cancelAll();
}
mBuilder =
new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(disableroot ? R.drawable.ic_stat_notification_autoroot_off : R.drawable.ic_stat_notification_autoroot_on)
.setContentIntent(pendingIntent)
.setContentTitle("Auto-root status changed")
.setContentText(rootMessage);
int mNotificationId = 1;
mNotifyMgr.notify(mNotificationId, mBuilder.build());
} else {
mNotifyMgr.cancelAll();
}
}

View File

@ -0,0 +1,139 @@
package com.topjohnwu.magisk.services;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.IBinder;
import android.service.quicksettings.Tile;
import com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder;
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Utils;
import java.util.List;
public class TileService extends Service {
private static BroadcastReceiver clickTileReceiver;
private static boolean running = false;
private static boolean root, autoRoot;
public static final String TILE_ID = "com.shovelgrill.magiskmmtile.TILE";
public static final String ACTION_TILE_CLICK = "com.shovelgrill.magiskmmtile.ACTION_TILE_CLICK";
public static final String EXTRA_CLICK_TYPE = "com.shovelgrill.magiskmmtile.EXTRA_CLICK_TYPE";
public static final int CLICK_TYPE_UNKNOWN = -1;
public static final int CLICK_TYPE_SIMPLE = 0;
public static final int CLICK_TYPE_LONG = 1;
public TileService() {
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
running = true;
root = true;
registerClickTileReceiver();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
root = Utils.rootEnabled();
autoRoot = Utils.autoRootEnabled(getApplicationContext());
updateTile();
return super.onStartCommand(intent, flags, startId);
}
private void registerClickTileReceiver() {
clickTileReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int clickType = intent.getIntExtra(EXTRA_CLICK_TYPE, CLICK_TYPE_UNKNOWN);
switch (clickType) {
case CLICK_TYPE_SIMPLE:
onSimpleClick();
break;
case CLICK_TYPE_LONG:
onLongClick();
break;
}
}
};
registerReceiver(clickTileReceiver, new IntentFilter(ACTION_TILE_CLICK));
}
private void onSimpleClick() {
Utils.toggleRoot(!root);
}
private void onLongClick() {
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(it);
openApp(this,"com.topjohnwu.magisk");
}
public static boolean openApp(Context context, String packageName) {
PackageManager manager = context.getPackageManager();
Intent i = manager.getLaunchIntentForPackage(packageName);
if (i == null) {
return false;
//throw new PackageManager.NameNotFoundException();
}
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(i);
return true;
}
private void updateTile() {
BroadcastTileIntentBuilder broadcastTileIntentBuilder = new BroadcastTileIntentBuilder(this, TILE_ID);
if (autoRoot) {
broadcastTileIntentBuilder.setLabel("Auto-root");
broadcastTileIntentBuilder.setIconResource(R.drawable.ic_autoroot_white);
} else {
if (root) {
broadcastTileIntentBuilder.setLabel("Root enabled");
broadcastTileIntentBuilder.setIconResource(R.drawable.root_white);
} else {
broadcastTileIntentBuilder.setLabel("Root disabled");
broadcastTileIntentBuilder.setIconResource(R.drawable.root_grey);
}
}
Intent simpleClick = new Intent(ACTION_TILE_CLICK);
simpleClick.putExtra(EXTRA_CLICK_TYPE, CLICK_TYPE_SIMPLE);
Intent longClick = new Intent(ACTION_TILE_CLICK);
longClick.putExtra(EXTRA_CLICK_TYPE, CLICK_TYPE_LONG);
broadcastTileIntentBuilder.setVisible(true);
broadcastTileIntentBuilder.setOnClickBroadcast(simpleClick);
broadcastTileIntentBuilder.setOnLongClickBroadcast(longClick);
this.sendBroadcast(broadcastTileIntentBuilder.build());
}
@Override
public void onDestroy() {
super.onDestroy();
unregisterReceiver(clickTileReceiver);
running = false;
}
}

View File

@ -0,0 +1,20 @@
package com.topjohnwu.magisk.utils;
import android.util.Log;
public class Logger {
private static final String LOG_TAG = "Magisk";
public static void dh(String msg, Object... args) {
if (PrefHelper.CheckBool("developer_logging")) {
if (args.length == 1 && args[0] instanceof Throwable) {
Log.d(LOG_TAG, msg, (Throwable) args[0]);
} else {
Log.d(LOG_TAG, String.format(msg, args));
}
}
}
}

View File

@ -0,0 +1,28 @@
package com.topjohnwu.magisk.utils;
import android.app.Application;
import android.content.Context;
import android.preference.PreferenceManager;
public class PrefHelper {
public PrefHelper() {
}
public static boolean CheckBool(String key) {
Context context = null;
try {
context = getApplicationUsingReflection();
} catch (Exception e) {
e.printStackTrace();
}
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(key, false);
}
private static Application getApplicationUsingReflection() throws Exception {
return (Application) Class.forName("android.app.AppGlobals")
.getMethod("getInitialApplication").invoke(null, (Object[]) null);
}
}

View File

@ -31,13 +31,16 @@ import com.topjohnwu.magisk.module.BaseModule;
import com.topjohnwu.magisk.receivers.PrivateBroadcastReceiver;
import com.topjohnwu.magisk.services.MonitorService;
import com.topjohnwu.magisk.services.QuickSettingTileService;
import com.topjohnwu.magisk.services.TileService;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import javax.crypto.BadPaddingException;
@ -68,6 +71,12 @@ public class Utils {
if (!Shell.rootAccess()) {
Snackbar.make(((Activity) context).findViewById(android.R.id.content), R.string.no_root_access, Snackbar.LENGTH_LONG).show();
}
if (PrefHelper.CheckBool("keep_root_off")) {
Utils.toggleRoot(false);
}
if (PrefHelper.CheckBool("enable_quicktile")) {
Utils.SetupQuickSettingsTile(context);
}
}
public static boolean fileExist(String path) {
@ -201,19 +210,19 @@ public class Utils {
}
public static void SetupQuickSettingsTile(Context mContext) {
Log.d("Magisk", "Utils: SetupQuickSettings called");
Logger.dh("Utils: SetupQuickSettings called");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Intent serviceIntent = new Intent(mContext, QuickSettingTileService.class);
mContext.startService(serviceIntent);
}
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
Log.d("Magisk", "Utils: Marshmallow build detected");
Logger.dh("Utils: Marshmallow build detected");
String mLabelString;
int mRootIcon = R.drawable.root_white;
int mAutoRootIcon = R.drawable.ic_autoroot_white;
int mRootDisabled = R.drawable.root_grey;
int mRootsState = CheckRootsState(mContext);
Log.d("Magisk", "Utils: Root State returned as " + mRootsState);
Logger.dh("Utils: Root State returned as " + mRootsState);
final Intent enableBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_ENABLEROOT);
final Intent disableBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_DISABLEROOT);
final Intent autoBroadcast = new Intent(PrivateBroadcastReceiver.ACTION_AUTOROOT);
@ -255,9 +264,67 @@ public class Utils {
}
}
public static void installTile(Context context) {
String qsTileId = "intent(" + TileService.TILE_ID + ")";
List<String> lines = Shell.su("settings get secure sysui_qs_tiles");
if (lines != null && lines.size() == 1) {
List<String> tiles = new LinkedList<String>(Arrays.asList(lines.get(0).split(",")));
if (tiles.size() > 1) {
for (String tile : tiles) {
if (tile.equals(qsTileId)) {
Toast.makeText(context, "Tile already installed", Toast.LENGTH_SHORT).show();
return;
}
}
String newTiles = TextUtils.join(",", tiles);
Shell.su("settings put secure sysui_qs_tiles \"" + newTiles + "\"");
Toast.makeText(context, "Tile installed", Toast.LENGTH_SHORT).show();
return;
}
}
Toast.makeText(context, "Tile installation error", Toast.LENGTH_SHORT).show();
}
public static void uninstallTile(Context context) {
String qsTileId = "intent(" + TileService.TILE_ID + ")";
List<String> lines = Shell.su("settings get secure sysui_qs_tiles");
if (lines != null && lines.size() == 1) {
List<String> tiles = new LinkedList<String>(Arrays.asList(lines.get(0).split(",")));
if (tiles.size() > 1) {
boolean isPresent = false;
for (int i = 0; i < tiles.size(); i++) {
if (tiles.get(i).equals(qsTileId)) {
isPresent = true;
tiles.remove(i);
break;
}
}
if (isPresent) {
String newTiles = TextUtils.join(",", tiles);
Shell.su("settings put secure sysui_qs_tiles \"" + newTiles + "\"");
Toast.makeText(context, "Tile uninstalled", Toast.LENGTH_SHORT).show();
return;
}
Toast.makeText(context, "Tile already uninstalled", Toast.LENGTH_SHORT).show();
}
}
Toast.makeText(context, "Tile uninstallation error", Toast.LENGTH_SHORT).show();
}
private void refreshService(Context context) {
context.startService(new Intent(context, TileService.class));
}
public static void UpdateRootFragmentUI(Context context) {
Log.d("Magisk", "Utils: UpdateRF called");
Logger.dh("Magisk", "Utils: UpdateRF called");
Intent intent = new Intent(context, RootFragment.class);
intent.setAction("com.magisk.UPDATEUI");
context.sendBroadcast(intent);

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
</vector>

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_marginBottom="8dp"
android:layout_marginTop="?attr/actionBarSize"
android:layout_width="fill_parent">
<PreferenceCategory android:layout_width="match_parent"
android:layout_height="match_parent">
</PreferenceCategory>
<PreferenceCategory
android:title="Test"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckBoxPreference
android:key="checkbox_preference"
android:title="Pref1"
android:defaultValue="Foo"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<EditTextPreference
android:key="edittext_preference"
android:title="TextPref"
android:summary="This is the summary"
android:dialogTitle="Dialog Title"
android:dependency="checkbox_preference"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</PreferenceCategory>
<PreferenceCategory
android:title="Section 2"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Preference
android:title="Intent Pref"
android:layout_width="match_parent"
android:layout_height="match_parent">
<intent android:action="android.intent.action.VIEW"
android:data="http://codepath.com/"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</Preference>
</PreferenceCategory>
</PreferenceScreen>

View File

@ -35,6 +35,11 @@
android:icon="@drawable/ic_bug_report"
android:title="@string/log"/>
<item
android:id="@+id/settings"
android:icon="@drawable/ic_settings"
android:title="@string/settings"/>
</group>
<group

View File

@ -70,7 +70,7 @@
<!--About Activity-->
<string name="about">About</string>
<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/dvdandroid">dvdandroid</a>]]></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="app_version">App\'s version</string>
@ -107,4 +107,18 @@
<string name="url_main">https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token=</string>
<string name="file_url">https://raw.githubusercontent.com/Magisk-Modules-Repo/%1$s/master/%2$s</string>
<string name="zip_url">https://github.com/Magisk-Modules-Repo/%1$s/archive/master.zip</string>
<!--Settings Fragment -->
<string name="settings">Settings</string>
<string name="settings_quicksettings_category">Quick Settings</string>
<string name="settings_enable_quicktile_title">Enable Quicksettings Tile</string>
<string name="settings_enable_quicktile_summary">Click here to enable or disable the quick settings tile.</string>
<string name="settings_keep_root_off_summary">Disable root unless otherwise enabled by Auto-root or toggle.</string>
<string name="settings_keep_root_off_title">Keep root turned off</string>
<string name="settings_developer_logging_title">Enable advanced debug logging</string>
<string name="settings_developer_logging_summary">Check this to enable more verbose logging.</string>
<string name="settings_root_category">Root</string>
<string name="settings_development_category">Development</string>
<string name="settings_hide_root_notification_summary">When checked, auto-root notifications will not be displayed.</string>
<string name="settings_hide_root_notification_title">Hide auto-root notifications</string>
</resources>

View File

@ -0,0 +1,38 @@
<PreferenceScreen
android:layout_marginTop="?attr/actionBarSize"
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/settings_quicksettings_category">
<CheckBoxPreference
android:key="enable_quicktile"
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: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">
<CheckBoxPreference
android:key="developer_logging"
android:title="@string/settings_developer_logging_title"
android:summary="@string/settings_developer_logging_summary" />
</PreferenceCategory>
</PreferenceScreen>