From 732b1d46c5ea85f3b2ee860fbfba5a197e7be1b0 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Thu, 30 Jan 2020 10:46:52 -0800 Subject: [PATCH] Fix a couple issues related to drag and drop in Touch Exploration mode => The framework no longer sends touch events after double-click and hold, and instead only triggers a single long-press event => As a result of the above, there is some additional state that must be set for accessible drag and drop, and further, we no longer initiate a drag in response to long press when Touch Exploration is on. Test: manual issue b/148308758 Change-Id: I26ab90b807965f31c8de93d451130410169f2fb0 --- src/com/android/launcher3/LauncherRootView.java | 1 - .../LauncherAccessibilityDelegate.java | 17 +++++++++++++---- .../launcher3/dragndrop/DragController.java | 4 +++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java index ce1795aa11..2b2224a600 100644 --- a/src/com/android/launcher3/LauncherRootView.java +++ b/src/com/android/launcher3/LauncherRootView.java @@ -8,7 +8,6 @@ import android.app.ActivityManager; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; -import android.graphics.Insets; import android.graphics.Paint; import android.graphics.Rect; import android.os.Build; diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java index a7ef9ef2a8..ed869bb09a 100644 --- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java +++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java @@ -166,13 +166,22 @@ 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(); + if (action == ACTION_LONG_CLICK) { + if (ShortcutUtil.isDeepShortcut(item)) { + CustomActionsPopup popup = new CustomActionsPopup(mLauncher, host); + if (popup.canShow()) { + popup.show(); + return true; + } + } else if (host instanceof BubbleTextView) { + // Long press should be consumed for workspace items, and it should invoke the + // Shortcuts / Notifications / Actions pop-up menu, and not start a drag as the + // standard long press path does. + PopupContainerWithArrow.showForIcon((BubbleTextView) host); return true; } } + if (action == MOVE) { beginAccessibleDrag(host, item); } else if (action == ADD_TO_WORKSPACE) { diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index 54a44eed30..1b7b01575e 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -565,11 +565,13 @@ public class DragController implements DragDriver.EventListener, TouchController /** * Since accessible drag and drop won't cause the same sequence of touch events, we manually - * inject the appropriate state. + * inject the appropriate state which would have been otherwise initiated via touch events. */ public void prepareAccessibleDrag(int x, int y) { mMotionDownX = x; mMotionDownY = y; + mLastTouch[0] = x; + mLastTouch[1] = y; } /**