From 55940ecfc70b87ddaf05f0cb181ecf7fc3aa6e8c Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Fri, 23 Oct 2020 22:37:51 -0700 Subject: [PATCH] Render and track live tile position when launching another app from Overview Fixes: 165394366 Fixes: 170338328 Test: Manual Change-Id: Idfcd423cbe062af33564eaa9e83ec21fbac0cdf9 --- .../android/quickstep/AbsSwipeUpHandler.java | 6 +-- .../com/android/quickstep/TaskViewUtils.java | 7 +++- .../quickstep/util/TaskViewSimulator.java | 31 +++++++-------- .../android/quickstep/views/RecentsView.java | 38 ++++++++++++++----- .../touch/LandscapePagedViewHandler.java | 8 ++-- .../touch/PagedOrientationHandler.java | 4 +- .../touch/PortraitPagedViewHandler.java | 4 +- 7 files changed, 58 insertions(+), 40 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index a1988a17fe..8286d87582 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -41,10 +41,8 @@ import static com.android.quickstep.GestureState.STATE_END_TARGET_ANIMATION_FINI import static com.android.quickstep.GestureState.STATE_END_TARGET_SET; import static com.android.quickstep.GestureState.STATE_RECENTS_SCROLLING_FINISHED; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; -import static com.android.quickstep.TaskUtils.taskIsATargetWithMode; import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME; -import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -1485,13 +1483,11 @@ public abstract class AbsSwipeUpHandler, Q extends mRecentsAnimationTargets.apps, mRecentsAnimationTargets.apps.length + 1); apps[apps.length - 1] = appearedTaskTarget; - boolean launcherClosing = - taskIsATargetWithMode(apps, mActivity.getTaskId(), MODE_CLOSING); AnimatorSet anim = new AnimatorSet(); TaskViewUtils.composeRecentsLaunchAnimator( anim, taskView, apps, - mRecentsAnimationTargets.wallpapers, launcherClosing, + mRecentsAnimationTargets.wallpapers, true /* launcherClosing */, mActivity.getStateManager(), mRecentsView, mActivityInterface.getDepthController()); anim.addListener(new AnimatorListenerAdapter(){ diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 46c77681ae..ed761cf640 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -297,7 +297,6 @@ public final class TaskViewUtils { PendingAnimation pa = new PendingAnimation(RECENTS_LAUNCH_DURATION); createRecentsWindowAnimator(taskView, skipLauncherChanges, appTargets, wallpaperTargets, depthController, pa); - anim.play(pa.buildAnim()); Animator childStateAnimation = null; // Found a visible recents task that matches the opening app, lets launch the app from there @@ -330,7 +329,11 @@ public final class TaskViewUtils { } }; } - anim.play(launcherAnim); + pa.add(launcherAnim); + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && recentsView.getRunningTaskIndex() != -1) { + pa.addOnFrameCallback(recentsView::redrawLiveTile); + } + anim.play(pa.buildAnim()); // Set the current animation first, before adding windowAnimEndListener. Setting current // animation adds some listeners which need to be called before windowAnimEndListener diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index 08fe48d5ce..61ba411363 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -52,16 +52,16 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { public static final IntProperty SCROLL = new IntProperty("scroll") { - @Override - public void setValue(TaskViewSimulator simulator, int i) { - simulator.setScroll(i); - } + @Override + public void setValue(TaskViewSimulator simulator, int scroll) { + simulator.setScroll(scroll); + } - @Override - public Integer get(TaskViewSimulator simulator) { - return simulator.mScrollState.scroll; - } - }; + @Override + public Integer get(TaskViewSimulator simulator) { + return simulator.mScrollState.scroll; + } + }; private final Rect mTmpCropRect = new Rect(); private final RectF mTempRectF = new RectF(); @@ -72,7 +72,6 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { private final BaseActivityInterface mSizeStrategy; private final Rect mTaskRect = new Rect(); - private float mOffsetY; private boolean mDrawsBelowRecents; private final PointF mPivot = new PointF(); private DeviceProfile mDp; @@ -89,6 +88,8 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { // TaskView properties private final FullscreenDrawParams mCurrentFullscreenParams; private float mCurveScale = 1; + public final AnimatedFloat taskPrimaryTranslation = new AnimatedFloat(); + public final AnimatedFloat taskSecondaryTranslation = new AnimatedFloat(); // RecentsView properties public final AnimatedFloat recentsViewScale = new AnimatedFloat(); @@ -178,10 +179,6 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { } } - public void setOffsetY(float offsetY) { - mOffsetY = offsetY; - } - public void setDrawsBelowRecents(boolean drawsBelowRecents) { mDrawsBelowRecents = drawsBelowRecents; } @@ -298,7 +295,11 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { // Apply TaskView matrix: scale, translate, scroll mMatrix.postScale(mCurveScale, mCurveScale, taskWidth / 2, taskHeight / 2); - mMatrix.postTranslate(mTaskRect.left, mTaskRect.top + mOffsetY); + mMatrix.postTranslate(mTaskRect.left, mTaskRect.top); + mOrientationState.getOrientationHandler().set(mMatrix, MATRIX_POST_TRANSLATE, + taskPrimaryTranslation.value); + mOrientationState.getOrientationHandler().setSecondary(mMatrix, MATRIX_POST_TRANSLATE, + taskSecondaryTranslation.value); mOrientationState.getOrientationHandler().set( mMatrix, MATRIX_POST_TRANSLATE, mScrollState.scroll); diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 826555c24b..264a182dc2 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -51,6 +51,7 @@ import android.animation.AnimatorSet; import android.animation.LayoutTransition; import android.animation.LayoutTransition.TransitionListener; import android.animation.ObjectAnimator; +import android.animation.PropertyValuesHolder; import android.animation.ValueAnimator; import android.annotation.TargetApi; import android.app.ActivityManager.RunningTaskInfo; @@ -99,7 +100,6 @@ import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.PendingAnimation.EndState; -import com.android.launcher3.anim.PropertyListBuilder; import com.android.launcher3.anim.SpringProperty; import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.config.FeatureFlags; @@ -114,6 +114,7 @@ import com.android.launcher3.util.OverScroller; import com.android.launcher3.util.ResourceBasedOverride.Overrides; import com.android.launcher3.util.Themes; import com.android.launcher3.util.ViewPool; +import com.android.quickstep.AnimatedFloat; import com.android.quickstep.BaseActivityInterface; import com.android.quickstep.GestureState; import com.android.quickstep.RecentsAnimationController; @@ -874,9 +875,10 @@ public abstract class RecentsView extends PagedView // Since we reuse the same mLiveTileTaskViewSimulator in the RecentsView, we need // to reset the params after it settles in Overview from swipe up so that we don't // render with obsolete param values. + mLiveTileTaskViewSimulator.taskPrimaryTranslation.value = 0; + mLiveTileTaskViewSimulator.taskSecondaryTranslation.value = 0; mLiveTileTaskViewSimulator.fullScreenProgress.value = 0; mLiveTileTaskViewSimulator.recentsViewScale.value = 1; - mLiveTileTaskViewSimulator.setOffsetY(0); // Reset the live tile rect DeviceProfile deviceProfile = mActivity.getDeviceProfile(); @@ -1545,7 +1547,10 @@ public abstract class RecentsView extends PagedView if (ENABLE_QUICKSTEP_LIVE_TILE.get() && getRunningTaskView() == taskView) { anim.addOnFrameCallback(() -> { - mLiveTileTaskViewSimulator.setOffsetY(taskView.getTranslationY()); + mLiveTileTaskViewSimulator.taskSecondaryTranslation.value = + mOrientationHandler.getSecondaryValue( + taskView.getTranslationX(), + taskView.getTranslationY()); redrawLiveTile(); }); } @@ -2090,22 +2095,35 @@ public abstract class RecentsView extends PagedView boolean launchingCenterTask = taskIndex == centerTaskIndex; float toScale = getMaxScaleForFullScreen(); + RecentsView recentsView = tv.getRecentsView(); if (launchingCenterTask) { - RecentsView recentsView = tv.getRecentsView(); anim.play(ObjectAnimator.ofFloat(recentsView, RECENTS_SCALE_PROPERTY, toScale)); anim.play(ObjectAnimator.ofFloat(recentsView, FULLSCREEN_PROGRESS, 1)); } else { // We are launching an adjacent task, so parallax the center and other adjacent task. float displacementX = tv.getWidth() * (toScale - tv.getCurveScale()); - anim.play(ObjectAnimator.ofFloat(getPageAt(centerTaskIndex), TRANSLATION_X, - mIsRtl ? -displacementX : displacementX)); + float primaryTranslation = mIsRtl ? -displacementX : displacementX; + anim.play(ObjectAnimator.ofFloat(getPageAt(centerTaskIndex), + mOrientationHandler.getPrimaryViewTranslate(), primaryTranslation)); + int runningTaskIndex = recentsView.getRunningTaskIndex(); + if (ENABLE_QUICKSTEP_LIVE_TILE.get() && runningTaskIndex != -1 + && runningTaskIndex != taskIndex) { + anim.play(ObjectAnimator.ofFloat( + recentsView.getLiveTileTaskViewSimulator().taskPrimaryTranslation, + AnimatedFloat.VALUE, + primaryTranslation)); + } int otherAdjacentTaskIndex = centerTaskIndex + (centerTaskIndex - taskIndex); if (otherAdjacentTaskIndex >= 0 && otherAdjacentTaskIndex < getPageCount()) { - anim.play(new PropertyListBuilder() - .translationX(mIsRtl ? -displacementX : displacementX) - .scale(1) - .build(getPageAt(otherAdjacentTaskIndex))); + PropertyValuesHolder[] properties = new PropertyValuesHolder[3]; + properties[0] = PropertyValuesHolder.ofFloat( + mOrientationHandler.getPrimaryViewTranslate(), primaryTranslation); + properties[1] = PropertyValuesHolder.ofFloat(View.SCALE_X, 1); + properties[2] = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1); + + anim.play(ObjectAnimator.ofPropertyValuesHolder(getPageAt(otherAdjacentTaskIndex), + properties)); } } return anim; diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index 17f02be5b4..ad6710f8e2 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -42,13 +42,13 @@ import com.android.launcher3.util.OverScroller; public class LandscapePagedViewHandler implements PagedOrientationHandler { @Override - public int getPrimaryValue(int x, int y) { - return y; + public T getPrimaryValue(T x, T y) { + return x; } @Override - public int getSecondaryValue(int x, int y) { - return x; + public T getSecondaryValue(T x, T y) { + return y; } @Override diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java index 114b75acec..a9c50cdffc 100644 --- a/src/com/android/launcher3/touch/PagedOrientationHandler.java +++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java @@ -84,8 +84,8 @@ public interface PagedOrientationHandler { boolean getRecentsRtlSetting(Resources resources); float getDegreesRotated(); int getRotation(); - int getPrimaryValue(int x, int y); - int getSecondaryValue(int x, int y); + T getPrimaryValue(T x, T y); + T getSecondaryValue(T x, T y); void delegateScrollTo(PagedView pagedView, int secondaryScroll, int primaryScroll); /** Uses {@params pagedView}.getScroll[X|Y]() method for the secondary amount*/ void delegateScrollTo(PagedView pagedView, int primaryScroll); diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index 5f5b2d1feb..587e35ad6c 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -40,12 +40,12 @@ import com.android.launcher3.util.OverScroller; public class PortraitPagedViewHandler implements PagedOrientationHandler { @Override - public int getPrimaryValue(int x, int y) { + public T getPrimaryValue(T x, T y) { return x; } @Override - public int getSecondaryValue(int x, int y) { + public T getSecondaryValue(T x, T y) { return y; }