From ed85be92ecc2bb94a99a98c752df9895e6f9ecdb Mon Sep 17 00:00:00 2001 From: Matthew Ng Date: Fri, 2 Jun 2017 12:46:33 -0700 Subject: Add back recents staggering entrance animation Since there was a change in ValueAnimator that did not allow setting initial play time per interpolator grouped in an AnimatorSet, set the initial play time for each animation to allow the same effect. Change-Id: I05445bde6e185a99250d7d193bd0e74d5ce98fa0 Fixes: 36175824 Test: manual - launch recents --- .../systemui/recents/views/AnimationProps.java | 30 -------------- .../views/RecentsEntrancePathInterpolator.java | 47 ++++++++++++++++++++++ .../recents/views/TaskStackAnimationHelper.java | 11 +++-- 3 files changed, 52 insertions(+), 36 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/recents/views/RecentsEntrancePathInterpolator.java diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/AnimationProps.java b/packages/SystemUI/src/com/android/systemui/recents/views/AnimationProps.java index 5e87e2a75c80..716d1bcf78c2 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/AnimationProps.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/AnimationProps.java @@ -54,7 +54,6 @@ public class AnimationProps { public static final int FOCUS_STATE = 8; private SparseLongArray mPropStartDelay; - private SparseLongArray mPropInitialPlayTime; private SparseLongArray mPropDuration; private SparseArray mPropInterpolators; private Animator.AnimatorListener mListener; @@ -122,10 +121,6 @@ public class AnimationProps { animator.setStartDelay(getStartDelay(propertyType)); animator.setDuration(getDuration(propertyType)); animator.setInterpolator(getInterpolator(propertyType)); - long initialPlayTime = getInitialPlayTime(propertyType); - if (initialPlayTime != 0) { - animator.setCurrentPlayTime(initialPlayTime); - } return animator; } @@ -140,17 +135,6 @@ public class AnimationProps { return this; } - /** - * Sets a initial play time for a specific property. - */ - public AnimationProps setInitialPlayTime(@PropType int propertyType, int initialPlayTime) { - if (mPropInitialPlayTime == null) { - mPropInitialPlayTime = new SparseLongArray(); - } - mPropInitialPlayTime.append(propertyType, initialPlayTime); - return this; - } - /** * Returns the start delay for a specific property. */ @@ -216,20 +200,6 @@ public class AnimationProps { return Interpolators.LINEAR; } - /** - * Returns the initial play time for a specific property, falling back to the general initial - * play time if there is no specific property interpolator. - */ - public long getInitialPlayTime(@PropType int propertyType) { - if (mPropInitialPlayTime != null) { - if (mPropInitialPlayTime.indexOfKey(propertyType) != -1) { - return mPropInitialPlayTime.get(propertyType); - } - return mPropInitialPlayTime.get(ALL, 0); - } - return 0; - } - /** * Sets an animator listener for this animation. */ diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsEntrancePathInterpolator.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsEntrancePathInterpolator.java new file mode 100644 index 000000000000..e32da2d3f6be --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsEntrancePathInterpolator.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.recents.views; + +import android.view.animation.PathInterpolator; + +/** + * A helper interpolator to stagger the entrance animation in recents by offsetting the start time + */ +public class RecentsEntrancePathInterpolator extends PathInterpolator { + final float mStartOffsetFraction; + + /** + * Create an interpolator for a cubic Bezier curve with an offset play time. The end points + * (0, 0) and (1, 1) are assumed. + * + * @param controlX1 The x coordinate of the first control point of the cubic Bezier. + * @param controlY1 The y coordinate of the first control point of the cubic Bezier. + * @param controlX2 The x coordinate of the second control point of the cubic Bezier. + * @param controlY2 The y coordinate of the second control point of the cubic Bezier. + * @param startOffsetFraction The fraction from 0 to 1 to start the animation from + */ + public RecentsEntrancePathInterpolator(float controlX1, float controlY1, float controlX2, + float controlY2, float startOffsetFraction) { + super(controlX1, controlY1, controlX2, controlY2); + mStartOffsetFraction = startOffsetFraction; + } + + @Override + public float getInterpolation(float t) { + return super.getInterpolation(t + mStartOffsetFraction); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java index f1314aba1b46..0fc68e6a96ce 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackAnimationHelper.java @@ -82,8 +82,6 @@ public class TaskStackAnimationHelper { private static final int ENTER_FROM_HOME_ALPHA_DURATION = 100; public static final int ENTER_FROM_HOME_TRANSLATION_DURATION = 300; - private static final Interpolator ENTER_FROM_HOME_TRANSLATION_INTERPOLATOR = - Interpolators.LINEAR_OUT_SLOW_IN; private static final Interpolator ENTER_FROM_HOME_ALPHA_INTERPOLATOR = Interpolators.LINEAR; public static final int EXIT_TO_HOME_TRANSLATION_DURATION = 200; @@ -260,17 +258,18 @@ public class TaskStackAnimationHelper { } else if (launchState.launchedFromHome) { // Animate the tasks up, but offset the animations to be relative to the front-most // task animation + final float startOffsetFraction = (float) (Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS, + taskIndexFromFront) * mEnterAndExitFromHomeTranslationOffset) / + ENTER_FROM_HOME_TRANSLATION_DURATION; AnimationProps taskAnimation = new AnimationProps() - .setInitialPlayTime(AnimationProps.BOUNDS, - Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS, taskIndexFromFront) * - mEnterAndExitFromHomeTranslationOffset) .setStartDelay(AnimationProps.ALPHA, Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS, taskIndexFromFront) * FRAME_OFFSET_MS) .setDuration(AnimationProps.BOUNDS, ENTER_FROM_HOME_TRANSLATION_DURATION) .setDuration(AnimationProps.ALPHA, ENTER_FROM_HOME_ALPHA_DURATION) .setInterpolator(AnimationProps.BOUNDS, - ENTER_FROM_HOME_TRANSLATION_INTERPOLATOR) + new RecentsEntrancePathInterpolator(0f, 0f, 0.2f, 1f, + startOffsetFraction)) .setInterpolator(AnimationProps.ALPHA, ENTER_FROM_HOME_ALPHA_INTERPOLATOR) .setListener(postAnimationTrigger.decrementOnAnimationEnd()); postAnimationTrigger.increment(); -- cgit v1.2.3-59-g8ed1b