Merge changes from topic "am-6122ccdb-5b5a-43f4-8f32-3d9e1a775ee9" into ub-launcher3-edmonton-polish

* changes:
  [automerger] Set correct target position for other targets am: 707c09d3e3
  Set correct target position for other targets
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b7c5793..3212980 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -56,7 +56,7 @@
         android:hardwareAccelerated="true"
         android:icon="@drawable/ic_launcher_home"
         android:label="@string/derived_app_name"
-        android:theme="@style/LauncherTheme"
+        android:theme="@style/AppTheme"
         android:largeHeap="@bool/config_largeHeap"
         android:restoreAnyVersion="true"
         android:supportsRtl="true" >
diff --git a/go/AndroidManifest.xml b/go/AndroidManifest.xml
index fbaf981..0a9ad7b 100644
--- a/go/AndroidManifest.xml
+++ b/go/AndroidManifest.xml
@@ -31,7 +31,7 @@
         android:hardwareAccelerated="true"
         android:icon="@drawable/ic_launcher_home"
         android:label="@string/derived_app_name"
-        android:theme="@style/LauncherTheme"
+        android:theme="@style/AppTheme"
         android:largeHeap="@bool/config_largeHeap"
         android:restoreAnyVersion="true"
         android:supportsRtl="true" >
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
index b895704..72d6260 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
@@ -672,6 +672,7 @@
 
                 if (mLauncher.hasSomeInvisibleFlag(PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION)) {
                     mLauncher.addForceInvisibleFlag(INVISIBLE_BY_PENDING_FLAGS);
+                    mLauncher.getStateManager().moveToRestState();
                 }
 
                 AnimatorSet anim = null;
diff --git a/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java b/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java
index 2e6dcc0..722f51b 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/BackButtonAlphaHandler.java
@@ -16,6 +16,8 @@
 
 package com.android.launcher3.uioverrides;
 
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
 import android.animation.ValueAnimator;
 
 import com.android.launcher3.Launcher;
@@ -56,6 +58,13 @@
                 final float alpha = (float) valueAnimator.getAnimatedValue();
                 mOverviewInteractionState.setBackButtonAlpha(alpha, false);
             });
+            anim.addListener(new AnimatorListenerAdapter() {
+                @Override
+                public void onAnimationEnd(Animator animation) {
+                    // Reapply the final alpha in case some state (e.g. window focus) changed.
+                    UiFactory.onLauncherStateOrFocusChanged(mLauncher);
+                }
+            });
             builder.play(anim);
         }
     }
diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java
index 0205c1f..8e4270e 100644
--- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java
+++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java
@@ -16,6 +16,7 @@
 package com.android.quickstep;
 
 import static android.view.View.TRANSLATION_Y;
+
 import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
 import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
 import static com.android.launcher3.LauncherState.FAST_OVERVIEW;
@@ -52,6 +53,7 @@
 import com.android.launcher3.R;
 import com.android.launcher3.allapps.AllAppsTransitionController;
 import com.android.launcher3.allapps.DiscoveryBounce;
+import com.android.launcher3.anim.AnimationSuccessListener;
 import com.android.launcher3.anim.AnimatorPlaybackController;
 import com.android.launcher3.dragndrop.DragLayer;
 import com.android.launcher3.uioverrides.FastOverviewState;
@@ -185,7 +187,9 @@
                 int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right;
                 return dp.hotseatBarSizePx + dp.hotseatBarSidePaddingPx + hotseatInset;
             } else {
-                return dp.heightPx - outRect.rect.bottom;
+                int shelfHeight = dp.hotseatBarSizePx + dp.getInsets().bottom;
+                // Track slightly below the top of the shelf (between top and content).
+                return shelfHeight - dp.edgeMarginPx * 2;
             }
         }
 
@@ -265,6 +269,14 @@
                         controller, ALL_APPS_PROGRESS, startProgress, endProgress);
                 shiftAnim.setInterpolator(LINEAR);
                 anim.play(shiftAnim);
+
+                // Since we are changing the start position of the UI, reapply the state, at the end
+                anim.addListener(new AnimationSuccessListener() {
+                    @Override
+                    public void onAnimationSuccess(Animator animator) {
+                        activity.getStateManager().reapplyState();
+                    }
+                });
             }
 
             if (interactionType == INTERACTION_NORMAL) {
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java b/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java
index 34d42ac..b0313fc 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java
@@ -49,6 +49,9 @@
         this.mController = controller;
         this.targetSet = targetSet;
 
+        if (controller == null) {
+            return;
+        }
         if (mInputConsumerEnabled) {
             enableInputConsumer();
         }
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 66bc501..410daa3 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -1021,8 +1021,6 @@
     private void setTargetAlphaProvider(
             BiFunction<RemoteAnimationTargetCompat, Float, Float> provider) {
         mClipAnimationHelper.setTaskAlphaCallback(provider);
-        // TODO: For some reason, when calling updateFinalShift multiple times on the same frame,
-        // only the first callback is executed.
-        Utilities.postAsyncCallback(mMainThreadHandler, this::updateFinalShift);
+        updateFinalShift();
     }
 }
