Sunny Goyal | 83a8f04 | 2015-05-19 12:52:12 -0700 | [diff] [blame] | 1 | package com.android.launcher3.accessibility; |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 2 | |
Pinyao Ting | 8a739f9 | 2019-09-12 11:56:18 -0700 | [diff] [blame] | 3 | import static android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK; |
| 4 | |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 5 | import static com.android.launcher3.LauncherState.NORMAL; |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 6 | import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE; |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 7 | |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 8 | import android.appwidget.AppWidgetProviderInfo; |
Sunny Goyal | 9b18010 | 2020-03-11 10:02:29 -0700 | [diff] [blame] | 9 | import android.graphics.Point; |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 10 | import android.graphics.Rect; |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 11 | import android.graphics.RectF; |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 12 | import android.os.Bundle; |
Sunny Goyal | 9ae7777 | 2015-04-29 16:30:23 -0700 | [diff] [blame] | 13 | import android.os.Handler; |
Sunny Goyal | 1a70cef | 2015-04-22 11:29:51 -0700 | [diff] [blame] | 14 | import android.text.TextUtils; |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 15 | import android.util.Log; |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 16 | import android.util.SparseArray; |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 17 | import android.view.KeyEvent; |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 18 | import android.view.View; |
| 19 | import android.view.View.AccessibilityDelegate; |
| 20 | import android.view.accessibility.AccessibilityNodeInfo; |
| 21 | import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; |
| 22 | |
Sunny Goyal | 83a8f04 | 2015-05-19 12:52:12 -0700 | [diff] [blame] | 23 | import com.android.launcher3.AppWidgetResizeFrame; |
Sunny Goyal | 3ffa64d | 2016-07-25 13:54:32 -0700 | [diff] [blame] | 24 | import com.android.launcher3.BubbleTextView; |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 25 | import com.android.launcher3.ButtonDropTarget; |
Sunny Goyal | 83a8f04 | 2015-05-19 12:52:12 -0700 | [diff] [blame] | 26 | import com.android.launcher3.CellLayout; |
Sunny Goyal | 94b510c | 2016-08-16 15:36:48 -0700 | [diff] [blame] | 27 | import com.android.launcher3.DropTarget.DragObject; |
Sunny Goyal | 83a8f04 | 2015-05-19 12:52:12 -0700 | [diff] [blame] | 28 | import com.android.launcher3.Launcher; |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 29 | import com.android.launcher3.LauncherSettings.Favorites; |
Sunny Goyal | 83a8f04 | 2015-05-19 12:52:12 -0700 | [diff] [blame] | 30 | import com.android.launcher3.PendingAddItemInfo; |
| 31 | import com.android.launcher3.R; |
Sunny Goyal | 83a8f04 | 2015-05-19 12:52:12 -0700 | [diff] [blame] | 32 | import com.android.launcher3.Workspace; |
Vadim Tryshev | fedca43 | 2015-08-19 17:55:02 -0700 | [diff] [blame] | 33 | import com.android.launcher3.dragndrop.DragController.DragListener; |
Sunny Goyal | a52ecb0 | 2016-12-16 15:04:51 -0800 | [diff] [blame] | 34 | import com.android.launcher3.dragndrop.DragOptions; |
| 35 | import com.android.launcher3.folder.Folder; |
Sunny Goyal | a4647b6 | 2021-02-02 13:45:34 -0800 | [diff] [blame] | 36 | import com.android.launcher3.keyboard.KeyboardDragAndDropView; |
Sunny Goyal | e396abf | 2020-04-06 15:11:17 -0700 | [diff] [blame] | 37 | import com.android.launcher3.model.data.AppInfo; |
| 38 | import com.android.launcher3.model.data.FolderInfo; |
| 39 | import com.android.launcher3.model.data.ItemInfo; |
| 40 | import com.android.launcher3.model.data.LauncherAppWidgetInfo; |
| 41 | import com.android.launcher3.model.data.WorkspaceItemInfo; |
Vadim Tryshev | a50d99f | 2018-05-04 17:58:29 -0700 | [diff] [blame] | 42 | import com.android.launcher3.notification.NotificationListener; |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 43 | import com.android.launcher3.popup.ArrowPopup; |
Mario Bertschler | c06af33 | 2017-03-28 12:23:22 -0700 | [diff] [blame] | 44 | import com.android.launcher3.popup.PopupContainerWithArrow; |
Vadim Tryshev | a50d99f | 2018-05-04 17:58:29 -0700 | [diff] [blame] | 45 | import com.android.launcher3.touch.ItemLongClickListener; |
Sunny Goyal | efb7e84 | 2018-10-04 15:11:00 -0700 | [diff] [blame] | 46 | import com.android.launcher3.util.IntArray; |
Pinyao Ting | 49a3e69 | 2019-07-26 12:28:38 -0700 | [diff] [blame] | 47 | import com.android.launcher3.util.ShortcutUtil; |
Adam Cohen | 091440a | 2015-03-18 14:16:05 -0700 | [diff] [blame] | 48 | import com.android.launcher3.util.Thunk; |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 49 | import com.android.launcher3.views.OptionsPopupView; |
| 50 | import com.android.launcher3.views.OptionsPopupView.OptionItem; |
Vadim Tryshev | a50d99f | 2018-05-04 17:58:29 -0700 | [diff] [blame] | 51 | import com.android.launcher3.widget.LauncherAppWidgetHostView; |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 52 | |
| 53 | import java.util.ArrayList; |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 54 | import java.util.Collections; |
| 55 | import java.util.List; |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 56 | |
Sunny Goyal | 4547802 | 2015-06-08 16:52:41 -0700 | [diff] [blame] | 57 | public class LauncherAccessibilityDelegate extends AccessibilityDelegate implements DragListener { |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 58 | |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 59 | private static final String TAG = "LauncherAccessibilityDelegate"; |
| 60 | |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 61 | public static final int REMOVE = R.id.action_remove; |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 62 | public static final int UNINSTALL = R.id.action_uninstall; |
Samuel Fufa | 5cf3e86 | 2020-02-03 20:22:54 -0800 | [diff] [blame] | 63 | public static final int DISMISS_PREDICTION = R.id.action_dismiss_prediction; |
Samuel Fufa | 6eaf989 | 2020-04-01 11:40:40 -0700 | [diff] [blame] | 64 | public static final int PIN_PREDICTION = R.id.action_pin_prediction; |
Winson Chung | 1054d4e | 2018-03-05 19:39:21 +0000 | [diff] [blame] | 65 | public static final int RECONFIGURE = R.id.action_reconfigure; |
Sunny Goyal | 3ffa64d | 2016-07-25 13:54:32 -0700 | [diff] [blame] | 66 | protected static final int ADD_TO_WORKSPACE = R.id.action_add_to_workspace; |
| 67 | protected static final int MOVE = R.id.action_move; |
| 68 | protected static final int MOVE_TO_WORKSPACE = R.id.action_move_to_workspace; |
| 69 | protected static final int RESIZE = R.id.action_resize; |
Sunny Goyal | 66b2457 | 2016-09-21 15:57:55 -0700 | [diff] [blame] | 70 | public static final int DEEP_SHORTCUTS = R.id.action_deep_shortcuts; |
Vadim Tryshev | a50d99f | 2018-05-04 17:58:29 -0700 | [diff] [blame] | 71 | public static final int SHORTCUTS_AND_NOTIFICATIONS = R.id.action_shortcuts_and_notifications; |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 72 | |
Sunny Goyal | e9b651e | 2015-04-24 11:44:51 -0700 | [diff] [blame] | 73 | public enum DragType { |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 74 | ICON, |
| 75 | FOLDER, |
| 76 | WIDGET |
| 77 | } |
| 78 | |
| 79 | public static class DragInfo { |
Sunny Goyal | e9b651e | 2015-04-24 11:44:51 -0700 | [diff] [blame] | 80 | public DragType dragType; |
| 81 | public ItemInfo info; |
| 82 | public View item; |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 83 | } |
| 84 | |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 85 | protected final SparseArray<LauncherAction> mActions = new SparseArray<>(); |
| 86 | protected final Launcher mLauncher; |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 87 | |
Sunny Goyal | e9b651e | 2015-04-24 11:44:51 -0700 | [diff] [blame] | 88 | private DragInfo mDragInfo = null; |
Sunny Goyal | e9b651e | 2015-04-24 11:44:51 -0700 | [diff] [blame] | 89 | |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 90 | public LauncherAccessibilityDelegate(Launcher launcher) { |
| 91 | mLauncher = launcher; |
| 92 | |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 93 | mActions.put(REMOVE, new LauncherAction( |
| 94 | REMOVE, R.string.remove_drop_target_label, KeyEvent.KEYCODE_X)); |
| 95 | mActions.put(UNINSTALL, new LauncherAction( |
| 96 | UNINSTALL, R.string.uninstall_drop_target_label, KeyEvent.KEYCODE_U)); |
| 97 | mActions.put(DISMISS_PREDICTION, new LauncherAction(DISMISS_PREDICTION, |
| 98 | R.string.dismiss_prediction_label, KeyEvent.KEYCODE_X)); |
| 99 | mActions.put(RECONFIGURE, new LauncherAction( |
| 100 | RECONFIGURE, R.string.gadget_setup_text, KeyEvent.KEYCODE_E)); |
| 101 | mActions.put(ADD_TO_WORKSPACE, new LauncherAction( |
| 102 | ADD_TO_WORKSPACE, R.string.action_add_to_workspace, KeyEvent.KEYCODE_P)); |
| 103 | mActions.put(MOVE, new LauncherAction( |
| 104 | MOVE, R.string.action_move, KeyEvent.KEYCODE_M)); |
| 105 | mActions.put(MOVE_TO_WORKSPACE, new LauncherAction(MOVE_TO_WORKSPACE, |
| 106 | R.string.action_move_to_workspace, KeyEvent.KEYCODE_P)); |
| 107 | mActions.put(RESIZE, new LauncherAction( |
| 108 | RESIZE, R.string.action_resize, KeyEvent.KEYCODE_R)); |
| 109 | mActions.put(DEEP_SHORTCUTS, new LauncherAction(DEEP_SHORTCUTS, |
| 110 | R.string.action_deep_shortcut, KeyEvent.KEYCODE_S)); |
| 111 | mActions.put(SHORTCUTS_AND_NOTIFICATIONS, new LauncherAction(DEEP_SHORTCUTS, |
| 112 | R.string.shortcuts_menu_with_notifications_description, KeyEvent.KEYCODE_S)); |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { |
| 117 | super.onInitializeAccessibilityNodeInfo(host, info); |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 118 | if (host.getTag() instanceof ItemInfo) { |
| 119 | ItemInfo item = (ItemInfo) host.getTag(); |
| 120 | |
| 121 | List<LauncherAction> actions = new ArrayList<>(); |
| 122 | getSupportedActions(host, item, actions); |
| 123 | actions.forEach(la -> info.addAction(la.accessibilityAction)); |
| 124 | |
| 125 | if (!itemSupportsLongClick(host, item)) { |
| 126 | info.setLongClickable(false); |
| 127 | info.removeAction(AccessibilityAction.ACTION_LONG_CLICK); |
| 128 | } |
| 129 | } |
Sunny Goyal | 3ffa64d | 2016-07-25 13:54:32 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 132 | /** |
| 133 | * Adds all the accessibility actions that can be handled. |
| 134 | */ |
| 135 | protected void getSupportedActions(View host, ItemInfo item, List<LauncherAction> out) { |
Sunny Goyal | 66b2457 | 2016-09-21 15:57:55 -0700 | [diff] [blame] | 136 | // If the request came from keyboard, do not add custom shortcuts as that is already |
| 137 | // exposed as a direct shortcut |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 138 | if (ShortcutUtil.supportsShortcuts(item)) { |
| 139 | out.add(mActions.get(NotificationListener.getInstanceIfConnected() != null |
Vadim Tryshev | a50d99f | 2018-05-04 17:58:29 -0700 | [diff] [blame] | 140 | ? SHORTCUTS_AND_NOTIFICATIONS : DEEP_SHORTCUTS)); |
Sunny Goyal | 3ffa64d | 2016-07-25 13:54:32 -0700 | [diff] [blame] | 141 | } |
| 142 | |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 143 | for (ButtonDropTarget target : mLauncher.getDropTargetBar().getDropTargets()) { |
Winson Chung | 1054d4e | 2018-03-05 19:39:21 +0000 | [diff] [blame] | 144 | if (target.supportsAccessibilityDrop(item, host)) { |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 145 | out.add(mActions.get(target.getAccessibilityAction())); |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 146 | } |
Sunny Goyal | 1a70cef | 2015-04-22 11:29:51 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Sunny Goyal | 66b2457 | 2016-09-21 15:57:55 -0700 | [diff] [blame] | 149 | // Do not add move actions for keyboard request as this uses virtual nodes. |
Sunny Goyal | a4647b6 | 2021-02-02 13:45:34 -0800 | [diff] [blame] | 150 | if (itemSupportsAccessibleDrag(item)) { |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 151 | out.add(mActions.get(MOVE)); |
Sunny Goyal | 9ae7777 | 2015-04-29 16:30:23 -0700 | [diff] [blame] | 152 | |
| 153 | if (item.container >= 0) { |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 154 | out.add(mActions.get(MOVE_TO_WORKSPACE)); |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 155 | } else if (item instanceof LauncherAppWidgetInfo) { |
| 156 | if (!getSupportedResizeActions(host, (LauncherAppWidgetInfo) item).isEmpty()) { |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 157 | out.add(mActions.get(RESIZE)); |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 158 | } |
Sunny Goyal | 9ae7777 | 2015-04-29 16:30:23 -0700 | [diff] [blame] | 159 | } |
Adam Cohen | 6e92f05 | 2016-06-07 14:30:10 -0700 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | if ((item instanceof AppInfo) || (item instanceof PendingAddItemInfo)) { |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 163 | out.add(mActions.get(ADD_TO_WORKSPACE)); |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 167 | /** |
| 168 | * Returns all the accessibility actions that can be handled by the host. |
| 169 | */ |
| 170 | public static List<LauncherAction> getSupportedActions(Launcher launcher, View host) { |
| 171 | if (host == null || !(host.getTag() instanceof ItemInfo)) { |
| 172 | return Collections.emptyList(); |
| 173 | } |
| 174 | PopupContainerWithArrow container = PopupContainerWithArrow.getOpen(launcher); |
| 175 | LauncherAccessibilityDelegate delegate = container != null |
| 176 | ? container.getAccessibilityDelegate() : launcher.getAccessibilityDelegate(); |
| 177 | List<LauncherAction> result = new ArrayList<>(); |
| 178 | delegate.getSupportedActions(host, (ItemInfo) host.getTag(), result); |
| 179 | return result; |
| 180 | } |
| 181 | |
Jon Miranda | cafe918 | 2020-03-25 11:46:11 -0700 | [diff] [blame] | 182 | private boolean itemSupportsLongClick(View host, ItemInfo info) { |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 183 | return PopupContainerWithArrow.canShow(host, info); |
Jon Miranda | cafe918 | 2020-03-25 11:46:11 -0700 | [diff] [blame] | 184 | } |
| 185 | |
vadimt | 5bc87ec | 2019-02-07 19:44:08 -0800 | [diff] [blame] | 186 | private boolean itemSupportsAccessibleDrag(ItemInfo item) { |
Sunny Goyal | 9589916 | 2019-03-27 16:03:06 -0700 | [diff] [blame] | 187 | if (item instanceof WorkspaceItemInfo) { |
vadimt | 5bc87ec | 2019-02-07 19:44:08 -0800 | [diff] [blame] | 188 | // Support the action unless the item is in a context menu. |
Samuel Fufa | 6eaf989 | 2020-04-01 11:40:40 -0700 | [diff] [blame] | 189 | return item.screenId >= 0 && item.container != Favorites.CONTAINER_HOTSEAT_PREDICTION; |
vadimt | 5bc87ec | 2019-02-07 19:44:08 -0800 | [diff] [blame] | 190 | } |
| 191 | return (item instanceof LauncherAppWidgetInfo) |
| 192 | || (item instanceof FolderInfo); |
| 193 | } |
| 194 | |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 195 | @Override |
| 196 | public boolean performAccessibilityAction(View host, int action, Bundle args) { |
| 197 | if ((host.getTag() instanceof ItemInfo) |
Sunny Goyal | a4647b6 | 2021-02-02 13:45:34 -0800 | [diff] [blame] | 198 | && performAction(host, (ItemInfo) host.getTag(), action, false)) { |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 199 | return true; |
| 200 | } |
| 201 | return super.performAccessibilityAction(host, action, args); |
| 202 | } |
| 203 | |
Sunny Goyal | a4647b6 | 2021-02-02 13:45:34 -0800 | [diff] [blame] | 204 | /** |
| 205 | * Performs the provided action on the host |
| 206 | */ |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 207 | protected boolean performAction(final View host, final ItemInfo item, int action, |
Sunny Goyal | a4647b6 | 2021-02-02 13:45:34 -0800 | [diff] [blame] | 208 | boolean fromKeyboard) { |
Adam Cohen | 732b1d4 | 2020-01-30 10:46:52 -0800 | [diff] [blame] | 209 | if (action == ACTION_LONG_CLICK) { |
Jon Miranda | ff65674 | 2020-03-31 19:25:48 -0700 | [diff] [blame] | 210 | if (PopupContainerWithArrow.canShow(host, item)) { |
Adam Cohen | 732b1d4 | 2020-01-30 10:46:52 -0800 | [diff] [blame] | 211 | // Long press should be consumed for workspace items, and it should invoke the |
| 212 | // Shortcuts / Notifications / Actions pop-up menu, and not start a drag as the |
| 213 | // standard long press path does. |
| 214 | PopupContainerWithArrow.showForIcon((BubbleTextView) host); |
Pinyao Ting | 8a739f9 | 2019-09-12 11:56:18 -0700 | [diff] [blame] | 215 | return true; |
| 216 | } |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 217 | } else if (action == MOVE) { |
Sunny Goyal | a4647b6 | 2021-02-02 13:45:34 -0800 | [diff] [blame] | 218 | return beginAccessibleDrag(host, item, fromKeyboard); |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 219 | } else if (action == ADD_TO_WORKSPACE) { |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 220 | final int[] coordinates = new int[2]; |
Sunny Goyal | efb7e84 | 2018-10-04 15:11:00 -0700 | [diff] [blame] | 221 | final int screenId = findSpaceOnWorkspace(item, coordinates); |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 222 | mLauncher.getStateManager().goToState(NORMAL, true, new Runnable() { |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 223 | |
| 224 | @Override |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 225 | public void run() { |
| 226 | if (item instanceof AppInfo) { |
Sunny Goyal | 9589916 | 2019-03-27 16:03:06 -0700 | [diff] [blame] | 227 | WorkspaceItemInfo info = ((AppInfo) item).makeWorkspaceItem(); |
Sunny Goyal | 43bf11d | 2017-02-02 13:52:53 -0800 | [diff] [blame] | 228 | mLauncher.getModelWriter().addItemToDatabase(info, |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 229 | Favorites.CONTAINER_DESKTOP, |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 230 | screenId, coordinates[0], coordinates[1]); |
| 231 | |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 232 | mLauncher.bindItems(Collections.singletonList(info), true); |
Pinyao Ting | c907427 | 2019-11-11 11:51:44 -0800 | [diff] [blame] | 233 | announceConfirmation(R.string.item_added_to_workspace); |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 234 | } else if (item instanceof PendingAddItemInfo) { |
| 235 | PendingAddItemInfo info = (PendingAddItemInfo) item; |
| 236 | Workspace workspace = mLauncher.getWorkspace(); |
| 237 | workspace.snapToPage(workspace.getPageIndexForScreenId(screenId)); |
Sunny Goyal | 3e3f44c | 2017-10-23 17:14:52 -0700 | [diff] [blame] | 238 | mLauncher.addPendingItem(info, Favorites.CONTAINER_DESKTOP, |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 239 | screenId, coordinates, info.spanX, info.spanY); |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 240 | } |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 241 | } |
| 242 | }); |
| 243 | return true; |
Sunny Goyal | 9ae7777 | 2015-04-29 16:30:23 -0700 | [diff] [blame] | 244 | } else if (action == MOVE_TO_WORKSPACE) { |
Sunny Goyal | 740ac7f | 2016-09-28 16:47:32 -0700 | [diff] [blame] | 245 | Folder folder = Folder.getOpen(mLauncher); |
| 246 | folder.close(true); |
Sunny Goyal | 9589916 | 2019-03-27 16:03:06 -0700 | [diff] [blame] | 247 | WorkspaceItemInfo info = (WorkspaceItemInfo) item; |
Sunny Goyal | c52ba71 | 2016-04-05 15:59:05 -0700 | [diff] [blame] | 248 | folder.getInfo().remove(info, false); |
Sunny Goyal | 9ae7777 | 2015-04-29 16:30:23 -0700 | [diff] [blame] | 249 | |
| 250 | final int[] coordinates = new int[2]; |
Sunny Goyal | efb7e84 | 2018-10-04 15:11:00 -0700 | [diff] [blame] | 251 | final int screenId = findSpaceOnWorkspace(item, coordinates); |
Sunny Goyal | 43bf11d | 2017-02-02 13:52:53 -0800 | [diff] [blame] | 252 | mLauncher.getModelWriter().moveItemInDatabase(info, |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 253 | Favorites.CONTAINER_DESKTOP, |
Sunny Goyal | 9ae7777 | 2015-04-29 16:30:23 -0700 | [diff] [blame] | 254 | screenId, coordinates[0], coordinates[1]); |
| 255 | |
| 256 | // Bind the item in next frame so that if a new workspace page was created, |
| 257 | // it will get laid out. |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 258 | new Handler().post(() -> { |
| 259 | mLauncher.bindItems(Collections.singletonList(item), true); |
| 260 | announceConfirmation(R.string.item_moved); |
Sunny Goyal | 9ae7777 | 2015-04-29 16:30:23 -0700 | [diff] [blame] | 261 | }); |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 262 | return true; |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 263 | } else if (action == RESIZE) { |
| 264 | final LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) item; |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 265 | List<OptionItem> actions = getSupportedResizeActions(host, info); |
| 266 | Rect pos = new Rect(); |
| 267 | mLauncher.getDragLayer().getDescendantRectRelativeToSelf(host, pos); |
Andy Wickham | 7d821d9 | 2021-04-01 16:04:44 -0700 | [diff] [blame] | 268 | ArrowPopup popup = OptionsPopupView.show(mLauncher, new RectF(pos), actions, false); |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 269 | popup.requestFocus(); |
| 270 | popup.setOnCloseCallback(host::requestFocus); |
Sunny Goyal | 3ffa64d | 2016-07-25 13:54:32 -0700 | [diff] [blame] | 271 | return true; |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 272 | } else if (action == DEEP_SHORTCUTS || action == SHORTCUTS_AND_NOTIFICATIONS) { |
Tony Wickham | 540913e | 2017-01-23 11:47:51 -0800 | [diff] [blame] | 273 | return PopupContainerWithArrow.showForIcon((BubbleTextView) host) != null; |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 274 | } else { |
| 275 | for (ButtonDropTarget dropTarget : mLauncher.getDropTargetBar().getDropTargets()) { |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 276 | if (dropTarget.supportsAccessibilityDrop(item, host) |
| 277 | && action == dropTarget.getAccessibilityAction()) { |
Sunny Goyal | 0236d0b | 2017-10-24 14:54:30 -0700 | [diff] [blame] | 278 | dropTarget.onAccessibilityDrop(host, item); |
| 279 | return true; |
| 280 | } |
| 281 | } |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 282 | } |
| 283 | return false; |
| 284 | } |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 285 | |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 286 | private List<OptionItem> getSupportedResizeActions(View host, LauncherAppWidgetInfo info) { |
| 287 | List<OptionItem> actions = new ArrayList<>(); |
Sunny Goyal | d3d8c95 | 2015-06-01 10:09:06 -0700 | [diff] [blame] | 288 | AppWidgetProviderInfo providerInfo = ((LauncherAppWidgetHostView) host).getAppWidgetInfo(); |
| 289 | if (providerInfo == null) { |
| 290 | return actions; |
| 291 | } |
| 292 | |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 293 | CellLayout layout = (CellLayout) host.getParent().getParent(); |
| 294 | if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0) { |
| 295 | if (layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY) || |
| 296 | layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY)) { |
Andy Wickham | 7d821d9 | 2021-04-01 16:04:44 -0700 | [diff] [blame] | 297 | actions.add(new OptionItem(mLauncher, |
| 298 | R.string.action_increase_width, |
| 299 | R.drawable.ic_widget_width_increase, |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 300 | IGNORE, |
| 301 | v -> performResizeAction(R.string.action_increase_width, host, info))); |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | if (info.spanX > info.minSpanX && info.spanX > 1) { |
Andy Wickham | 7d821d9 | 2021-04-01 16:04:44 -0700 | [diff] [blame] | 305 | actions.add(new OptionItem(mLauncher, |
| 306 | R.string.action_decrease_width, |
| 307 | R.drawable.ic_widget_width_decrease, |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 308 | IGNORE, |
| 309 | v -> performResizeAction(R.string.action_decrease_width, host, info))); |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 310 | } |
| 311 | } |
| 312 | |
| 313 | if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0) { |
| 314 | if (layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1) || |
| 315 | layout.isRegionVacant(info.cellX, info.cellY - 1, info.spanX, 1)) { |
Andy Wickham | 7d821d9 | 2021-04-01 16:04:44 -0700 | [diff] [blame] | 316 | actions.add(new OptionItem(mLauncher, |
| 317 | R.string.action_increase_height, |
| 318 | R.drawable.ic_widget_height_increase, |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 319 | IGNORE, |
| 320 | v -> performResizeAction(R.string.action_increase_height, host, info))); |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | if (info.spanY > info.minSpanY && info.spanY > 1) { |
Andy Wickham | 7d821d9 | 2021-04-01 16:04:44 -0700 | [diff] [blame] | 324 | actions.add(new OptionItem(mLauncher, |
| 325 | R.string.action_decrease_height, |
| 326 | R.drawable.ic_widget_height_decrease, |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 327 | IGNORE, |
| 328 | v -> performResizeAction(R.string.action_decrease_height, host, info))); |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 329 | } |
| 330 | } |
| 331 | return actions; |
| 332 | } |
| 333 | |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 334 | private boolean performResizeAction(int action, View host, LauncherAppWidgetInfo info) { |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 335 | CellLayout.LayoutParams lp = (CellLayout.LayoutParams) host.getLayoutParams(); |
| 336 | CellLayout layout = (CellLayout) host.getParent().getParent(); |
| 337 | layout.markCellsAsUnoccupiedForView(host); |
| 338 | |
| 339 | if (action == R.string.action_increase_width) { |
| 340 | if (((host.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) |
| 341 | && layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY)) |
| 342 | || !layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY)) { |
| 343 | lp.cellX --; |
| 344 | info.cellX --; |
| 345 | } |
| 346 | lp.cellHSpan ++; |
| 347 | info.spanX ++; |
| 348 | } else if (action == R.string.action_decrease_width) { |
| 349 | lp.cellHSpan --; |
| 350 | info.spanX --; |
| 351 | } else if (action == R.string.action_increase_height) { |
| 352 | if (!layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1)) { |
| 353 | lp.cellY --; |
| 354 | info.cellY --; |
| 355 | } |
| 356 | lp.cellVSpan ++; |
| 357 | info.spanY ++; |
| 358 | } else if (action == R.string.action_decrease_height) { |
| 359 | lp.cellVSpan --; |
| 360 | info.spanY --; |
| 361 | } |
| 362 | |
| 363 | layout.markCellsAsOccupiedForView(host); |
Pierre Barbier de Reuille | b2526fe | 2021-02-03 22:02:43 +0000 | [diff] [blame] | 364 | AppWidgetResizeFrame.updateWidgetSizeRanges(((LauncherAppWidgetHostView) host), mLauncher, |
| 365 | info.spanX, info.spanY); |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 366 | host.requestLayout(); |
Sunny Goyal | 43bf11d | 2017-02-02 13:52:53 -0800 | [diff] [blame] | 367 | mLauncher.getModelWriter().updateItemInDatabase(info); |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 368 | announceConfirmation(mLauncher.getString(R.string.widget_resized, info.spanX, info.spanY)); |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 369 | return true; |
Sunny Goyal | 9ca9c13 | 2015-04-29 14:57:22 -0700 | [diff] [blame] | 370 | } |
| 371 | |
Adam Cohen | 091440a | 2015-03-18 14:16:05 -0700 | [diff] [blame] | 372 | @Thunk void announceConfirmation(int resId) { |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 373 | announceConfirmation(mLauncher.getResources().getString(resId)); |
| 374 | } |
| 375 | |
Adam Cohen | 091440a | 2015-03-18 14:16:05 -0700 | [diff] [blame] | 376 | @Thunk void announceConfirmation(String confirmation) { |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 377 | mLauncher.getDragLayer().announceForAccessibility(confirmation); |
| 378 | |
| 379 | } |
| 380 | |
| 381 | public boolean isInAccessibleDrag() { |
| 382 | return mDragInfo != null; |
| 383 | } |
| 384 | |
| 385 | public DragInfo getDragInfo() { |
| 386 | return mDragInfo; |
| 387 | } |
| 388 | |
Sunny Goyal | 1a70cef | 2015-04-22 11:29:51 -0700 | [diff] [blame] | 389 | /** |
| 390 | * @param clickedTarget the actual view that was clicked |
| 391 | * @param dropLocation relative to {@param clickedTarget}. If provided, its center is used |
| 392 | * as the actual drop location otherwise the views center is used. |
| 393 | */ |
| 394 | public void handleAccessibleDrop(View clickedTarget, Rect dropLocation, |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 395 | String confirmation) { |
| 396 | if (!isInAccessibleDrag()) return; |
| 397 | |
| 398 | int[] loc = new int[2]; |
Sunny Goyal | 1a70cef | 2015-04-22 11:29:51 -0700 | [diff] [blame] | 399 | if (dropLocation == null) { |
| 400 | loc[0] = clickedTarget.getWidth() / 2; |
| 401 | loc[1] = clickedTarget.getHeight() / 2; |
| 402 | } else { |
| 403 | loc[0] = dropLocation.centerX(); |
| 404 | loc[1] = dropLocation.centerY(); |
| 405 | } |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 406 | |
Sunny Goyal | 1a70cef | 2015-04-22 11:29:51 -0700 | [diff] [blame] | 407 | mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(clickedTarget, loc); |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 408 | mLauncher.getDragController().completeAccessibleDrag(loc); |
| 409 | |
Sunny Goyal | 1a70cef | 2015-04-22 11:29:51 -0700 | [diff] [blame] | 410 | if (!TextUtils.isEmpty(confirmation)) { |
| 411 | announceConfirmation(confirmation); |
| 412 | } |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 413 | } |
| 414 | |
Sunny Goyal | a4647b6 | 2021-02-02 13:45:34 -0800 | [diff] [blame] | 415 | private boolean beginAccessibleDrag(View item, ItemInfo info, boolean fromKeyboard) { |
| 416 | if (!itemSupportsAccessibleDrag(info)) { |
| 417 | return false; |
| 418 | } |
| 419 | |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 420 | mDragInfo = new DragInfo(); |
| 421 | mDragInfo.info = info; |
| 422 | mDragInfo.item = item; |
| 423 | mDragInfo.dragType = DragType.ICON; |
| 424 | if (info instanceof FolderInfo) { |
| 425 | mDragInfo.dragType = DragType.FOLDER; |
| 426 | } else if (info instanceof LauncherAppWidgetInfo) { |
| 427 | mDragInfo.dragType = DragType.WIDGET; |
| 428 | } |
| 429 | |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 430 | Rect pos = new Rect(); |
| 431 | mLauncher.getDragLayer().getDescendantRectRelativeToSelf(item, pos); |
Sunny Goyal | 94b510c | 2016-08-16 15:36:48 -0700 | [diff] [blame] | 432 | mLauncher.getDragController().addDragListener(this); |
| 433 | |
| 434 | DragOptions options = new DragOptions(); |
| 435 | options.isAccessibleDrag = true; |
Sunny Goyal | a4647b6 | 2021-02-02 13:45:34 -0800 | [diff] [blame] | 436 | options.isKeyboardDrag = fromKeyboard; |
Sunny Goyal | 9b18010 | 2020-03-11 10:02:29 -0700 | [diff] [blame] | 437 | options.simulatedDndStartPoint = new Point(pos.centerX(), pos.centerY()); |
Sunny Goyal | a4647b6 | 2021-02-02 13:45:34 -0800 | [diff] [blame] | 438 | |
| 439 | if (fromKeyboard) { |
| 440 | KeyboardDragAndDropView popup = (KeyboardDragAndDropView) mLauncher.getLayoutInflater() |
| 441 | .inflate(R.layout.keyboard_drag_and_drop, mLauncher.getDragLayer(), false); |
| 442 | popup.showForIcon(item, info, options); |
| 443 | } else { |
| 444 | ItemLongClickListener.beginDrag(item, mLauncher, info, options); |
| 445 | } |
| 446 | return true; |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 447 | } |
| 448 | |
Sunny Goyal | 4547802 | 2015-06-08 16:52:41 -0700 | [diff] [blame] | 449 | @Override |
Sunny Goyal | 94b510c | 2016-08-16 15:36:48 -0700 | [diff] [blame] | 450 | public void onDragStart(DragObject dragObject, DragOptions options) { |
Sunny Goyal | 4547802 | 2015-06-08 16:52:41 -0700 | [diff] [blame] | 451 | // No-op |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 452 | } |
| 453 | |
Sunny Goyal | 4547802 | 2015-06-08 16:52:41 -0700 | [diff] [blame] | 454 | @Override |
| 455 | public void onDragEnd() { |
| 456 | mLauncher.getDragController().removeDragListener(this); |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 457 | mDragInfo = null; |
Adam Cohen | c9735cf | 2015-01-23 16:11:55 -0800 | [diff] [blame] | 458 | } |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 459 | |
| 460 | /** |
| 461 | * Find empty space on the workspace and returns the screenId. |
| 462 | */ |
Sunny Goyal | efb7e84 | 2018-10-04 15:11:00 -0700 | [diff] [blame] | 463 | protected int findSpaceOnWorkspace(ItemInfo info, int[] outCoordinates) { |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 464 | Workspace workspace = mLauncher.getWorkspace(); |
Sunny Goyal | efb7e84 | 2018-10-04 15:11:00 -0700 | [diff] [blame] | 465 | IntArray workspaceScreens = workspace.getScreenOrder(); |
| 466 | int screenId; |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 467 | |
| 468 | // First check if there is space on the current screen. |
| 469 | int screenIndex = workspace.getCurrentPage(); |
| 470 | screenId = workspaceScreens.get(screenIndex); |
| 471 | CellLayout layout = (CellLayout) workspace.getPageAt(screenIndex); |
| 472 | |
| 473 | boolean found = layout.findCellForSpan(outCoordinates, info.spanX, info.spanY); |
Sunny Goyal | 7ce471b | 2017-08-02 03:37:39 -0700 | [diff] [blame] | 474 | screenIndex = 0; |
Sunny Goyal | a911672 | 2015-04-29 13:55:58 -0700 | [diff] [blame] | 475 | while (!found && screenIndex < workspaceScreens.size()) { |
| 476 | screenId = workspaceScreens.get(screenIndex); |
| 477 | layout = (CellLayout) workspace.getPageAt(screenIndex); |
| 478 | found = layout.findCellForSpan(outCoordinates, info.spanX, info.spanY); |
| 479 | screenIndex++; |
| 480 | } |
| 481 | |
| 482 | if (found) { |
| 483 | return screenId; |
| 484 | } |
| 485 | |
| 486 | workspace.addExtraEmptyScreen(); |
| 487 | screenId = workspace.commitExtraEmptyScreen(); |
| 488 | layout = workspace.getScreenWithId(screenId); |
| 489 | found = layout.findCellForSpan(outCoordinates, info.spanX, info.spanY); |
| 490 | |
| 491 | if (!found) { |
| 492 | Log.wtf(TAG, "Not enough space on an empty screen"); |
| 493 | } |
| 494 | return screenId; |
| 495 | } |
Samuel Fufa | 6eaf989 | 2020-04-01 11:40:40 -0700 | [diff] [blame] | 496 | |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 497 | public class LauncherAction { |
| 498 | public final int keyCode; |
| 499 | public final AccessibilityAction accessibilityAction; |
| 500 | |
| 501 | private final LauncherAccessibilityDelegate mDelegate; |
| 502 | |
| 503 | public LauncherAction(int id, int labelRes, int keyCode) { |
| 504 | this.keyCode = keyCode; |
| 505 | accessibilityAction = new AccessibilityAction(id, mLauncher.getString(labelRes)); |
| 506 | mDelegate = LauncherAccessibilityDelegate.this; |
| 507 | } |
Samuel Fufa | 6eaf989 | 2020-04-01 11:40:40 -0700 | [diff] [blame] | 508 | |
| 509 | /** |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 510 | * Invokes the action for the provided host |
Samuel Fufa | 6eaf989 | 2020-04-01 11:40:40 -0700 | [diff] [blame] | 511 | */ |
Sunny Goyal | 384b578 | 2021-02-09 22:50:02 -0800 | [diff] [blame] | 512 | public boolean invokeFromKeyboard(View host) { |
| 513 | if (host != null && host.getTag() instanceof ItemInfo) { |
| 514 | return mDelegate.performAction( |
| 515 | host, (ItemInfo) host.getTag(), accessibilityAction.getId(), true); |
| 516 | } else { |
| 517 | return false; |
| 518 | } |
| 519 | } |
Samuel Fufa | 6eaf989 | 2020-04-01 11:40:40 -0700 | [diff] [blame] | 520 | } |
Sunny Goyal | 71b5c0b | 2015-01-08 16:59:04 -0800 | [diff] [blame] | 521 | } |