From 3e99b90ab183a8a7399431df0b3ec3be9ed2ff76 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 31 Mar 2021 13:21:01 -0700 Subject: [PATCH] More minor menu changes - Don't wait for double tap timeout when clicking to unstash (you can't double tap while stashed to expand) - Hide the menu when stashing so that it doesn't show again when unstashed - Only log unstash if previously stashed Bug: 183756396 Test: Tap to show unstashed pip/stash with menu showing Change-Id: I693b67d38f32d28636ff6b5d0aaf096af78b825b --- .../wm/shell/pip/phone/PipTouchHandler.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java index 287f68f397ca5..d474b6638e4a0 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java @@ -782,7 +782,6 @@ public class PipTouchHandler { private final Point mStartPosition = new Point(); private final PointF mDelta = new PointF(); private boolean mShouldHideMenuAfterFling; - private float mDownSavedFraction = -1f; @Override public void onDown(PipTouchState touchState) { @@ -796,7 +795,6 @@ public class PipTouchHandler { mMovementWithinDismiss = touchState.getDownTouchPosition().y >= mPipBoundsState.getMovementBounds().bottom; mMotionHelper.setSpringingToTouch(false); - mDownSavedFraction = mPipBoundsAlgorithm.getSnapFraction(mPipBoundsState.getBounds()); // If the menu is still visible then just poke the menu // so that it will timeout after the user stops touching it @@ -867,9 +865,12 @@ public class PipTouchHandler { if (mEnableStash && shouldStash(vel, getPossiblyMotionBounds())) { mMotionHelper.stashToEdge(vel.x, vel.y, this::stashEndAction /* endAction */); } else { - mPipUiEventLogger.log( - PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_STASH_UNSTASHED); - mPipBoundsState.setStashed(STASH_TYPE_NONE); + if (mPipBoundsState.isStashed()) { + // Reset stashed state if previously stashed + mPipUiEventLogger.log( + PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_STASH_UNSTASHED); + mPipBoundsState.setStashed(STASH_TYPE_NONE); + } mMotionHelper.flingToSnapTarget(vel.x, vel.y, this::flingEndAction /* endAction */); } @@ -896,19 +897,19 @@ public class PipTouchHandler { mMotionHelper.expandLeavePip(); } } else if (mMenuState != MENU_STATE_FULL) { - if (!mTouchState.isWaitingForDoubleTap()) { - if (mPipBoundsState.isStashed()) { - animateToUnStashedState(); - mPipUiEventLogger.log( - PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_STASH_UNSTASHED); - mPipBoundsState.setStashed(STASH_TYPE_NONE); - } else { - // User has stalled long enough for this not to be a drag or a double tap, - // just expand the menu - mMenuController.showMenu(MENU_STATE_FULL, mPipBoundsState.getBounds(), - true /* allowMenuTimeout */, willResizeMenu(), - shouldShowResizeHandle()); - } + if (mPipBoundsState.isStashed()) { + // Unstash immediately if stashed, and don't wait for the double tap timeout + animateToUnStashedState(); + mPipUiEventLogger.log( + PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_STASH_UNSTASHED); + mPipBoundsState.setStashed(STASH_TYPE_NONE); + mTouchState.removeDoubleTapTimeoutCallback(); + } else if (!mTouchState.isWaitingForDoubleTap()) { + // User has stalled long enough for this not to be a drag or a double tap, + // just expand the menu + mMenuController.showMenu(MENU_STATE_FULL, mPipBoundsState.getBounds(), + true /* allowMenuTimeout */, willResizeMenu(), + shouldShowResizeHandle()); } else { // Next touch event _may_ be the second tap for the double-tap, schedule a // fallback runnable to trigger the menu if no touch event occurs before the @@ -916,7 +917,6 @@ public class PipTouchHandler { mTouchState.scheduleDoubleTapTimeoutCallback(); } } - mDownSavedFraction = -1f; return true; } @@ -932,6 +932,7 @@ public class PipTouchHandler { PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_STASH_RIGHT); mPipBoundsState.setStashed(STASH_TYPE_RIGHT); } + mMenuController.hideMenu(); } private void flingEndAction() {