summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-07-28 19:23:28 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-07-28 19:23:29 +0000
commit55f5bd730cace56d224de33461f575f41bdd480f (patch)
treef7a8da0070df451118f42917626ecd8da2f4bd74 /src
parente34dd33156ec0e6651dda3aa73fe4e6a1df9d5ae (diff)
parent70a7c9b70003ae87e2b2968bc6ceded0fe0f0e8b (diff)
downloadandroid_packages_apps_Trebuchet-55f5bd730cace56d224de33461f575f41bdd480f.tar.gz
android_packages_apps_Trebuchet-55f5bd730cace56d224de33461f575f41bdd480f.tar.bz2
android_packages_apps_Trebuchet-55f5bd730cace56d224de33461f575f41bdd480f.zip
Merge "Showing the shortcuts in the disabled state and removing ti from the menu when its disabled" into ub-launcher3-calgary
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java2
-rw-r--r--src/com/android/launcher3/LauncherModel.java8
-rw-r--r--src/com/android/launcher3/ShortcutInfo.java19
-rw-r--r--src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java4
4 files changed, 26 insertions, 7 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index df856c1b6..78e0aa0c1 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2659,6 +2659,8 @@ public class Launcher extends Activity
int error = R.string.activity_not_available;
if ((shortcut.isDisabled & ShortcutInfo.FLAG_DISABLED_SAFEMODE) != 0) {
error = R.string.safemode_shortcut_error;
+ } else if ((shortcut.isDisabled & ShortcutInfo.FLAG_DISABLED_BY_PUBLISHER) != 0) {
+ error = R.string.shortcut_not_available;
}
Toast.makeText(this, error, Toast.LENGTH_SHORT).show();
return;
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 61dda1c52..b42f80c0f 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -2842,9 +2842,11 @@ public class LauncherModel extends BroadcastReceiver
// Now add the new shortcuts to the map.
for (ShortcutInfoCompat shortcut : shortcuts) {
- ComponentKey targetComponent
- = new ComponentKey(shortcut.getActivity(), shortcut.getUserHandle());
- mBgDeepShortcutMap.addToList(targetComponent, shortcut.getId());
+ if (shortcut.isEnabled()) {
+ ComponentKey targetComponent
+ = new ComponentKey(shortcut.getActivity(), shortcut.getUserHandle());
+ mBgDeepShortcutMap.addToList(targetComponent, shortcut.getId());
+ }
}
}
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index c87bc08c9..00ac9bda4 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -100,22 +100,28 @@ public class ShortcutInfo extends ItemInfo {
/**
* Indicates that the icon is disabled due to safe mode restrictions.
*/
- public static final int FLAG_DISABLED_SAFEMODE = 1;
+ public static final int FLAG_DISABLED_SAFEMODE = 1 << 0;
/**
* Indicates that the icon is disabled as the app is not available.
*/
- public static final int FLAG_DISABLED_NOT_AVAILABLE = 2;
+ public static final int FLAG_DISABLED_NOT_AVAILABLE = 1 << 1;
/**
* Indicates that the icon is disabled as the app is suspended
*/
- public static final int FLAG_DISABLED_SUSPENDED = 4;
+ public static final int FLAG_DISABLED_SUSPENDED = 1 << 2;
/**
* Indicates that the icon is disabled as the user is in quiet mode.
*/
- public static final int FLAG_DISABLED_QUIET_USER = 8;
+ public static final int FLAG_DISABLED_QUIET_USER = 1 << 3;
+
+
+ /**
+ * Indicates that the icon is disabled as the publisher has disabled the actual shortcut.
+ */
+ public static final int FLAG_DISABLED_BY_PUBLISHER = 1 << 4;
/**
* Could be disabled, if the the app is installed but unavailable (eg. in safe mode or when
@@ -293,6 +299,11 @@ public class ShortcutInfo extends ItemInfo {
}
contentDescription = UserManagerCompat.getInstance(context)
.getBadgedLabelForUser(label, user);
+ if (shortcutInfo.isEnabled()) {
+ isDisabled &= ~FLAG_DISABLED_BY_PUBLISHER;
+ } else {
+ isDisabled |= FLAG_DISABLED_BY_PUBLISHER;
+ }
LauncherAppState launcherAppState = LauncherAppState.getInstance();
Drawable unbadgedIcon = launcherAppState.getShortcutManager()
diff --git a/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java b/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
index 00553dfbd..9e7add56c 100644
--- a/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
+++ b/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
@@ -101,6 +101,10 @@ public class ShortcutInfoCompat {
return mShortcutInfo.isDeclaredInManifest();
}
+ public boolean isEnabled() {
+ return mShortcutInfo.isEnabled();
+ }
+
public int getRank() {
return mShortcutInfo.getRank();
}