diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2019-06-20 11:34:14 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2019-06-21 12:47:56 -0700 |
commit | c4bb3739b1ff3b3e34daa1fc53550b2ef2e8398a (patch) | |
tree | 64a6f1b13972278c631fd0a28356b2c6479f19c3 /quickstep | |
parent | 06954c18faacdf440f09c2d0b67c03e68b192fd2 (diff) | |
download | android_packages_apps_Trebuchet-c4bb3739b1ff3b3e34daa1fc53550b2ef2e8398a.tar.gz android_packages_apps_Trebuchet-c4bb3739b1ff3b3e34daa1fc53550b2ef2e8398a.tar.bz2 android_packages_apps_Trebuchet-c4bb3739b1ff3b3e34daa1fc53550b2ef2e8398a.zip |
Cleaning up some animation states:
> When running one-off animations during quickstep, cancelling prevoisly
running animations.
> Cancelling such one-off animations when state is reset
> Preventing touch proxied from recent transition to affect quickswitch
(by affecting pagedView)
Bug: 135686388
Bug: 135571566
Change-Id: Id647015a583761d8fd46a02e3e2d88027e282a79
Diffstat (limited to 'quickstep')
4 files changed, 75 insertions, 68 deletions
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java index eac4dce18..371161ebd 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java @@ -16,25 +16,32 @@ package com.android.launcher3; +import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X; import static com.android.launcher3.LauncherState.NORMAL; +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.LINEAR; import static com.android.quickstep.TaskViewUtils.findTaskViewToLaunch; import static com.android.quickstep.TaskViewUtils.getRecentsWindowAnimator; +import static androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS; +import static androidx.dynamicanimation.animation.SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY; +import static androidx.dynamicanimation.animation.SpringForce.STIFFNESS_MEDIUM; + import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; -import android.app.ActivityOptions; import android.content.Context; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.Interpolators; +import com.android.launcher3.anim.SpringObjectAnimator; import com.android.quickstep.util.ClipAnimationHelper; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; @@ -46,11 +53,12 @@ import com.android.systemui.shared.system.RemoteAnimationTargetCompat; */ public final class LauncherAppTransitionManagerImpl extends QuickstepAppTransitionManagerImpl { - private RecentsView mRecentsView; + public static final int INDEX_SHELF_ANIM = 0; + public static final int INDEX_RECENTS_FADE_ANIM = 1; + public static final int INDEX_RECENTS_TRANSLATE_X_ANIM = 2; public LauncherAppTransitionManagerImpl(Context context) { super(context); - mRecentsView = mLauncher.getOverviewPanel(); } @Override @@ -133,4 +141,25 @@ public final class LauncherAppTransitionManagerImpl extends QuickstepAppTransiti mLauncher.getStateManager().reapplyState(); }; } + + @Override + public int getStateElementAnimationsCount() { + return 3; + } + + @Override + public Animator createStateElementAnimation(int index, float... values) { + switch (index) { + case INDEX_SHELF_ANIM: + return mLauncher.getAllAppsController().createSpringAnimation(values); + case INDEX_RECENTS_FADE_ANIM: + return ObjectAnimator.ofFloat(mLauncher.getOverviewPanel(), + RecentsView.CONTENT_ALPHA, values); + case INDEX_RECENTS_TRANSLATE_X_ANIM: + return new SpringObjectAnimator<>(mLauncher.getOverviewPanel(), + VIEW_TRANSLATE_X, MIN_VISIBLE_CHANGE_PIXELS, 0.8f, 250, values); + default: + return super.createStateElementAnimation(index, values); + } + } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java index 755d978fc..07c049642 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java @@ -16,14 +16,15 @@ package com.android.quickstep; import static android.view.View.TRANSLATION_Y; + import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; +import static com.android.launcher3.LauncherAppTransitionManagerImpl.INDEX_RECENTS_FADE_ANIM; +import static com.android.launcher3.LauncherAppTransitionManagerImpl.INDEX_RECENTS_TRANSLATE_X_ANIM; +import static com.android.launcher3.LauncherAppTransitionManagerImpl.INDEX_SHELF_ANIM; import static com.android.launcher3.LauncherState.BACKGROUND_APP; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.LauncherStateManager.ANIM_ALL; -import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS; -import static com.android.launcher3.allapps.AllAppsTransitionController.SPRING_DAMPING_RATIO; -import static com.android.launcher3.allapps.AllAppsTransitionController.SPRING_STIFFNESS; import static com.android.launcher3.anim.Interpolators.ACCEL_2; import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL; import static com.android.launcher3.anim.Interpolators.INSTANT; @@ -31,7 +32,6 @@ import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.quickstep.WindowTransformSwipeHandler.RECENTS_ATTACH_DURATION; import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; @@ -48,8 +48,6 @@ import android.view.animation.Interpolator; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.UiThread; -import androidx.dynamicanimation.animation.SpringAnimation; -import androidx.dynamicanimation.animation.SpringForce; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; @@ -60,7 +58,6 @@ import com.android.launcher3.LauncherStateManager; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.AnimatorSetBuilder; -import com.android.launcher3.anim.SpringObjectAnimator; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.uioverrides.states.OverviewState; import com.android.launcher3.userevent.nano.LauncherLogProto; @@ -68,6 +65,7 @@ import com.android.launcher3.views.FloatingIconView; import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.util.StaggeredWorkspaceAnim; +import com.android.quickstep.views.LauncherRecentsView; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; @@ -217,10 +215,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe activity.getAppsView().getContentView().setVisibility(View.GONE); return new AnimationFactory() { - private Animator mShelfAnim; private ShelfAnimState mShelfState; - private Animator mAttachToWindowFadeAnim; - private SpringAnimation mAttachToWindowTranslationXAnim; private boolean mIsAttachedToWindow; @Override @@ -253,9 +248,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe return; } mShelfState = shelfState; - if (mShelfAnim != null) { - mShelfAnim.cancel(); - } + activity.getStateManager().cancelStateElementAnimation(INDEX_SHELF_ANIM); if (mShelfState == ShelfAnimState.CANCEL) { return; } @@ -271,16 +264,10 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe : mShelfState == ShelfAnimState.PEEK ? shelfPeekingProgress : shelfOverviewProgress; - mShelfAnim = createShelfAnim(activity, toProgress); - mShelfAnim.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - mShelfAnim = null; - } - }); - mShelfAnim.setInterpolator(interpolator); - mShelfAnim.setDuration(duration); - mShelfAnim.start(); + Animator shelfAnim = activity.getStateManager() + .createStateElementAnimation(INDEX_SHELF_ANIM, toProgress); + shelfAnim.setInterpolator(interpolator); + shelfAnim.setDuration(duration).start(); } @Override @@ -289,12 +276,10 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe return; } mIsAttachedToWindow = attached; - if (mAttachToWindowFadeAnim != null) { - mAttachToWindowFadeAnim.cancel(); - } - RecentsView recentsView = activity.getOverviewPanel(); - mAttachToWindowFadeAnim = ObjectAnimator.ofFloat(recentsView, - RecentsView.CONTENT_ALPHA, attached ? 1 : 0); + LauncherRecentsView recentsView = activity.getOverviewPanel(); + Animator fadeAnim = activity.getStateManager() + .createStateElementAnimation( + INDEX_RECENTS_FADE_ANIM, attached ? 1 : 0); int runningTaskIndex = recentsView.getRunningTaskIndex(); if (runningTaskIndex == 0) { @@ -316,33 +301,28 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe float fromTranslationX = attached ? offscreenX - scrollOffsetX : 0; float toTranslationX = attached ? 0 : offscreenX - scrollOffsetX; - if (mAttachToWindowTranslationXAnim == null) { - mAttachToWindowTranslationXAnim = new SpringAnimation(recentsView, - SpringAnimation.TRANSLATION_X).setSpring(new SpringForce() - .setDampingRatio(0.8f) - .setStiffness(250)); - } + activity.getStateManager() + .cancelStateElementAnimation(INDEX_RECENTS_TRANSLATE_X_ANIM); + if (!recentsView.isShown() && animate) { recentsView.setTranslationX(fromTranslationX); - mAttachToWindowTranslationXAnim.setStartValue(fromTranslationX); + } else { + fromTranslationX = recentsView.getTranslationX(); } - mAttachToWindowTranslationXAnim.animateToFinalPosition(toTranslationX); - if (!animate && mAttachToWindowTranslationXAnim.canSkipToEnd()) { - mAttachToWindowTranslationXAnim.skipToEnd(); + + if (!animate) { + recentsView.setTranslationX(toTranslationX); + } else { + activity.getStateManager().createStateElementAnimation( + INDEX_RECENTS_TRANSLATE_X_ANIM, + fromTranslationX, toTranslationX).start(); } - mAttachToWindowFadeAnim.setInterpolator(attached ? INSTANT : ACCEL_2); + fadeAnim.setInterpolator(attached ? INSTANT : ACCEL_2); } else { - mAttachToWindowFadeAnim.setInterpolator(ACCEL_DEACCEL); + fadeAnim.setInterpolator(ACCEL_DEACCEL); } - mAttachToWindowFadeAnim.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - mAttachToWindowFadeAnim = null; - } - }); - mAttachToWindowFadeAnim.setDuration(animate ? RECENTS_ATTACH_DURATION : 0); - mAttachToWindowFadeAnim.start(); + fadeAnim.setDuration(animate ? RECENTS_ATTACH_DURATION : 0).start(); } }; } @@ -358,10 +338,10 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe if (!activity.getDeviceProfile().isVerticalBarLayout() && SysUINavigationMode.getMode(activity) != Mode.NO_BUTTON) { // Don't animate the shelf when the mode is NO_BUTTON, because we update it atomically. - Animator shiftAnim = createShelfAnim(activity, + anim.play(activity.getStateManager().createStateElementAnimation( + INDEX_SHELF_ANIM, fromState.getVerticalProgress(activity), - endState.getVerticalProgress(activity)); - anim.play(shiftAnim); + endState.getVerticalProgress(activity))); } playScaleDownAnim(anim, activity, fromState, endState); @@ -379,13 +359,6 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe callback.accept(controller); } - private Animator createShelfAnim(Launcher activity, float ... progressValues) { - Animator shiftAnim = new SpringObjectAnimator<>(activity.getAllAppsController(), - ALL_APPS_PROGRESS, activity.getAllAppsController().getShiftRange(), - SPRING_DAMPING_RATIO, SPRING_STIFFNESS, progressValues); - return shiftAnim; - } - /** * Scale down recents from the center task being full screen to being in overview. */ diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java index 5eecf1713..ddd28a350 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java @@ -19,6 +19,8 @@ import static android.view.MotionEvent.ACTION_CANCEL; import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_UP; +import static com.android.launcher3.Utilities.FLAG_NO_GESTURES; + import android.view.InputEvent; import android.view.KeyEvent; import android.view.MotionEvent; @@ -182,7 +184,10 @@ public class RecentsAnimationWrapper { } } if (mInputConsumer != null) { + int flags = ev.getEdgeFlags(); + ev.setEdgeFlags(flags | FLAG_NO_GESTURES); mInputConsumer.onMotionEvent(ev); + ev.setEdgeFlags(flags); } return true; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index 06a8e2eaf..a98df0fa1 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -16,6 +16,8 @@ package com.android.quickstep.views; +import static androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS; + import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS; import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; @@ -125,10 +127,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl private static final String TAG = RecentsView.class.getSimpleName(); - public static final float SPRING_MIN_VISIBLE_CHANGE = 0.001f; - public static final float SPRING_DAMPING_RATIO = SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY; - public static final float SPRING_STIFFNESS = SpringForce.STIFFNESS_MEDIUM; - public static final FloatProperty<RecentsView> CONTENT_ALPHA = new FloatProperty<RecentsView>("contentAlpha") { @Override @@ -1033,7 +1031,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl addAnim(ObjectAnimator.ofFloat(taskView, ALPHA, 0), duration, ACCEL_2, anim); if (QUICKSTEP_SPRINGS.get() && taskView instanceof TaskView) addAnim(new SpringObjectAnimator<>(taskView, VIEW_TRANSLATE_Y, - SPRING_MIN_VISIBLE_CHANGE, SPRING_DAMPING_RATIO, SPRING_STIFFNESS, + MIN_VISIBLE_CHANGE_PIXELS, SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY, + SpringForce.STIFFNESS_MEDIUM, 0, -taskView.getHeight()), duration, LINEAR, anim); else { @@ -1111,7 +1110,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl if (scrollDiff != 0) { if (QUICKSTEP_SPRINGS.get() && child instanceof TaskView) { addAnim(new SpringObjectAnimator<>(child, VIEW_TRANSLATE_X, - SPRING_MIN_VISIBLE_CHANGE, SPRING_DAMPING_RATIO, SPRING_STIFFNESS, + MIN_VISIBLE_CHANGE_PIXELS, SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY, + SpringForce.STIFFNESS_MEDIUM, 0, scrollDiff), duration, ACCEL, anim); } else { addAnim(ObjectAnimator.ofFloat(child, TRANSLATION_X, scrollDiff), duration, |