From 4ed31efe0020faeafb062c2b1f86477cfe5e7180 Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Mon, 31 Aug 2020 12:11:59 -0700 Subject: [PATCH] PiP: Hide menu when resize starts. Attempting to do resize while PIP menu is still visible causes weird isseus such as jank and flickering, so just hide it. This usually always happen already when user taps the outside bounds, but if the user starts from the inside corners it's problematic. Bug: 164882662 Test: Tap on PIP, see it expands and PIP menu shows up, try to resize - no more flickering Merged-In: If32aacc7e8d8f6784ad7fb83be14a8ba93c3491f Change-Id: I68b42195fa70d3f61fb42cb33297152a4da963fc --- .../systemui/pip/phone/PipResizeGestureHandler.java | 12 +++++++++--- .../android/systemui/pip/phone/PipTouchHandler.java | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java index ef73aa7cbbfe7..badd8835cdd4b 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java @@ -80,6 +80,7 @@ public class PipResizeGestureHandler { private final Context mContext; private final PipBoundsHandler mPipBoundsHandler; private final PipMotionHelper mMotionHelper; + private final PipMenuActivityController mMenuController; private final int mDisplayId; private final Executor mMainExecutor; private final SysUiState mSysUiState; @@ -117,13 +118,14 @@ public class PipResizeGestureHandler { public PipResizeGestureHandler(Context context, PipBoundsHandler pipBoundsHandler, PipMotionHelper motionHelper, DeviceConfigProxy deviceConfig, - PipTaskOrganizer pipTaskOrganizer, Function movementBoundsSupplier, - Runnable updateMovementBoundsRunnable, SysUiState sysUiState, - PipUiEventLogger pipUiEventLogger) { + PipTaskOrganizer pipTaskOrganizer, PipMenuActivityController pipMenuController, + Function movementBoundsSupplier, Runnable updateMovementBoundsRunnable, + SysUiState sysUiState, PipUiEventLogger pipUiEventLogger) { mContext = context; mDisplayId = context.getDisplayId(); mMainExecutor = context.getMainExecutor(); mPipBoundsHandler = pipBoundsHandler; + mMenuController = pipMenuController; mMotionHelper = motionHelper; mPipTaskOrganizer = pipTaskOrganizer; mMovementBoundsSupplier = movementBoundsSupplier; @@ -322,6 +324,10 @@ public class PipResizeGestureHandler { mInputMonitor.pilferPointers(); } if (mThresholdCrossed) { + if (mMenuController.isMenuActivityVisible()) { + mMenuController.hideMenuWithoutResize(); + mMenuController.hideMenu(); + } final Rect currentPipBounds = mMotionHelper.getBounds(); mLastResizeBounds.set(TaskResizingAlgorithm.resizeDrag(x, y, mDownPoint.x, mDownPoint.y, currentPipBounds, mCtrlType, mMinSize.x, diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java index 0127ff310b782..11e609b2ffefd 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java @@ -232,7 +232,7 @@ public class PipTouchHandler { mSnapAlgorithm, floatingContentCoordinator); mPipResizeGestureHandler = new PipResizeGestureHandler(context, pipBoundsHandler, mMotionHelper, - deviceConfig, pipTaskOrganizer, this::getMovementBounds, + deviceConfig, pipTaskOrganizer, menuController, this::getMovementBounds, this::updateMovementBounds, sysUiState, pipUiEventLogger); mTouchState = new PipTouchState(ViewConfiguration.get(context), mHandler, () -> mMenuController.showMenuWithDelay(MENU_STATE_FULL, mMotionHelper.getBounds(),