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
diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
index 1bae1c5..819e484 100644
--- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
+++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
@@ -182,6 +182,12 @@
return new FloatingViewHomeAnimationFactory(floatingWidgetView) {
@Override
+ @Nullable
+ protected View getViewIgnoredInWorkspaceRevealAnimation() {
+ return hostView;
+ }
+
+ @Override
public RectF getWindowTargetRect() {
super.getWindowTargetRect();
return backgroundLocation;
@@ -370,6 +376,16 @@
}
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 @@
@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 49aec93..ccc587c 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.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 @@
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 @@
* @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.