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

Commit 45cc6e8c authored by Winson Chung's avatar Winson Chung Committed by android-build-merger
Browse files

Fixing issue with lingering dismiss PiP overlay.

am: b54b65b0

Change-Id: Iedc5f922b8e4db9cec6fc9f2b28e59846682df2c
parents 880433d5 b54b65b0
Loading
Loading
Loading
Loading
+33 −17
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ public class PipTouchHandler implements TunerService.Tunable {
        if (mIsMinimized) {
            setMinimizedStateInternal(false);
        }
        mDismissViewController.destroyDismissTarget();
        cleanUpDismissTarget();
        mShowPipMenuOnAnimationEnd = true;
    }

@@ -334,6 +334,12 @@ public class PipTouchHandler implements TunerService.Tunable {
        mAccessibilityManager.setPictureInPictureActionReplacingConnection(isRegistered
                ? new PipAccessibilityInteractionConnection(mMotionHelper,
                        this::onAccessibilityShowMenu, mHandler) : null);

        if (!isRegistered && mTouchState.isUserInteracting()) {
            // If the input consumer is unregistered while the user is interacting, then we may not
            // get the final TOUCH_UP event, so clean up the dismiss target as well
            cleanUpDismissTarget();
        }
    }

    private void onAccessibilityShowMenu() {
@@ -578,12 +584,12 @@ public class PipTouchHandler implements TunerService.Tunable {

            if (touchState.startedDragging()) {
                mSavedSnapFraction = -1f;
            }

            if (touchState.startedDragging() && ENABLE_DISMISS_DRAG_TO_EDGE) {
                if (ENABLE_DISMISS_DRAG_TO_EDGE) {
                    mHandler.removeCallbacks(mShowDismissAffordance);
                    mDismissViewController.showDismissTarget();
                }
            }

            if (touchState.isDragging()) {
                // Move the pinned stack freely
@@ -625,6 +631,12 @@ public class PipTouchHandler implements TunerService.Tunable {

        @Override
        public boolean onUp(PipTouchState touchState) {
            if (ENABLE_DISMISS_DRAG_TO_EDGE) {
                // Clean up the dismiss target regardless of the touch state in case the touch
                // enabled state changes while the user is interacting
                cleanUpDismissTarget();
            }

            if (!touchState.isUserInteracting()) {
                return false;
            }
@@ -640,8 +652,7 @@ public class PipTouchHandler implements TunerService.Tunable {
            final boolean isFlingToBot = isFling && vel.y > 0 && !isHorizontal
                    && (mMovementWithinDismiss || isUpWithinDimiss);
            if (ENABLE_DISMISS_DRAG_TO_EDGE) {
                try {
                    mHandler.removeCallbacks(mShowDismissAffordance);
                // Check if the user dragged or flung the PiP offscreen to dismiss it
                if (mMotionHelper.shouldDismissPip() || isFlingToBot) {
                    mMotionHelper.animateDismiss(mMotionHelper.getBounds(), vel.x,
                        vel.y, mUpdateScrimListener);
@@ -650,9 +661,6 @@ public class PipTouchHandler implements TunerService.Tunable {
                            METRIC_VALUE_DISMISSED_BY_DRAG);
                    return true;
                }
                } finally {
                    mDismissViewController.destroyDismissTarget();
                }
            }

            if (touchState.isDragging()) {
@@ -728,6 +736,14 @@ public class PipTouchHandler implements TunerService.Tunable {
                : mNormalMovementBounds;
    }

    /**
     * Removes the dismiss target and cancels any pending callbacks to show it.
     */
    private void cleanUpDismissTarget() {
        mHandler.removeCallbacks(mShowDismissAffordance);
        mDismissViewController.destroyDismissTarget();
    }

    public void dump(PrintWriter pw, String prefix) {
        final String innerPrefix = prefix + "  ";
        pw.println(prefix + TAG);