From edc6fb4061c1e2dfdf80ef055ff18a25db3e77ab Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 22 Mar 2018 10:45:46 -0700 Subject: [PATCH] Clearing the touch state on ACTON_UP/ACTIUON_CANCEL The touch listener may not get ACTION_DOWN if it came through an intercept, in which case it will continue to use the previous state. Clearing the state ensures that the next touch is not affected. Bug: 76152745 Change-Id: I18cfbac67aa373e935822003e746af9def6d9122 --- .../launcher3/touch/WorkspaceTouchListener.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java index df11686b2c..2f9cf3aab6 100644 --- a/src/com/android/launcher3/touch/WorkspaceTouchListener.java +++ b/src/com/android/launcher3/touch/WorkspaceTouchListener.java @@ -102,23 +102,30 @@ public class WorkspaceTouchListener implements OnTouchListener, Runnable { // Inform the workspace to cancel touch handling ev.setAction(ACTION_CANCEL); mWorkspace.onTouchEvent(ev); + ev.setAction(action); mLongPressState = STATE_COMPLETED; } + final boolean result; if (mLongPressState == STATE_COMPLETED) { // We have handled the touch, so workspace does not need to know anything anymore. - return true; + result = true; } else if (mLongPressState == STATE_REQUESTED) { mWorkspace.onTouchEvent(ev); - if (action == ACTION_UP || action == ACTION_CANCEL || mWorkspace.isHandlingTouch()) { + if (mWorkspace.isHandlingTouch()) { cancelLongPress(); } - return true; + + result = true; } else { // We don't want to handle touch, let workspace handle it as usual. - return false; + result = false; } + if (action == ACTION_UP || action == ACTION_CANCEL) { + cancelLongPress(); + } + return result; } private void cancelLongPress() {