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

Commit 406c0872 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Ensure workspace is still in a valid state when handling long press."...

Merge "Ensure workspace is still in a valid state when handling long press." into ub-launcher3-edmonton
parents e6e77ca4 ce2c6ebd
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -71,8 +71,7 @@ public class WorkspaceTouchListener implements OnTouchListener, Runnable {
        int action = ev.getActionMasked();
        if (action == ACTION_DOWN) {
            // Check if we can handle long press.
            boolean handleLongPress = AbstractFloatingView.getTopOpenView(mLauncher) == null
                    && mLauncher.isInState(NORMAL);
            boolean handleLongPress = canHandleLongPress();

            if (handleLongPress) {
                // Check if the event is not near the edges
@@ -128,6 +127,11 @@ public class WorkspaceTouchListener implements OnTouchListener, Runnable {
        return result;
    }

    private boolean canHandleLongPress() {
        return AbstractFloatingView.getTopOpenView(mLauncher) == null
                && mLauncher.isInState(NORMAL);
    }

    private void cancelLongPress() {
        mWorkspace.removeCallbacks(this);
        mLongPressState = STATE_CANCELLED;
@@ -136,6 +140,7 @@ public class WorkspaceTouchListener implements OnTouchListener, Runnable {
    @Override
    public void run() {
        if (mLongPressState == STATE_REQUESTED) {
            if (canHandleLongPress()) {
                mLongPressState = STATE_PENDING_PARENT_INFORM;
                mWorkspace.getParent().requestDisallowInterceptTouchEvent(true);

@@ -145,6 +150,9 @@ public class WorkspaceTouchListener implements OnTouchListener, Runnable {
                        Action.Direction.NONE, ContainerType.WORKSPACE,
                        mWorkspace.getCurrentPage());
                OptionsPopupView.showDefaultOptions(mLauncher, mTouchDownPoint.x, mTouchDownPoint.y);
            } else {
                cancelLongPress();
            }
        }
    }
}