Fix the issue deep shortcuts cannot be added to workspace via
voice/switch access Bug: 140405990 Change-Id: Ie54d9c738fc51445f3aa49458ff4fc1dd6e4fc67
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
/**
|
||||
* Returns true when we should show shortcut menu for the item.
|
||||
*/
|
||||
public static boolean supportsShortcuts(ItemInfo info) {
|
||||
return isActive(info) && (isApp(info) || isPinnedShortcut(info));
|
||||
}
|
||||
|
||||
public static boolean supportsDeepShortcuts(ItemInfo info) {
|
||||
return isActive(info) && isApp(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);
|
||||
}
|
||||
|
||||
public static String getShortcutIdIfPinnedShortcut(ItemInfo info) {
|
||||
return isActive(info) && isPinnedShortcut(info) ?
|
||||
ShortcutKey.fromItemInfo(info).getId() : null;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
public static String[] getPersonKeysIfPinnedShortcut(ItemInfo info) {
|
||||
return isActive(info) && isPinnedShortcut(info) ?
|
||||
((WorkspaceItemInfo) info).getPersonKeys() : Utilities.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
private static boolean isActive(ItemInfo info) {
|
||||
boolean isLoading = info instanceof WorkspaceItemInfo
|
||||
&& ((WorkspaceItemInfo) info).hasPromiseIconUi();
|
||||
return !isLoading && !info.isDisabled() && !FeatureFlags.GO_DISABLE_WIDGETS;
|
||||
}
|
||||
/**
|
||||
* 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 isApp(ItemInfo info) {
|
||||
return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
|
||||
}
|
||||
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 isPinnedShortcut(ItemInfo info) {
|
||||
return info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT
|
||||
&& info.container != ItemInfo.NO_ID
|
||||
&& info instanceof WorkspaceItemInfo;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user