From 4b49331d975aaf70ff271742183d6022cebd89ce Mon Sep 17 00:00:00 2001 From: d8ahazard Date: Fri, 23 Sep 2016 16:42:25 -0500 Subject: [PATCH] I think...that...might be it? --- .../magisk/services/TileServiceCompat.java | 28 +++++++------------ .../com/topjohnwu/magisk/utils/Utils.java | 2 +- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/services/TileServiceCompat.java b/app/src/main/java/com/topjohnwu/magisk/services/TileServiceCompat.java index d316b4b0b..3e530efb5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/services/TileServiceCompat.java +++ b/app/src/main/java/com/topjohnwu/magisk/services/TileServiceCompat.java @@ -41,12 +41,15 @@ public class TileServiceCompat extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { - root = Utils.rootEnabled(); - autoRoot = Utils.autoToggleEnabled(getApplicationContext()); + updateRoots(); updateTile(); return super.onStartCommand(intent, flags, startId); } + private void updateRoots() { + root = Utils.rootEnabled(); + autoRoot = Utils.autoToggleEnabled(getApplicationContext()); + } private void registerClickTileReceiver() { @@ -70,26 +73,15 @@ public class TileServiceCompat extends Service { private void onSimpleClick() { + updateRoots(); + updateTile(); Utils.toggleRoot(!root); } private void onLongClick() { - Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); - sendBroadcast(it); - Utils.toggleAutoRoot(!Utils.autoToggleEnabled(getApplicationContext()),getApplicationContext()); - } - - 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; + updateRoots(); + updateTile(); + Utils.toggleAutoRoot(!autoRoot,getApplicationContext()); } private void updateTile() { diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java index 34a15fcee..9e8ec848b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java @@ -287,7 +287,7 @@ public class Utils { } } - tiles.add(tiles.size() + 1, qsTileId); + tiles.add(Math.round(tiles.size()/2), qsTileId); String newTiles = TextUtils.join(",", tiles); Logger.dh("Utils: NewtilesString is "+ newTiles); Shell.su("settings put secure sysui_qs_tiles \"" + newTiles + "\"");