Merge "Add back recents staggering entrance animation" into oc-dev

am: 229119e06b

Change-Id: I4516daadd7ec9ceba523b3b6e1d58f6843c7600d
This commit is contained in:
Matthew Ng
2017-06-06 19:24:43 +00:00
committed by android-build-merger
3 changed files with 52 additions and 36 deletions

View File

@@ -54,7 +54,6 @@ public class AnimationProps {
public static final int FOCUS_STATE = 8; public static final int FOCUS_STATE = 8;
private SparseLongArray mPropStartDelay; private SparseLongArray mPropStartDelay;
private SparseLongArray mPropInitialPlayTime;
private SparseLongArray mPropDuration; private SparseLongArray mPropDuration;
private SparseArray<Interpolator> mPropInterpolators; private SparseArray<Interpolator> mPropInterpolators;
private Animator.AnimatorListener mListener; private Animator.AnimatorListener mListener;
@@ -122,10 +121,6 @@ public class AnimationProps {
animator.setStartDelay(getStartDelay(propertyType)); animator.setStartDelay(getStartDelay(propertyType));
animator.setDuration(getDuration(propertyType)); animator.setDuration(getDuration(propertyType));
animator.setInterpolator(getInterpolator(propertyType)); animator.setInterpolator(getInterpolator(propertyType));
long initialPlayTime = getInitialPlayTime(propertyType);
if (initialPlayTime != 0) {
animator.setCurrentPlayTime(initialPlayTime);
}
return animator; return animator;
} }
@@ -140,17 +135,6 @@ public class AnimationProps {
return this; 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. * Returns the start delay for a specific property.
*/ */
@@ -216,20 +200,6 @@ public class AnimationProps {
return Interpolators.LINEAR; 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. * Sets an animator listener for this animation.
*/ */

View File

@@ -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
* <code>(0, 0)</code> and <code>(1, 1)</code> 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);
}
}

View File

@@ -82,8 +82,6 @@ public class TaskStackAnimationHelper {
private static final int ENTER_FROM_HOME_ALPHA_DURATION = 100; private static final int ENTER_FROM_HOME_ALPHA_DURATION = 100;
public static final int ENTER_FROM_HOME_TRANSLATION_DURATION = 300; 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; private static final Interpolator ENTER_FROM_HOME_ALPHA_INTERPOLATOR = Interpolators.LINEAR;
public static final int EXIT_TO_HOME_TRANSLATION_DURATION = 200; public static final int EXIT_TO_HOME_TRANSLATION_DURATION = 200;
@@ -260,17 +258,18 @@ public class TaskStackAnimationHelper {
} else if (launchState.launchedFromHome) { } else if (launchState.launchedFromHome) {
// Animate the tasks up, but offset the animations to be relative to the front-most // Animate the tasks up, but offset the animations to be relative to the front-most
// task animation // task animation
final float startOffsetFraction = (float) (Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS,
taskIndexFromFront) * mEnterAndExitFromHomeTranslationOffset) /
ENTER_FROM_HOME_TRANSLATION_DURATION;
AnimationProps taskAnimation = new AnimationProps() AnimationProps taskAnimation = new AnimationProps()
.setInitialPlayTime(AnimationProps.BOUNDS,
Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS, taskIndexFromFront) *
mEnterAndExitFromHomeTranslationOffset)
.setStartDelay(AnimationProps.ALPHA, .setStartDelay(AnimationProps.ALPHA,
Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS, taskIndexFromFront) * Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS, taskIndexFromFront) *
FRAME_OFFSET_MS) FRAME_OFFSET_MS)
.setDuration(AnimationProps.BOUNDS, ENTER_FROM_HOME_TRANSLATION_DURATION) .setDuration(AnimationProps.BOUNDS, ENTER_FROM_HOME_TRANSLATION_DURATION)
.setDuration(AnimationProps.ALPHA, ENTER_FROM_HOME_ALPHA_DURATION) .setDuration(AnimationProps.ALPHA, ENTER_FROM_HOME_ALPHA_DURATION)
.setInterpolator(AnimationProps.BOUNDS, .setInterpolator(AnimationProps.BOUNDS,
ENTER_FROM_HOME_TRANSLATION_INTERPOLATOR) new RecentsEntrancePathInterpolator(0f, 0f, 0.2f, 1f,
startOffsetFraction))
.setInterpolator(AnimationProps.ALPHA, ENTER_FROM_HOME_ALPHA_INTERPOLATOR) .setInterpolator(AnimationProps.ALPHA, ENTER_FROM_HOME_ALPHA_INTERPOLATOR)
.setListener(postAnimationTrigger.decrementOnAnimationEnd()); .setListener(postAnimationTrigger.decrementOnAnimationEnd());
postAnimationTrigger.increment(); postAnimationTrigger.increment();