From 68fc44ffadb80bb6bb5c3432092dcc5536cd5f54 Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Fri, 23 Sep 2022 17:50:07 -0500 Subject: [PATCH] Prevent double touch inputs in the BaseDragLayer If you hold a long press and while pressing you start another long press again with another finger, then a new onLongPress event will trigger and in some cases we are not processing that case. By ignoring the evetns with the flag ACTION_OUTSIDE we can prevent such cases. Fix: 247477725 Test: ReorderWidgets Change-Id: I31833bc54db2771809562bd1f92c8523eb2f05ab --- src/com/android/launcher3/views/BaseDragLayer.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index 800b1f6ad7..1e154a2dfb 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -273,6 +273,12 @@ public abstract class BaseDragLayer @Override public boolean dispatchTouchEvent(MotionEvent ev) { + if (ev.getActionIndex() > 0) { + // This means there is multiple touch inputs, ignore it, we could also cancel the + // previous touch but the user might cancel the drag by accident. + return true; + } + switch (ev.getAction()) { case ACTION_DOWN: { if ((mTouchDispatchState & TOUCH_DISPATCHING_TO_VIEW_IN_PROGRESS) != 0) {