Merge "Change default animation duration for all apps open and close." into ub-launcher3-calgary

This commit is contained in:
Hyunyoung Song
2016-07-27 18:55:29 +00:00
committed by Android (Google) Code Review
3 changed files with 20 additions and 5 deletions
+1
View File
@@ -26,6 +26,7 @@
<!-- Fade/zoom in/out duration & scale in a Launcher overlay transition. <!-- Fade/zoom in/out duration & scale in a Launcher overlay transition.
Note: This should be less than the config_overlayTransitionTime as they happen together. --> Note: This should be less than the config_overlayTransitionTime as they happen together. -->
<integer name="config_overlayRevealTime">220</integer> <integer name="config_overlayRevealTime">220</integer>
<integer name="config_overlaySlideRevealTime">320</integer>
<integer name="config_overlayTransitionTime">300</integer> <integer name="config_overlayTransitionTime">300</integer>
<integer name="config_overlayItemsAlphaStagger">60</integer> <integer name="config_overlayItemsAlphaStagger">60</integer>
@@ -237,6 +237,8 @@ public class LauncherStateTransitionAnimation {
final Resources res = mLauncher.getResources(); final Resources res = mLauncher.getResources();
final boolean material = Utilities.ATLEAST_LOLLIPOP; final boolean material = Utilities.ATLEAST_LOLLIPOP;
final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime); final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime);
final int revealDurationSlide = res.getInteger(R.integer.config_overlaySlideRevealTime);
final int itemsAlphaStagger = res.getInteger(R.integer.config_overlayItemsAlphaStagger); final int itemsAlphaStagger = res.getInteger(R.integer.config_overlayItemsAlphaStagger);
final View fromView = mLauncher.getWorkspace(); final View fromView = mLauncher.getWorkspace();
@@ -435,7 +437,7 @@ public class LauncherStateTransitionAnimation {
pCb.onTransitionComplete(); pCb.onTransitionComplete();
} }
}); });
mAllAppsController.animateToAllApps(animation, revealDuration); mAllAppsController.animateToAllApps(animation, revealDurationSlide);
dispatchOnLauncherTransitionPrepare(fromView, animated, false); dispatchOnLauncherTransitionPrepare(fromView, animated, false);
dispatchOnLauncherTransitionPrepare(toView, animated, false); dispatchOnLauncherTransitionPrepare(toView, animated, false);
@@ -680,6 +682,7 @@ public class LauncherStateTransitionAnimation {
final Resources res = mLauncher.getResources(); final Resources res = mLauncher.getResources();
final boolean material = Utilities.ATLEAST_LOLLIPOP; final boolean material = Utilities.ATLEAST_LOLLIPOP;
final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime); final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime);
final int revealDurationSlide = res.getInteger(R.integer.config_overlaySlideRevealTime);
final int itemsAlphaStagger = final int itemsAlphaStagger =
res.getInteger(R.integer.config_overlayItemsAlphaStagger); res.getInteger(R.integer.config_overlayItemsAlphaStagger);
@@ -918,7 +921,7 @@ public class LauncherStateTransitionAnimation {
} }
}); });
mAllAppsController.animateToWorkspace(animation, revealDuration); mAllAppsController.animateToWorkspace(animation, revealDurationSlide);
// Dispatch the prepare transition signal // Dispatch the prepare transition signal
dispatchOnLauncherTransitionPrepare(fromView, animated, multiplePagesVisible); dispatchOnLauncherTransitionPrepare(fromView, animated, multiplePagesVisible);
@@ -6,6 +6,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ArgbEvaluator; import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@@ -43,7 +44,8 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
private static final boolean DBG = false; private static final boolean DBG = false;
private final Interpolator mAccelInterpolator = new AccelerateInterpolator(2f); private final Interpolator mAccelInterpolator = new AccelerateInterpolator(2f);
private final Interpolator mDecelInterpolator = new DecelerateInterpolator(1f); private final Interpolator mFastOutSlowInInterpolator = new FastOutSlowInInterpolator();
private final Interpolator mScrollInterpolator = new PagedView.ScrollInterpolator();
private static final float ANIMATION_DURATION = 1200; private static final float ANIMATION_DURATION = 1200;
@@ -249,6 +251,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
public boolean isTransitioning() { public boolean isTransitioning() {
return mDetector.isDraggingOrSettling(); return mDetector.isDraggingOrSettling();
} }
/** /**
* @param start {@code true} if start of new drag. * @param start {@code true} if start of new drag.
*/ */
@@ -345,6 +348,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
} }
public void animateToAllApps(AnimatorSet animationOut, long duration) { public void animateToAllApps(AnimatorSet animationOut, long duration) {
Interpolator interpolator;
if (animationOut == null) { if (animationOut == null) {
return; return;
} }
@@ -352,12 +356,15 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
preparePull(true); preparePull(true);
mAnimationDuration = duration; mAnimationDuration = duration;
mShiftStart = mAppsView.getTranslationY(); mShiftStart = mAppsView.getTranslationY();
interpolator = mFastOutSlowInInterpolator;
} else {
interpolator = mScrollInterpolator;
} }
final float fromAllAppsTop = mAppsView.getTranslationY(); final float fromAllAppsTop = mAppsView.getTranslationY();
ObjectAnimator driftAndAlpha = ObjectAnimator.ofFloat(this, "progress", ObjectAnimator driftAndAlpha = ObjectAnimator.ofFloat(this, "progress",
fromAllAppsTop / mShiftRange, 0f); fromAllAppsTop / mShiftRange, 0f);
driftAndAlpha.setDuration(mAnimationDuration); driftAndAlpha.setDuration(mAnimationDuration);
driftAndAlpha.setInterpolator(new PagedView.ScrollInterpolator()); driftAndAlpha.setInterpolator(interpolator);
animationOut.play(driftAndAlpha); animationOut.play(driftAndAlpha);
animationOut.addListener(new AnimatorListenerAdapter() { animationOut.addListener(new AnimatorListenerAdapter() {
@@ -416,17 +423,21 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
if (animationOut == null) { if (animationOut == null) {
return; return;
} }
Interpolator interpolator;
if (mDetector.isIdleState()) { if (mDetector.isIdleState()) {
preparePull(true); preparePull(true);
mAnimationDuration = duration; mAnimationDuration = duration;
mShiftStart = mAppsView.getTranslationY(); mShiftStart = mAppsView.getTranslationY();
interpolator = mFastOutSlowInInterpolator;
} else {
interpolator = mScrollInterpolator;
} }
final float fromAllAppsTop = mAppsView.getTranslationY(); final float fromAllAppsTop = mAppsView.getTranslationY();
ObjectAnimator driftAndAlpha = ObjectAnimator.ofFloat(this, "progress", ObjectAnimator driftAndAlpha = ObjectAnimator.ofFloat(this, "progress",
fromAllAppsTop / mShiftRange, 1f); fromAllAppsTop / mShiftRange, 1f);
driftAndAlpha.setDuration(mAnimationDuration); driftAndAlpha.setDuration(mAnimationDuration);
driftAndAlpha.setInterpolator(new PagedView.ScrollInterpolator()); driftAndAlpha.setInterpolator(interpolator);
animationOut.play(driftAndAlpha); animationOut.play(driftAndAlpha);
animationOut.addListener(new AnimatorListenerAdapter() { animationOut.addListener(new AnimatorListenerAdapter() {