Merge "Suppress Splash Screen on widget reconfiguration activity start" into sc-dev
diff --git a/go/quickstep/res/layout/overview_panel.xml b/go/quickstep/res/layout/overview_panel.xml
deleted file mode 100644
index 241b63d..0000000
--- a/go/quickstep/res/layout/overview_panel.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!--
-     Copyright (C) 2021 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <com.android.quickstep.views.LauncherRecentsView
-        android:id="@+id/overview_panel"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:accessibilityPaneTitle="@string/accessibility_recent_apps"
-        android:clipChildren="false"
-        android:clipToPadding="false"
-        android:background="?attr/overviewBackgroundColor"
-        android:visibility="invisible" />
-
-    <com.android.quickstep.views.SplitPlaceholderView
-        android:id="@+id/split_placeholder"
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/split_placeholder_size"
-        android:background="@android:color/darker_gray"
-        android:visibility="gone" />
-
-    <include
-        android:id="@+id/overview_actions_view"
-        layout="@layout/overview_actions_container" />
-
-</merge>
diff --git a/go/quickstep/res/values/attrs.xml b/go/quickstep/res/values/attrs.xml
index 3adf462..03eab50 100644
--- a/go/quickstep/res/values/attrs.xml
+++ b/go/quickstep/res/values/attrs.xml
@@ -16,7 +16,6 @@
 -->
 <resources>
     <!-- Attributes used for Overview theming -->
-    <attr name="overviewBackgroundColor" format="color" />
     <attr name="overviewButtonTextColor" format="color" />
     <attr name="overviewButtonIconColor" format="color" />
     <attr name="overviewButtonBackgroundColor" format="color" />
diff --git a/go/quickstep/res/values/colors.xml b/go/quickstep/res/values/colors.xml
index f815f54..ae72ef6 100644
--- a/go/quickstep/res/values/colors.xml
+++ b/go/quickstep/res/values/colors.xml
@@ -16,10 +16,8 @@
 -->
 <resources>
     <!-- Overview -->
-    <color name="go_overview_background_color">#DADADA</color>
-    <color name="go_overview_background_color_dark">#000000</color>
     <color name="go_overview_text_color">#3C4043</color>
     <color name="go_overview_text_color_dark">#F8F9FA</color>
     <color name="go_overview_button_color">#70FFFFFF</color>
-    <color name="go_overview_button_color_dark">#303030</color>
+    <color name="go_overview_button_color_dark">#474747</color>
 </resources>
diff --git a/go/quickstep/res/values/styles.xml b/go/quickstep/res/values/styles.xml
index 59f7377..ffe8f46 100644
--- a/go/quickstep/res/values/styles.xml
+++ b/go/quickstep/res/values/styles.xml
@@ -17,14 +17,12 @@
 <resources>
     <!-- App themes -->
     <style name="AppTheme" parent="@style/LauncherTheme">
-        <item name="overviewBackgroundColor">@color/go_overview_background_color</item>
         <item name="overviewButtonTextColor">@color/go_overview_text_color</item>
         <item name="overviewButtonIconColor">@color/go_overview_text_color</item>
         <item name="overviewButtonBackgroundColor">@color/go_overview_button_color</item>
     </style>
 
     <style name="AppTheme.Dark" parent="@style/LauncherTheme.Dark">
-        <item name="overviewBackgroundColor">@color/go_overview_background_color_dark</item>
         <item name="overviewButtonTextColor">@color/go_overview_text_color_dark</item>
         <item name="overviewButtonIconColor">@color/go_overview_text_color_dark</item>
         <item name="overviewButtonBackgroundColor">@color/go_overview_button_color_dark</item>
diff --git a/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java b/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java
index 3a6e9b5..b823c36 100644
--- a/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java
+++ b/go/quickstep/src/com/android/quickstep/TaskOverlayFactoryGo.java
@@ -51,7 +51,8 @@
     public static final String ACTIONS_URL = "niu_actions_app_url";
     public static final String ACTIONS_APP_PACKAGE = "niu_actions_app_package";
     public static final String ACTIONS_ERROR_CODE = "niu_actions_app_error_code";
-    public static final int ERROR_PERMISSIONS = 1;
+    public static final int ERROR_PERMISSIONS_STRUCTURE = 1;
+    public static final int ERROR_PERMISSIONS_SCREENSHOT = 2;
     private static final String TAG = "TaskOverlayFactoryGo";
 
     private AssistContentRequester mContentRequester;
@@ -75,7 +76,8 @@
         private String mNIUPackageName;
         private String mTaskPackageName;
         private String mWebUrl;
