Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edc6fb40 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

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
parent 25a54729
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -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() {