Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +20 −8 Original line number Original line Diff line number Diff line Loading @@ -661,14 +661,26 @@ public class BubblePositioner { final boolean startOnLeft = final boolean startOnLeft = mContext.getResources().getConfiguration().getLayoutDirection() mContext.getResources().getConfiguration().getLayoutDirection() != LAYOUT_DIRECTION_RTL; != LAYOUT_DIRECTION_RTL; 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( final float startingVerticalOffset = mContext.getResources().getDimensionPixelOffset( R.dimen.bubble_stack_starting_offset_y); R.dimen.bubble_stack_starting_offset_y); // TODO: placement bug here because mPositionRect doesn't handle the overhanging edge // TODO: placement bug here because mPositionRect doesn't handle the overhanging edge return new BubbleStackView.RelativeStackPosition( return new BubbleStackView.RelativeStackPosition( startOnLeft, startOnLeft, startingVerticalOffset / mPositionRect.height()) startingVerticalOffset / mPositionRect.height()) .getAbsolutePositionInRegion(getAllowableStackPositionRegion( .getAbsolutePositionInRegion(allowableStackPositionRegion); 1 /* default starts with 1 bubble */)); } } } /** /** Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubblePositionerTest.java +12 −2 Original line number Original line Diff line number Diff line Loading @@ -209,9 +209,19 @@ public class BubblePositionerTest extends ShellTestCase { * {@link BubbleStackView.RelativeStackPosition}. * {@link BubbleStackView.RelativeStackPosition}. */ */ private float getDefaultYPosition() { 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); 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)); offsetPercent = Math.max(0f, Math.min(1f, offsetPercent)); final RectF allowableStackRegion = final RectF allowableStackRegion = mPositioner.getAllowableStackPositionRegion(1 /* bubbleCount */); mPositioner.getAllowableStackPositionRegion(1 /* bubbleCount */); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +20 −8 Original line number Original line Diff line number Diff line Loading @@ -661,14 +661,26 @@ public class BubblePositioner { final boolean startOnLeft = final boolean startOnLeft = mContext.getResources().getConfiguration().getLayoutDirection() mContext.getResources().getConfiguration().getLayoutDirection() != LAYOUT_DIRECTION_RTL; != LAYOUT_DIRECTION_RTL; 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( final float startingVerticalOffset = mContext.getResources().getDimensionPixelOffset( R.dimen.bubble_stack_starting_offset_y); R.dimen.bubble_stack_starting_offset_y); // TODO: placement bug here because mPositionRect doesn't handle the overhanging edge // TODO: placement bug here because mPositionRect doesn't handle the overhanging edge return new BubbleStackView.RelativeStackPosition( return new BubbleStackView.RelativeStackPosition( startOnLeft, startOnLeft, startingVerticalOffset / mPositionRect.height()) startingVerticalOffset / mPositionRect.height()) .getAbsolutePositionInRegion(getAllowableStackPositionRegion( .getAbsolutePositionInRegion(allowableStackPositionRegion); 1 /* default starts with 1 bubble */)); } } } /** /** Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubblePositionerTest.java +12 −2 Original line number Original line Diff line number Diff line Loading @@ -209,9 +209,19 @@ public class BubblePositionerTest extends ShellTestCase { * {@link BubbleStackView.RelativeStackPosition}. * {@link BubbleStackView.RelativeStackPosition}. */ */ private float getDefaultYPosition() { 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); 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)); offsetPercent = Math.max(0f, Math.min(1f, offsetPercent)); final RectF allowableStackRegion = final RectF allowableStackRegion = mPositioner.getAllowableStackPositionRegion(1 /* bubbleCount */); mPositioner.getAllowableStackPositionRegion(1 /* bubbleCount */); Loading