Merge "Moving some utility methods around" into ub-launcher3-master
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 4df1b37..af25355 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
@@ -272,7 +272,8 @@
             Consumer<AnimatorPlaybackController> callback) {
         LauncherState endState = interactionType == INTERACTION_QUICK_SCRUB
                 ? FAST_OVERVIEW : OVERVIEW;
-        if (wasVisible) {
+        if (wasVisible && fromState != BACKGROUND_APP) {
+            // If a translucent app was launched fom launcher, animate launcher states.
             DeviceProfile dp = activity.getDeviceProfile();
             long accuracy = 2 * Math.max(dp.widthPx, dp.heightPx);
             callback.accept(activity.getStateManager()
@@ -330,14 +331,17 @@
         }
 
         // Setup the clip animation helper source/target rects in the final transformed state
-        // of the recents view (a scale may be applied prior to this animation starting to
-        // line up the side pages during swipe up)
+        // of the recents view (a scale/translationY may be applied prior to this animation
+        // starting to line up the side pages during swipe up)
         float prevRvScale = recentsView.getScaleX();
+        float prevRvTransY = recentsView.getTranslationY();
         float targetRvScale = endState.getOverviewScaleAndTranslationYFactor(launcher)[0];
         SCALE_PROPERTY.set(recentsView, targetRvScale);
+        recentsView.setTranslationY(0);
         ClipAnimationHelper clipHelper = new ClipAnimationHelper(launcher);
         clipHelper.fromTaskThumbnailView(v.getThumbnail(), (RecentsView) v.getParent(), null);
         SCALE_PROPERTY.set(recentsView, prevRvScale);
+        recentsView.setTranslationY(prevRvTransY);
 
         if (!clipHelper.getSourceRect().isEmpty() && !clipHelper.getTargetRect().isEmpty()) {
             float fromScale = clipHelper.getSourceRect().width()
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index a99fc0f..c1417dd 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -1164,11 +1164,18 @@
     @UiThread
     private void startNewTask() {
         // Launch the task user scrolled to (mRecentsView.getNextPage()).
-        mRecentsAnimationWrapper.finish(true /* toRecents */, () -> {
+        if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
+            // We finish recents animation inside launchTask() when live tile is enabled.
             mRecentsView.getTaskViewAt(mRecentsView.getNextPage()).launchTask(false,
                     result -> setStateOnUiThread(STATE_HANDLER_INVALIDATED),
                     mMainThreadHandler);
-        });
+        } else {
+            mRecentsAnimationWrapper.finish(true /* toRecents */, () -> {
+                mRecentsView.getTaskViewAt(mRecentsView.getNextPage()).launchTask(false,
+                        result -> setStateOnUiThread(STATE_HANDLER_INVALIDATED),
+                        mMainThreadHandler);
+            });
+        }
         mTouchInteractionLog.finishRecentsAnimation(false);
         doLogGesture(NEW_TASK);
     }
diff --git a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
index c612b05..57400bd 100644
--- a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
+++ b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
@@ -32,7 +32,6 @@
 import android.os.Build;
 import android.os.RemoteException;
 import android.view.animation.Interpolator;
-
 import androidx.annotation.Nullable;
 
 import com.android.launcher3.BaseDraggingActivity;
@@ -277,7 +276,8 @@
             updateStackBoundsToMultiWindowTaskSize(activity);
         } else {
             mSourceStackBounds.set(mHomeStackBounds);
-            mSourceInsets.set(ttv.getInsets());
+            Rect fallback = dl.getInsets();
+            mSourceInsets.set(ttv.getInsets(fallback));
         }
 
         TransformedRect targetRect = new TransformedRect();
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index d0289d0..90604ef 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -169,11 +169,11 @@
         return mDimAlpha;
     }
 
-    public Rect getInsets() {
+    public Rect getInsets(Rect fallback) {
         if (mThumbnailData != null) {
             return mThumbnailData.insets;
         }
-        return new Rect();
+        return fallback;
     }
 
     public int getSysUiStatusNavFlags() {