From 4efffc5ba69fdf44be1bf2b540e24cd2bd85d18c Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Thu, 4 Aug 2016 16:34:49 -0700 Subject: Use shortcut disabled message if available. Bug: 30681210 Change-Id: Ibb5fd58e5fc9557b63730bc1e3c3977133769466 --- src/com/android/launcher3/Launcher.java | 6 ++++++ src/com/android/launcher3/ShortcutInfo.java | 7 +++++++ src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java | 4 ++++ 3 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index d76d3e290..adf07a1ca 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2668,6 +2668,12 @@ public class Launcher extends Activity // If the app is only disabled because of the above flags, launch activity anyway. // Framework will tell the user why the app is suspended. } else { + if (!TextUtils.isEmpty(shortcut.disabledMessage)) { + // Use a message specific to this shortcut, if it has one. + Toast.makeText(this, shortcut.disabledMessage, Toast.LENGTH_SHORT).show(); + return; + } + // Otherwise just use a generic error message. int error = R.string.activity_not_available; if ((shortcut.isDisabled & ShortcutInfo.FLAG_DISABLED_SAFEMODE) != 0) { error = R.string.safemode_shortcut_error; diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java index a2182e85e..8c466b2b0 100644 --- a/src/com/android/launcher3/ShortcutInfo.java +++ b/src/com/android/launcher3/ShortcutInfo.java @@ -133,6 +133,12 @@ public class ShortcutInfo extends ItemInfo { */ int isDisabled = DEFAULT; + /** + * A message to display when the user tries to start a disabled shortcut. + * This is currently only used for deep shortcuts. + */ + CharSequence disabledMessage; + int status; /** @@ -309,6 +315,7 @@ public class ShortcutInfo extends ItemInfo { } else { isDisabled |= FLAG_DISABLED_BY_PUBLISHER; } + disabledMessage = shortcutInfo.getDisabledMessage(); // TODO: Use cache for this LauncherAppState launcherAppState = LauncherAppState.getInstance(); diff --git a/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java b/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java index 410693ada..a6da6683c 100644 --- a/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java +++ b/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java @@ -114,6 +114,10 @@ public class ShortcutInfoCompat { return mShortcutInfo.getRank(); } + public CharSequence getDisabledMessage() { + return mShortcutInfo.getDisabledMessage(); + } + @Override public String toString() { return mShortcutInfo.toString(); -- cgit v1.2.3