From 74a33141721c1ec5b3f4a112fb15e4781f1b2558 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Wed, 3 Apr 2024 12:29:08 -0700 Subject: [PATCH] Explicitly set animation and timings for split cancel button * Mismatched animation durations were causing recents task thumbnails to flash in at the end. * Following a similar pattern started at ag/26378432, except here we manually call all the steps to create launcherState animation Fixes: 321863575 Test: Repro steps from bug no longer occur. Tested on phone and large screen, workspace, overview and all apps Change-Id: I02696c0470bf4cfe6a278f0a2bc0786367a9fe37 (cherry picked from commit aeb9595b3764d64b5de63f4b4b546be3f5c182cd) --- .../views/SplitInstructionsView.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java b/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java index 6a59ab4875..a3e5a35fbb 100644 --- a/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java +++ b/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java @@ -16,10 +16,12 @@ package com.android.quickstep.views; +import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SPLIT_SELECTION_EXIT_CANCEL_BUTTON; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorSet; import android.content.Context; import android.util.AttributeSet; import android.util.FloatProperty; @@ -33,12 +35,14 @@ import androidx.dynamicanimation.animation.SpringAnimation; import androidx.dynamicanimation.animation.SpringForce; import com.android.app.animation.Interpolators; -import com.android.launcher3.LauncherState; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.config.FeatureFlags; +import com.android.launcher3.statemanager.BaseState; +import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.statemanager.StatefulActivity; +import com.android.launcher3.states.StateAnimationConfig; import com.android.quickstep.util.SplitSelectStateController; /** @@ -51,6 +55,7 @@ import com.android.quickstep.util.SplitSelectStateController; public class SplitInstructionsView extends LinearLayout { private static final int BOUNCE_DURATION = 250; private static final float BOUNCE_HEIGHT = 20; + private static final int DURATION_DEFAULT_SPLIT_DISMISS = 350; private final StatefulActivity mLauncher; public boolean mIsCurrentlyAnimating = false; @@ -137,9 +142,24 @@ public class SplitInstructionsView extends LinearLayout { SplitSelectStateController splitSelectController = ((RecentsView) mLauncher.getOverviewPanel()).getSplitSelectController(); - splitSelectController.getSplitAnimationController().playPlaceholderDismissAnim(mLauncher, - LAUNCHER_SPLIT_SELECTION_EXIT_CANCEL_BUTTON); - mLauncher.getStateManager().goToState(LauncherState.NORMAL); + StateManager stateManager = mLauncher.getStateManager(); + BaseState startState = stateManager.getState(); + long duration = startState.getTransitionDuration(mLauncher, false); + if (duration == 0) { + // Case where we're in contextual on workspace (NORMAL), which by default has 0 + // transition duration + duration = DURATION_DEFAULT_SPLIT_DISMISS; + } + StateAnimationConfig config = new StateAnimationConfig(); + config.duration = duration; + AnimatorSet stateAnim = stateManager.createAtomicAnimation( + startState, NORMAL, config); + AnimatorSet dismissAnim = splitSelectController.getSplitAnimationController() + .createPlaceholderDismissAnim(mLauncher, + LAUNCHER_SPLIT_SELECTION_EXIT_CANCEL_BUTTON, duration); + stateAnim.play(dismissAnim); + stateManager.setCurrentAnimation(stateAnim, NORMAL); + stateAnim.start(); } void ensureProperRotation() {