Merge "Fix an issue where the start position of the stack is wrong in RTL" into tm-dev am: 68559c1680
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18528569 Change-Id: I5f4fcbc22ffa91457c0dfc95ade2c1b8b0fee343 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -88,6 +88,9 @@ public class BubblePositioner {
|
|||||||
private int mMaxBubbles;
|
private int mMaxBubbles;
|
||||||
private int mBubbleSize;
|
private int mBubbleSize;
|
||||||
private int mSpacingBetweenBubbles;
|
private int mSpacingBetweenBubbles;
|
||||||
|
private int mBubblePaddingTop;
|
||||||
|
private int mBubbleOffscreenAmount;
|
||||||
|
private int mStackOffset;
|
||||||
|
|
||||||
private int mExpandedViewMinHeight;
|
private int mExpandedViewMinHeight;
|
||||||
private int mExpandedViewLargeScreenWidth;
|
private int mExpandedViewLargeScreenWidth;
|
||||||
@@ -187,6 +190,10 @@ 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);
|
||||||
|
mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
|
||||||
|
mBubbleOffscreenAmount = res.getDimensionPixelSize(R.dimen.bubble_stack_offscreen);
|
||||||
|
mStackOffset = res.getDimensionPixelSize(R.dimen.bubble_stack_offset);
|
||||||
|
|
||||||
if (mIsSmallTablet) {
|
if (mIsSmallTablet) {
|
||||||
mExpandedViewLargeScreenWidth = (int) (bounds.width()
|
mExpandedViewLargeScreenWidth = (int) (bounds.width()
|
||||||
* EXPANDED_VIEW_SMALL_TABLET_WIDTH_PERCENT);
|
* EXPANDED_VIEW_SMALL_TABLET_WIDTH_PERCENT);
|
||||||
@@ -329,6 +336,21 @@ public class BubblePositioner {
|
|||||||
: mBubbleSize;
|
: mBubbleSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The amount of padding at the top of the screen that the bubbles avoid when being placed. */
|
||||||
|
public int getBubblePaddingTop() {
|
||||||
|
return mBubblePaddingTop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The amount the stack hang off of the screen when collapsed. */
|
||||||
|
public int getStackOffScreenAmount() {
|
||||||
|
return mBubbleOffscreenAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Offset of bubbles in the stack (i.e. how much they overlap). */
|
||||||
|
public int getStackOffset() {
|
||||||
|
return mStackOffset;
|
||||||
|
}
|
||||||
|
|
||||||
/** Size of the visible (non-overlapping) part of the pointer. */
|
/** Size of the visible (non-overlapping) part of the pointer. */
|
||||||
public int getPointerSize() {
|
public int getPointerSize() {
|
||||||
return mPointerHeight - mPointerOverlap;
|
return mPointerHeight - mPointerOverlap;
|
||||||
@@ -678,7 +700,28 @@ public class BubblePositioner {
|
|||||||
return new BubbleStackView.RelativeStackPosition(
|
return new BubbleStackView.RelativeStackPosition(
|
||||||
startOnLeft,
|
startOnLeft,
|
||||||
startingVerticalOffset / mPositionRect.height())
|
startingVerticalOffset / mPositionRect.height())
|
||||||
.getAbsolutePositionInRegion(new RectF(mPositionRect));
|
.getAbsolutePositionInRegion(getAllowableStackPositionRegion(
|
||||||
|
1 /* default starts with 1 bubble */));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the region that the stack position must stay within. This goes slightly off the left
|
||||||
|
* and right sides of the screen, below the status bar/cutout and above the navigation bar.
|
||||||
|
* While the stack position is not allowed to rest outside of these bounds, it can temporarily
|
||||||
|
* be animated or dragged beyond them.
|
||||||
|
*/
|
||||||
|
public RectF getAllowableStackPositionRegion(int bubbleCount) {
|
||||||
|
final RectF allowableRegion = new RectF(getAvailableRect());
|
||||||
|
final int imeHeight = getImeHeight();
|
||||||
|
final float bottomPadding = bubbleCount > 1
|
||||||
|
? mBubblePaddingTop + mStackOffset
|
||||||
|
: mBubblePaddingTop;
|
||||||
|
allowableRegion.left -= mBubbleOffscreenAmount;
|
||||||
|
allowableRegion.top += mBubblePaddingTop;
|
||||||
|
allowableRegion.right += mBubbleOffscreenAmount - mBubbleSize;
|
||||||
|
allowableRegion.bottom -= imeHeight + bottomPadding + mBubbleSize;
|
||||||
|
return allowableRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1296,7 +1296,7 @@ public class BubbleStackView extends FrameLayout
|
|||||||
public void onOrientationChanged() {
|
public void onOrientationChanged() {
|
||||||
mRelativeStackPositionBeforeRotation = new RelativeStackPosition(
|
mRelativeStackPositionBeforeRotation = new RelativeStackPosition(
|
||||||
mPositioner.getRestingPosition(),
|
mPositioner.getRestingPosition(),
|
||||||
mStackAnimationController.getAllowableStackPositionRegion());
|
mPositioner.getAllowableStackPositionRegion(getBubbleCount()));
|
||||||
addOnLayoutChangeListener(mOrientationChangedListener);
|
addOnLayoutChangeListener(mOrientationChangedListener);
|
||||||
hideFlyoutImmediate();
|
hideFlyoutImmediate();
|
||||||
}
|
}
|
||||||
@@ -1340,7 +1340,7 @@ public class BubbleStackView extends FrameLayout
|
|||||||
mStackAnimationController.setStackPosition(
|
mStackAnimationController.setStackPosition(
|
||||||
new RelativeStackPosition(
|
new RelativeStackPosition(
|
||||||
mPositioner.getRestingPosition(),
|
mPositioner.getRestingPosition(),
|
||||||
mStackAnimationController.getAllowableStackPositionRegion()));
|
mPositioner.getAllowableStackPositionRegion(getBubbleCount())));
|
||||||
}
|
}
|
||||||
if (mIsExpanded) {
|
if (mIsExpanded) {
|
||||||
updateExpandedView();
|
updateExpandedView();
|
||||||
@@ -1440,7 +1440,7 @@ public class BubbleStackView extends FrameLayout
|
|||||||
if (super.performAccessibilityActionInternal(action, arguments)) {
|
if (super.performAccessibilityActionInternal(action, arguments)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final RectF stackBounds = mStackAnimationController.getAllowableStackPositionRegion();
|
final RectF stackBounds = mPositioner.getAllowableStackPositionRegion(getBubbleCount());
|
||||||
|
|
||||||
// R constants are not final so we cannot use switch-case here.
|
// R constants are not final so we cannot use switch-case here.
|
||||||
if (action == AccessibilityNodeInfo.ACTION_DISMISS) {
|
if (action == AccessibilityNodeInfo.ACTION_DISMISS) {
|
||||||
|
|||||||
@@ -185,8 +185,6 @@ public class StackAnimationController extends
|
|||||||
* stack goes offscreen intentionally.
|
* stack goes offscreen intentionally.
|
||||||
*/
|
*/
|
||||||
private int mBubblePaddingTop;
|
private int mBubblePaddingTop;
|
||||||
/** How far offscreen the stack rests. */
|
|
||||||
private int mBubbleOffscreen;
|
|
||||||
/** Contains display size, orientation, and inset information. */
|
/** Contains display size, orientation, and inset information. */
|
||||||
private BubblePositioner mPositioner;
|
private BubblePositioner mPositioner;
|
||||||
|
|
||||||
@@ -212,7 +210,8 @@ public class StackAnimationController extends
|
|||||||
public Rect getAllowedFloatingBoundsRegion() {
|
public Rect getAllowedFloatingBoundsRegion() {
|
||||||
final Rect floatingBounds = getFloatingBoundsOnScreen();
|
final Rect floatingBounds = getFloatingBoundsOnScreen();
|
||||||
final Rect allowableStackArea = new Rect();
|
final Rect allowableStackArea = new Rect();
|
||||||
getAllowableStackPositionRegion().roundOut(allowableStackArea);
|
mPositioner.getAllowableStackPositionRegion(getBubbleCount())
|
||||||
|
.roundOut(allowableStackArea);
|
||||||
allowableStackArea.right += floatingBounds.width();
|
allowableStackArea.right += floatingBounds.width();
|
||||||
allowableStackArea.bottom += floatingBounds.height();
|
allowableStackArea.bottom += floatingBounds.height();
|
||||||
return allowableStackArea;
|
return allowableStackArea;
|
||||||
@@ -349,7 +348,7 @@ public class StackAnimationController extends
|
|||||||
? velX < ESCAPE_VELOCITY
|
? velX < ESCAPE_VELOCITY
|
||||||
: velX < -ESCAPE_VELOCITY;
|
: velX < -ESCAPE_VELOCITY;
|
||||||
|
|
||||||
final RectF stackBounds = getAllowableStackPositionRegion();
|
final RectF stackBounds = mPositioner.getAllowableStackPositionRegion(getBubbleCount());
|
||||||
|
|
||||||
// Target X translation (either the left or right side of the screen).
|
// Target X translation (either the left or right side of the screen).
|
||||||
final float destinationRelativeX = stackShouldFlingLeft
|
final float destinationRelativeX = stackShouldFlingLeft
|
||||||
@@ -425,7 +424,7 @@ public class StackAnimationController extends
|
|||||||
}
|
}
|
||||||
final PointF stackPos = getStackPosition();
|
final PointF stackPos = getStackPosition();
|
||||||
final boolean onLeft = mLayout.isFirstChildXLeftOfCenter(stackPos.x);
|
final boolean onLeft = mLayout.isFirstChildXLeftOfCenter(stackPos.x);
|
||||||
final RectF bounds = getAllowableStackPositionRegion();
|
final RectF bounds = mPositioner.getAllowableStackPositionRegion(getBubbleCount());
|
||||||
|
|
||||||
stackPos.x = onLeft ? bounds.left : bounds.right;
|
stackPos.x = onLeft ? bounds.left : bounds.right;
|
||||||
return stackPos;
|
return stackPos;
|
||||||
@@ -464,7 +463,7 @@ public class StackAnimationController extends
|
|||||||
|
|
||||||
StackPositionProperty firstBubbleProperty = new StackPositionProperty(property);
|
StackPositionProperty firstBubbleProperty = new StackPositionProperty(property);
|
||||||
final float currentValue = firstBubbleProperty.getValue(this);
|
final float currentValue = firstBubbleProperty.getValue(this);
|
||||||
final RectF bounds = getAllowableStackPositionRegion();
|
final RectF bounds = mPositioner.getAllowableStackPositionRegion(getBubbleCount());
|
||||||
final float min =
|
final float min =
|
||||||
property.equals(DynamicAnimation.TRANSLATION_X)
|
property.equals(DynamicAnimation.TRANSLATION_X)
|
||||||
? bounds.left
|
? bounds.left
|
||||||
@@ -525,7 +524,8 @@ public class StackAnimationController extends
|
|||||||
* of the stack if it's not moving).
|
* of the stack if it's not moving).
|
||||||
*/
|
*/
|
||||||
public float animateForImeVisibility(boolean imeVisible) {
|
public float animateForImeVisibility(boolean imeVisible) {
|
||||||
final float maxBubbleY = getAllowableStackPositionRegion().bottom;
|
final float maxBubbleY = mPositioner.getAllowableStackPositionRegion(
|
||||||
|
getBubbleCount()).bottom;
|
||||||
float destinationY = UNSET;
|
float destinationY = UNSET;
|
||||||
|
|
||||||
if (imeVisible) {
|
if (imeVisible) {
|
||||||
@@ -567,25 +567,6 @@ public class StackAnimationController extends
|
|||||||
mFloatingContentCoordinator.onContentMoved(mStackFloatingContent);
|
mFloatingContentCoordinator.onContentMoved(mStackFloatingContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the region that the stack position must stay within. This goes slightly off the left
|
|
||||||
* and right sides of the screen, below the status bar/cutout and above the navigation bar.
|
|
||||||
* While the stack position is not allowed to rest outside of these bounds, it can temporarily
|
|
||||||
* be animated or dragged beyond them.
|
|
||||||
*/
|
|
||||||
public RectF getAllowableStackPositionRegion() {
|
|
||||||
final RectF allowableRegion = new RectF(mPositioner.getAvailableRect());
|
|
||||||
final int imeHeight = mPositioner.getImeHeight();
|
|
||||||
final float bottomPadding = getBubbleCount() > 1
|
|
||||||
? mBubblePaddingTop + mStackOffset
|
|
||||||
: mBubblePaddingTop;
|
|
||||||
allowableRegion.left -= mBubbleOffscreen;
|
|
||||||
allowableRegion.top += mBubblePaddingTop;
|
|
||||||
allowableRegion.right += mBubbleOffscreen - mBubbleSize;
|
|
||||||
allowableRegion.bottom -= imeHeight + bottomPadding + mBubbleSize;
|
|
||||||
return allowableRegion;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Moves the stack in response to a touch event. */
|
/** Moves the stack in response to a touch event. */
|
||||||
public void moveStackFromTouch(float x, float y) {
|
public void moveStackFromTouch(float x, float y) {
|
||||||
// Begin the spring-to-touch catch up animation if needed.
|
// Begin the spring-to-touch catch up animation if needed.
|
||||||
@@ -861,13 +842,12 @@ public class StackAnimationController extends
|
|||||||
@Override
|
@Override
|
||||||
void onActiveControllerForLayout(PhysicsAnimationLayout layout) {
|
void onActiveControllerForLayout(PhysicsAnimationLayout layout) {
|
||||||
Resources res = layout.getResources();
|
Resources res = layout.getResources();
|
||||||
mStackOffset = res.getDimensionPixelSize(R.dimen.bubble_stack_offset);
|
mStackOffset = mPositioner.getStackOffset();
|
||||||
mSwapAnimationOffset = res.getDimensionPixelSize(R.dimen.bubble_swap_animation_offset);
|
mSwapAnimationOffset = res.getDimensionPixelSize(R.dimen.bubble_swap_animation_offset);
|
||||||
mMaxBubbles = res.getInteger(R.integer.bubbles_max_rendered);
|
mMaxBubbles = res.getInteger(R.integer.bubbles_max_rendered);
|
||||||
mElevation = res.getDimensionPixelSize(R.dimen.bubble_elevation);
|
mElevation = res.getDimensionPixelSize(R.dimen.bubble_elevation);
|
||||||
mBubbleSize = mPositioner.getBubbleSize();
|
mBubbleSize = mPositioner.getBubbleSize();
|
||||||
mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
|
mBubblePaddingTop = mPositioner.getBubblePaddingTop();
|
||||||
mBubbleOffscreen = res.getDimensionPixelSize(R.dimen.bubble_stack_offscreen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -958,7 +938,8 @@ public class StackAnimationController extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setStackPosition(BubbleStackView.RelativeStackPosition position) {
|
public void setStackPosition(BubbleStackView.RelativeStackPosition position) {
|
||||||
setStackPosition(position.getAbsolutePositionInRegion(getAllowableStackPositionRegion()));
|
setStackPosition(position.getAbsolutePositionInRegion(
|
||||||
|
mPositioner.getAllowableStackPositionRegion(getBubbleCount())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStackPositionSet() {
|
private boolean isStackPositionSet() {
|
||||||
|
|||||||
Reference in New Issue
Block a user