-        private boolean mAssistPermissionsEnabled;
+        private boolean mAssistStructurePermitted;
+        private boolean mAssistScreenshotPermitted;
         private AssistContentRequester mFactoryContentRequester;
 
         private TaskOverlayGo(TaskThumbnailView taskThumbnailView,
@@ -104,7 +106,7 @@
             getActionsView().setCallbacks(new OverlayUICallbacksGoImpl(isAllowedByPolicy, task));
             mTaskPackageName = task.key.getPackageName();
 
-            if (!mAssistPermissionsEnabled) {
+            if (!mAssistStructurePermitted || !mAssistScreenshotPermitted) {
                 return;
             }
 
@@ -131,10 +133,14 @@
         private void sendNIUIntent(String actionType) {
             Intent intent = createNIUIntent(actionType);
             // Only add and send the image if the appropriate permissions are held
-            if (mAssistPermissionsEnabled) {
+            if (mAssistStructurePermitted && mAssistScreenshotPermitted) {
                 mImageApi.shareAsDataWithExplicitIntent(/* crop */ null, intent);
             } else {
-                intent.putExtra(ACTIONS_ERROR_CODE, ERROR_PERMISSIONS);
+                // If both permissions are disabled, the structure error code takes priority
+                // The user must enable that one before they can enable screenshots
+                int code = mAssistStructurePermitted ? ERROR_PERMISSIONS_SCREENSHOT
+                        : ERROR_PERMISSIONS_STRUCTURE;
+                intent.putExtra(ACTIONS_ERROR_CODE, code);
                 try {
                     mApplicationContext.startActivity(intent);
                 } catch (ActivityNotFoundException e) {
@@ -164,11 +170,10 @@
         @VisibleForTesting
         public void checkSettings() {
             ContentResolver contentResolver = mApplicationContext.getContentResolver();
-            boolean structureEnabled = Settings.Secure.getInt(contentResolver,
+            mAssistStructurePermitted = Settings.Secure.getInt(contentResolver,
                     Settings.Secure.ASSIST_STRUCTURE_ENABLED, 1) != 0;
-            boolean screenshotEnabled = Settings.Secure.getInt(contentResolver,
+            mAssistScreenshotPermitted = Settings.Secure.getInt(contentResolver,
                     Settings.Secure.ASSIST_SCREENSHOT_ENABLED, 1) != 0;
-            mAssistPermissionsEnabled = structureEnabled && screenshotEnabled;
 
             String assistantPackage =
                     Settings.Secure.getString(contentResolver, Settings.Secure.ASSISTANT);
diff --git a/quickstep/res/drawable/ic_all_set.xml b/quickstep/res/drawable/ic_all_set.xml
index a6852aa..656c596 100644
--- a/quickstep/res/drawable/ic_all_set.xml
+++ b/quickstep/res/drawable/ic_all_set.xml
@@ -15,10 +15,10 @@
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
     android:width="42dp"
-    android:height="40dp"
+    android:height="42dp"
     android:viewportWidth="42"
-    android:viewportHeight="40">
+    android:viewportHeight="42">
     <path
-        android:pathData="M38,14H25.38L27.28,4.86L27.34,4.22C27.34,3.4 27,2.64 26.46,2.1L24.34,0C24.34,0 10.16,13.7 10,14H0V40H32C33.66,40 35.08,39 35.68,37.56L41.72,23.46C41.9,23 42,22.52 42,22V18C42,15.8 40.2,14 38,14ZM10,36H4V18H10V36ZM38,22L32,36H14V16L22.68,7.32L20,18H38V22Z"
+        android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"
         android:fillColor="#FFFFFF"/>
 </vector>
diff --git a/quickstep/src/com/android/launcher3/WrappedLauncherAnimationRunner.java b/quickstep/src/com/android/launcher3/WrappedLauncherAnimationRunner.java
index e319275..fcf9857 100644
--- a/quickstep/src/com/android/launcher3/WrappedLauncherAnimationRunner.java
+++ b/quickstep/src/com/android/launcher3/WrappedLauncherAnimationRunner.java
@@ -58,6 +58,8 @@
         if (animationRunnerImpl != null) {
             animationRunnerImpl.onCreateAnimation(transit, appTargets, wallpaperTargets,
                     nonAppTargets, result);
+        } else {
+            result.setAnimation(null, null);
         }
     }
 }
diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
index 5b4e5f2..e6333d1 100644
--- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
+++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java
@@ -161,14 +161,14 @@
         if (mSurface != surface) {
             mSurface = surface;
             if (surface != null) {
-                dispatchTransactionSurface(mDepth);
+                dispatchTransactionSurface();
             }
         }
     }
 
     @Override
     public void setState(LauncherState toState) {
-        if (mSurface == null || mIgnoreStateChangesDuringMultiWindowAnimation) {
+        if (mIgnoreStateChangesDuringMultiWindowAnimation) {
             return;
         }
 
@@ -176,7 +176,7 @@
         if (Float.compare(mDepth, toDepth) != 0) {
             setDepth(toDepth);
         } else if (toState == LauncherState.OVERVIEW) {
-            dispatchTransactionSurface(mDepth);
+            dispatchTransactionSurface();
         }
     }
 
@@ -202,35 +202,30 @@
         if (Float.compare(mDepth, depthF) == 0) {
             return;
         }
-        if (dispatchTransactionSurface(depthF)) {
-            mDepth = depthF;
-        }
+        mDepth = depthF;
+        dispatchTransactionSurface();
     }
 
-    private boolean dispatchTransactionSurface(float depth) {
+    private void dispatchTransactionSurface() {
         boolean supportsBlur = BlurUtils.supportsBlursOnWindows();
-        if (supportsBlur && (mSurface == null || !mSurface.isValid())) {
-            return false;
-        }
         ensureDependencies();
         IBinder windowToken = mLauncher.getRootView().getWindowToken();
         if (windowToken != null) {
-            mWallpaperManager.setWallpaperZoomOut(windowToken, depth);
+            mWallpaperManager.setWallpaperZoomOut(windowToken, mDepth);
         }
 
-        if (supportsBlur) {
+        if (supportsBlur && (mSurface != null && mSurface.isValid())) {
             // We cannot mark the window as opaque in overview because there will be an app window
             // below the launcher layer, and we need to draw it -- without blurs.
             boolean isOverview = mLauncher.isInState(LauncherState.OVERVIEW);
             boolean opaque = mLauncher.getScrimView().isFullyOpaque() && !isOverview;
 
-            int blur = opaque || isOverview ? 0 : (int) (depth * mMaxBlurRadius);
+            int blur = opaque || isOverview ? 0 : (int) (mDepth * mMaxBlurRadius);
             new SurfaceControl.Transaction()
                     .setBackgroundBlurRadius(mSurface, blur)
                     .setOpaque(mSurface, opaque)
                     .apply();
         }
-        return true;
     }
 
     @Override
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index e52405b..c9b68df 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -813,7 +813,13 @@
     }
 
     private void reset() {
-        mConsumer = mUncheckedConsumer = mResetGestureInputConsumer;
+        if (mResetGestureInputConsumer != null) {
+            mConsumer = mUncheckedConsumer = mResetGestureInputConsumer;
+        } else {
+            // mResetGestureInputConsumer isn't initialized until onUserUnlocked(), so reset to
+            // NO_OP until then (we never want these to be null).
+            mConsumer = mUncheckedConsumer = InputConsumer.NO_OP;
+        }
         mGestureState = DEFAULT_STATE;
         // By default, use batching of the input events, but check receiver before using in the rare
         // case that the monitor was disposed before the swipe settled
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index df7f8b5..8c3e5b5 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -2245,7 +2245,7 @@
     public PendingAnimation createTaskDismissAnimation(TaskView taskView, boolean animateTaskView,
             boolean shouldRemoveTask, long duration) {
         if (mPendingAnimation != null) {
-            mPendingAnimation.createPlaybackController().dispatchOnCancel();
+            mPendingAnimation.createPlaybackController().dispatchOnCancel().dispatchOnEnd();
         }
         PendingAnimation anim = new PendingAnimation(duration);
 
diff --git a/res/color-night-v31/all_apps_tabs_background.xml b/res/color-night-v31/all_apps_tabs_background.xml
deleted file mode 100644
index b396f33..0000000
--- a/res/color-night-v31/all_apps_tabs_background.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2021 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:color="@android:color/system_neutral2_100"/>
-</selector>
\ No newline at end of file
diff --git a/res/color-night/all_apps_tabs_background.xml b/res/color-night/all_apps_tabs_background.xml
deleted file mode 100644
index c0c1621..0000000
--- a/res/color-night/all_apps_tabs_background.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2021 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:color="#E2E2E2"/>
-</selector>
\ No newline at end of file
diff --git a/res/drawable/all_apps_tabs_background.xml b/res/drawable/all_apps_tabs_background.xml
index 4e95315..bf7ee8c 100644
--- a/res/drawable/all_apps_tabs_background.xml
+++ b/res/drawable/all_apps_tabs_background.xml
@@ -13,13 +13,27 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:enterFadeDuration="500">
     <item
-        android:top="@dimen/all_apps_tabs_vertical_padding"
-        android:bottom="@dimen/all_apps_tabs_vertical_padding">
+        android:id="@+id/unselected"
+        android:state_selected="false">
+        <ripple android:color="@color/all_apps_tab_background_selected">
+            <item>
+                <shape android:shape="rectangle">
+                    <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
+                    <solid android:color="@color/all_apps_tabs_background" />
+                </shape>
+            </item>
+        </ripple>
+    </item>
+
+    <item
+        android:id="@+id/selected"
+        android:state_selected="true">
         <shape android:shape="rectangle">
-            <solid android:color="@color/all_apps_tabs_background" />
             <corners android:radius="@dimen/all_apps_header_pill_corner_radius" />
+            <solid android:color="@color/all_apps_tab_background_selected" />
         </shape>
     </item>
-</layer-list>
\ No newline at end of file
+</selector>
\ No newline at end of file
diff --git a/res/layout/all_apps_personal_work_tabs.xml b/res/layout/all_apps_personal_work_tabs.xml
index cfaa261..11143fb 100644
--- a/res/layout/all_apps_personal_work_tabs.xml
+++ b/res/layout/all_apps_personal_work_tabs.xml
@@ -14,12 +14,12 @@
   ~ limitations under the License.
 -->
 
-<com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip
+    xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/tabs"
-    android:layout_width="@dimen/all_apps_header_pills_width"
+    android:layout_width="match_parent"
     android:layout_height="@dimen/all_apps_header_pill_height"
     android:layout_gravity="center_horizontal"
-    android:background="@drawable/all_apps_tabs_background"
     android:orientation="horizontal"
     style="@style/TextHeadline">
 
@@ -27,19 +27,25 @@
         android:id="@+id/tab_personal"
         android:layout_width="0dp"
         android:layout_height="match_parent"
+        android:layout_marginEnd="@dimen/all_apps_tabs_button_horizontal_padding"
+        android:layout_marginVertical="@dimen/all_apps_tabs_vertical_padding"
         android:layout_weight="1"
-        android:background="@drawable/personal_work_tabs_ripple"
+        android:background="@drawable/all_apps_tabs_background"
         android:text="@string/all_apps_personal_tab"
         android:textColor="@color/all_apps_tab_text"
-        android:textSize="14sp" />
+        android:textSize="14sp"
+        style="?android:attr/borderlessButtonStyle" />
 
     <Button
         android:id="@+id/tab_work"
         android:layout_width="0dp"
         android:layout_height="match_parent"
+        android:layout_marginStart="@dimen/all_apps_tabs_button_horizontal_padding"
+        android:layout_marginVertical="@dimen/all_apps_tabs_vertical_padding"
         android:layout_weight="1"
-        android:background="@drawable/personal_work_tabs_ripple"
+        android:background="@drawable/all_apps_tabs_background"
         android:text="@string/all_apps_work_tab"
         android:textColor="@color/all_apps_tab_text"
-        android:textSize="14sp" />
+        android:textSize="14sp"
+        style="?android:attr/borderlessButtonStyle" />
 </com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip>
\ No newline at end of file
diff --git a/res/layout/widgets_full_sheet_search_and_recommendations.xml b/res/layout/widgets_full_sheet_search_and_recommendations.xml
index a89f85f..4a3e20d 100644
--- a/res/layout/widgets_full_sheet_search_and_recommendations.xml
+++ b/res/layout/widgets_full_sheet_search_and_recommendations.xml
@@ -53,7 +53,7 @@
         android:id="@+id/recommended_widget_table"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginHorizontal="16dp"
+        android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
         android:layout_marginTop="8dp"
         android:background="@drawable/widgets_recommendation_background"
         android:paddingVertical="@dimen/recommended_widgets_table_vertical_padding"
diff --git a/res/layout/widgets_list_row_header.xml b/res/layout/widgets_list_row_header.xml
index 0bfa2b2..7f84050 100644
--- a/res/layout/widgets_list_row_header.xml
+++ b/res/layout/widgets_list_row_header.xml
@@ -19,8 +19,7 @@
     android:id="@+id/widgets_list_header"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:layout_marginHorizontal="16dp"
-    android:layout_marginBottom="@dimen/widget_list_entry_bottom_margin"
+    android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
     android:paddingVertical="@dimen/widget_list_header_view_vertical_padding"
     android:orientation="horizontal"
     launcher:appIconSize="48dp">
diff --git a/res/layout/widgets_personal_work_tabs.xml b/res/layout/widgets_personal_work_tabs.xml
index 15275a6..532c422 100644
--- a/res/layout/widgets_personal_work_tabs.xml
+++ b/res/layout/widgets_personal_work_tabs.xml
@@ -20,28 +20,34 @@
     android:id="@+id/tabs"
     android:layout_width="match_parent"
     android:layout_height="@dimen/all_apps_header_pill_height"
-    android:layout_marginHorizontal="32dp"
+    android:gravity="center_horizontal"
     android:orientation="horizontal"
-    android:background="@drawable/all_apps_tabs_background"
+    android:layout_marginHorizontal="@dimen/widget_tabs_horizontal_margin"
     style="@style/TextHeadline">
 
     <Button
         android:id="@+id/tab_personal"
         android:layout_width="0dp"
         android:layout_height="match_parent"
+        android:layout_marginEnd="@dimen/widget_tabs_button_horizontal_padding"
+        android:layout_marginVertical="@dimen/widget_apps_tabs_vertical_padding"
         android:layout_weight="1"
-        android:background="@drawable/personal_work_tabs_ripple"
+        android:background="@drawable/all_apps_tabs_background"
         android:text="@string/widgets_full_sheet_personal_tab"
         android:textColor="@color/all_apps_tab_text"
-        android:textSize="14sp" />
+        android:textSize="14sp"
+        style="?android:attr/borderlessButtonStyle" />
 
     <Button
         android:id="@+id/tab_work"
         android:layout_width="0dp"
         android:layout_height="match_parent"
+        android:layout_marginEnd="@dimen/widget_tabs_button_horizontal_padding"
+        android:layout_marginVertical="@dimen/widget_apps_tabs_vertical_padding"
         android:layout_weight="1"
-        android:background="@drawable/personal_work_tabs_ripple"
+        android:background="@drawable/all_apps_tabs_background"
         android:text="@string/widgets_full_sheet_work_tab"
         android:textColor="@color/all_apps_tab_text"
-        android:textSize="14sp" />
+        android:textSize="14sp"
+        style="?android:attr/borderlessButtonStyle" />
 </com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip>
\ No newline at end of file
diff --git a/res/layout/widgets_search_bar.xml b/res/layout/widgets_search_bar.xml
index 6a4bb4d..0b354e8 100644
--- a/res/layout/widgets_search_bar.xml
+++ b/res/layout/widgets_search_bar.xml
@@ -6,7 +6,7 @@
     android:layout_height="wrap_content"
     android:orientation="horizontal"
     android:layout_marginTop="24dp"
-    android:layout_marginHorizontal="16dp"
+    android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin"
     android:background="@drawable/bg_widgets_searchbox">
 
     <com.android.launcher3.ExtendedEditText
diff --git a/res/layout/widgets_table_container.xml b/res/layout/widgets_table_container.xml
index 4f70a05..ab470d8 100644
--- a/res/layout/widgets_table_container.xml
+++ b/res/layout/widgets_table_container.xml
@@ -18,5 +18,4 @@
     android:id="@+id/widgets_table"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:layout_marginHorizontal="16dp"
-    android:layout_marginBottom="@dimen/widget_list_entry_bottom_margin"/>
+    android:layout_marginHorizontal="@dimen/widget_list_horizontal_margin" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 251f04a..bc63c06 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -93,14 +93,14 @@
     <dimen name="all_apps_background_canvas_width">700dp</dimen>
     <dimen name="all_apps_background_canvas_height">475dp</dimen>
     <dimen name="all_apps_header_pill_height">48dp</dimen>
-    <dimen name="all_apps_header_pill_corner_radius">18dp</dimen>
-    <dimen name="all_apps_header_pills_width">348dp</dimen>
+    <dimen name="all_apps_header_pill_corner_radius">12dp</dimen>
     <dimen name="all_apps_header_tab_height">48dp</dimen>
     <dimen name="all_apps_tabs_indicator_height">2dp</dimen>
     <dimen name="all_apps_header_top_padding">36dp</dimen>
     <dimen name="all_apps_header_bottom_padding">6dp</dimen>
     <dimen name="all_apps_work_profile_tab_footer_top_padding">16dp</dimen>
     <dimen name="all_apps_work_profile_tab_footer_bottom_padding">20dp</dimen>
+    <dimen name="all_apps_tabs_button_horizontal_padding">4dp</dimen>
     <dimen name="all_apps_tabs_vertical_padding">6dp</dimen>
     <dimen name="all_apps_divider_height">2dp</dimen>
     <dimen name="all_apps_divider_width">128dp</dimen>
@@ -136,6 +136,11 @@
     <dimen name="widget_cell_horizontal_padding">16dp</dimen>
     <dimen name="widget_cell_font_size">14sp</dimen>
 
+    <dimen name="widget_tabs_button_horizontal_padding">4dp</dimen>
+    <dimen name="widget_tabs_horizontal_margin">32dp</dimen>
+    <dimen name="widget_apps_header_pill_height">48dp</dimen>
+    <dimen name="widget_apps_tabs_vertical_padding">6dp</dimen>
+
     <dimen name="recommended_widgets_table_vertical_padding">8dp</dimen>
 
     <!-- Bottom margin for the search and recommended widgets container without work profile -->
@@ -147,7 +152,8 @@
     <dimen name="widget_list_content_corner_radius">4dp</dimen>
 
     <dimen name="widget_list_header_view_vertical_padding">20dp</dimen>
-    <dimen name="widget_list_entry_bottom_margin">2dp</dimen>
+    <dimen name="widget_list_entry_spacing">2dp</dimen>
+    <dimen name="widget_list_horizontal_margin">16dp</dimen>
 
     <dimen name="widget_preview_shadow_blur">0.5dp</dimen>
     <dimen name="widget_preview_key_shadow_distance">1dp</dimen>
diff --git a/res/values/id.xml b/res/values/id.xml
index 1bd40ce..1709c59 100644
--- a/res/values/id.xml
+++ b/res/values/id.xml
@@ -16,6 +16,7 @@
 -->
 <resources>
     <item type="id" name="apps_list_view_work" />
+    <item type="id" name="tag_widget_entry" />
     <item type="id" name="view_type_widgets_list" />
     <item type="id" name="view_type_widgets_header" />
     <item type="id" name="view_type_widgets_search_header" />
diff --git a/src/com/android/launcher3/anim/AnimatorPlaybackController.java b/src/com/android/launcher3/anim/AnimatorPlaybackController.java
index 7d8b82a..85ca280 100644
--- a/src/com/android/launcher3/anim/AnimatorPlaybackController.java
+++ b/src/com/android/launcher3/anim/AnimatorPlaybackController.java
@@ -278,12 +278,19 @@
         }
     }
 
-    public void dispatchOnStart() {
+    public AnimatorPlaybackController dispatchOnStart() {
         callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationStart);
+        return this;
     }
 
-    public void dispatchOnCancel() {
+    public AnimatorPlaybackController dispatchOnCancel() {
         callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationCancel);
+        return this;
+    }
+
+    public AnimatorPlaybackController dispatchOnEnd() {
+        callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationEnd);
+        return this;
     }
 
     public void dispatchSetInterpolator(TimeInterpolator interpolator) {
@@ -328,7 +335,7 @@
         public void onAnimationSuccess(Animator animator) {
             // We wait for the spring (if any) to finish running before completing the end callback.
             if (!mDispatched) {
-                callListenerCommandRecursively(mAnim, AnimatorListener::onAnimationEnd);
+                dispatchOnEnd();
                 if (mEndAction != null) {
                     mEndAction.run();
                 }
diff --git a/src/com/android/launcher3/model/data/ItemInfo.java b/src/com/android/launcher3/model/data/ItemInfo.java
index 3abcc2b..7091d2b 100644
--- a/src/com/android/launcher3/model/data/ItemInfo.java
+++ b/src/com/android/launcher3/model/data/ItemInfo.java
@@ -168,6 +168,8 @@
         cellY = info.cellY;
         spanX = info.spanX;
         spanY = info.spanY;
+        minSpanX = info.minSpanX;
+        minSpanY = info.minSpanY;
         rank = info.rank;
         screenId = info.screenId;
         itemType = info.itemType;
diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java
index dbd9c28..915e140 100644
--- a/src/com/android/launcher3/settings/SettingsActivity.java
+++ b/src/com/android/launcher3/settings/SettingsActivity.java
@@ -113,12 +113,6 @@
         Utilities.getPrefs(getApplicationContext()).registerOnSharedPreferenceChangeListener(this);
     }
 
-    @Override
-    protected void onStop() {
-        super.onStop();
-        finish();
-    }
-
     /**
      * Obtains the preference fragment to instantiate in this activity.
      *
diff --git a/src/com/android/launcher3/statemanager/StateManager.java b/src/com/android/launcher3/statemanager/StateManager.java
index 13d6568..b34af97 100644
--- a/src/com/android/launcher3/statemanager/StateManager.java
+++ b/src/com/android/launcher3/statemanager/StateManager.java
@@ -209,7 +209,7 @@
 
         // Cancel the current animation. This will reset mState to mCurrentStableState, so store it.
         STATE_TYPE fromState = mState;
-        mConfig.reset();
+        cancelAnimation();
 
         if (!animated) {
             mAtomicAnimationFactory.cancelAllStateElementAnimation();
@@ -303,7 +303,7 @@
     public AnimatorPlaybackController createAnimationToNewWorkspace(STATE_TYPE state,
             StateAnimationConfig config) {
         config.userControlled = true;
-        mConfig.reset();
+        cancelAnimation();
         config.copyTo(mConfig);
         mConfig.playbackController = createAnimationToNewWorkspaceInternal(state)
                 .createPlaybackController();
@@ -393,6 +393,11 @@
      */
     public void cancelAnimation() {
         mConfig.reset();
+        // It could happen that a new animation is set as a result of an endListener on the
+        // existing animation.
+        while (mConfig.currentAnimation != null || mConfig.playbackController != null) {
+            mConfig.reset();
+        }
     }
 
     public void setCurrentUserControlledAnimation(AnimatorPlaybackController controller) {
@@ -508,14 +513,19 @@
          * Cancels the current animation and resets config variables.
          */
         public void reset() {
+            AnimatorSet anim = currentAnimation;
+            AnimatorPlaybackController pc = playbackController;
+
             DEFAULT.copyTo(this);
             targetState = null;
+            currentAnimation = null;
+            playbackController = null;
+            changeId++;
 
-            if (playbackController != null) {
-                playbackController.getAnimationPlayer().cancel();
-                playbackController.dispatchOnCancel();
-            } else if (currentAnimation != null) {
-                AnimatorSet anim = currentAnimation;
+            if (pc != null) {
+                pc.getAnimationPlayer().cancel();
+                pc.dispatchOnCancel().dispatchOnEnd();
+            } else if (anim != null) {
                 anim.setDuration(0);
                 if (!anim.isStarted()) {
                     // If the animation is not started the listeners do not get notified,
@@ -525,10 +535,6 @@
                 }
                 anim.cancel();
             }
-
-            currentAnimation = null;
-            playbackController = null;
-            changeId++;
         }
 
         @Override
diff --git a/src/com/android/launcher3/widget/model/WidgetsListSearchHeaderEntry.java b/src/com/android/launcher3/widget/model/WidgetsListSearchHeaderEntry.java
index c0f89bc..055e4ec 100644
--- a/src/com/android/launcher3/widget/model/WidgetsListSearchHeaderEntry.java
+++ b/src/com/android/launcher3/widget/model/WidgetsListSearchHeaderEntry.java
@@ -60,7 +60,7 @@
         WidgetsListSearchHeaderEntry otherEntry = (WidgetsListSearchHeaderEntry) obj;
         return mWidgets.equals(otherEntry.mWidgets) && mPkgItem.equals(otherEntry.mPkgItem)
                 && mTitleSectionName.equals(otherEntry.mTitleSectionName)
-                && mIsWidgetListShown;
+                && mIsWidgetListShown == otherEntry.mIsWidgetListShown;
     }
 
     /** Returns a copy of this {@link WidgetsListSearchHeaderEntry} with the widget list shown. */
diff --git a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java
index 5d9adf0..b668c90 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsListAdapter.java
@@ -18,6 +18,7 @@
 import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_APP_EXPANDED;
 
 import android.content.Context;
+import android.graphics.Rect;
 import android.os.Process;
 import android.util.Log;
 import android.util.Size;
@@ -34,6 +35,7 @@
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 import androidx.recyclerview.widget.RecyclerView.Adapter;
+import androidx.recyclerview.widget.RecyclerView.LayoutParams;
 import androidx.recyclerview.widget.RecyclerView.ViewHolder;
 
 import com.android.launcher3.BaseActivity;
@@ -107,7 +109,8 @@
     @Nullable private Predicate<WidgetsListBaseEntry> mFilter = null;
     @Nullable private RecyclerView mRecyclerView;
     @Nullable private PackageUserKey mPendingClickHeader;
-    private int mShortcutPreviewPadding;
+    private final int mShortcutPreviewPadding;
+    private final int mSpacingBetweenEntries;
 
     private final WidgetPreviewLoadedCallback mPreviewLoadedCallback =
             ignored -> updateVisibleEntries();
@@ -141,11 +144,28 @@
         mShortcutPreviewPadding =
                 2 * context.getResources()
                         .getDimensionPixelSize(R.dimen.widget_preview_shortcut_padding);
+        mSpacingBetweenEntries =
+                context.getResources().getDimensionPixelSize(R.dimen.widget_list_entry_spacing);
     }
 
     @Override
     public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
         mRecyclerView = recyclerView;
+
+        mRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
+            @Override
+            public void getItemOffsets(
+                    @NonNull Rect outRect,
+                    @NonNull View view,
+                    @NonNull RecyclerView parent,
+                    @NonNull RecyclerView.State state) {
+                super.getItemOffsets(outRect, view, parent, state);
+                int position = ((LayoutParams) view.getLayoutParams()).getViewLayoutPosition();
+                boolean isHeader =
+                        view.getTag(R.id.tag_widget_entry) instanceof WidgetsListBaseEntry.Header;
+                outRect.top += position > 0 && isHeader ? mSpacingBetweenEntries : 0;
+            }
+        });
     }
 
     @Override
@@ -329,7 +349,9 @@
     @Override
     public void onBindViewHolder(ViewHolder holder, int pos) {
         ViewHolderBinder viewHolderBinder = mViewHolderBinders.get(getItemViewType(pos));
+        WidgetsListBaseEntry entry = mVisibleEntries.get(pos);
         viewHolderBinder.bindViewHolder(holder, mVisibleEntries.get(pos), pos);
+        holder.itemView.setTag(R.id.tag_widget_entry, entry);
     }
 
     @Override
diff --git a/src/com/android/launcher3/widget/picker/WidgetsListHeader.java b/src/com/android/launcher3/widget/picker/WidgetsListHeader.java
index cdab964..ef2adbb 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsListHeader.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsListHeader.java
@@ -30,7 +30,6 @@
 
 import androidx.annotation.Nullable;
 import androidx.annotation.UiThread;
-import androidx.recyclerview.widget.RecyclerView;
 
 import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.LauncherAppState;
@@ -59,7 +58,6 @@
     @Nullable private HandlerRunnable mIconLoadRequest;
     @Nullable private Drawable mIconDrawable;
     private final int mIconSize;
-    private final int mBottomMarginSize;
 
     private ImageView mAppIcon;
     private TextView mTitle;
@@ -86,8 +84,6 @@
                 R.styleable.WidgetsListRowHeader, defStyleAttr, /* defStyleRes= */ 0);
         mIconSize = a.getDimensionPixelSize(R.styleable.WidgetsListRowHeader_appIconSize,
                 grid.iconSizePx);
-        mBottomMarginSize =
-                getResources().getDimensionPixelSize(R.dimen.widget_list_entry_bottom_margin);
     }
 
     @Override
@@ -146,13 +142,6 @@
     public void setExpanded(boolean isExpanded) {
         this.mIsExpanded = isExpanded;
         mExpandToggle.setChecked(isExpanded);
-        if (getLayoutParams() instanceof RecyclerView.LayoutParams) {
-            int bottomMargin = isExpanded ? 0 : mBottomMarginSize;
-            RecyclerView.LayoutParams layoutParams =
-                    ((RecyclerView.LayoutParams) getLayoutParams());
-            layoutParams.bottomMargin = bottomMargin;
-            setLayoutParams(layoutParams);
-        }
     }
 
     /** Sets the {@link WidgetsListDrawableState} and refreshes the background drawable. */
diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
index 3ee8b33..7671841 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java
@@ -52,7 +52,7 @@
     private HeaderViewDimensionsProvider mHeaderViewDimensionsProvider;
     private int mLastVisibleWidgetContentTableHeight = 0;
     private int mWidgetHeaderHeight = 0;
-    private final int mCollapsedHeaderBottomMarginSize;
+    private final int mSpacingBetweenEntries;
     @Nullable private OnContentChangeListener mOnContentChangeListener;
 
     public WidgetsRecyclerView(Context context) {
@@ -72,9 +72,9 @@
         ActivityContext activity = ActivityContext.lookupContext(getContext());
         DeviceProfile grid = activity.getDeviceProfile();
 
-        // The bottom margin used when the header is not expanded.
-        mCollapsedHeaderBottomMarginSize =
-                getResources().getDimensionPixelSize(R.dimen.widget_list_entry_bottom_margin);
+        // The spacing used between entries.
+        mSpacingBetweenEntries =
+                getResources().getDimensionPixelSize(R.dimen.widget_list_entry_spacing);
     }
 
     @Override
@@ -270,16 +270,16 @@
         if (untilIndex > mAdapter.getItems().size()) {
             untilIndex = mAdapter.getItems().size();
         }
-        int expandedHeaderPosition = mAdapter.getSelectedHeaderPosition().orElse(-1);
         int totalItemsHeight = 0;
         for (int i = 0; i < untilIndex; i++) {
             WidgetsListBaseEntry entry = mAdapter.getItems().get(i);
             if (entry instanceof WidgetsListHeaderEntry
                     || entry instanceof WidgetsListSearchHeaderEntry) {
                 totalItemsHeight += mWidgetHeaderHeight;
-                if (expandedHeaderPosition != i) {
-                    // If the header is collapsed, include the bottom margin it will use.
-                    totalItemsHeight += mCollapsedHeaderBottomMarginSize;
+                if (i > 0) {
+                    // Each header contains the spacing between entries as top decoration, except
+                    // the first one.
+                    totalItemsHeight += mSpacingBetweenEntries;
                 }
             } else if (entry instanceof WidgetsListContentEntry) {
                 totalItemsHeight += mLastVisibleWidgetContentTableHeight;
diff --git a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
index df5d465..11185fb 100644
--- a/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/workprofile/PersonalWorkSlidingTabStrip.java
@@ -16,118 +16,43 @@
 package com.android.launcher3.workprofile;
 
 import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Paint;
 import android.util.AttributeSet;
-import android.view.View;
 import android.widget.Button;
 import android.widget.LinearLayout;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
-import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
 import com.android.launcher3.pageindicators.PageIndicator;
 
 /**
  * Supports two indicator colors, dedicated for personal and work tabs.
  */
 public class PersonalWorkSlidingTabStrip extends LinearLayout implements PageIndicator {
-    private final Paint mSelectedIndicatorPaint;
-
-    private int mTabVerticalPadding;
-    private final int mSelectedIndicatorRadius;
-
-    private int mIndicatorLeft = -1;
-    private int mIndicatorRight = -1;
-    private float mScrollOffset;
-    private int mSelectedPosition = 0;
-
     private OnActivePageChangedListener mOnActivePageChangedListener;
     private int mLastActivePage = 0;
-    private boolean mIsRtl;
 
     public PersonalWorkSlidingTabStrip(@NonNull Context context, @Nullable AttributeSet attrs) {
         super(context, attrs);
-        setWillNotDraw(false);
-
-        mTabVerticalPadding =
-                getResources().getDimensionPixelSize(R.dimen.all_apps_tabs_vertical_padding);
-
-        mSelectedIndicatorRadius = getResources().getDimensionPixelSize(
-                R.dimen.all_apps_header_pill_corner_radius);
-
-        mSelectedIndicatorPaint = new Paint();
-        mSelectedIndicatorPaint.setColor(
-                context.getColor(R.color.all_apps_tab_background_selected));
-
-        mIsRtl = Utilities.isRtl(getResources());
     }
 
     /**
      * Highlights tab with index pos
      */
     public void updateTabTextColor(int pos) {
-        mSelectedPosition = pos;
         for (int i = 0; i < getChildCount(); i++) {
             Button tab = (Button) getChildAt(i);
             tab.setSelected(i == pos);
         }
     }
 
-    private void updateIndicatorPosition(float scrollOffset) {
-        mScrollOffset = scrollOffset;
-        updateIndicatorPosition();
-    }
-
-    @Override
-    protected void onLayout(boolean changed, int l, int t, int r, int b) {
-        super.onLayout(changed, l, t, r, b);
-        updateTabTextColor(mSelectedPosition);
-        updateIndicatorPosition(mScrollOffset);
-    }
-
-    private void updateIndicatorPosition() {
-        int left = -1, right = -1;
-        final View leftTab = getLeftTab();
-        if (leftTab != null) {
-            left = (int) (leftTab.getLeft() + leftTab.getWidth() * mScrollOffset);
-            right = left + leftTab.getWidth();
-        }
-        setIndicatorPosition(left, right);
-    }
-
-    private View getLeftTab() {
-        return mIsRtl ? getChildAt(1) : getChildAt(0);
-    }
-
-    private void setIndicatorPosition(int left, int right) {
-        if (left != mIndicatorLeft || right != mIndicatorRight) {
-            mIndicatorLeft = left;
-            mIndicatorRight = right;
-            invalidate();
-        }
-    }
-
-    @Override
-    protected void onDraw(Canvas canvas) {
-        super.onDraw(canvas);
-        canvas.drawRoundRect(mIndicatorLeft, mTabVerticalPadding, mIndicatorRight,
-                getHeight() - mTabVerticalPadding, mSelectedIndicatorRadius,
-                mSelectedIndicatorRadius, mSelectedIndicatorPaint);
-    }
-
     @Override
     public void setScroll(int currentScroll, int totalScroll) {
-        float scrollOffset = ((float) currentScroll) / totalScroll;
-        updateIndicatorPosition(scrollOffset);
     }
 
     @Override
     public void setActiveMarker(int activePage) {
         updateTabTextColor(activePage);
-        updateIndicatorPosition(mIsRtl ? 1 - activePage : activePage);
         if (mOnActivePageChangedListener != null && mLastActivePage != activePage) {
             mOnActivePageChangedListener.onActivePageChanged(activePage);
         }
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index e32250e..1cb6b2d 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -25,6 +25,7 @@
 import androidx.test.uiautomator.By;
 import androidx.test.uiautomator.BySelector;
 import androidx.test.uiautomator.Direction;
+import androidx.test.uiautomator.StaleObjectException;
 import androidx.test.uiautomator.UiObject2;
 
 import com.android.launcher3.testing.TestProtocol;
@@ -61,7 +62,13 @@
 
     private boolean hasClickableIcon(UiObject2 allAppsContainer, UiObject2 appListRecycler,
             BySelector appIconSelector, int displayBottom) {
-        final UiObject2 icon = appListRecycler.findObject(appIconSelector);
+        final UiObject2 icon;
+        try {
+            icon = appListRecycler.findObject(appIconSelector);
+        } catch (StaleObjectException e) {
+            mLauncher.fail("All apps recycler disappeared from screen");
+            return false;
+        }
         if (icon == null) {
             LauncherInstrumentation.log("hasClickableIcon: icon not visible");
             return false;
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 96e8222..c05fc57 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -496,7 +496,7 @@
         }
     }
 
-    private void fail(String message) {
+    void fail(String message) {
         checkForAnomaly();
         Assert.fail(formatSystemHealthMessage(formatErrorWithEvents(
                 "http://go/tapl test failure:\nSummary: " + getContextDescription()
@@ -1449,6 +1449,9 @@
     Rect getVisibleBounds(UiObject2 object) {
         try {
             return object.getVisibleBounds();
+        } catch (StaleObjectException e) {
+            fail("Object " + object + " disappeared from screen");
+            return null;
         } catch (Throwable t) {
             fail(t.toString());
             return null;