From d303a0262785c2d1da3bb7ab354cdbddcd19f5d4 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Fri, 8 Apr 2022 21:09:06 +0000 Subject: [PATCH] Fix bubble position with IME when the bubble has a custom height Usually bubbles are full height, but it is possible for a bubble to have a smaller height. In this case the pointer didn't align correctly when the IME came up. This change makes it so that the expanded view will translate up a bit with the bubble (only when the view isn't full height and has space to translate), which keeps it aligned with the pointer. This is a bit of a nicer experience because the IME doesn't overlap as much of the app as it would before. Test: manual - have a bubble that has a small height, focus the IME => verify the pointer follows the bubble Bug: 223906486 Change-Id: I1542f06887ccc8370a762fc6ebe42aca26559cb4 --- .../com/android/wm/shell/bubbles/BubbleExpandedView.java | 9 +++++++++ .../com/android/wm/shell/bubbles/BubbleStackView.java | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java index 7af8cfafe7495..a2b35fc9211ae 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java @@ -112,6 +112,7 @@ public class BubbleExpandedView extends LinearLayout { private ShapeDrawable mRightPointer; private float mCornerRadius = 0f; private int mBackgroundColorFloating; + private boolean mUsingMaxHeight; @Nullable private Bubble mBubble; private PendingIntent mPendingIntent; @@ -621,6 +622,13 @@ public class BubbleExpandedView extends LinearLayout { return prevWasIntentBased != newIsIntentBased; } + /** + * Whether the bubble is using all available height to display or not. + */ + public boolean isUsingMaxHeight() { + return mUsingMaxHeight; + } + void updateHeight() { if (mExpandedViewContainerLocation == null) { return; @@ -632,6 +640,7 @@ public class BubbleExpandedView extends LinearLayout { float height = desiredHeight == MAX_HEIGHT ? maxHeight : Math.min(desiredHeight, maxHeight); + mUsingMaxHeight = height == maxHeight; FrameLayout.LayoutParams lp = mIsOverflow ? (FrameLayout.LayoutParams) mOverflowView.getLayoutParams() : (FrameLayout.LayoutParams) mTaskView.getLayoutParams(); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index a5998666b3f00..f60b6599e3505 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -2355,7 +2355,14 @@ public class BubbleStackView extends FrameLayout } } else if (mPositioner.showBubblesVertically() && mIsExpanded && mExpandedBubble != null && mExpandedBubble.getExpandedView() != null) { + float selectedY = mPositioner.getExpandedBubbleXY(getState().selectedIndex, + getState()).y; + float newExpandedViewTop = mPositioner.getExpandedViewY(mExpandedBubble, selectedY); mExpandedBubble.getExpandedView().setImeVisible(visible); + if (!mExpandedBubble.getExpandedView().isUsingMaxHeight()) { + mExpandedViewContainer.animate().translationY(newExpandedViewTop); + } + List animList = new ArrayList(); for (int i = 0; i < mBubbleContainer.getChildCount(); i++) { View child = mBubbleContainer.getChildAt(i);