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 ae5300502993a7cd99e630289c19959dce9810a9..725f87d93e4e1544929f5b356304bc51d79176c1 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); } } @@ -403,15 +415,6 @@ public class PhonePipMenuController implements PipMenuController { } } - /** - * Preemptively mark the menu as invisible, used when we are directly manipulating the pinned - * stack and don't want to trigger a resize which can animate the stack in a conflicting way - * (ie. when manually expanding or dismissing). - */ - public void hideMenuWithoutResize() { - onMenuStateChanged(MENU_STATE_NONE, false /* resize */, null /* callback */); - } - /** * Sets the menu actions to the actions provided by the current PiP menu. */ 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 962c4672644a754157099fd7ac6b3e2e6bc6f5fa..1cf3a48e957553a2f2bc03e51802885c4e2cab09 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/PipMotionHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java index b19dcae2def8c8eb5de9259be62002d0f72289e7..4bcd76fdf4e64ad5320e2d8019a814542d9a838f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java @@ -325,7 +325,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, + " callers=\n" + Debug.getCallers(5, " ")); } cancelPhysicsAnimation(); - mMenuController.hideMenuWithoutResize(); + mMenuController.hideMenu(false /* animate */, false /* resize */); mPipTaskOrganizer.exitPip(skipAnimation ? 0 : LEAVE_PIP_DURATION); } @@ -338,7 +338,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, Log.d(TAG, "removePip: callers=\n" + Debug.getCallers(5, " ")); } cancelPhysicsAnimation(); - mMenuController.hideMenuWithoutResize(); + mMenuController.hideMenu(true /* animate*/, false /* resize */); mPipTaskOrganizer.removePip(); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java index 1ef9ffa494f4537562e28579a0a189ecbc1f6ae8..6740ce3a3bdfc9046fc4a93fd5dad8b1835edc9e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java @@ -516,8 +516,8 @@ public class PipResizeGestureHandler { } if (mThresholdCrossed) { if (mPhonePipMenuController.isMenuVisible()) { - mPhonePipMenuController.hideMenuWithoutResize(); - mPhonePipMenuController.hideMenu(); + mPhonePipMenuController.hideMenu(false /* animate */, + false /* resize */); } final Rect currentPipBounds = mPipBoundsState.getBounds(); mLastResizeBounds.set(TaskResizingAlgorithm.resizeDrag(x, y, 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 e69c6f2f47bcc28110b8105612575c20fa47860f..fa2abf40e88fd2e0ac5f04f4cf55d75b237191aa 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);