summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mykola Podolian <mpodolian@google.com> 2024-04-10 18:30:27 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-04-10 18:30:27 +0000
commit944383b470ce1e140c07184914eaff402ebaf680 (patch)
tree5aded28e7562af7d310406f96852394ca5624577
parent59c66ae43bac618ef8054d3b3ba784c1e8f83a21 (diff)
parent8b628d4532dc71b93c9f44c127cb861af91f8627 (diff)
Merge "Update bubble bar expanded view sizes" into main
-rw-r--r--libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt56
-rw-r--r--libs/WindowManager/Shell/res/values/dimen.xml2
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java44
3 files changed, 96 insertions, 6 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 e73d8802f0b2..8487e3792993 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
@@ -18,6 +18,7 @@ package com.android.wm.shell.bubbles
import android.content.Context
import android.content.Intent
import android.content.pm.ShortcutInfo
+import android.content.res.Resources
import android.graphics.Insets
import android.graphics.PointF
import android.graphics.Rect
@@ -43,6 +44,9 @@ class BubblePositionerTest {
private lateinit var positioner: BubblePositioner
private val context = ApplicationProvider.getApplicationContext<Context>()
+ private val resources: Resources
+ get() = context.resources
+
private val defaultDeviceConfig =
DeviceConfig(
windowBounds = Rect(0, 0, 1000, 2000),
@@ -205,6 +209,58 @@ class BubblePositionerTest {
}
@Test
+ fun testBubbleBarExpandedViewHeightAndWidth() {
+ val deviceConfig =
+ defaultDeviceConfig.copy(
+ // portrait orientation
+ isLandscape = false,
+ isLargeScreen = true,
+ insets = Insets.of(10, 20, 5, 15),
+ windowBounds = Rect(0, 0, 1800, 2600)
+ )
+ val bubbleBarBounds = Rect(1700, 2500, 1780, 2600)
+
+ positioner.setShowingInBubbleBar(true)
+ positioner.update(deviceConfig)
+ positioner.bubbleBarBounds = bubbleBarBounds
+
+ val spaceBetweenTopInsetAndBubbleBarInLandscape = 1680
+ val expandedViewVerticalSpacing =
+ resources.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding)
+ val expectedHeight =
+ spaceBetweenTopInsetAndBubbleBarInLandscape - 2 * expandedViewVerticalSpacing
+ val expectedWidth = resources.getDimensionPixelSize(R.dimen.bubble_bar_expanded_view_width)
+
+ assertThat(positioner.getExpandedViewWidthForBubbleBar(false)).isEqualTo(expectedWidth)
+ assertThat(positioner.getExpandedViewHeightForBubbleBar(false)).isEqualTo(expectedHeight)
+ }
+
+ @Test
+ fun testBubbleBarExpandedViewHeightAndWidth_screenWidthTooSmall() {
+ val screenWidth = 300
+ val deviceConfig =
+ defaultDeviceConfig.copy(
+ // portrait orientation
+ isLandscape = false,
+ isLargeScreen = true,
+ insets = Insets.of(10, 20, 5, 15),
+ windowBounds = Rect(0, 0, screenWidth, 2600)
+ )
+ val bubbleBarBounds = Rect(100, 2500, 280, 2550)
+ positioner.setShowingInBubbleBar(true)
+ positioner.update(deviceConfig)
+ positioner.bubbleBarBounds = bubbleBarBounds
+
+ val spaceBetweenTopInsetAndBubbleBarInLandscape = 180
+ val expandedViewSpacing =
+ resources.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding)
+ val expectedHeight = spaceBetweenTopInsetAndBubbleBarInLandscape - 2 * expandedViewSpacing
+ val expectedWidth = screenWidth - 15 /* horizontal insets */ - 2 * expandedViewSpacing
+ assertThat(positioner.getExpandedViewWidthForBubbleBar(false)).isEqualTo(expectedWidth)
+ assertThat(positioner.getExpandedViewHeightForBubbleBar(false)).isEqualTo(expectedHeight)
+ }
+
+ @Test
fun testGetExpandedViewHeight_max() {
val deviceConfig =
defaultDeviceConfig.copy(
diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml
index 6d5bf6233366..4ee2c1a1da60 100644
--- a/libs/WindowManager/Shell/res/values/dimen.xml
+++ b/libs/WindowManager/Shell/res/values/dimen.xml
@@ -254,6 +254,8 @@
<dimen name="bubble_bar_expanded_view_caption_dot_size">4dp</dimen>
<!-- The spacing between the dots for the caption menu in the bubble bar expanded view.. -->
<dimen name="bubble_bar_expanded_view_caption_dot_spacing">4dp</dimen>
+ <!-- Width of the expanded bubble bar view shown when the bubble is expanded. -->
+ <dimen name="bubble_bar_expanded_view_width">412dp</dimen>
<!-- Minimum width of the bubble bar manage menu. -->
<dimen name="bubble_bar_manage_menu_min_width">200dp</dimen>
<!-- Size of the dismiss icon in the bubble bar manage menu. -->
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 4d5e516f76e5..14c3a0701c83 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
@@ -149,9 +149,10 @@ public class BubblePositioner {
mStackOffset = res.getDimensionPixelSize(R.dimen.bubble_stack_offset);
if (mShowingInBubbleBar) {
- mExpandedViewLargeScreenWidth = isLandscape()
- ? (int) (bounds.width() * EXPANDED_VIEW_BUBBLE_BAR_LANDSCAPE_WIDTH_PERCENT)
- : (int) (bounds.width() * EXPANDED_VIEW_BUBBLE_BAR_PORTRAIT_WIDTH_PERCENT);
+ mExpandedViewLargeScreenWidth = Math.min(
+ res.getDimensionPixelSize(R.dimen.bubble_bar_expanded_view_width),
+ mPositionRect.width() - 2 * mExpandedViewPadding
+ );
} else if (mDeviceConfig.isSmallTablet()) {
mExpandedViewLargeScreenWidth = (int) (bounds.width()
* EXPANDED_VIEW_SMALL_TABLET_WIDTH_PERCENT);
@@ -839,11 +840,42 @@ public class BubblePositioner {
* How tall the expanded view should be when showing from the bubble bar.
*/
public int getExpandedViewHeightForBubbleBar(boolean isOverflow) {
- return isOverflow
- ? mOverflowHeight
- : getExpandedViewBottomForBubbleBar() - mInsets.top - mExpandedViewPadding;
+ if (isOverflow) {
+ return mOverflowHeight;
+ } else {
+ return getBubbleBarExpandedViewHeightForLandscape();
+ }
}
+ /**
+ * Calculate the height of expanded view in landscape mode regardless current orientation.
+ * Here is an explanation:
+ * ------------------------ mScreenRect.top
+ * | top inset ↕ |
+ * |-----------------------
+ * | 16dp spacing ↕ |
+ * | --------- | --- expanded view top
+ * | | | | ↑
+ * | | | | ↓ expanded view height
+ * | --------- | --- expanded view bottom
+ * | 16dp spacing ↕ | ↑
+ * | @bubble bar@ | | height of the bubble bar container
+ * ------------------------ | already includes bottom inset and spacing
+ * | bottom inset ↕ | ↓
+ * |----------------------| --- mScreenRect.bottom
+ */
+ private int getBubbleBarExpandedViewHeightForLandscape() {
+ int heightOfBubbleBarContainer =
+ mScreenRect.height() - getExpandedViewBottomForBubbleBar();
+ // getting landscape height from screen rect
+ int expandedViewHeight = Math.min(mScreenRect.width(), mScreenRect.height());
+ expandedViewHeight -= heightOfBubbleBarContainer; /* removing bubble container height */
+ expandedViewHeight -= mInsets.top; /* removing top inset */
+ expandedViewHeight -= mExpandedViewPadding; /* removing spacing */
+ return expandedViewHeight;
+ }
+
+
/** The bottom position of the expanded view when showing above the bubble bar. */
public int getExpandedViewBottomForBubbleBar() {
return mBubbleBarBounds.top - mExpandedViewPadding;