From 0764d9e8f3a4efca9465a1a4044e2478c7396497 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 25 Jun 2020 20:21:47 -0700 Subject: [PATCH] Fix a couple minor but visible issues - b/156431985 was not completely fixed -- when the PIP was below the shelf offset, opening the ime (ie. on the homescreen) would not push the PIP above the ime. The logic to check if the PIP was incorrect and should only be checking in each direction if the current bounds is above or below the area to be offset from - the fix for b/156431985 (ag/11453136) calls setAllowTouches to reset the touch state after the fling settles, but if the user touches and tries to grab the PIP while it is settling, the subsequent call to reset will prevent that new touch gesture from working. Instead we can just reset the touch state on up after we calculated everything we need for the fling Change-Id: I0b3265780035bf6c7d7b74bf05a5ed07564740c6 Bug: 159959599 Test: Move pip above the auto shift region, show ime then go home and ensure it never moves the PIP (also landscape) Test: Move pip into the shelf region, show ime then go home and ensure it shifts to show the ime and then goes back (also landscape) Test: Move pip above the auto shift region, show ime then move the PIP above the ime, go home and ensure it shifts the pip down (also landscape) Test: Fling the pip from the bottom of the screen to the top and try to grab it just as it settles, ensure that this works --- .../systemui/pip/phone/PipTouchHandler.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) 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 a4d7bad2891f2..79f99f459ace9 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java @@ -480,6 +480,8 @@ public class PipTouchHandler { mSnapAlgorithm.getMovementBounds(curBounds, insetBounds, toMovementBounds, mIsImeShowing ? mImeHeight : 0); final int prevBottom = mMovementBounds.bottom - mMovementBoundsExtraOffsets; + // This is to handle landscape fullscreen IMEs, don't apply the extra offset in this + // case final int toBottom = toMovementBounds.bottom < toMovementBounds.top ? toMovementBounds.bottom : toMovementBounds.bottom - extraOffset; @@ -490,10 +492,16 @@ public class PipTouchHandler { mSavedSnapFraction); } - if ((Math.min(prevBottom, toBottom) - mBottomOffsetBufferPx) <= curBounds.top - && curBounds.top <= (Math.max(prevBottom, toBottom) - + mBottomOffsetBufferPx)) { - mMotionHelper.animateToOffset(curBounds, toBottom - curBounds.top); + if (prevBottom < toBottom) { + // The movement bounds are expanding + if (curBounds.top > prevBottom - mBottomOffsetBufferPx) { + mMotionHelper.animateToOffset(curBounds, toBottom - curBounds.top); + } + } else if (prevBottom > toBottom) { + // The movement bounds are shrinking + if (curBounds.top > toBottom - mBottomOffsetBufferPx) { + mMotionHelper.animateToOffset(curBounds, toBottom - curBounds.top); + } } } } @@ -971,6 +979,8 @@ public class PipTouchHandler { } mShouldHideMenuAfterFling = mMenuState == MENU_STATE_NONE; + // Reset the touch state on up before the fling settles + mTouchState.reset(); mMotionHelper.flingToSnapTarget(vel.x, vel.y, PipTouchHandler.this::updateDismissFraction /* updateAction */, this::flingEndAction /* endAction */); @@ -997,7 +1007,6 @@ public class PipTouchHandler { } private void flingEndAction() { - mTouchState.setAllowTouches(true); if (mShouldHideMenuAfterFling) { // If the menu is not visible, then we can still be showing the activity for the // dismiss overlay, so just finish it after the animation completes