From 50ee3ce879762696d03bab67a15ce6a0f254efd9 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Tue, 22 Mar 2022 18:49:18 +0000 Subject: [PATCH] Fix an issue where stack education and the stack weren't aligned On rotation the stack position is updated using the relative stack position based on the last resting position. This doesn't work well with the user education which relies on the stack being in the "default" position & updating to the relative position clobbers this. This change updates it so that: 1 - when the stack user education is shown it always updates the stack to be in the default position 2 - if stack user education is showing, don't set the stack position Bug: 223635730 Test: manual - rotate device with stack user education showing and make sure the stack is aligned with the education view Change-Id: I232227aed29ceef060883ed60ed02563093a9bbb --- .../wm/shell/bubbles/BubbleStackView.java | 16 +++++++++++----- .../wm/shell/bubbles/StackEducationView.kt | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) 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 58f79f3600def..62c6a814c028f 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 @@ -899,7 +899,7 @@ public class BubbleStackView extends FrameLayout mStackAnimationController.updateResources(); mBubbleOverflow.updateResources(); - if (mRelativeStackPositionBeforeRotation != null) { + if (!isStackEduShowing() && mRelativeStackPositionBeforeRotation != null) { mStackAnimationController.setStackPosition( mRelativeStackPositionBeforeRotation); mRelativeStackPositionBeforeRotation = null; @@ -1193,6 +1193,8 @@ public class BubbleStackView extends FrameLayout addView(mStackEduView); } mBubbleContainer.bringToFront(); + // Ensure the stack is in the correct spot + mStackAnimationController.setStackPosition(mPositioner.getDefaultStartPosition()); return mStackEduView.show(mPositioner.getDefaultStartPosition()); } @@ -1207,6 +1209,8 @@ public class BubbleStackView extends FrameLayout mStackEduView = new StackEducationView(mContext, mPositioner, mBubbleController); addView(mStackEduView); mBubbleContainer.bringToFront(); // Stack appears on top of the stack education + // Ensure the stack is in the correct spot + mStackAnimationController.setStackPosition(mPositioner.getDefaultStartPosition()); mStackEduView.show(mPositioner.getDefaultStartPosition()); } if (mManageEduView != null && mManageEduView.getVisibility() == VISIBLE) { @@ -1324,10 +1328,12 @@ public class BubbleStackView extends FrameLayout mStackAnimationController.updateResources(); mDismissView.updateResources(); mMagneticTarget.setMagneticFieldRadiusPx(mBubbleSize * 2); - mStackAnimationController.setStackPosition( - new RelativeStackPosition( - mPositioner.getRestingPosition(), - mStackAnimationController.getAllowableStackPositionRegion())); + if (!isStackEduShowing()) { + mStackAnimationController.setStackPosition( + new RelativeStackPosition( + mPositioner.getRestingPosition(), + mStackAnimationController.getAllowableStackPositionRegion())); + } if (mIsExpanded) { updateExpandedView(); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt index 824b5f82d6430..1ff4be887fb28 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/StackEducationView.kt @@ -122,7 +122,7 @@ class StackEducationView constructor( * If necessary, shows the user education view for the bubble stack. This appears the first * time a user taps on a bubble. * - * @return true if user education was shown, false otherwise. + * @return true if user education was shown and wasn't showing before, false otherwise. */ fun show(stackPosition: PointF): Boolean { isHiding = false