Merge "Modify the default position of bubbles on tablet to be centered" into udc-qpr-dev
This commit is contained in:
@@ -661,14 +661,26 @@ public class BubblePositioner {
|
||||
final boolean startOnLeft =
|
||||
mContext.getResources().getConfiguration().getLayoutDirection()
|
||||
!= LAYOUT_DIRECTION_RTL;
|
||||
final float startingVerticalOffset = mContext.getResources().getDimensionPixelOffset(
|
||||
R.dimen.bubble_stack_starting_offset_y);
|
||||
// TODO: placement bug here because mPositionRect doesn't handle the overhanging edge
|
||||
return new BubbleStackView.RelativeStackPosition(
|
||||
startOnLeft,
|
||||
startingVerticalOffset / mPositionRect.height())
|
||||
.getAbsolutePositionInRegion(getAllowableStackPositionRegion(
|
||||
1 /* default starts with 1 bubble */));
|
||||
final RectF allowableStackPositionRegion = getAllowableStackPositionRegion(
|
||||
1 /* default starts with 1 bubble */);
|
||||
if (isLargeScreen()) {
|
||||
// We want the stack to be visually centered on the edge, so we need to base it
|
||||
// of a rect that includes insets.
|
||||
final float desiredY = mScreenRect.height() / 2f - (mBubbleSize / 2f);
|
||||
final float offset = desiredY / mScreenRect.height();
|
||||
return new BubbleStackView.RelativeStackPosition(
|
||||
startOnLeft,
|
||||
offset)
|
||||
.getAbsolutePositionInRegion(allowableStackPositionRegion);
|
||||
} else {
|
||||
final float startingVerticalOffset = mContext.getResources().getDimensionPixelOffset(
|
||||
R.dimen.bubble_stack_starting_offset_y);
|
||||
// TODO: placement bug here because mPositionRect doesn't handle the overhanging edge
|
||||
return new BubbleStackView.RelativeStackPosition(
|
||||
startOnLeft,
|
||||
startingVerticalOffset / mPositionRect.height())
|
||||
.getAbsolutePositionInRegion(allowableStackPositionRegion);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -209,9 +209,19 @@ public class BubblePositionerTest extends ShellTestCase {
|
||||
* {@link BubbleStackView.RelativeStackPosition}.
|
||||
*/
|
||||
private float getDefaultYPosition() {
|
||||
final float desiredY = mContext.getResources().getDimensionPixelOffset(
|
||||
final boolean isTablet = mPositioner.isLargeScreen();
|
||||
|
||||
// On tablet the position is centered, on phone it is an offset from the top.
|
||||
final float desiredY = isTablet
|
||||
? mPositioner.getScreenRect().height() / 2f - (mPositioner.getBubbleSize() / 2f)
|
||||
: mContext.getResources().getDimensionPixelOffset(
|
||||
R.dimen.bubble_stack_starting_offset_y);
|
||||
float offsetPercent = desiredY / mPositioner.getAvailableRect().height();
|
||||
// Since we're visually centering the bubbles on tablet, use total screen height rather
|
||||
// than the available height.
|
||||
final float height = isTablet
|
||||
? mPositioner.getScreenRect().height()
|
||||
: mPositioner.getAvailableRect().height();
|
||||
float offsetPercent = desiredY / height;
|
||||
offsetPercent = Math.max(0f, Math.min(1f, offsetPercent));
|
||||
final RectF allowableStackRegion =
|
||||
mPositioner.getAllowableStackPositionRegion(1 /* bubbleCount */);
|
||||
|
||||
Reference in New Issue
Block a user