diff options
| author | 2017-07-21 00:09:46 +0000 | |
|---|---|---|
| committer | 2017-07-21 00:09:46 +0000 | |
| commit | 82bc67193db74bd26ebaface958655a9c7f0dc61 (patch) | |
| tree | d4928c5a307efa4883ae15d2b5f88b8b84f26c63 | |
| parent | f4292bacf95a273f73d2a190f2d3a6d8fdaeadd2 (diff) | |
| parent | a363ab9d6fee50f4d96445f4b5cb26bca1206d08 (diff) | |
Merge "Apply static offset to PiP IME adjustment." into oc-dr1-dev
am: a363ab9d6f
Change-Id: I05701052c0eeaef4453f044039f8fe7af2a63a2a
| -rw-r--r-- | packages/SystemUI/res/values/dimens.xml | 3 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java | 24 |
2 files changed, 19 insertions, 8 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index fcbe3e99e033..94687de68704 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -784,6 +784,9 @@ <!-- The shortest-edge size of the expanded PiP. --> <dimen name="pip_expanded_shortest_edge_size">160dp</dimen> + <!-- The additional offset to apply to the IME animation to account for the input field. --> + <dimen name="pip_ime_offset">48dp</dimen> + <!-- The padding between actions in the PiP in landscape Note that the PiP does not reflect the configuration of the device, so we can't use -land resources. --> <dimen name="pip_between_action_padding_land">8dp</dimen> 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 278fdc3a6ded..d3be19d3df87 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java @@ -27,6 +27,7 @@ import android.animation.ValueAnimator.AnimatorUpdateListener; import android.app.IActivityManager; import android.content.ComponentName; import android.content.Context; +import android.content.res.Resources; import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; @@ -122,6 +123,7 @@ public class PipTouchHandler { private boolean mIsMinimized; private boolean mIsImeShowing; private int mImeHeight; + private int mImeOffset; private float mSavedSnapFraction = -1f; private boolean mSendingHoverAccessibilityEvents; private boolean mMovementWithinMinimize; @@ -192,8 +194,11 @@ public class PipTouchHandler { }; mMotionHelper = new PipMotionHelper(mContext, mActivityManager, mMenuController, mSnapAlgorithm, mFlingAnimationUtils); - mExpandedShortestEdgeSize = context.getResources().getDimensionPixelSize( + + Resources res = context.getResources(); + mExpandedShortestEdgeSize = res.getDimensionPixelSize( R.dimen.pip_expanded_shortest_edge_size); + mImeOffset = res.getDimensionPixelSize(R.dimen.pip_ime_offset); // Register the listener for input consumer touch events inputConsumerController.setTouchListener(this::handleTouchEvent); @@ -265,7 +270,6 @@ public class PipTouchHandler { mSnapAlgorithm.getMovementBounds(mExpandedBounds, insetBounds, expandedMovementBounds, mIsImeShowing ? mImeHeight : 0); - // If this is from an IME adjustment, then we should move the PiP so that it is not occluded // by the IME if (fromImeAdjustement) { @@ -278,18 +282,22 @@ public class PipTouchHandler { ? expandedMovementBounds : normalMovementBounds; if (mIsImeShowing) { - // IME visible + // IME visible, apply the IME offset if the space allows for it + final int imeOffset = toMovementBounds.bottom - Math.max(toMovementBounds.top, + toMovementBounds.bottom - mImeOffset); if (bounds.top == mMovementBounds.bottom) { // If the PIP is currently resting on top of the IME, then adjust it with - // the hiding IME - bounds.offsetTo(bounds.left, toMovementBounds.bottom); + // the showing IME + bounds.offsetTo(bounds.left, toMovementBounds.bottom - imeOffset); } else { - bounds.offset(0, Math.min(0, toMovementBounds.bottom - bounds.top)); + bounds.offset(0, Math.min(0, toMovementBounds.bottom - imeOffset + - bounds.top)); } } else { // IME hidden - if (bounds.top == mMovementBounds.bottom) { - // If the PIP is resting on top of the IME, then adjust it with the hiding IME + if (bounds.top >= (mMovementBounds.bottom - mImeOffset)) { + // If the PIP is resting on top of the IME, then adjust it with the hiding + // IME bounds.offsetTo(bounds.left, toMovementBounds.bottom); } } |