From edad8e7fe0ec2bba51105dd9bc4777e93b0ced63 Mon Sep 17 00:00:00 2001 From: "jorgegil@google.com" Date: Thu, 11 Feb 2021 13:54:01 -0800 Subject: [PATCH] Hide the PIP menu on double tap to resize Bug: 178391622 Test: enter PIP, tap once to show menu, tap twice to resize - verify the menu is hidden immediately before the window is resized Change-Id: Ic6d973e38377d55524ff8e2224969d57698a7495 --- .../pip/phone/PhonePipMenuController.java | 16 ++++++++++++++-- .../wm/shell/pip/phone/PipMenuView.java | 18 ++++++++++++------ .../wm/shell/pip/phone/PipTouchHandler.java | 3 +++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java index ae5300502993a..a1eeca1f93e3e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java @@ -375,17 +375,29 @@ public class PhonePipMenuController implements PipMenuController { } /** - * Hides the menu activity. + * Hides the menu view. */ public void hideMenu() { + hideMenu(true /* animate */, true /* resize */); + } + + /** + * Hides the menu view. + * + * @param animate whether to animate the menu fadeout + * @param resize whether or not to resize the PiP with the state change + */ + public void hideMenu(boolean animate, boolean resize) { final boolean isMenuVisible = isMenuVisible(); if (DEBUG) { Log.d(TAG, "hideMenu() state=" + mMenuState + " isMenuVisible=" + isMenuVisible + + " animate=" + animate + + " resize=" + resize + " callers=\n" + Debug.getCallers(5, " ")); } if (isMenuVisible) { - mPipMenuView.hideMenu(); + mPipMenuView.hideMenu(animate, resize); } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java index 962c4672644a7..1cf3a48e95755 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java @@ -89,7 +89,6 @@ public class PipMenuView extends FrameLayout { private static final boolean ENABLE_RESIZE_HANDLE = false; private int mMenuState; - private boolean mResize = true; private boolean mAllowMenuTimeout = true; private boolean mAllowTouches = true; @@ -329,16 +328,21 @@ public class PipMenuView extends FrameLayout { hideMenu(null); } + void hideMenu(boolean animate, boolean resize) { + hideMenu(null, true /* notifyMenuVisibility */, animate, resize); + } + void hideMenu(Runnable animationEndCallback) { - hideMenu(animationEndCallback, true /* notifyMenuVisibility */, true /* animate */); + hideMenu(animationEndCallback, true /* notifyMenuVisibility */, true /* animate */, + true /* resize */); } private void hideMenu(final Runnable animationFinishedRunnable, boolean notifyMenuVisibility, - boolean animate) { + boolean animate, boolean resize) { if (mMenuState != MENU_STATE_NONE) { cancelDelayedHide(); if (notifyMenuVisibility) { - notifyMenuStateChange(MENU_STATE_NONE, mResize, null); + notifyMenuStateChange(MENU_STATE_NONE, resize, null); } mMenuContainerAnimator = new AnimatorSet(); ObjectAnimator menuAnim = ObjectAnimator.ofFloat(mMenuContainer, View.ALPHA, @@ -469,7 +473,8 @@ public class PipMenuView extends FrameLayout { private void expandPip() { // Do not notify menu visibility when hiding the menu, the controller will do this when it // handles the message - hideMenu(mController::onPipExpand, false /* notifyMenuVisibility */, true /* animate */); + hideMenu(mController::onPipExpand, false /* notifyMenuVisibility */, true /* animate */, + true /* resize */); } private void dismissPip() { @@ -479,7 +484,8 @@ public class PipMenuView extends FrameLayout { final boolean animate = mMenuState != MENU_STATE_CLOSE; // Do not notify menu visibility when hiding the menu, the controller will do this when it // handles the message - hideMenu(mController::onPipDismiss, false /* notifyMenuVisibility */, animate); + hideMenu(mController::onPipDismiss, false /* notifyMenuVisibility */, animate, + true /* resize */); } private void showSettings() { 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 e69c6f2f47bcc..fa2abf40e88fd 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 @@ -876,6 +876,9 @@ public class PipTouchHandler { < mPipBoundsState.getMaxSize().x && mPipBoundsState.getBounds().height() < mPipBoundsState.getMaxSize().y; + if (mMenuController.isMenuVisible()) { + mMenuController.hideMenu(false /* animate */, false /* resize */); + } if (toExpand) { mPipResizeGestureHandler.setUserResizeBounds(mPipBoundsState.getBounds()); animateToMaximizedState(null);