Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt +56 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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), Loading Loading @@ -204,6 +208,58 @@ class BubblePositionerTest { assertThat(positioner.hasUserModifiedDefaultPosition()).isTrue() } @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 = Loading libs/WindowManager/Shell/res/values/dimen.xml +2 −0 Original line number Diff line number Diff line Loading @@ -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. --> Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +38 −6 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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; Loading Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt +56 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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), Loading Loading @@ -204,6 +208,58 @@ class BubblePositionerTest { assertThat(positioner.hasUserModifiedDefaultPosition()).isTrue() } @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 = Loading
libs/WindowManager/Shell/res/values/dimen.xml +2 −0 Original line number Diff line number Diff line Loading @@ -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. --> Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +38 −6 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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; Loading