diff options
5 files changed, 29 insertions, 24 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationController.java index 48bd8943b25a..fc499572bbc3 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/ExpandedAnimationController.java @@ -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; } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayout.java index 0618d5d5f213..4ec2c8d4d362 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayout.java @@ -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); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java index 578f87fbfbf8..6209051d38ef 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/animation/StackAnimationController.java @@ -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()) { diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayoutTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayoutTest.java index c4edbb286e16..964711ee8dcb 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayoutTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayoutTest.java @@ -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); } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayoutTestCase.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayoutTestCase.java index a7a7db869776..48ae2961b4be 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayoutTestCase.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/animation/PhysicsAnimationLayoutTestCase.java @@ -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 |