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

Allow hiding icon from launchers #169

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -154,6 +156,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 "magiskhide":
enabled = prefs.getBoolean("magiskhide", false);
if (enabled) {
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 @@ -14,6 +14,12 @@
android:title="@string/settings_notification_title"
android:summary="@string/settings_notification_summary" />

<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