diff options
author | Pinyao Ting <pinyaoting@google.com> | 2019-09-12 11:56:18 -0700 |
---|---|---|
committer | Pinyao Ting <pinyaoting@google.com> | 2019-09-12 20:33:03 +0000 |
commit | 39216c1533330a8fc0f5d86f3b8193eb85f2f195 (patch) | |
tree | 3f9d0f4abe0217fc00140549af0d46dbce11b744 /src/com/android/launcher3/util | |
parent | de5e5afae5f8e674b5acae3faab7f5071d7f6f61 (diff) | |
download | packages_apps_Trebuchet-39216c1533330a8fc0f5d86f3b8193eb85f2f195.tar.gz packages_apps_Trebuchet-39216c1533330a8fc0f5d86f3b8193eb85f2f195.tar.bz2 packages_apps_Trebuchet-39216c1533330a8fc0f5d86f3b8193eb85f2f195.zip |
Fix the issue deep shortcuts cannot be added to workspace via
voice/switch access
Bug: 140405990
Change-Id: Ie54d9c738fc51445f3aa49458ff4fc1dd6e4fc67
Merged-In: Ie54d9c738fc51445f3aa49458ff4fc1dd6e4fc67
(cherry picked from commit 8a739f9511cc3833fdd9df33ce35bd6126ba1ea4)
Diffstat (limited to 'src/com/android/launcher3/util')
-rw-r--r-- | src/com/android/launcher3/util/ShortcutUtil.java | 86 |
1 files changed, 53 insertions, 33 deletions
diff --git a/src/com/android/launcher3/util/ShortcutUtil.java b/src/com/android/launcher3/util/ShortcutUtil.java index 792d69fc3..af99713a1 100644 --- a/src/com/android/launcher3/util/ShortcutUtil.java +++ b/src/com/android/launcher3/util/ShortcutUtil.java @@ -23,37 +23,57 @@ import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.shortcuts.ShortcutKey; public class ShortcutUtil { - public static boolean supportsShortcuts(ItemInfo info) { - return isActive(info) && (isApp(info) || isPinnedShortcut(info)); - } - - public static boolean supportsDeepShortcuts(ItemInfo info) { - return isActive(info) && isApp(info); - } - - public static String getShortcutIdIfPinnedShortcut(ItemInfo info) { - return isActive(info) && isPinnedShortcut(info) ? - ShortcutKey.fromItemInfo(info).getId() : null; - } - - public static String[] getPersonKeysIfPinnedShortcut(ItemInfo info) { - return isActive(info) && isPinnedShortcut(info) ? - ((WorkspaceItemInfo) info).getPersonKeys() : Utilities.EMPTY_STRING_ARRAY; - } - - private static boolean isActive(ItemInfo info) { - boolean isLoading = info instanceof WorkspaceItemInfo - && ((WorkspaceItemInfo) info).hasPromiseIconUi(); - return !isLoading && !info.isDisabled() && !FeatureFlags.GO_DISABLE_WIDGETS; - } - - private static boolean isApp(ItemInfo info) { - return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; - } - - private static boolean isPinnedShortcut(ItemInfo info) { - return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT - && info.container != ItemInfo.NO_ID - && info instanceof WorkspaceItemInfo; - } + /** + * Returns true when we should show shortcut menu for the item. + */ + public static boolean supportsShortcuts(ItemInfo info) { + return isActive(info) && (isApp(info) || isPinnedShortcut(info)); + } + + /** + * Returns true when we should show depp shortcuts in shortcut menu for the item. + */ + public static boolean supportsDeepShortcuts(ItemInfo info) { + return isActive(info) && isApp(info); + } + + /** + * Returns the shortcut id if the item is a pinned shortcut. + */ + public static String getShortcutIdIfPinnedShortcut(ItemInfo info) { + return isActive(info) && isPinnedShortcut(info) + ? ShortcutKey.fromItemInfo(info).getId() : null; + } + + /** + * Returns the person keys associated with the item. (Has no function right now.) + */ + public static String[] getPersonKeysIfPinnedShortcut(ItemInfo info) { + return isActive(info) && isPinnedShortcut(info) + ? ((WorkspaceItemInfo) info).getPersonKeys() : Utilities.EMPTY_STRING_ARRAY; + } + + /** + * Returns true if the item is a deep shortcut. + */ + public static boolean isDeepShortcut(ItemInfo info) { + return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT + && info instanceof WorkspaceItemInfo; + } + + private static boolean isActive(ItemInfo info) { + boolean isLoading = info instanceof WorkspaceItemInfo + && ((WorkspaceItemInfo) info).hasPromiseIconUi(); + return !isLoading && !info.isDisabled() && !FeatureFlags.GO_DISABLE_WIDGETS; + } + + private static boolean isApp(ItemInfo info) { + return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; + } + + private static boolean isPinnedShortcut(ItemInfo info) { + return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT + && info.container != ItemInfo.NO_ID + && info instanceof WorkspaceItemInfo; + } }
\ No newline at end of file |