summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mady Mellor <madym@google.com> 2024-02-12 18:22:40 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-02-12 18:22:40 +0000
commite01abc47176cc7789caf460b14abe713e94e1893 (patch)
treeca2c0c6c1b20998ce2aec6359a7de89c3cc1c827
parent23e028aad78c2aadb3ff0cb3c7edd03e9e4be58e (diff)
parent3ac5d4e8066c88d437a188b1b02f20f7c2c7c97d (diff)
Merge "Fix bubbles being on the wrong side after fold -> unfold" into main
-rw-r--r--libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt19
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java13
2 files changed, 32 insertions, 0 deletions
diff --git a/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt b/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt
index ea7c6edd4b56..5825bbfbfefa 100644
--- a/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt
+++ b/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt
@@ -165,6 +165,25 @@ class BubblePositionerTest {
}
@Test
+ fun testGetRestingPosition_afterBoundsChange() {
+ positioner.update(defaultDeviceConfig.copy(isLargeScreen = true,
+ windowBounds = Rect(0, 0, 2000, 1600)))
+
+ // Set the resting position to the right side
+ var allowableStackRegion = positioner.getAllowableStackPositionRegion(1 /* bubbleCount */)
+ val restingPosition = PointF(allowableStackRegion.right, allowableStackRegion.centerY())
+ positioner.restingPosition = restingPosition
+
+ // Now make the device smaller
+ positioner.update(defaultDeviceConfig.copy(isLargeScreen = false,
+ windowBounds = Rect(0, 0, 1000, 1600)))
+
+ // Check the resting position is on the correct side
+ allowableStackRegion = positioner.getAllowableStackPositionRegion(1 /* bubbleCount */)
+ assertThat(positioner.restingPosition.x).isEqualTo(allowableStackRegion.right)
+ }
+
+ @Test
fun testHasUserModifiedDefaultPosition_false() {
positioner.update(defaultDeviceConfig.copy(isLargeScreen = true, isRtl = true))
assertThat(positioner.hasUserModifiedDefaultPosition()).isFalse()
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 c03b6f805cf7..cda29c95281d 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
@@ -120,6 +120,13 @@ public class BubblePositioner {
@VisibleForTesting
public void updateInternal(int rotation, Insets insets, Rect bounds) {
+ BubbleStackView.RelativeStackPosition prevStackPosition = null;
+ if (mRestingStackPosition != null && mScreenRect != null && !mScreenRect.equals(bounds)) {
+ // Save the resting position as a relative position with the previous bounds, at the
+ // end of the update we'll restore it based on the new bounds.
+ prevStackPosition = new BubbleStackView.RelativeStackPosition(getRestingPosition(),
+ getAllowableStackPositionRegion(1));
+ }
mRotation = rotation;
mInsets = insets;
@@ -182,6 +189,12 @@ public class BubblePositioner {
R.dimen.bubbles_flyout_min_width_large_screen);
mMaxBubbles = calculateMaxBubbles();
+
+ if (prevStackPosition != null) {
+ // Get the new resting position based on the updated values
+ mRestingStackPosition = prevStackPosition.getAbsolutePositionInRegion(
+ getAllowableStackPositionRegion(1));
+ }
}
/**