Merge "Adjustments to expanded view size and position" into tm-dev
This commit is contained in:
@@ -129,6 +129,9 @@
|
|||||||
<dimen name="bubble_dismiss_encircle_size">52dp</dimen>
|
<dimen name="bubble_dismiss_encircle_size">52dp</dimen>
|
||||||
<!-- Padding around the view displayed when the bubble is expanded -->
|
<!-- Padding around the view displayed when the bubble is expanded -->
|
||||||
<dimen name="bubble_expanded_view_padding">16dp</dimen>
|
<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
|
<!-- 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. -->
|
a slight touch slop around the expanded view. -->
|
||||||
<dimen name="bubble_expanded_view_slop">8dp</dimen>
|
<dimen name="bubble_expanded_view_slop">8dp</dimen>
|
||||||
|
|||||||
@@ -67,7 +67,11 @@ public class BubblePositioner {
|
|||||||
/** The max percent of screen width to use for the flyout on phone. */
|
/** The max percent of screen width to use for the flyout on phone. */
|
||||||
public static final float FLYOUT_MAX_WIDTH_PERCENT = 0.6f;
|
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. **/
|
/** 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 Context mContext;
|
||||||
private WindowManager mWindowManager;
|
private WindowManager mWindowManager;
|
||||||
@@ -77,6 +81,7 @@ public class BubblePositioner {
|
|||||||
private boolean mImeVisible;
|
private boolean mImeVisible;
|
||||||
private int mImeHeight;
|
private int mImeHeight;
|
||||||
private boolean mIsLargeScreen;
|
private boolean mIsLargeScreen;
|
||||||
|
private boolean mIsSmallTablet;
|
||||||
|
|
||||||
private Rect mPositionRect;
|
private Rect mPositionRect;
|
||||||
private int mDefaultMaxBubbles;
|
private int mDefaultMaxBubbles;
|
||||||
@@ -86,7 +91,8 @@ public class BubblePositioner {
|
|||||||
|
|
||||||
private int mExpandedViewMinHeight;
|
private int mExpandedViewMinHeight;
|
||||||
private int mExpandedViewLargeScreenWidth;
|
private int mExpandedViewLargeScreenWidth;
|
||||||
private int mExpandedViewLargeScreenInset;
|
private int mExpandedViewLargeScreenInsetClosestEdge;
|
||||||
|
private int mExpandedViewLargeScreenInsetFurthestEdge;
|
||||||
|
|
||||||
private int mOverflowWidth;
|
private int mOverflowWidth;
|
||||||
private int mExpandedViewPadding;
|
private int mExpandedViewPadding;
|
||||||
@@ -127,17 +133,26 @@ public class BubblePositioner {
|
|||||||
| WindowInsets.Type.statusBars()
|
| WindowInsets.Type.statusBars()
|
||||||
| WindowInsets.Type.displayCutout());
|
| 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) {
|
if (BubbleDebugConfig.DEBUG_POSITIONER) {
|
||||||
Log.w(TAG, "update positioner:"
|
Log.w(TAG, "update positioner:"
|
||||||
+ " rotation: " + mRotation
|
+ " rotation: " + mRotation
|
||||||
+ " insets: " + insets
|
+ " insets: " + insets
|
||||||
+ " isLargeScreen: " + mIsLargeScreen
|
+ " isLargeScreen: " + mIsLargeScreen
|
||||||
+ " bounds: " + windowMetrics.getBounds()
|
+ " isSmallTablet: " + mIsSmallTablet
|
||||||
|
+ " bounds: " + bounds
|
||||||
+ " showingInTaskbar: " + mShowingInTaskbar);
|
+ " 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);
|
mSpacingBetweenBubbles = res.getDimensionPixelSize(R.dimen.bubble_spacing);
|
||||||
mDefaultMaxBubbles = res.getInteger(R.integer.bubbles_max_rendered);
|
mDefaultMaxBubbles = res.getInteger(R.integer.bubbles_max_rendered);
|
||||||
mExpandedViewPadding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding);
|
mExpandedViewPadding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding);
|
||||||
mExpandedViewLargeScreenWidth = (int) (bounds.width()
|
if (mIsSmallTablet) {
|
||||||
* EXPANDED_VIEW_LARGE_SCREEN_WIDTH_PERCENT);
|
mExpandedViewLargeScreenWidth = (int) (bounds.width()
|
||||||
mExpandedViewLargeScreenInset = mIsLargeScreen
|
* EXPANDED_VIEW_SMALL_TABLET_WIDTH_PERCENT);
|
||||||
? (bounds.width() - mExpandedViewLargeScreenWidth) / 2
|
} else {
|
||||||
: mExpandedViewPadding;
|
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
|
mOverflowWidth = mIsLargeScreen
|
||||||
? mExpandedViewLargeScreenWidth
|
? mExpandedViewLargeScreenWidth
|
||||||
: res.getDimensionPixelSize(
|
: res.getDimensionPixelSize(
|
||||||
@@ -328,15 +363,18 @@ public class BubblePositioner {
|
|||||||
public int[] getExpandedViewContainerPadding(boolean onLeft, boolean isOverflow) {
|
public int[] getExpandedViewContainerPadding(boolean onLeft, boolean isOverflow) {
|
||||||
final int pointerTotalHeight = mPointerHeight - mPointerOverlap;
|
final int pointerTotalHeight = mPointerHeight - mPointerOverlap;
|
||||||
if (mIsLargeScreen) {
|
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]
|
// [left, top, right, bottom]
|
||||||
mPaddings[0] = onLeft
|
mPaddings[0] = onLeft
|
||||||
? mExpandedViewLargeScreenInset - pointerTotalHeight
|
? mExpandedViewLargeScreenInsetClosestEdge - pointerTotalHeight
|
||||||
: mExpandedViewLargeScreenInset;
|
: mExpandedViewLargeScreenInsetFurthestEdge;
|
||||||
mPaddings[1] = 0;
|
mPaddings[1] = 0;
|
||||||
mPaddings[2] = onLeft
|
mPaddings[2] = onLeft
|
||||||
? mExpandedViewLargeScreenInset
|
? mExpandedViewLargeScreenInsetFurthestEdge
|
||||||
: mExpandedViewLargeScreenInset - pointerTotalHeight;
|
: mExpandedViewLargeScreenInsetClosestEdge - pointerTotalHeight;
|
||||||
// Overflow doesn't show manage button / get padding from it so add padding here for it
|
// Overflow doesn't show manage button / get padding from it so add padding here
|
||||||
mPaddings[3] = isOverflow ? mExpandedViewPadding : 0;
|
mPaddings[3] = isOverflow ? mExpandedViewPadding : 0;
|
||||||
return mPaddings;
|
return mPaddings;
|
||||||
} else {
|
} else {
|
||||||
@@ -494,12 +532,13 @@ public class BubblePositioner {
|
|||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
if (showBubblesVertically()) {
|
if (showBubblesVertically()) {
|
||||||
|
int inset = mExpandedViewLargeScreenInsetClosestEdge;
|
||||||
y = rowStart + positionInRow;
|
y = rowStart + positionInRow;
|
||||||
int left = mIsLargeScreen
|
int left = mIsLargeScreen
|
||||||
? mExpandedViewLargeScreenInset - mExpandedViewPadding - mBubbleSize
|
? inset - mExpandedViewPadding - mBubbleSize
|
||||||
: mPositionRect.left;
|
: mPositionRect.left;
|
||||||
int right = mIsLargeScreen
|
int right = mIsLargeScreen
|
||||||
? mPositionRect.right - mExpandedViewLargeScreenInset + mExpandedViewPadding
|
? mPositionRect.right - inset + mExpandedViewPadding
|
||||||
: mPositionRect.right - mBubbleSize;
|
: mPositionRect.right - mBubbleSize;
|
||||||
x = state.onLeft
|
x = state.onLeft
|
||||||
? left
|
? left
|
||||||
|
|||||||
Reference in New Issue
Block a user