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

Commit e7a25c27 authored by Winson Chung's avatar Winson Chung
Browse files

Minor touch changes for resizing

- Pilfer whenever we cross the threshold in either axis (otherwise
  the app under pip will continue to receive touch events while
  it is resizing)
- Only resize once you pass the threshold, otherwise a sloppy tap
  would trigger an unexpected micro-resize
- Handle cancel when triggering notification from launcher (when
  pip starts pilfering touches and sends a cancel to launcher, it
  should not continue to treat that as an up event and trigger
  notifications to show)

Change-Id: Id31d12484f7ecd55a8e48073979c1886764a9648
Bug: 158887398
Test: Resize PIP, try resizing over home with a swipe down
parent a4c3cd42
Loading
Loading
Loading
Loading
+19 −14
Original line number Original line Diff line number Diff line
@@ -260,12 +260,14 @@ public class PipResizeGestureHandler {


    private void onMotionEvent(MotionEvent ev) {
    private void onMotionEvent(MotionEvent ev) {
        int action = ev.getActionMasked();
        int action = ev.getActionMasked();
        float x = ev.getX();
        float y = ev.getY();
        if (action == MotionEvent.ACTION_DOWN) {
        if (action == MotionEvent.ACTION_DOWN) {
            mLastResizeBounds.setEmpty();
            mLastResizeBounds.setEmpty();
            mAllowGesture = isWithinTouchRegion((int) ev.getX(), (int) ev.getY());
            mAllowGesture = isWithinTouchRegion((int) x, (int) y);
            if (mAllowGesture) {
            if (mAllowGesture) {
                setCtrlType((int) ev.getX(), (int) ev.getY());
                setCtrlType((int) x, (int) y);
                mDownPoint.set(ev.getX(), ev.getY());
                mDownPoint.set(x, y);
                mLastDownBounds.set(mMotionHelper.getBounds());
                mLastDownBounds.set(mMotionHelper.getBounds());
            }
            }


@@ -277,20 +279,23 @@ public class PipResizeGestureHandler {
                    break;
                    break;
                case MotionEvent.ACTION_MOVE:
                case MotionEvent.ACTION_MOVE:
                    // Capture inputs
                    // Capture inputs
                    float dx = Math.abs(ev.getX() - mDownPoint.x);
                    if (!mThresholdCrossed
                    float dy = Math.abs(ev.getY() - mDownPoint.y);
                            && Math.hypot(x - mDownPoint.x, y - mDownPoint.y) > mTouchSlop) {
                    if (!mThresholdCrossed && dx > mTouchSlop && dy > mTouchSlop) {
                        mThresholdCrossed = true;
                        mThresholdCrossed = true;
                        // Reset the down to begin resizing from this point
                        mDownPoint.set(x, y);
                        mInputMonitor.pilferPointers();
                        mInputMonitor.pilferPointers();
                    }
                    }
                    if (mThresholdCrossed) {
                        final Rect currentPipBounds = mMotionHelper.getBounds();
                        final Rect currentPipBounds = mMotionHelper.getBounds();
                    mLastResizeBounds.set(TaskResizingAlgorithm.resizeDrag(ev.getX(), ev.getY(),
                        mLastResizeBounds.set(TaskResizingAlgorithm.resizeDrag(x, y,
                                mDownPoint.x, mDownPoint.y, currentPipBounds, mCtrlType, mMinSize.x,
                                mDownPoint.x, mDownPoint.y, currentPipBounds, mCtrlType, mMinSize.x,
                                mMinSize.y, mMaxSize, true,
                                mMinSize.y, mMaxSize, true,
                                mLastDownBounds.width() > mLastDownBounds.height()));
                                mLastDownBounds.width() > mLastDownBounds.height()));
                        mPipBoundsHandler.transformBoundsToAspectRatio(mLastResizeBounds);
                        mPipBoundsHandler.transformBoundsToAspectRatio(mLastResizeBounds);
                        mPipTaskOrganizer.scheduleUserResizePip(mLastDownBounds, mLastResizeBounds,
                        mPipTaskOrganizer.scheduleUserResizePip(mLastDownBounds, mLastResizeBounds,
                                null);
                                null);
                    }
                    break;
                    break;
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL:
                case MotionEvent.ACTION_CANCEL:
+5 −2
Original line number Original line Diff line number Diff line
@@ -200,11 +200,13 @@ public class OverviewProxyService extends CurrentUserTracker implements
                            mInputFocusTransferStartY = event.getY();
                            mInputFocusTransferStartY = event.getY();
                            mInputFocusTransferStartMillis = event.getEventTime();
                            mInputFocusTransferStartMillis = event.getEventTime();
                            statusBar.onInputFocusTransfer(
                            statusBar.onInputFocusTransfer(
                                    mInputFocusTransferStarted, 0 /* velocity */);
                                    mInputFocusTransferStarted, false /* cancel */,
                                    0 /* velocity */);
                        }
                        }
                        if (action == ACTION_UP || action == ACTION_CANCEL) {
                        if (action == ACTION_UP || action == ACTION_CANCEL) {
                            mInputFocusTransferStarted = false;
                            mInputFocusTransferStarted = false;
                            statusBar.onInputFocusTransfer(mInputFocusTransferStarted,
                            statusBar.onInputFocusTransfer(mInputFocusTransferStarted,
                                    action == ACTION_CANCEL,
                                    (event.getY() - mInputFocusTransferStartY)
                                    (event.getY() - mInputFocusTransferStartY)
                                    / (event.getEventTime() - mInputFocusTransferStartMillis));
                                    / (event.getEventTime() - mInputFocusTransferStartMillis));
                        }
                        }
@@ -692,7 +694,8 @@ public class OverviewProxyService extends CurrentUserTracker implements
            mHandler.post(()-> {
            mHandler.post(()-> {
                mStatusBarOptionalLazy.ifPresent(statusBarLazy -> {
                mStatusBarOptionalLazy.ifPresent(statusBarLazy -> {
                    mInputFocusTransferStarted = false;
                    mInputFocusTransferStarted = false;
                    statusBarLazy.get().onInputFocusTransfer(false, 0 /* velocity */);
                    statusBarLazy.get().onInputFocusTransfer(false, true /* cancel */,
                            0 /* velocity */);
                });
                });
            });
            });
        }
        }
+7 −3
Original line number Original line Diff line number Diff line
@@ -1328,11 +1328,15 @@ public class NotificationPanelViewController extends PanelViewController {
     *
     *
     * @param velocity unit is in px / millis
     * @param velocity unit is in px / millis
     */
     */
    public void stopWaitingForOpenPanelGesture(final float velocity) {
    public void stopWaitingForOpenPanelGesture(boolean cancel, final float velocity) {
        if (mExpectingSynthesizedDown) {
        if (mExpectingSynthesizedDown) {
            mExpectingSynthesizedDown = false;
            mExpectingSynthesizedDown = false;
            if (cancel) {
                collapse(false /* delayed */, 1.0f /* speedUpFactor */);
            } else {
                maybeVibrateOnOpening();
                maybeVibrateOnOpening();
                fling(velocity > 1f ? 1000f * velocity : 0, true /* expand */);
                fling(velocity > 1f ? 1000f * velocity : 0, true /* expand */);
            }
            onTrackingStopped(false);
            onTrackingStopped(false);
        }
        }
    }
    }
+2 −2
Original line number Original line Diff line number Diff line
@@ -2090,7 +2090,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    /**
    /**
     * Called when another window is about to transfer it's input focus.
     * Called when another window is about to transfer it's input focus.
     */
     */
    public void onInputFocusTransfer(boolean start, float velocity) {
    public void onInputFocusTransfer(boolean start, boolean cancel, float velocity) {
        if (!mCommandQueue.panelsEnabled()) {
        if (!mCommandQueue.panelsEnabled()) {
            return;
            return;
        }
        }
@@ -2098,7 +2098,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        if (start) {
        if (start) {
            mNotificationPanelViewController.startWaitingForOpenPanelGesture();
            mNotificationPanelViewController.startWaitingForOpenPanelGesture();
        } else {
        } else {
            mNotificationPanelViewController.stopWaitingForOpenPanelGesture(velocity);
            mNotificationPanelViewController.stopWaitingForOpenPanelGesture(cancel, velocity);
        }
        }
    }
    }