Skip to content

Commit 904cae7

Browse files
nathanchanceeyosen
authored andcommitted
Add Magisk Manager dashboard option
The primary reason for bringing this into the dashboard is that the Magisk Manager will soon have root management options, meaning that people will no longer need the Superuser app I would have liked to use the actual Magisk icon from within the app but it just does not look good at lower DPIs so I picked a tuning icon from https://materialdesignicons.com/ Preview with summary: http://i.imgur.com/Zc1FJN8.png Change-Id: If7df9976d371b29797ec4c237c77c7489f6a3541 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
1 parent 3a0c1f2 commit 904cae7

5 files changed

Lines changed: 71 additions & 1 deletion

File tree

AndroidManifest.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,6 +3037,27 @@
30373037
android:value="true" />
30383038
</activity>
30393039

3040+
<activity android:name="Settings$MagiskActivity"
3041+
android:label="@string/magisk_title"
3042+
android:icon="@drawable/ic_settings_magisk"
3043+
android:taskAffinity="">
3044+
<intent-filter android:priority="4">
3045+
<action android:name="android.intent.action.MAIN" />
3046+
<category android:name="android.intent.category.DEFAULT" />
3047+
<category android:name="android.intent.category.VOICE_LAUNCH" />
3048+
<category android:name="com.android.settings.SHORTCUT" />
3049+
</intent-filter>
3050+
<intent-filter android:priority="9">
3051+
<action android:name="com.android.settings.action.SETTINGS" />
3052+
</intent-filter>
3053+
<meta-data android:name="com.android.settings.category"
3054+
android:value="com.android.settings.category.aicpextras" />
3055+
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
3056+
android:value="com.android.settings.MagiskManager" />
3057+
<meta-data android:name="com.android.settings.summary"
3058+
android:resource="@string/magisk_summary" />
3059+
</activity>
3060+
30403061
<!-- Smartbar settings activity. -->
30413062
<activity android:name="Settings$SmartbarSettingsActivity"
30423063
android:label="@string/smartbar_settings_title"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (C) 2017 Flash ROM
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:height="24dp"
19+
android:width="24dp"
20+
android:viewportWidth="24"
21+
android:viewportHeight="24"
22+
android:tint="?android:attr/colorAccent">
23+
<path
24+
android:fillColor="#FFF"
25+
android:pathData="M3,17V19H9V17H3M3,5V7H13V5H3M13,21V19H21V17H13V15H11V21H13M7,9V11H3V13H7V15H9V9H7M21,13V11H11V13H21M15,9H17V7H21V5H17V3H15V9Z" />
26+
</vector>

res/values/aicp_strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,8 @@
397397
<string name="night_bright_min">Minimum brightness</string>
398398
<string name="night_bright_low">Low brightness</string>
399399
<string name="night_bright_medium">Medium brightness</string>
400+
401+
<string name="magisk_title">Magisk Manager</string>
402+
<string name="magisk_summary">Root management</string>
403+
400404
</resources>

src/com/android/settings/Settings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public static class DeviceSettings extends SettingsActivity { /* empty */ }
163163
public static class PersonalSettings extends SettingsActivity { /* empty */ }
164164
public static class SystemSettings extends SettingsActivity { /* empty */ }
165165
public static class AEStartActivityActivity extends SettingsActivity { /* empty */ }
166+
public static class MagiskActivity extends SettingsActivity { /* empty */ }
166167
public static class NavigationSettingsActivity extends SettingsActivity { /* empty */ }
167168
public static class FlingSettingsActivity extends SettingsActivity { /* empty */ }
168169
public static class SmartbarSettingsActivity extends SettingsActivity { /* empty */ }

src/com/android/settings/SettingsActivity.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ public class SettingsActivity extends SettingsDrawerActivity
242242

243243
private static final String ACTION_TIMER_SWITCH = "qualcomm.intent.action.TIMER_SWITCH";
244244

245+
private static final String MAGISK_FRAGMENT = "com.android.settings.MagiskManager";
246+
245247
private String mFragmentClass;
246248
private String mActivityAction;
247249

@@ -1059,7 +1061,13 @@ public void startPreferenceFragment(Fragment fragment, boolean push) {
10591061
*/
10601062
private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
10611063
boolean addToBackStack, int titleResId, CharSequence title, boolean withTransition) {
1062-
1064+
if (MAGISK_FRAGMENT.equals(fragmentName)) {
1065+
Intent magiskIntent = new Intent();
1066+
magiskIntent.setClassName("com.topjohnwu.magisk", "com.topjohnwu.magisk.SplashActivity");
1067+
startActivity(magiskIntent);
1068+
finish();
1069+
return null;
1070+
}
10631071
if (validate && !isValidFragment(fragmentName)) {
10641072
throw new IllegalArgumentException("Invalid fragment for this activity: "
10651073
+ fragmentName);
@@ -1157,6 +1165,16 @@ private void doUpdateTilesList() {
11571165
// Reveal development-only quick settings tiles
11581166
DevelopmentTiles.setTilesEnabled(this, showDev);
11591167

1168+
// Magisk Manager
1169+
boolean magiskSupported = false;
1170+
try {
1171+
magiskSupported = (getPackageManager().getPackageInfo("com.topjohnwu.magisk", 0).versionCode > 0);
1172+
} catch (PackageManager.NameNotFoundException e) {
1173+
}
1174+
setTileEnabled(new ComponentName(packageName,
1175+
Settings.MagiskActivity.class.getName()),
1176+
magiskSupported, isAdmin, pm);
1177+
11601178
// Show scheduled power on and off if support
11611179
boolean showTimerSwitch = false;
11621180
Intent intent = new Intent(ACTION_TIMER_SWITCH);

0 commit comments

Comments
 (0)