diff options
| -rw-r--r-- | libs/WindowManager/Shell/res/values/dimen.xml | 3 | ||||
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java | 73 |
2 files changed, 59 insertions, 17 deletions
diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index 8a8231d00195..3852c69b4325 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -129,6 +129,9 @@ <dimen name="bubble_dismiss_encircle_size">52dp</dimen> <!-- Padding around the view displayed when the bubble is expanded --> <dimen name="bubble_expanded_view_padding">16dp</dimen> + <!-- Padding for the edge of the expanded view that is closest to the edge of the screen used + when displaying in landscape on a large screen. --> + <dimen name="bubble_expanded_view_largescreen_landscape_padding">128dp</dimen> <!-- This should be at least the size of bubble_expanded_view_padding; it is used to include a slight touch slop around the expanded view. --> <dimen name="bubble_expanded_view_slop">8dp</dimen> 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 75b19fb03e73..bc0db3635e35 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 @@ -67,7 +67,11 @@ public class BubblePositioner { /** The max percent of screen width to use for the flyout on phone. */ public static final float FLYOUT_MAX_WIDTH_PERCENT = 0.6f; /** The percent of screen width that should be used for the expanded view on a large screen. **/ - public static final float EXPANDED_VIEW_LARGE_SCREEN_WIDTH_PERCENT = 0.72f; + private static final float EXPANDED_VIEW_LARGE_SCREEN_LANDSCAPE_WIDTH_PERCENT = 0.48f; + /** The percent of screen width that should be used for the expanded view on a large screen. **/ + private static final float EXPANDED_VIEW_LARGE_SCREEN_PORTRAIT_WIDTH_PERCENT = 0.70f; + /** The percent of screen width that should be used for the expanded view on a small tablet. **/ + private static final float EXPANDED_VIEW_SMALL_TABLET_WIDTH_PERCENT = 0.72f; private Context mContext; private WindowManager mWindowManager; @@ -77,6 +81,7 @@ public class BubblePositioner { private boolean mImeVisible; private int mImeHeight; private boolean mIsLargeScreen; + private boolean mIsSmallTablet; private Rect mPositionRect; private int mDefaultMaxBubbles; @@ -86,7 +91,8 @@ public class BubblePositioner { private int mExpandedViewMinHeight; private int mExpandedViewLargeScreenWidth; - private int mExpandedViewLargeScreenInset; + private int mExpandedViewLargeScreenInsetClosestEdge; + private int mExpandedViewLargeScreenInsetFurthestEdge; private int mOverflowWidth; private int mExpandedViewPadding; @@ -127,17 +133,26 @@ public class BubblePositioner { | WindowInsets.Type.statusBars() | WindowInsets.Type.displayCutout()); - mIsLargeScreen = mContext.getResources().getConfiguration().smallestScreenWidthDp >= 600; + final Rect bounds = windowMetrics.getBounds(); + Configuration config = mContext.getResources().getConfiguration(); + mIsLargeScreen = config.smallestScreenWidthDp >= 600; + if (mIsLargeScreen) { + float largestEdgeDp = Math.max(config.screenWidthDp, config.screenHeightDp); + mIsSmallTablet = largestEdgeDp < 960; + } else { + mIsSmallTablet = false; + } if (BubbleDebugConfig.DEBUG_POSITIONER) { Log.w(TAG, "update positioner:" + " rotation: " + mRotation + " insets: " + insets + " isLargeScreen: " + mIsLargeScreen - + " bounds: " + windowMetrics.getBounds() + + " isSmallTablet: " + mIsSmallTablet + + " bounds: " + bounds + " showingInTaskbar: " + mShowingInTaskbar); } - updateInternal(mRotation, insets, windowMetrics.getBounds()); + updateInternal(mRotation, insets, bounds); } /** @@ -172,11 +187,31 @@ public class BubblePositioner { mSpacingBetweenBubbles = res.getDimensionPixelSize(R.dimen.bubble_spacing); mDefaultMaxBubbles = res.getInteger(R.integer.bubbles_max_rendered); mExpandedViewPadding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding); - mExpandedViewLargeScreenWidth = (int) (bounds.width() - * EXPANDED_VIEW_LARGE_SCREEN_WIDTH_PERCENT); - mExpandedViewLargeScreenInset = mIsLargeScreen - ? (bounds.width() - mExpandedViewLargeScreenWidth) / 2 - : mExpandedViewPadding; + if (mIsSmallTablet) { + mExpandedViewLargeScreenWidth = (int) (bounds.width() + * EXPANDED_VIEW_SMALL_TABLET_WIDTH_PERCENT); + } else { + mExpandedViewLargeScreenWidth = isLandscape() + ? (int) (bounds.width() * EXPANDED_VIEW_LARGE_SCREEN_LANDSCAPE_WIDTH_PERCENT) + : (int) (bounds.width() * EXPANDED_VIEW_LARGE_SCREEN_PORTRAIT_WIDTH_PERCENT); + } + if (mIsLargeScreen) { + if (isLandscape() && !mIsSmallTablet) { + mExpandedViewLargeScreenInsetClosestEdge = res.getDimensionPixelSize( + R.dimen.bubble_expanded_view_largescreen_landscape_padding); + mExpandedViewLargeScreenInsetFurthestEdge = bounds.width() + - mExpandedViewLargeScreenInsetClosestEdge + - mExpandedViewLargeScreenWidth; + } else { + final int centeredInset = (bounds.width() - mExpandedViewLargeScreenWidth) / 2; + mExpandedViewLargeScreenInsetClosestEdge = centeredInset; + mExpandedViewLargeScreenInsetFurthestEdge = centeredInset; + } + } else { + mExpandedViewLargeScreenInsetClosestEdge = mExpandedViewPadding; + mExpandedViewLargeScreenInsetFurthestEdge = mExpandedViewPadding; + } + mOverflowWidth = mIsLargeScreen ? mExpandedViewLargeScreenWidth : res.getDimensionPixelSize( @@ -328,15 +363,18 @@ public class BubblePositioner { public int[] getExpandedViewContainerPadding(boolean onLeft, boolean isOverflow) { final int pointerTotalHeight = mPointerHeight - mPointerOverlap; if (mIsLargeScreen) { + // Note: + // If we're in portrait OR if we're a small tablet, then the two insets values will + // be equal. If we're landscape and a large tablet, the two values will be different. // [left, top, right, bottom] mPaddings[0] = onLeft - ? mExpandedViewLargeScreenInset - pointerTotalHeight - : mExpandedViewLargeScreenInset; + ? mExpandedViewLargeScreenInsetClosestEdge - pointerTotalHeight + : mExpandedViewLargeScreenInsetFurthestEdge; mPaddings[1] = 0; mPaddings[2] = onLeft - ? mExpandedViewLargeScreenInset - : mExpandedViewLargeScreenInset - pointerTotalHeight; - // Overflow doesn't show manage button / get padding from it so add padding here for it + ? mExpandedViewLargeScreenInsetFurthestEdge + : mExpandedViewLargeScreenInsetClosestEdge - pointerTotalHeight; + // Overflow doesn't show manage button / get padding from it so add padding here mPaddings[3] = isOverflow ? mExpandedViewPadding : 0; return mPaddings; } else { @@ -494,12 +532,13 @@ public class BubblePositioner { float x; float y; if (showBubblesVertically()) { + int inset = mExpandedViewLargeScreenInsetClosestEdge; y = rowStart + positionInRow; int left = mIsLargeScreen - ? mExpandedViewLargeScreenInset - mExpandedViewPadding - mBubbleSize + ? inset - mExpandedViewPadding - mBubbleSize : mPositionRect.left; int right = mIsLargeScreen - ? mPositionRect.right - mExpandedViewLargeScreenInset + mExpandedViewPadding + ? mPositionRect.right - inset + mExpandedViewPadding : mPositionRect.right - mBubbleSize; x = state.onLeft ? left |