From 118295e07c5b44d9999a5f8631617afc599567fd Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Thu, 26 Apr 2018 14:47:44 +0200 Subject: [PATCH] Fix some jank with transitions - Animations in WorkspacePageIndicator while the app transition was running was causing layer trashing, potentially leading to jank. - Make sure to use a layer in the wallpaper open animation. Test: Open app while indicators are about to fade out. Bug: 75985430 Change-Id: Iad6a511d98dff81b5cde727f4472f0f039ffc4be --- .../LauncherAppTransitionManagerImpl.java | 12 ++++++++- .../WorkspacePageIndicator.java | 25 ++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java index ab350e49ca..731c4191d9 100644 --- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java +++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java @@ -333,10 +333,14 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag launcherAnimator.play(dragLayerAlpha); launcherAnimator.play(dragLayerTransY); mDragLayer.setLayerType(View.LAYER_TYPE_HARDWARE, null); + + // Pause page indicator animations as they lead to layer trashing. + mLauncher.getWorkspace().getPageIndicator().pauseAnimations(); endListener = () -> { mDragLayer.setLayerType(View.LAYER_TYPE_NONE, null); mDragLayer.setAlpha(1); mDragLayer.setTranslationY(0); + mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd(); }; } return new Pair<>(launcherAnimator, endListener); @@ -699,6 +703,13 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag workspaceAnimator.setStartDelay(LAUNCHER_RESUME_START_DELAY); workspaceAnimator.setDuration(333); workspaceAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); + currentPage.setLayerType(View.LAYER_TYPE_HARDWARE, null); + workspaceAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + currentPage.setLayerType(View.LAYER_TYPE_NONE, null); + } + }); // Animate the shelf in two parts: slide in, and overeshoot. AllAppsTransitionController allAppsController = mLauncher.getAllAppsController(); @@ -720,7 +731,6 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag allAppsOvershoot.setDuration(153); allAppsOvershoot.setInterpolator(Interpolators.OVERSHOOT_0); - anim.play(workspaceAnimator); anim.playSequentially(allAppsSlideIn, allAppsOvershoot); anim.addListener(mReapplyStateListener); diff --git a/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java b/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java index 3c16cde24f..1383f53aba 100644 --- a/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java +++ b/src/com/android/launcher3/pageindicators/WorkspacePageIndicator.java @@ -41,8 +41,9 @@ public class WorkspacePageIndicator extends View implements Insettable, PageIndi private static final int LINE_ALPHA_ANIMATOR_INDEX = 0; private static final int NUM_PAGES_ANIMATOR_INDEX = 1; private static final int TOTAL_SCROLL_ANIMATOR_INDEX = 2; + private static final int ANIMATOR_COUNT = 3; - private ValueAnimator[] mAnimators = new ValueAnimator[3]; + private ValueAnimator[] mAnimators = new ValueAnimator[ANIMATOR_COUNT]; private final Handler mDelayedLineFadeHandler = new Handler(Looper.getMainLooper()); private final Launcher mLauncher; @@ -232,6 +233,28 @@ public class WorkspacePageIndicator extends View implements Insettable, PageIndi mAnimators[animatorIndex].start(); } + /** + * Pauses all currently running animations. + */ + public void pauseAnimations() { + for (int i = 0; i < ANIMATOR_COUNT; i++) { + if (mAnimators[i] != null) { + mAnimators[i].pause(); + } + } + } + + /** + * Force-ends all currently running or paused animations. + */ + public void skipAnimationsToEnd() { + for (int i = 0; i < ANIMATOR_COUNT; i++) { + if (mAnimators[i] != null) { + mAnimators[i].end(); + } + } + } + @Override public void setInsets(Rect insets) { DeviceProfile grid = mLauncher.getDeviceProfile();