Merge "Import translations. DO NOT MERGE" into ub-launcher3-edmonton
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
index 43772fb..f0bdcbd 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
@@ -267,7 +267,7 @@
             }
             mActivity = activity;
             mRecentsView = mActivity.getOverviewPanel();
-            mRecentsView.setFirstTaskIconScaledDown(true /* isScaledDown */, false /* animate */);
+            mRecentsView.setRunningTaskIconScaledDown(true /* isScaledDown */, false /* animate */);
             return false;
         }
 
@@ -280,7 +280,7 @@
                 @Override
                 public void onAnimationSuccess(Animator animator) {
                     if (mRecentsView != null) {
-                        mRecentsView.setFirstTaskIconScaledDown(false /* isScaledDown */,
+                        mRecentsView.setRunningTaskIconScaledDown(false /* isScaledDown */,
                                 true /* animate */);
                     }
                 }
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 614ba6e..2fa3875 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -387,7 +387,7 @@
 
         mRecentsView.showTask(mRunningTaskId);
         mRecentsView.setRunningTaskHidden(true);
-        mRecentsView.setFirstTaskIconScaledDown(true /* isScaledDown */, false /* animate */);
+        mRecentsView.setRunningTaskIconScaledDown(true /* isScaledDown */, false /* animate */);
         mLayoutListener.open();
         mStateCallback.setState(STATE_LAUNCHER_STARTED);
     }
@@ -685,7 +685,7 @@
         mLayoutListener.finish();
 
         mRecentsView.setRunningTaskHidden(false);
-        mRecentsView.setFirstTaskIconScaledDown(false /* isScaledDown */, false /* animate */);
+        mRecentsView.setRunningTaskIconScaledDown(false /* isScaledDown */, false /* animate */);
     }
 
     private void notifyTransitionCancelled() {
@@ -749,7 +749,7 @@
         mActivityControlHelper.onSwipeUpComplete(mActivity);
 
         // Animate the first icon.
-        mRecentsView.setFirstTaskIconScaledDown(false /* isScaledDown */, true /* animate */);
+        mRecentsView.setRunningTaskIconScaledDown(false /* isScaledDown */, true /* animate */);
         mRecentsView.setSwipeDownShouldLaunchApp(true);
 
         RecentsModel.getInstance(mContext).onOverviewShown(false, TAG);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index ce460bc..82a5bdc 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -170,7 +170,7 @@
     private boolean mRunningTaskTileHidden;
     private Task mTmpRunningTask;
 
-    private boolean mFirstTaskIconScaledDown = false;
+    private boolean mRunningTaskIconScaledDown = false;
 
     private boolean mOverviewStateEnabled;
     private boolean mTaskStackListenerRegistered;
@@ -327,25 +327,12 @@
         final int childCount = getChildCount();
         if (mShowEmptyMessage || childCount == 0) return 0;
 
-        final View lastChild = getChildAt(childCount - 1);
-
-        // Current visible coordinate of the end of the oldest task.
-        final int carouselCurrentEnd =
-                (mIsRtl ? lastChild.getLeft() : lastChild.getRight()) - getScrollX();
-
-        // Visible button-facing end of a centered task.
-        final int centeredTaskEnd = mIsRtl ?
-                getPaddingLeft() + mInsets.left :
-                getWidth() - getPaddingRight() - mInsets.right;
-
-        // The distance of the carousel travel during which the alpha changes from 0 to 1. This
-        // is the motion between the oldest task in its centered position and the oldest task
-        // scrolled to the end.
-        final int alphaChangeRange = (mIsRtl ? 0 : mMaxScrollX) - getScrollForPage(childCount - 1);
+        final int scrollEnd = mIsRtl ? 0 : mMaxScrollX;
+        final int oldestChildScroll = getScrollForPage(childCount - 1);
 
         return Utilities.boundToRange(
-                ((float) (centeredTaskEnd - carouselCurrentEnd)) /
-                        alphaChangeRange, 0, 1);
+                ((float) (getScrollX() - oldestChildScroll)) /
+                        (scrollEnd - oldestChildScroll), 0, 1);
     }
 
     private void updateClearAllButtonAlpha() {
@@ -638,13 +625,15 @@
      * Similar to {@link #showTask(int)} but does not put any restrictions on the first tile.
      */
     public void setCurrentTask(int runningTaskId) {
-        if (mRunningTaskTileHidden) {
-            setRunningTaskHidden(false);
-            mRunningTaskId = runningTaskId;
-            setRunningTaskHidden(true);
-        } else {
-            mRunningTaskId = runningTaskId;
-        }
+        boolean runningTaskTileHidden = mRunningTaskTileHidden;
+        boolean runningTaskIconScaledDown = mRunningTaskIconScaledDown;
+
+        setRunningTaskIconScaledDown(false, false);
+        setRunningTaskHidden(false);
+        mRunningTaskId = runningTaskId;
+        setRunningTaskIconScaledDown(runningTaskIconScaledDown, false);
+        setRunningTaskHidden(runningTaskTileHidden);
+
         setCurrentPage(0);
 
         // Load the tasks (if the loading is already
@@ -672,17 +661,17 @@
         return mQuickScrubController;
     }
 
-    public void setFirstTaskIconScaledDown(boolean isScaledDown, boolean animate) {
-        if (mFirstTaskIconScaledDown == isScaledDown) {
+    public void setRunningTaskIconScaledDown(boolean isScaledDown, boolean animate) {
+        if (mRunningTaskIconScaledDown == isScaledDown) {
             return;
         }
-        mFirstTaskIconScaledDown = isScaledDown;
+        mRunningTaskIconScaledDown = isScaledDown;
         applyIconScale(animate);
     }
 
     private void applyIconScale(boolean animate) {
-        float scale = mFirstTaskIconScaledDown ? 0 : 1;
-        TaskView firstTask = (TaskView) getChildAt(0);
+        float scale = mRunningTaskIconScaledDown ? 0 : 1;
+        TaskView firstTask = getTaskView(mRunningTaskId);
         if (firstTask != null) {
             if (animate) {
                 firstTask.animateIconToScaleAndDim(scale);
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 5fffb50..b8b9196 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -213,6 +213,7 @@
         setTranslationY(0f);
         setTranslationZ(0);
         setAlpha(1f);
+        setIconScaleAndDim(1);
     }
 
     @Override
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index 7f25301..1b9ac21 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -374,7 +374,18 @@
      */
     public void setCurrentAnimation(AnimatorSet anim, Animator... childAnimations) {
         for (Animator childAnim : childAnimations) {
-            if (childAnim != null && mConfig.mCurrentAnimation == childAnim) {
+            if (childAnim == null) {
+                continue;
+            }
+            if (mConfig.playbackController != null
+                    && mConfig.playbackController.getTarget() == childAnim) {
+                if (mConfig.mCurrentAnimation != null) {
+                    mConfig.mCurrentAnimation.removeListener(mConfig);
+                    mConfig.mCurrentAnimation = null;
+                }
+                mConfig.playbackController = null;
+                break;
+            } else if (mConfig.mCurrentAnimation == childAnim) {
                 mConfig.mCurrentAnimation.removeListener(mConfig);
                 mConfig.mCurrentAnimation = null;
                 break;