From 4ff301eb9d4e67e68f076f25249a1e4b83211ac6 Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Fri, 18 Nov 2022 22:00:33 +0000 Subject: [PATCH] Do not start drag from pre-drag if cancelled during animation. This change affects the preDragCondition for icons that do not have a popup menu. The condition assumes we are still in pre-drag after DragView is finished animating, but the user can cancel the drag in this time (e.g. by releasing their finger early). Test: Manual. Holding and releasing on suspended icon does not crash, while holding and dragging still works as expected. Fix: 258233476 Change-Id: Ic76f785cffcbfe0fe51eb1473022f2dc34563070 --- .../android/launcher3/taskbar/TaskbarDragController.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java index 3045eca052..9d084e79d4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java @@ -207,8 +207,13 @@ public class TaskbarDragController extends DragController im if (FeatureFlags.ENABLE_TASKBAR_POPUP_MENU.get() && !shouldStartDrag(0)) { - // Immediately close the popup menu. - mDragView.setOnAnimationEndCallback(() -> callOnDragStart()); + mDragView.setOnAnimationEndCallback(() -> { + // Drag might be cancelled during the DragView animation, so check + // mIsPreDrag again. + if (mIsInPreDrag) { + callOnDragStart(); + } + }); } }