Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

Commit

Permalink
Allow hiding icon from launchers
Browse files Browse the repository at this point in the history
Fixes #167
  • Loading branch information
DVDAndroid committed May 24, 2017
1 parent 1ecbfd7 commit d2e88da
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,22 @@
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity-alias
android:name=".SplashActivity-main"
android:configChanges="orientation|screenSize"
android:enabled="true"
android:exported="true"
android:targetActivity=".SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>

<activity
android:name=".AboutActivity"
android:theme="@style/AppTheme.Transparent"/>
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.topjohnwu.magisk;

import android.content.ComponentName;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceCategory;
Expand Down Expand Up @@ -163,6 +165,14 @@ protected Void doInBackground(Void... voids) {
}.exec();
Toast.makeText(getActivity(), R.string.settings_reboot_toast, Toast.LENGTH_LONG).show();
break;
case "icon_launcher":
PackageManager pm = getActivity().getPackageManager();
String activity = "com.topjohnwu.magisk.SplashActivity-main";

int state = prefs.getBoolean("icon_launcher", true) ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;

pm.setComponentEnabledSetting(new ComponentName(getActivity(), activity), state, PackageManager.DONT_KILL_APP);
break;
case "busybox":
enabled = prefs.getBoolean("busybox", false);
new SerialTask<Void, Void, Void>() {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
<string name="settings_dark_theme_summary">Enable dark theme</string>
<string name="settings_notification_title">Update Notification</string>
<string name="settings_notification_summary">Show update notifications when new version is available</string>
<string name="icon_launcher">Show app icon in the launcher</string>
<string name="icon_launcher_summary">It may require a launcher reboot</string>
<string name="settings_clear_cache_title">Clear Repo Cache</string>
<string name="settings_clear_cache_summary">Clear the cached information for online repos, forces the app to refresh online</string>

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/app_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
android:summary="@string/settings_notification_summary"
android:key="notification" />

<CheckBoxPreference
android:title="@string/icon_launcher"
android:summary="@string/icon_launcher_summary"
android:defaultValue="true"
android:key="icon_launcher"/>

<Preference
android:key="clear"
android:title="@string/settings_clear_cache_title"
Expand Down

0 comments on commit d2e88da

Please sign in to comment.