summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPinyao Ting <pinyaoting@google.com>2019-09-12 11:56:18 -0700
committerPinyao Ting <pinyaoting@google.com>2019-09-12 20:33:03 +0000
commit39216c1533330a8fc0f5d86f3b8193eb85f2f195 (patch)
tree3f9d0f4abe0217fc00140549af0d46dbce11b744 /src
parentde5e5afae5f8e674b5acae3faab7f5071d7f6f61 (diff)
downloadandroid_packages_apps_Trebuchet-39216c1533330a8fc0f5d86f3b8193eb85f2f195.tar.gz
android_packages_apps_Trebuchet-39216c1533330a8fc0f5d86f3b8193eb85f2f195.tar.bz2
android_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')
-rw-r--r--src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java13
-rw-r--r--src/com/android/launcher3/util/ShortcutUtil.java86
2 files changed, 64 insertions, 35 deletions
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index 0c1303b64..0c12c60a0 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -1,5 +1,7 @@
package com.android.launcher3.accessibility;
+import static android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK;
+
import static com.android.launcher3.LauncherState.NORMAL;
import android.app.AlertDialog;
@@ -30,14 +32,14 @@ import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.PendingAddItemInfo;
import com.android.launcher3.R;
-import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.Workspace;
+import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.dragndrop.DragController.DragListener;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.folder.Folder;
+import com.android.launcher3.keyboard.CustomActionsPopup;
import com.android.launcher3.notification.NotificationListener;
import com.android.launcher3.popup.PopupContainerWithArrow;
-import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.ShortcutUtil;
@@ -164,6 +166,13 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
}
public boolean performAction(final View host, final ItemInfo item, int action) {
+ if (action == ACTION_LONG_CLICK && ShortcutUtil.isDeepShortcut(item)) {
+ CustomActionsPopup popup = new CustomActionsPopup(mLauncher, host);
+ if (popup.canShow()) {
+ popup.show();
+ return true;
+ }
+ }
if (action == MOVE) {
beginAccessibleDrag(host, item);
} else if (action == ADD_TO_WORKSPACE) {
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