Merge "Using model-time for swiping up from workspace to all apps" into ub-launcher3-qt-dev
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
index c33d25c..434353d 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
@@ -118,16 +118,15 @@
}
final RectF iconLocation = new RectF();
boolean canUseWorkspaceView = workspaceView != null && workspaceView.isAttachedToWindow();
- final FloatingIconView floatingView = canUseWorkspaceView
- ? FloatingIconView.getFloatingIconView(activity, workspaceView,
- true /* hideOriginal */, iconLocation, false /* isOpening */, null /* recycle */)
+ FloatingIconView floatingIconView = canUseWorkspaceView
+ ? recentsView.getFloatingIconView(activity, workspaceView, iconLocation)
: null;
return new HomeAnimationFactory() {
@Nullable
@Override
public View getFloatingView() {
- return floatingView;
+ return floatingIconView;
}
@NonNull
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
index 525ead8..bded5ba 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
@@ -75,6 +75,7 @@
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
import com.android.launcher3.InvariantDeviceProfile;
+import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils.ViewProgressProperty;
import com.android.launcher3.PagedView;
import com.android.launcher3.R;
@@ -91,6 +92,7 @@
import com.android.launcher3.util.PendingAnimation;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.ViewPool;
+import com.android.launcher3.views.FloatingIconView;
import com.android.quickstep.RecentsAnimationWrapper;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.RecentsModel.TaskThumbnailChangeListener;
@@ -288,6 +290,8 @@
private Layout mEmptyTextLayout;
private LiveTileOverlay mLiveTileOverlay;
+ private FloatingIconView mFloatingIconView;
+
private BaseActivity.MultiWindowModeChangedListener mMultiWindowModeChangedListener =
(inMultiWindowMode) -> {
if (!inMultiWindowMode && mOverviewStateEnabled) {
@@ -1704,4 +1708,10 @@
return super::onTouchEvent;
}
}
+
+ public FloatingIconView getFloatingIconView(Launcher launcher, View view, RectF iconLocation) {
+ mFloatingIconView = FloatingIconView.getFloatingIconView(launcher, view,
+ true /* hideOriginal */, iconLocation, false /* isOpening */, mFloatingIconView);
+ return mFloatingIconView;
+ }
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
index 2b86f5e..c67058d 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
@@ -475,7 +475,12 @@
@Override
public void onRecycle() {
resetViewTransforms();
- setFullscreenProgress(0);
+ // Clear any references to the thumbnail (it will be re-read either from the cache or the
+ // system on next bind)
+ mSnapshotView.setThumbnail(mTask, null);
+ if (mTask != null) {
+ mTask.thumbnail = null;
+ }
}
@Override
diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java
index 06a36c9..3538373 100644
--- a/quickstep/src/com/android/quickstep/RecentTasksList.java
+++ b/quickstep/src/com/android/quickstep/RecentTasksList.java
@@ -120,6 +120,16 @@
}
@Override
+ public void onTaskRemoved(int taskId) {
+ for (int i = mTasks.size() - 1; i >= 0; i--) {
+ if (mTasks.get(i).key.id == taskId) {
+ mTasks.remove(i);
+ return;
+ }
+ }
+ }
+
+ @Override
public synchronized void onActivityPinned(String packageName, int userId, int taskId,
int stackId) {
mChangeId++;
diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java
index 675cfe2..9f12484 100644
--- a/quickstep/src/com/android/quickstep/RecentsModel.java
+++ b/quickstep/src/com/android/quickstep/RecentsModel.java
@@ -166,6 +166,12 @@
}
}
+ @Override
+ public void onTaskRemoved(int taskId) {
+ Task.TaskKey dummyKey = new Task.TaskKey(taskId, 0, null, null, 0, 0);
+ mThumbnailCache.remove(dummyKey);
+ }
+
public void setSystemUiProxy(ISystemUiProxy systemUiProxy) {
mSystemUiProxy = systemUiProxy;
}
diff --git a/quickstep/src/com/android/quickstep/TaskThumbnailCache.java b/quickstep/src/com/android/quickstep/TaskThumbnailCache.java
index d05196b..57c5a27 100644
--- a/quickstep/src/com/android/quickstep/TaskThumbnailCache.java
+++ b/quickstep/src/com/android/quickstep/TaskThumbnailCache.java
@@ -187,6 +187,13 @@
}
/**
+ * Removes the cached thumbnail for the given task.
+ */
+ public void remove(Task.TaskKey key) {
+ mCache.remove(key);
+ }
+
+ /**
* @return The cache size.
*/
public int getCacheSize() {
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index cd0ae3d..1a432a7 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -62,6 +62,9 @@
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
+import androidx.dynamicanimation.animation.FloatPropertyCompat;
+import androidx.dynamicanimation.animation.SpringAnimation;
+import androidx.dynamicanimation.animation.SpringForce;
/**
* A view that is created to look like another view with the purpose of creating fluid animations.
@@ -76,6 +79,39 @@
private static final RectF sTmpRectF = new RectF();
private static final Object[] sTmpObjArray = new Object[1];
+ // We spring the foreground drawable relative to the icon's movement in the DragLayer.
+ // We then use these two factor values to scale the movement of the fg within this view.
+ private static final int FG_TRANS_X_FACTOR = 80;
+ private static final int FG_TRANS_Y_FACTOR = 100;
+
+ private static final FloatPropertyCompat<FloatingIconView> mFgTransYProperty
+ = new FloatPropertyCompat<FloatingIconView>("FloatingViewFgTransY") {
+ @Override
+ public float getValue(FloatingIconView view) {
+ return view.mFgTransY;
+ }
+
+ @Override
+ public void setValue(FloatingIconView view, float transY) {
+ view.mFgTransY = transY;
+ view.invalidate();
+ }
+ };
+
+ private static final FloatPropertyCompat<FloatingIconView> mFgTransXProperty
+ = new FloatPropertyCompat<FloatingIconView>("FloatingViewFgTransX") {
+ @Override
+ public float getValue(FloatingIconView view) {
+ return view.mFgTransX;
+ }
+
+ @Override
+ public void setValue(FloatingIconView view, float transX) {
+ view.mFgTransX = transX;
+ view.invalidate();
+ }
+ };
+
private Runnable mEndRunnable;
private CancellationSignal mLoadIconSignal;
@@ -100,17 +136,30 @@
private final Rect mOutline = new Rect();
private final Rect mFinalDrawableBounds = new Rect();
- private final Rect mBgDrawableBounds = new Rect();
private AnimatorSet mFadeAnimatorSet;
private ListenerView mListenerView;
+ private final SpringAnimation mFgSpringY;
+ private float mFgTransY;
+ private final SpringAnimation mFgSpringX;
+ private float mFgTransX;
+
private FloatingIconView(Launcher launcher) {
super(launcher);
mLauncher = launcher;
mBlurSizeOutline = getResources().getDimensionPixelSize(
R.dimen.blur_size_medium_outline);
mListenerView = new ListenerView(launcher, null);
+
+ mFgSpringX = new SpringAnimation(this, mFgTransXProperty)
+ .setSpring(new SpringForce()
+ .setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY)
+ .setStiffness(SpringForce.STIFFNESS_LOW));
+ mFgSpringY = new SpringAnimation(this, mFgTransYProperty)
+ .setSpring(new SpringForce()
+ .setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY)
+ .setStiffness(SpringForce.STIFFNESS_LOW));
}
@Override
@@ -178,7 +227,31 @@
mRevealAnimator.setCurrentFraction(shapeRevealProgress);
}
- setBackgroundDrawableBounds(mOutline.height() / minSize);
+ float drawableScale = mOutline.height() / minSize;
+ setBackgroundDrawableBounds(drawableScale);
+ if (isOpening) {
+ // Center align foreground
+ int height = mFinalDrawableBounds.height();
+ int width = mFinalDrawableBounds.width();
+ int diffY = mIsVerticalBarLayout ? 0
+ : (int) (((height * drawableScale) - height) / 2);
+ int diffX = mIsVerticalBarLayout ? (int) (((width * drawableScale) - width) / 2)
+ : 0;
+ sTmpRect.set(mFinalDrawableBounds);
+ sTmpRect.offset(diffX, diffY);
+ mForeground.setBounds(sTmpRect);
+ } else {
+ // Spring the foreground relative to the icon's movement within the DragLayer.
+ int diffX = (int) (dX / mLauncher.getDeviceProfile().availableWidthPx
+ * FG_TRANS_X_FACTOR);
+ int diffY = (int) (dY / mLauncher.getDeviceProfile().availableHeightPx
+ * FG_TRANS_Y_FACTOR);
+
+ mFgSpringX.animateToFinalPosition(diffX);
+ mFgSpringY.animateToFinalPosition(diffY);
+ }
+
+
}
invalidate();
invalidateOutline();
@@ -393,17 +466,15 @@
}
private void setBackgroundDrawableBounds(float scale) {
- mBgDrawableBounds.set(mFinalDrawableBounds);
- Utilities.scaleRectAboutCenter(mBgDrawableBounds, scale);
+ sTmpRect.set(mFinalDrawableBounds);
+ Utilities.scaleRectAboutCenter(sTmpRect, scale);
// Since the drawable is at the top of the view, we need to offset to keep it centered.
if (mIsVerticalBarLayout) {
- mBgDrawableBounds.offsetTo((int) (mFinalDrawableBounds.left * scale),
- mBgDrawableBounds.top);
+ sTmpRect.offsetTo((int) (mFinalDrawableBounds.left * scale), sTmpRect.top);
} else {
- mBgDrawableBounds.offsetTo(mBgDrawableBounds.left,
- (int) (mFinalDrawableBounds.top * scale));
+ sTmpRect.offsetTo(sTmpRect.left, (int) (mFinalDrawableBounds.top * scale));
}
- mBackground.setBounds(mBgDrawableBounds);
+ mBackground.setBounds(sTmpRect);
}
@WorkerThread
@@ -448,7 +519,10 @@
mBackground.draw(canvas);
}
if (mForeground != null) {
+ int count2 = canvas.save();
+ canvas.translate(mFgTransX, mFgTransY);
mForeground.draw(canvas);
+ canvas.restoreToCount(count2);
}
canvas.restoreToCount(count);
}
@@ -624,7 +698,6 @@
mBackground = null;
mClipPath = null;
mFinalDrawableBounds.setEmpty();
- mBgDrawableBounds.setEmpty();
if (mRevealAnimator != null) {
mRevealAnimator.cancel();
}
@@ -639,5 +712,9 @@
mOnTargetChangeRunnable = null;
mTaskCornerRadius = 0;
mOutline.setEmpty();
+ mFgTransY = 0;
+ mFgSpringX.cancel();
+ mFgTransX = 0;
+ mFgSpringY.cancel();
}
}