Merge changes Ib640add6,I168a14e1 into sc-dev
* changes: Bubbles don't hang off screen Only show the first 2 bubbles in the stack when collapsed
This commit is contained in:
@@ -164,8 +164,9 @@
|
||||
<dimen name="bubble_stack_offset">10dp</dimen>
|
||||
<!-- Offset between stack y and animation y for bubble swap. -->
|
||||
<dimen name="bubble_swap_animation_offset">15dp</dimen>
|
||||
<!-- How far offscreen the bubble stack rests. Cuts off padding and part of icon bitmap. -->
|
||||
<dimen name="bubble_stack_offscreen">9dp</dimen>
|
||||
<!-- How far offscreen the bubble stack rests. There's some padding around the bubble so
|
||||
add 3dp to the desired overhang. -->
|
||||
<dimen name="bubble_stack_offscreen">3dp</dimen>
|
||||
<!-- How far down the screen the stack starts. -->
|
||||
<dimen name="bubble_stack_starting_offset_y">120dp</dimen>
|
||||
<!-- Space between the pointer triangle and the bubble expanded view -->
|
||||
|
||||
@@ -290,7 +290,7 @@ public class ExpandedAnimationController
|
||||
path.lineTo(stackedX, expandedY);
|
||||
|
||||
// Then, draw a line down to the stack position.
|
||||
path.lineTo(stackedX, mCollapsePoint.y + index * mStackOffsetPx);
|
||||
path.lineTo(stackedX, mCollapsePoint.y + Math.min(index, 1) * mStackOffsetPx);
|
||||
}
|
||||
|
||||
// The lead bubble should be the bubble with the longest distance to travel when we're
|
||||
@@ -509,7 +509,7 @@ public class ExpandedAnimationController
|
||||
}
|
||||
|
||||
@Override
|
||||
float getOffsetForChainedPropertyAnimation(DynamicAnimation.ViewProperty property) {
|
||||
float getOffsetForChainedPropertyAnimation(DynamicAnimation.ViewProperty property, int index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,8 @@ public class PhysicsAnimationLayout extends FrameLayout {
|
||||
* This is used for things like maintaining the 'stack' effect in Bubbles, where bubbles
|
||||
* stack off to the left or right side slightly.
|
||||
*/
|
||||
abstract float getOffsetForChainedPropertyAnimation(DynamicAnimation.ViewProperty property);
|
||||
abstract float getOffsetForChainedPropertyAnimation(
|
||||
DynamicAnimation.ViewProperty property, int index);
|
||||
|
||||
/**
|
||||
* Returns the SpringForce to be used for the given child view's property animation. Despite
|
||||
@@ -496,7 +497,7 @@ public class PhysicsAnimationLayout extends FrameLayout {
|
||||
// setting up animations for all children when setActiveController is called.
|
||||
if (mController != null && !isReorder) {
|
||||
for (DynamicAnimation.ViewProperty property : mController.getAnimatedProperties()) {
|
||||
setUpAnimationForChild(property, child, index);
|
||||
setUpAnimationForChild(property, child);
|
||||
}
|
||||
|
||||
mController.onChildAdded(child, index);
|
||||
@@ -536,23 +537,22 @@ public class PhysicsAnimationLayout extends FrameLayout {
|
||||
/** Sets up SpringAnimations of the given property for each child view in the layout. */
|
||||
private void setUpAnimationsForProperty(DynamicAnimation.ViewProperty property) {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
setUpAnimationForChild(property, getChildAt(i), i);
|
||||
setUpAnimationForChild(property, getChildAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
/** Constructs a SpringAnimation of the given property for a child view. */
|
||||
private void setUpAnimationForChild(
|
||||
DynamicAnimation.ViewProperty property, View child, int index) {
|
||||
private void setUpAnimationForChild(DynamicAnimation.ViewProperty property, View child) {
|
||||
SpringAnimation newAnim = new SpringAnimation(child, property);
|
||||
newAnim.addUpdateListener((animation, value, velocity) -> {
|
||||
final int indexOfChild = indexOfChild(child);
|
||||
final int nextAnimInChain = mController.getNextAnimationInChain(property, indexOfChild);
|
||||
|
||||
if (nextAnimInChain == PhysicsAnimationController.NONE || indexOfChild < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final float offset = mController.getOffsetForChainedPropertyAnimation(property);
|
||||
final float offset = mController.getOffsetForChainedPropertyAnimation(property,
|
||||
nextAnimInChain);
|
||||
if (nextAnimInChain < getChildCount()) {
|
||||
final SpringAnimation nextAnim = getSpringAnimationAtIndex(
|
||||
property, nextAnimInChain);
|
||||
|
||||
@@ -709,14 +709,16 @@ public class StackAnimationController extends
|
||||
|
||||
|
||||
@Override
|
||||
float getOffsetForChainedPropertyAnimation(DynamicAnimation.ViewProperty property) {
|
||||
float getOffsetForChainedPropertyAnimation(DynamicAnimation.ViewProperty property, int index) {
|
||||
if (property.equals(DynamicAnimation.TRANSLATION_Y)) {
|
||||
// If we're in the dismiss target, have the bubbles pile on top of each other with no
|
||||
// offset.
|
||||
if (isStackStuckToTarget()) {
|
||||
return 0f;
|
||||
} else {
|
||||
return mStackOffset;
|
||||
// We only show the first two bubbles in the stack & the rest hide behind them
|
||||
// so they don't need an offset.
|
||||
return index > 1 ? 0f : mStackOffset;
|
||||
}
|
||||
} else {
|
||||
return 0f;
|
||||
@@ -825,7 +827,7 @@ public class StackAnimationController extends
|
||||
private void moveToFinalIndex(View view, int newIndex,
|
||||
Runnable finishReorder) {
|
||||
final ViewPropertyAnimator animator = view.animate()
|
||||
.translationY(getStackPosition().y + newIndex * mStackOffset)
|
||||
.translationY(getStackPosition().y + Math.min(newIndex, 1) * mStackOffset)
|
||||
.setDuration(BUBBLE_SWAP_DURATION)
|
||||
.withEndAction(() -> {
|
||||
view.setTag(R.id.reorder_animator_tag, null);
|
||||
@@ -912,8 +914,9 @@ public class StackAnimationController extends
|
||||
if (mLayout.getChildCount() > 0) {
|
||||
property.setValue(mLayout.getChildAt(0), value);
|
||||
if (mLayout.getChildCount() > 1) {
|
||||
float newValue = value + getOffsetForChainedPropertyAnimation(property, 0);
|
||||
animationForChildAtIndex(1)
|
||||
.property(property, value + getOffsetForChainedPropertyAnimation(property))
|
||||
.property(property, newValue)
|
||||
.start();
|
||||
}
|
||||
}
|
||||
@@ -935,12 +938,12 @@ public class StackAnimationController extends
|
||||
|
||||
// Since we're not using the chained animations, apply the offsets manually.
|
||||
final float xOffset = getOffsetForChainedPropertyAnimation(
|
||||
DynamicAnimation.TRANSLATION_X);
|
||||
DynamicAnimation.TRANSLATION_X, 0);
|
||||
final float yOffset = getOffsetForChainedPropertyAnimation(
|
||||
DynamicAnimation.TRANSLATION_Y);
|
||||
DynamicAnimation.TRANSLATION_Y, 0);
|
||||
for (int i = 0; i < mLayout.getChildCount(); i++) {
|
||||
mLayout.getChildAt(i).setTranslationX(pos.x + (i * xOffset));
|
||||
mLayout.getChildAt(i).setTranslationY(pos.y + (i * yOffset));
|
||||
mLayout.getChildAt(i).setTranslationX(pos.x + (Math.min(i, 1) * xOffset));
|
||||
mLayout.getChildAt(i).setTranslationY(pos.y + (Math.min(i, 1) * yOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -960,7 +963,7 @@ public class StackAnimationController extends
|
||||
}
|
||||
|
||||
final float yOffset =
|
||||
getOffsetForChainedPropertyAnimation(DynamicAnimation.TRANSLATION_Y);
|
||||
getOffsetForChainedPropertyAnimation(DynamicAnimation.TRANSLATION_Y, 0);
|
||||
float endY = mStackPosition.y + yOffset * index;
|
||||
float endX = mStackPosition.x;
|
||||
if (mPositioner.showBubblesVertically()) {
|
||||
|
||||
@@ -249,7 +249,7 @@ public class PhysicsAnimationLayoutTest extends PhysicsAnimationLayoutTestCase {
|
||||
Mockito.verify(mTestableController, Mockito.never())
|
||||
.getNextAnimationInChain(eq(DynamicAnimation.SCALE_X), anyInt());
|
||||
Mockito.verify(mTestableController, Mockito.never())
|
||||
.getOffsetForChainedPropertyAnimation(eq(DynamicAnimation.SCALE_X));
|
||||
.getOffsetForChainedPropertyAnimation(eq(DynamicAnimation.SCALE_X), anyInt());
|
||||
|
||||
// Make sure we asked the new controller about its animated properties, and configuration
|
||||
// options.
|
||||
@@ -258,7 +258,7 @@ public class PhysicsAnimationLayoutTest extends PhysicsAnimationLayoutTestCase {
|
||||
Mockito.verify(secondController, Mockito.atLeastOnce())
|
||||
.getNextAnimationInChain(eq(DynamicAnimation.SCALE_X), anyInt());
|
||||
Mockito.verify(secondController, Mockito.atLeastOnce())
|
||||
.getOffsetForChainedPropertyAnimation(eq(DynamicAnimation.SCALE_X));
|
||||
.getOffsetForChainedPropertyAnimation(eq(DynamicAnimation.SCALE_X), anyInt());
|
||||
|
||||
mLayout.setActiveController(mTestableController);
|
||||
mTestableController.animationForChildAtIndex(0)
|
||||
@@ -271,7 +271,7 @@ public class PhysicsAnimationLayoutTest extends PhysicsAnimationLayoutTestCase {
|
||||
Mockito.verify(secondController, Mockito.never())
|
||||
.getNextAnimationInChain(eq(DynamicAnimation.TRANSLATION_X), anyInt());
|
||||
Mockito.verify(secondController, Mockito.never())
|
||||
.getOffsetForChainedPropertyAnimation(eq(DynamicAnimation.TRANSLATION_X));
|
||||
.getOffsetForChainedPropertyAnimation(eq(DynamicAnimation.TRANSLATION_X), anyInt());
|
||||
|
||||
}
|
||||
|
||||
@@ -479,7 +479,8 @@ public class PhysicsAnimationLayoutTest extends PhysicsAnimationLayoutTestCase {
|
||||
}
|
||||
|
||||
@Override
|
||||
float getOffsetForChainedPropertyAnimation(DynamicAnimation.ViewProperty property) {
|
||||
float getOffsetForChainedPropertyAnimation(DynamicAnimation.ViewProperty property,
|
||||
int index) {
|
||||
return mOffsetForProperty.getOrDefault(property, 0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -258,8 +258,9 @@ public class PhysicsAnimationLayoutTestCase extends ShellTestCase {
|
||||
}
|
||||
|
||||
@Override
|
||||
float getOffsetForChainedPropertyAnimation(DynamicAnimation.ViewProperty property) {
|
||||
return mWrappedController.getOffsetForChainedPropertyAnimation(property);
|
||||
float getOffsetForChainedPropertyAnimation(DynamicAnimation.ViewProperty property,
|
||||
int index) {
|
||||
return mWrappedController.getOffsetForChainedPropertyAnimation(property, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user