Tweaks to app closing animation.

Change-Id: Ia2cbc1401a57ad8dc3e3553110497eb35c19fe64
This commit is contained in:
Jon Miranda committed 2018-05-09 12:51:34 -07:00
1 parent 639b07178f
commit d26d5aaa6d
3 files changed
+56 -72

No files matched your search

+3 -2
View File
@@ -30,8 +30,9 @@
<dimen name="quickstep_fling_min_velocity">250dp</dimen> <dimen name="quickstep_fling_min_velocity">250dp</dimen>
<!-- Launcher app transition --> <!-- Launcher app transition -->
<dimen name="content_trans_y">25dp</dimen> <dimen name="content_trans_y">50dp</dimen>
<dimen name="workspace_trans_y">80dp</dimen> <dimen name="workspace_trans_y">50dp</dimen>
<dimen name="closing_window_trans_y">115dp</dimen>
<dimen name="recents_empty_message_text_size">16sp</dimen> <dimen name="recents_empty_message_text_size">16sp</dimen>
<dimen name="recents_empty_message_text_padding">16dp</dimen> <dimen name="recents_empty_message_text_padding">16dp</dimen>
@@ -19,12 +19,11 @@ package com.android.launcher3;
import static com.android.launcher3.BaseActivity.INVISIBLE_ALL; import static com.android.launcher3.BaseActivity.INVISIBLE_ALL;
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_APP_TRANSITIONS; import static com.android.launcher3.BaseActivity.INVISIBLE_BY_APP_TRANSITIONS;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.Utilities.postAsyncCallback; import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE; import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT; import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
import static com.android.launcher3.anim.Interpolators.APP_CLOSE_ALPHA;
import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.quickstep.TaskUtils.findTaskViewToLaunch; import static com.android.quickstep.TaskUtils.findTaskViewToLaunch;
import static com.android.quickstep.TaskUtils.getRecentsWindowAnimator; import static com.android.quickstep.TaskUtils.getRecentsWindowAnimator;
@@ -58,7 +57,6 @@ import android.view.ViewGroup;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener; import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.InsettableFrameLayout.LayoutParams; import com.android.launcher3.InsettableFrameLayout.LayoutParams;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators; import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.dragndrop.DragLayer;
@@ -102,11 +100,10 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
public static final int RECENTS_LAUNCH_DURATION = 336; public static final int RECENTS_LAUNCH_DURATION = 336;
private static final int LAUNCHER_RESUME_START_DELAY = 100; private static final int LAUNCHER_RESUME_START_DELAY = 100;
private static final int CLOSING_TRANSITION_DURATION_MS = 350; private static final int CLOSING_TRANSITION_DURATION_MS = 250;
// Progress = 0: All apps is fully pulled up, Progress = 1: All apps is fully pulled down. // Progress = 0: All apps is fully pulled up, Progress = 1: All apps is fully pulled down.
public static final float ALL_APPS_PROGRESS_OFF_SCREEN = 1.3059858f; public static final float ALL_APPS_PROGRESS_OFF_SCREEN = 1.3059858f;
public static final float ALL_APPS_PROGRESS_OVERSHOOT = 0.99581414f;
private final DragLayer mDragLayer; private final DragLayer mDragLayer;
private final Launcher mLauncher; private final Launcher mLauncher;
@@ -116,6 +113,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
private final float mContentTransY; private final float mContentTransY;
private final float mWorkspaceTransY; private final float mWorkspaceTransY;
private final float mClosingWindowTransY;
private DeviceProfile mDeviceProfile; private DeviceProfile mDeviceProfile;
private View mFloatingView; private View mFloatingView;
@@ -129,6 +127,16 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
} }
}; };
private final Runnable mDragLayerResetRunnable = new Runnable() {
@Override
public void run() {
mDragLayer.setLayerType(View.LAYER_TYPE_NONE, null);
mDragLayer.setAlpha(1);
mDragLayer.setTranslationY(0);
mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd();
}
};
private final AnimatorListenerAdapter mForceInvisibleListener = new AnimatorListenerAdapter() { private final AnimatorListenerAdapter mForceInvisibleListener = new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationStart(Animator animation) { public void onAnimationStart(Animator animation) {
@@ -151,6 +159,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
Resources res = mLauncher.getResources(); Resources res = mLauncher.getResources();
mContentTransY = res.getDimensionPixelSize(R.dimen.content_trans_y); mContentTransY = res.getDimensionPixelSize(R.dimen.content_trans_y);
mWorkspaceTransY = res.getDimensionPixelSize(R.dimen.workspace_trans_y); mWorkspaceTransY = res.getDimensionPixelSize(R.dimen.workspace_trans_y);
mClosingWindowTransY = res.getDimensionPixelSize(R.dimen.closing_window_trans_y);
mLauncher.addOnDeviceProfileChangeListener(this); mLauncher.addOnDeviceProfileChangeListener(this);
registerRemoteAnimations(); registerRemoteAnimations();
@@ -187,7 +196,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
anim.play(getIconAnimator(v)); anim.play(getIconAnimator(v));
if (launcherClosing) { if (launcherClosing) {
Pair<AnimatorSet, Runnable> launcherContentAnimator = Pair<AnimatorSet, Runnable> launcherContentAnimator =
getLauncherContentAnimator(false /* show */); getLauncherContentAnimator(true /* isAppOpening */);
anim.play(launcherContentAnimator.first); anim.play(launcherContentAnimator.first);
anim.addListener(new AnimatorListenerAdapter() { anim.addListener(new AnimatorListenerAdapter() {
@Override @Override
@@ -281,21 +290,21 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
/** /**
* Content is everything on screen except the background and the floating view (if any). * Content is everything on screen except the background and the floating view (if any).
* *
* @param show If true: Animate the content so that it moves upwards and fades in. * @param isAppOpening True when this is called when an app is opening.
* Else: Animate the content so that it moves downwards and fades out. * False when this is called when an app is closing.
*/ */
private Pair<AnimatorSet, Runnable> getLauncherContentAnimator(boolean show) { private Pair<AnimatorSet, Runnable> getLauncherContentAnimator(boolean isAppOpening) {
AnimatorSet launcherAnimator = new AnimatorSet(); AnimatorSet launcherAnimator = new AnimatorSet();
Runnable endListener; Runnable endListener;
float[] alphas = show if (mLauncher.isInState(ALL_APPS)) {
? new float[] {0, 1} float[] alphas = isAppOpening
: new float[] {1, 0}; ? new float[] {1, 0}
float[] trans = show : new float[] {0, 1};
? new float[] {mContentTransY, 0,} float[] trans = isAppOpening
: new float[] {0, mContentTransY}; ? new float[] {0, mContentTransY}
: new float[] {-mContentTransY, 0};
if (mLauncher.isInState(LauncherState.ALL_APPS) && !mDeviceProfile.isVerticalBarLayout()) {
// All Apps in portrait mode is full screen, so we only animate AllAppsContainerView. // All Apps in portrait mode is full screen, so we only animate AllAppsContainerView.
final View appsView = mLauncher.getAppsView(); final View appsView = mLauncher.getAppsView();
final float startAlpha = appsView.getAlpha(); final float startAlpha = appsView.getAlpha();
@@ -326,6 +335,9 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
appsView.setLayerType(View.LAYER_TYPE_NONE, null); appsView.setLayerType(View.LAYER_TYPE_NONE, null);
}; };
} else { } else {
float[] alphas = new float[] {1, 0};
float[] trans = new float[] {0, mContentTransY};
mDragLayer.setAlpha(alphas[0]); mDragLayer.setAlpha(alphas[0]);
mDragLayer.setTranslationY(trans[0]); mDragLayer.setTranslationY(trans[0]);
@@ -343,12 +355,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
// Pause page indicator animations as they lead to layer trashing. // Pause page indicator animations as they lead to layer trashing.
mLauncher.getWorkspace().getPageIndicator().pauseAnimations(); mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
endListener = () -> { endListener = mDragLayerResetRunnable;
mDragLayer.setLayerType(View.LAYER_TYPE_NONE, null);
mDragLayer.setAlpha(1);
mDragLayer.setTranslationY(0);
mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd();
};
} }
return new Pair<>(launcherAnimator, endListener); return new Pair<>(launcherAnimator, endListener);
} }
@@ -646,16 +653,14 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
*/ */
private Animator getClosingWindowAnimators(RemoteAnimationTargetCompat[] targets) { private Animator getClosingWindowAnimators(RemoteAnimationTargetCompat[] targets) {
Matrix matrix = new Matrix(); Matrix matrix = new Matrix();
float height = mLauncher.getDeviceProfile().heightPx;
float width = mLauncher.getDeviceProfile().widthPx;
float endX = (mLauncher.<RecentsView>getOverviewPanel().isRtl() ? -width : width) * 1.16f;
ValueAnimator closingAnimator = ValueAnimator.ofFloat(0, 1); ValueAnimator closingAnimator = ValueAnimator.ofFloat(0, 1);
closingAnimator.setDuration(CLOSING_TRANSITION_DURATION_MS); int duration = CLOSING_TRANSITION_DURATION_MS;
closingAnimator.setDuration(duration);
Rect crop = new Rect();
closingAnimator.addUpdateListener(new MultiValueUpdateListener() { closingAnimator.addUpdateListener(new MultiValueUpdateListener() {
FloatProp mDx = new FloatProp(0, endX, 0, 350, AGGRESSIVE_EASE_IN_OUT); FloatProp mDy = new FloatProp(0, mClosingWindowTransY, 0, duration, DEACCEL_1_7);
FloatProp mScale = new FloatProp(1f, 0.8f, 0, 267, AGGRESSIVE_EASE); FloatProp mScale = new FloatProp(1f, 1.075f, 0, duration, DEACCEL_1_7);
FloatProp mAlpha = new FloatProp(1f, 0f, 0, 350, APP_CLOSE_ALPHA); FloatProp mAlpha = new FloatProp(1f, 0f, 0, duration, DEACCEL_1_7);
boolean isFirstFrame = true; boolean isFirstFrame = true;
@@ -667,13 +672,16 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
isFirstFrame = false; isFirstFrame = false;
} }
for (RemoteAnimationTargetCompat app : targets) { for (RemoteAnimationTargetCompat app : targets) {
crop.set(app.clipRect);
crop.top = mDeviceProfile.getInsets().top;
if (app.mode == RemoteAnimationTargetCompat.MODE_CLOSING) { if (app.mode == RemoteAnimationTargetCompat.MODE_CLOSING) {
t.setAlpha(app.leash, mAlpha.value); t.setAlpha(app.leash, mAlpha.value);
matrix.setScale(mScale.value, mScale.value, matrix.setScale(mScale.value, mScale.value,
app.sourceContainerBounds.centerX(), app.sourceContainerBounds.centerX(),
app.sourceContainerBounds.centerY()); app.sourceContainerBounds.centerY());
matrix.postTranslate(mDx.value, 0); matrix.postTranslate(0, mDy.value);
matrix.postTranslate(app.position.x, app.position.y); matrix.postTranslate(app.position.x, app.position.y);
t.setWindowCrop(app.leash, crop);
t.setMatrix(app.leash, matrix); t.setMatrix(app.leash, matrix);
} }
} }
@@ -694,7 +702,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
if (mLauncher.isInState(LauncherState.ALL_APPS) if (mLauncher.isInState(LauncherState.ALL_APPS)
|| mLauncher.getDeviceProfile().isVerticalBarLayout()) { || mLauncher.getDeviceProfile().isVerticalBarLayout()) {
Pair<AnimatorSet, Runnable> contentAnimator = Pair<AnimatorSet, Runnable> contentAnimator =
getLauncherContentAnimator(true /* show */); getLauncherContentAnimator(false /* isAppOpening */);
contentAnimator.first.setStartDelay(LAUNCHER_RESUME_START_DELAY); contentAnimator.first.setStartDelay(LAUNCHER_RESUME_START_DELAY);
anim.play(contentAnimator.first); anim.play(contentAnimator.first);
anim.addListener(new AnimatorListenerAdapter() { anim.addListener(new AnimatorListenerAdapter() {
@@ -706,53 +714,29 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
} else { } else {
AnimatorSet workspaceAnimator = new AnimatorSet(); AnimatorSet workspaceAnimator = new AnimatorSet();
mLauncher.getWorkspace().setTranslationY(mWorkspaceTransY); mDragLayer.setTranslationY(-mWorkspaceTransY);
workspaceAnimator.play(ObjectAnimator.ofFloat(mLauncher.getWorkspace(), workspaceAnimator.play(ObjectAnimator.ofFloat(mDragLayer, View.TRANSLATION_Y,
View.TRANSLATION_Y, mWorkspaceTransY, 0)); -mWorkspaceTransY, 0));
View currentPage = ((CellLayout) mLauncher.getWorkspace() mDragLayer.setAlpha(0);
.getChildAt(mLauncher.getWorkspace().getCurrentPage())) workspaceAnimator.play(ObjectAnimator.ofFloat(mDragLayer, View.ALPHA, 0, 1f));
.getShortcutsAndWidgets();
currentPage.setAlpha(0f);
workspaceAnimator.play(ObjectAnimator.ofFloat(currentPage, View.ALPHA, 0, 1f));
workspaceAnimator.setStartDelay(LAUNCHER_RESUME_START_DELAY); workspaceAnimator.setStartDelay(LAUNCHER_RESUME_START_DELAY);
workspaceAnimator.setDuration(333); workspaceAnimator.setDuration(333);
workspaceAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); workspaceAnimator.setInterpolator(Interpolators.DEACCEL_1_7);
currentPage.setLayerType(View.LAYER_TYPE_HARDWARE, null);
// Pause page indicator animations as they lead to layer trashing.
mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
mDragLayer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
workspaceAnimator.addListener(new AnimatorListenerAdapter() { workspaceAnimator.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
currentPage.setLayerType(View.LAYER_TYPE_NONE, null); mDragLayerResetRunnable.run();
} }
}); });
// Animate the shelf in two parts: slide in, and overeshoot.
AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
// The shelf will start offscreen
final float startY = ALL_APPS_PROGRESS_OFF_SCREEN;
// And will end slightly pulled up, so that there is something to overshoot back to 1f.
final float slideEnd = ALL_APPS_PROGRESS_OVERSHOOT;
allAppsController.setProgress(startY);
Animator allAppsSlideIn =
ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS, startY, slideEnd);
allAppsSlideIn.setStartDelay(LAUNCHER_RESUME_START_DELAY);
allAppsSlideIn.setDuration(317);
allAppsSlideIn.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
Animator allAppsOvershoot =
ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS, slideEnd, 1f);
allAppsOvershoot.setDuration(153);
allAppsOvershoot.setInterpolator(Interpolators.OVERSHOOT_0);
anim.play(workspaceAnimator); anim.play(workspaceAnimator);
anim.playSequentially(allAppsSlideIn, allAppsOvershoot);
anim.addListener(mReapplyStateListener);
} }
} }
private boolean hasControlRemoteAppTransitionPermission() { private boolean hasControlRemoteAppTransitionPermission() {
return mLauncher.checkSelfPermission(CONTROL_REMOTE_APP_TRANSITION_PERMISSION) return mLauncher.checkSelfPermission(CONTROL_REMOTE_APP_TRANSITION_PERMISSION)
== PackageManager.PERMISSION_GRANTED; == PackageManager.PERMISSION_GRANTED;
@@ -38,6 +38,7 @@ public class Interpolators {
public static final Interpolator DEACCEL = new DecelerateInterpolator(); public static final Interpolator DEACCEL = new DecelerateInterpolator();
public static final Interpolator DEACCEL_1_5 = new DecelerateInterpolator(1.5f); public static final Interpolator DEACCEL_1_5 = new DecelerateInterpolator(1.5f);
public static final Interpolator DEACCEL_1_7 = new DecelerateInterpolator(1.7f);
public static final Interpolator DEACCEL_2 = new DecelerateInterpolator(2); public static final Interpolator DEACCEL_2 = new DecelerateInterpolator(2);
public static final Interpolator DEACCEL_2_5 = new DecelerateInterpolator(2.5f); public static final Interpolator DEACCEL_2_5 = new DecelerateInterpolator(2.5f);
public static final Interpolator DEACCEL_3 = new DecelerateInterpolator(3f); public static final Interpolator DEACCEL_3 = new DecelerateInterpolator(3f);
@@ -57,8 +58,6 @@ public class Interpolators {
EXAGGERATED_EASE = new PathInterpolator(exaggeratedEase); EXAGGERATED_EASE = new PathInterpolator(exaggeratedEase);
} }
public static final Interpolator APP_CLOSE_ALPHA = new PathInterpolator(0.4f, 0, 1f, 1f);
public static final Interpolator OVERSHOOT_0 = new OvershootInterpolator(0); public static final Interpolator OVERSHOOT_0 = new OvershootInterpolator(0);
public static final Interpolator TOUCH_RESPONSE_INTERPOLATOR = public static final Interpolator TOUCH_RESPONSE_INTERPOLATOR =