Skip to content

Commit

Permalink
Add Magisk Manager dashboard option
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nathanchance authored and eyosen committed Feb 11, 2017
1 parent 3a0c1f2 commit 904cae7
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
21 changes: 21 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3037,6 +3037,27 @@
android:value="true" />
</activity>

<activity android:name="Settings$MagiskActivity"
android:label="@string/magisk_title"
android:icon="@drawable/ic_settings_magisk"
android:taskAffinity="">
<intent-filter android:priority="4">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
<category android:name="com.android.settings.SHORTCUT" />
</intent-filter>
<intent-filter android:priority="9">
<action android:name="com.android.settings.action.SETTINGS" />
</intent-filter>
<meta-data android:name="com.android.settings.category"
android:value="com.android.settings.category.aicpextras" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.MagiskManager" />
<meta-data android:name="com.android.settings.summary"
android:resource="@string/magisk_summary" />
</activity>

<!-- Smartbar settings activity. -->
<activity android:name="Settings$SmartbarSettingsActivity"
android:label="@string/smartbar_settings_title"
Expand Down
26 changes: 26 additions & 0 deletions res/drawable/ic_settings_magisk.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 Flash ROM
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?android:attr/colorAccent">
<path
android:fillColor="#FFF"
android:pathData="M3,17V19H9V17H3M3,5V7H13V5H3M13,21V19H21V17H13V15H11V21H13M7,9V11H3V13H7V15H9V9H7M21,13V11H11V13H21M15,9H17V7H21V5H17V3H15V9Z" />
</vector>
4 changes: 4 additions & 0 deletions res/values/aicp_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,8 @@
<string name="night_bright_min">Minimum brightness</string>
<string name="night_bright_low">Low brightness</string>
<string name="night_bright_medium">Medium brightness</string>

<string name="magisk_title">Magisk Manager</string>
<string name="magisk_summary">Root management</string>

</resources>
1 change: 1 addition & 0 deletions src/com/android/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public static class DeviceSettings extends SettingsActivity { /* empty */ }
public static class PersonalSettings extends SettingsActivity { /* empty */ }
public static class SystemSettings extends SettingsActivity { /* empty */ }
public static class AEStartActivityActivity extends SettingsActivity { /* empty */ }
public static class MagiskActivity extends SettingsActivity { /* empty */ }
public static class NavigationSettingsActivity extends SettingsActivity { /* empty */ }
public static class FlingSettingsActivity extends SettingsActivity { /* empty */ }
public static class SmartbarSettingsActivity extends SettingsActivity { /* empty */ }
Expand Down
20 changes: 19 additions & 1 deletion src/com/android/settings/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ public class SettingsActivity extends SettingsDrawerActivity

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

private static final String MAGISK_FRAGMENT = "com.android.settings.MagiskManager";

private String mFragmentClass;
private String mActivityAction;

Expand Down Expand Up @@ -1059,7 +1061,13 @@ public void startPreferenceFragment(Fragment fragment, boolean push) {
*/
private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
boolean addToBackStack, int titleResId, CharSequence title, boolean withTransition) {

if (MAGISK_FRAGMENT.equals(fragmentName)) {
Intent magiskIntent = new Intent();
magiskIntent.setClassName("com.topjohnwu.magisk", "com.topjohnwu.magisk.SplashActivity");
startActivity(magiskIntent);
finish();
return null;
}
if (validate && !isValidFragment(fragmentName)) {
throw new IllegalArgumentException("Invalid fragment for this activity: "
+ fragmentName);
Expand Down Expand Up @@ -1157,6 +1165,16 @@ private void doUpdateTilesList() {
// Reveal development-only quick settings tiles
DevelopmentTiles.setTilesEnabled(this, showDev);

// Magisk Manager
boolean magiskSupported = false;
try {
magiskSupported = (getPackageManager().getPackageInfo("com.topjohnwu.magisk", 0).versionCode > 0);
} catch (PackageManager.NameNotFoundException e) {
}
setTileEnabled(new ComponentName(packageName,
Settings.MagiskActivity.class.getName()),
magiskSupported, isAdmin, pm);

// Show scheduled power on and off if support
boolean showTimerSwitch = false;
Intent intent = new Intent(ACTION_TIMER_SWITCH);
Expand Down

0 comments on commit 904cae7

Please sign in to comment.