diff --git a/res/values-v26/styles.xml b/res/values-v26/styles.xml
index b25f46a..e810ab2 100644
--- a/res/values-v26/styles.xml
+++ b/res/values-v26/styles.xml
@@ -21,7 +21,7 @@
     <style name="WidgetContainerTheme" parent="@android:style/Theme.DeviceDefault.Settings">
         <item name="android:colorEdgeEffect">?android:attr/textColorSecondary</item>
     </style>
-    <style name="WidgetContainerTheme.Dark" parent="LauncherThemeDark">
+    <style name="WidgetContainerTheme.Dark" parent="AppTheme.Dark">
         <item name="android:colorEdgeEffect">?android:attr/textColorSecondary</item>
         <item name="android:colorPrimaryDark">#616161</item> <!-- Gray 700 -->
     </style>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 31cbaa1..0645f41 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -56,7 +56,7 @@
         <item name="workspaceStatusBarScrim">@null</item>
     </style>
 
-    <style name="LauncherThemeDark" parent="@style/LauncherTheme">
+    <style name="LauncherTheme.Dark" parent="@style/LauncherTheme">
         <item name="android:textColorPrimary">#FFFFFFFF</item>
         <item name="android:textColorSecondary">#FFFFFFFF</item>
         <item name="android:textColorTertiary">#CCFFFFFF</item>
@@ -73,7 +73,7 @@
         <item name="isMainColorDark">true</item>
     </style>
 
-    <style name="LauncherThemeDark.DarKText" parent="@style/LauncherThemeDark">
+    <style name="LauncherTheme.Dark.DarkText" parent="@style/LauncherTheme.Dark">
         <item name="allAppsInterimScrimAlpha">25</item>
         <item name="workspaceTextColor">#FF212121</item>
         <item name="workspaceShadowColor">@android:color/transparent</item>
@@ -83,6 +83,13 @@
         <item name="workspaceStatusBarScrim">@null</item>
     </style>
 
+    <!-- A derivative project can extend these themes to customize the application theme without
+         affecting the base theme -->
+    <style name="AppTheme" parent="@style/LauncherTheme" />
+    <style name="AppTheme.DarkText" parent="@style/LauncherTheme.DarkText" />
+    <style name="AppTheme.Dark" parent="@style/LauncherTheme.Dark" />
+    <style name="AppTheme.Dark.DarkText" parent="@style/LauncherTheme.Dark.DarkText" />
+
     <!--
     Theme overrides to element on homescreen, i.e., which are drawn on top on wallpaper.
     Various foreground colors are overridden to be workspaceTextColor so that they are properly
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index 8af9acc..eec196e 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -61,7 +61,7 @@
 
     private OnStartCallback mOnStartCallback;
 
-    private int mThemeRes = R.style.LauncherTheme;
+    private int mThemeRes = R.style.AppTheme;
 
     private DisplayRotationListener mRotationListener;
 
@@ -91,10 +91,10 @@
     protected int getThemeRes(WallpaperColorInfo wallpaperColorInfo) {
         if (wallpaperColorInfo.isDark()) {
             return wallpaperColorInfo.supportsDarkText() ?
-                    R.style.LauncherThemeDark_DarKText : R.style.LauncherThemeDark;
+                    R.style.AppTheme_Dark_DarkText : R.style.AppTheme_Dark;
         } else {
             return wallpaperColorInfo.supportsDarkText() ?
-                    R.style.LauncherTheme_DarkText : R.style.LauncherTheme;
+                    R.style.AppTheme_DarkText : R.style.AppTheme;
         }
     }
 
diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java
index 1b91e88..9217ca9 100644
--- a/src/com/android/launcher3/FastBitmapDrawable.java
+++ b/src/com/android/launcher3/FastBitmapDrawable.java
@@ -261,7 +261,7 @@
     /**
      * Updates the paint to reflect the current brightness and saturation.
      */
-    private void updateFilter() {
+    protected void updateFilter() {
         boolean usePorterDuffFilter = false;
         int key = -1;
         if (mDesaturation > 0) {