From 81bd659c441335eba001a5f9bd5ba371d48869a2 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Thu, 14 Apr 2022 21:29:22 +0000 Subject: [PATCH] Fix bubble expanded view jumping to the left when switching bubbles When the bubbles are shown vertically on the left side of the screen and you tapped between them, the view would be misaligned for a bit during the animation. This was happening because the padding being applied to the view didn't account for the space the pointer triangle took up. The fix is to add the size of the pointer to the padding when showing vertically on the left side. Bug: 196444014 Test: manual - expand a bubble on a large screen on the left side - tap between the bubble and the overflow or other bubbles => observe that the expanded view doesn't jump a bit to the left manual - test switching between bubbles on phone, phone landscape (left & right sides), and tablet on the right side => observe that the animation looks correct Change-Id: Icb3cd87843504ab31da8005fb72f36daae387d39 --- .../src/com/android/wm/shell/bubbles/BubblePositioner.java | 7 ++++++- .../src/com/android/wm/shell/bubbles/BubbleStackView.java | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java index 6eb8d8aec417f..7cfacbcc92f8b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java @@ -329,6 +329,11 @@ public class BubblePositioner { : mBubbleSize; } + /** Size of the visible (non-overlapping) part of the pointer. */ + public int getPointerSize() { + return mPointerHeight - mPointerOverlap; + } + /** The maximum number of bubbles that can be displayed comfortably on screen. */ public int getMaxBubbles() { return mMaxBubbles; @@ -367,7 +372,7 @@ public class BubblePositioner { * padding is added. */ public int[] getExpandedViewContainerPadding(boolean onLeft, boolean isOverflow) { - final int pointerTotalHeight = mPointerHeight - mPointerOverlap; + final int pointerTotalHeight = getPointerSize(); final int expandedViewLargeScreenInsetFurthestEdge = getExpandedViewLargeScreenInsetFurthestEdge(isOverflow); if (mIsLargeScreen) { 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 322c0bf808162..cb88203349fa9 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 @@ -2887,7 +2887,10 @@ public class BubbleStackView extends FrameLayout PhysicsAnimator.getInstance(mAnimatingOutSurfaceContainer).cancel(); mAnimatingOutSurfaceContainer.setScaleX(1f); mAnimatingOutSurfaceContainer.setScaleY(1f); - mAnimatingOutSurfaceContainer.setTranslationX(mExpandedViewContainer.getPaddingLeft()); + final float translationX = mPositioner.showBubblesVertically() && mStackOnLeftOrWillBe + ? mExpandedViewContainer.getPaddingLeft() + mPositioner.getPointerSize() + : mExpandedViewContainer.getPaddingLeft(); + mAnimatingOutSurfaceContainer.setTranslationX(translationX); mAnimatingOutSurfaceContainer.setTranslationY(0); final int[] taskViewLocation =