From 5fcc3a90b0fc302dc89c740e5d177bb0a89a7dfb Mon Sep 17 00:00:00 2001 From: Cyrus Boadway Date: Fri, 11 Jun 2021 17:27:49 +0000 Subject: [PATCH] Fix foreground position during widget home animation The home return animation applies a position animation to all views in the workspace. Since the widget uses a GhostView of the original widget to represent the foreground of the animation, that animation was reflected in the foreground's positioning. The CL creates an ignore list of workspace views to which an animator should not be applied. Bug: 190488979 Test: manual Change-Id: I5a86165e945336693eedd253a02bda1e1eb6662d --- .../quickstep/LauncherSwipeHandlerV2.java | 19 ++++++++++++++++++- .../util/StaggeredWorkspaceAnim.java | 12 +++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java index 1bae1c5f6b..819e484025 100644 --- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java +++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java @@ -181,6 +181,12 @@ public class LauncherSwipeHandlerV2 extends return new FloatingViewHomeAnimationFactory(floatingWidgetView) { + @Override + @Nullable + protected View getViewIgnoredInWorkspaceRevealAnimation() { + return hostView; + } + @Override public RectF getWindowTargetRect() { super.getWindowTargetRect(); @@ -370,6 +376,16 @@ public class LauncherSwipeHandlerV2 extends } private class LauncherHomeAnimationFactory extends HomeAnimationFactory { + + /** + * Returns a view which should be excluded from the Workspace animation, or null if there + * is no view to exclude. + */ + @Nullable + protected View getViewIgnoredInWorkspaceRevealAnimation() { + return null; + } + @NonNull @Override public AnimatorPlaybackController createActivityAnimationToHome() { @@ -383,7 +399,8 @@ public class LauncherSwipeHandlerV2 extends @Override public void playAtomicAnimation(float velocity) { if (!PROTOTYPE_APP_CLOSE.get()) { - new StaggeredWorkspaceAnim(mActivity, velocity, true /* animateOverviewScrim */) + new StaggeredWorkspaceAnim(mActivity, velocity, true /* animateOverviewScrim */, + getViewIgnoredInWorkspaceRevealAnimation()) .start(); } else if (shouldPlayAtomicWorkspaceReveal()) { new WorkspaceRevealAnim(mActivity, true).start(); diff --git a/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java b/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java index 49aec933b7..ccc587cd87 100644 --- a/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java +++ b/quickstep/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java @@ -32,6 +32,8 @@ import android.animation.ValueAnimator; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.Nullable; + import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.CellLayout; import com.android.launcher3.DeviceProfile; @@ -68,15 +70,18 @@ public class StaggeredWorkspaceAnim { private final float mSpringTransY; private final AnimatorSet mAnimators = new AnimatorSet(); + private final @Nullable View mIgnoredView; - public StaggeredWorkspaceAnim(Launcher launcher, float velocity, boolean animateOverviewScrim) { - this(launcher, velocity, animateOverviewScrim, true); + public StaggeredWorkspaceAnim(Launcher launcher, float velocity, boolean animateOverviewScrim, + @Nullable View ignoredView) { + this(launcher, velocity, animateOverviewScrim, ignoredView, true); } public StaggeredWorkspaceAnim(Launcher launcher, float velocity, boolean animateOverviewScrim, - boolean staggerWorkspace) { + @Nullable View ignoredView, boolean staggerWorkspace) { prepareToAnimate(launcher, animateOverviewScrim); + mIgnoredView = ignoredView; mVelocity = velocity; // Scale the translationY based on the initial velocity to better sync the workspace items @@ -224,6 +229,7 @@ public class StaggeredWorkspaceAnim { * @param totalRows Total number of rows. */ private void addStaggeredAnimationForView(View v, int row, int totalRows) { + if (mIgnoredView != null && mIgnoredView == v) return; // Invert the rows, because we stagger starting from the bottom of the screen. int invertedRow = totalRows - row; // Add 1 to the inverted row so that the bottom most row has a start delay.