Merge "[reset] Clean up ActivityAllAppsContainerView#reset." into main
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index d5306fb..3654e5f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -378,6 +378,12 @@
                     return (flags & FLAG_DISABLE_BACK) == 0
                             && ((flags & FLAG_KEYGUARD_VISIBLE) == 0 || showingOnKeyguard);
                 }));
+        // Hide back button in SUW if keyboard is showing (IME draws its own back).
+        if (mIsImeRenderingNavButtons) {
+            mPropertyHolders.add(new StatePropertyHolder(
+                    mBackButtonAlpha.get(ALPHA_INDEX_SUW),
+                    flags -> (flags & FLAG_IME_VISIBLE) == 0));
+        }
         mPropertyHolders.add(new StatePropertyHolder(mBackButton,
                 flags -> (flags & FLAG_IME_VISIBLE) != 0,
                 ROTATION_DRAWABLE_PERCENT, 1f, 0f));
@@ -791,13 +797,6 @@
 
         if (isInSetup) {
             handleSetupUi();
-
-            // Hide back button in SUW if keyboard is showing (IME draws its own back).
-            if (mIsImeRenderingNavButtons) {
-                mPropertyHolders.add(new StatePropertyHolder(
-                        mBackButtonAlpha.get(ALPHA_INDEX_SUW),
-                        flags -> (flags & FLAG_IME_VISIBLE) == 0));
-            }
         } else if (isInKidsMode) {
             int iconSize = res.getDimensionPixelSize(
                     R.dimen.taskbar_icon_size_kids);
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 8845813..a4b6ad0 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -272,7 +272,7 @@
                 R.drawable.ic_sysbar_rotate_button_cw_start_0,
                 R.drawable.ic_sysbar_rotate_button_cw_start_90,
                 () -> getDisplay().getRotation());
-        rotationButtonController.setBgExecutor(Executors.THREAD_POOL_EXECUTOR);
+        rotationButtonController.setBgExecutor(Executors.UI_HELPER_EXECUTOR);
 
         mControllers = new TaskbarControllers(this,
                 new TaskbarDragController(this),
diff --git a/res/drawable/ic_plus.xml b/res/drawable/ic_plus.xml
index 3ab926a..d004f42 100644
--- a/res/drawable/ic_plus.xml
+++ b/res/drawable/ic_plus.xml
@@ -14,7 +14,7 @@
      limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="19dp"
+    android:width="@dimen/widget_cell_add_button_drawable_width"
     android:height="18dp"
     android:viewportWidth="19"
     android:viewportHeight="18">
diff --git a/res/layout/widget_cell_content.xml b/res/layout/widget_cell_content.xml
index 8f786bf..462bb52 100644
--- a/res/layout/widget_cell_content.xml
+++ b/res/layout/widget_cell_content.xml
@@ -46,20 +46,22 @@
             android:layout_gravity="center_vertical"
             android:id="@+id/widget_text_container"
             android:orientation="vertical">
-            <!-- The name of the widget. -->
-            <TextView
-                android:id="@+id/widget_name"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:ellipsize="end"
-                android:fadingEdge="horizontal"
-                android:layout_gravity="center_horizontal"
-                android:gravity="center_horizontal|center_vertical"
-                android:singleLine="true"
-                android:maxLines="1"
-                android:textColor="?android:attr/textColorPrimary"
-                android:drawablePadding="@dimen/widget_cell_app_icon_padding"
-                android:textSize="@dimen/widget_cell_font_size" />
+                <!-- The name of the widget. -->
+                <TextView
+                    android:id="@+id/widget_name"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:ellipsize="end"
+                    android:fadingEdge="horizontal"
+                    android:layout_gravity="center_horizontal"
+                    android:gravity="center_horizontal|center_vertical"
+                    android:singleLine="true"
+                    android:maxLines="1"
+                    android:textColor="?attr/widgetCellTitleColor"
+                    android:textSize="@dimen/widget_cell_title_font_size"
+                    android:textFontWeight="@integer/widget_cell_title_font_weight"
+                    android:lineHeight="@dimen/widget_cell_title_line_height"
+                    android:drawablePadding="@dimen/widget_cell_app_icon_padding" />
 
                 <!-- The original dimensions of the widget -->
                 <TextView
@@ -67,21 +69,23 @@
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:gravity="center_horizontal"
-                    android:textColor="?android:attr/textColorSecondary"
-                    android:textSize="@dimen/widget_cell_font_size"
-                    android:alpha="0.7" />
+                    android:textColor="?attr/widgetCellSubtitleColor"
+                    android:textSize="@dimen/widget_cell_dims_font_size"
+                    android:textFontWeight="@integer/widget_cell_dims_font_weight"
+                    android:lineHeight="@dimen/widget_cell_dims_line_height" />
 
                 <TextView
                     android:id="@+id/widget_description"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:gravity="center_horizontal"
-                    android:textSize="@dimen/widget_cell_font_size"
-                    android:textColor="?android:attr/textColorSecondary"
+                    android:textColor="?attr/widgetCellSubtitleColor"
+                    android:textSize="@dimen/widget_cell_description_font_size"
+                    android:textFontWeight="@integer/widget_cell_description_font_weight"
+                    android:lineHeight="@dimen/widget_cell_description_line_height"
                     android:maxLines="3"
                     android:ellipsize="end"
-                    android:fadingEdge="horizontal"
-                    android:alpha="0.7" />
+                    android:fadingEdge="horizontal" />
         </LinearLayout>
 
         <Button
@@ -94,12 +98,15 @@
             android:paddingEnd="@dimen/widget_cell_add_button_end_padding"
             android:text="@string/widget_add_button_label"
             android:textColor="?attr/widgetPickerAddButtonTextColor"
-            android:textSize="@dimen/widget_cell_font_size"
+            android:textSize="@dimen/widget_cell_add_button_font_size"
+            android:fontWeight="@integer/widget_cell_add_button_font_weight"
+            android:lineHeight="@dimen/widget_cell_add_button_line_height"
             android:gravity="center"
             android:visibility="gone"
             android:drawableStart="@drawable/ic_plus"
-            android:drawablePadding="8dp"
+            android:drawablePadding="@dimen/widget_cell_add_button_drawable_padding"
             android:drawableTint="?attr/widgetPickerAddButtonTextColor"
+            android:maxLines="1"
             android:background="@drawable/widget_cell_add_button_background" />
     </FrameLayout>
 </merge>
diff --git a/res/layout/widgets_list_row_header.xml b/res/layout/widgets_list_row_header.xml
index 6d26ce3..98f9dac 100644
--- a/res/layout/widgets_list_row_header.xml
+++ b/res/layout/widgets_list_row_header.xml
@@ -48,8 +48,10 @@
             android:layout_gravity="start|center_vertical"
             android:ellipsize="end"
             android:maxLines="1"
-            android:textColor="?android:attr/textColorPrimary"
-            android:textSize="16sp"
+            android:textColor="?attr/widgetPickerHeaderAppTitleColor"
+            android:textSize="@dimen/widget_picker_header_app_title_font_size"
+            android:textFontWeight="@integer/widget_picker_header_app_title_font_weight"
+            android:lineHeight="@dimen/widget_picker_header_app_title_line_height"
             tools:text="App name" />
 
         <TextView
@@ -58,8 +60,10 @@
             android:layout_height="wrap_content"
             android:ellipsize="end"
             android:maxLines="1"
-            android:textColor="?android:attr/textColorSecondary"
-            android:alpha="0.7"
+            android:textColor="?attr/widgetPickerHeaderAppSubtitleColor"
+            android:textSize="@dimen/widget_picker_header_app_subtitle_font_size"
+            android:textFontWeight="@integer/widget_picker_header_app_subtitle_font_weight"
+            android:lineHeight="@dimen/widget_picker_header_app_subtitle_line_height"
             tools:text="m widgets, n shortcuts" />
 
     </LinearLayout>
diff --git a/res/layout/widgets_list_row_header_two_pane.xml b/res/layout/widgets_list_row_header_two_pane.xml
index bdb2aed..d4baf0a 100644
--- a/res/layout/widgets_list_row_header_two_pane.xml
+++ b/res/layout/widgets_list_row_header_two_pane.xml
@@ -51,7 +51,9 @@
             android:ellipsize="end"
             android:maxLines="1"
             android:textColor="?attr/widgetPickerHeaderAppTitleColor"
-            android:textSize="16sp"
+            android:textSize="@dimen/widget_picker_header_app_title_font_size"
+            android:textFontWeight="@integer/widget_picker_header_app_title_font_weight"
+            android:lineHeight="@dimen/widget_picker_header_app_title_line_height"
             android:duplicateParentState="true"
             tools:text="App name" />
 
@@ -62,7 +64,9 @@
             android:ellipsize="end"
             android:maxLines="1"
             android:textColor="?attr/widgetPickerHeaderAppSubtitleColor"
-            android:alpha="0.7"
+            android:textSize="@dimen/widget_picker_header_app_subtitle_font_size"
+            android:textFontWeight="@integer/widget_picker_header_app_subtitle_font_weight"
+            android:lineHeight="@dimen/widget_picker_header_app_subtitle_line_height"
             android:duplicateParentState="true"
             tools:text="m widgets, n shortcuts" />
 
diff --git a/res/values-night-v34/colors.xml b/res/values-night-v34/colors.xml
new file mode 100644
index 0000000..af28119
--- /dev/null
+++ b/res/values-night-v34/colors.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2024, 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.
+*/
+-->
+<resources  xmlns:android="http://schemas.android.com/apk/res/android">
+    <color name="widget_picker_secondary_surface_color_dark">
+        @android:color/system_surface_bright_dark</color>
+    <color name="widget_picker_header_app_title_color_dark">
+        @android:color/system_on_surface_dark</color>
+    <color name="widget_picker_header_app_subtitle_color_dark">
+        @android:color/system_on_surface_variant_dark</color>
+    <color name="widget_cell_title_color_dark">
+        @android:color/system_on_surface_dark</color>
+    <color name="widget_cell_subtitle_color_dark">
+        @android:color/system_on_surface_variant_dark</color>
+</resources>
diff --git a/res/values-v34/colors.xml b/res/values-v34/colors.xml
new file mode 100644
index 0000000..26d3712
--- /dev/null
+++ b/res/values-v34/colors.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2024, 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.
+*/
+-->
+<resources  xmlns:android="http://schemas.android.com/apk/res/android">
+    <color name="widget_picker_secondary_surface_color_light">
+        @android:color/system_surface_bright_light</color>
+    <color name="widget_picker_header_app_title_color_light">
+        @android:color/system_on_surface_light</color>
+    <color name="widget_picker_header_app_subtitle_color_light">
+        @android:color/system_on_surface_variant_light</color>
+    <color name="widget_cell_title_color_light">
+        @android:color/system_on_surface_light</color>
+    <color name="widget_cell_subtitle_color_light">
+        @android:color/system_on_surface_variant_light</color>
+</resources>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index f23c790..be8b2e1 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -76,6 +76,8 @@
     <attr name="widgetPickerCollapseHandleColor" format="color"/>
     <attr name="widgetPickerAddButtonBackgroundColor" format="color"/>
     <attr name="widgetPickerAddButtonTextColor" format="color"/>
+    <attr name="widgetCellTitleColor" format="color" />
+    <attr name="widgetCellSubtitleColor" format="color" />
 
     <!-- BubbleTextView specific attributes. -->
     <declare-styleable name="BubbleTextView">
diff --git a/res/values/colors.xml b/res/values/colors.xml
index dfe40fc..ce80964 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -117,6 +117,8 @@
     <color name="widget_picker_collapse_handle_color_light">#C4C7C5</color>
     <color name="widget_picker_add_button_background_color_light">#0B57D0</color>
     <color name="widget_picker_add_button_text_color_light">#0B57D0</color>
+    <color name="widget_cell_title_color_light">@color/material_color_on_surface</color>
+    <color name="widget_cell_subtitle_color_light">@color/material_color_on_surface_variant</color>
 
     <color name="widget_picker_primary_surface_color_dark">#1F2020</color>
     <color name="widget_picker_secondary_surface_color_dark">#393939</color>
@@ -134,6 +136,8 @@
     <color name="widget_picker_collapse_handle_color_dark">#444746</color>
     <color name="widget_picker_add_button_background_color_dark">#062E6F</color>
     <color name="widget_picker_add_button_text_color_dark">#FFFFFF</color>
+    <color name="widget_cell_title_color_dark">@color/material_color_on_surface</color>
+    <color name="widget_cell_subtitle_color_dark">@color/material_color_on_surface_variant</color>
 
     <color name="material_color_on_secondary_fixed_variant">#3F4759</color>
     <color name="material_color_on_tertiary_fixed_variant">#583E5B</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 1bf59e8..4e5ef12 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -179,19 +179,39 @@
     <!-- Widget tray -->
     <dimen name="widget_cell_vertical_padding">8dp</dimen>
     <dimen name="widget_cell_horizontal_padding">8dp</dimen>
-    <dimen name="widget_cell_font_size">14sp</dimen>
+    <dimen name="widget_cell_title_font_size">14sp</dimen>
+    <integer name="widget_cell_title_font_weight">500</integer>
+    <dimen name="widget_cell_title_line_height">20sp</dimen>
+    <dimen name="widget_cell_dims_font_size">14sp</dimen>
+    <integer name="widget_cell_dims_font_weight">400</integer>
+    <dimen name="widget_cell_dims_line_height">20sp</dimen>
+    <dimen name="widget_cell_description_font_size">12sp</dimen>
+    <integer name="widget_cell_description_font_weight">400</integer>
+    <dimen name="widget_cell_description_line_height">16sp</dimen>
     <dimen name="widget_cell_app_icon_size">24dp</dimen>
     <dimen name="widget_cell_app_icon_padding">8dp</dimen>
     <dimen name="widget_cell_add_button_height">48dp</dimen>
     <dimen name="widget_cell_add_button_start_padding">8dp</dimen>
+    <dimen name="widget_cell_add_icon_button_start_padding">16dp</dimen>
     <dimen name="widget_cell_add_button_end_padding">16dp</dimen>
     <dimen name="widget_cell_add_button_scroll_padding">24dp</dimen>
+    <dimen name="widget_cell_add_button_font_size">14sp</dimen>
+    <integer name="widget_cell_add_button_font_weight">500</integer>
+    <dimen name="widget_cell_add_button_line_height">20sp</dimen>
+    <dimen name="widget_cell_add_button_drawable_padding">8dp</dimen>
+    <dimen name="widget_cell_add_button_drawable_width">19dp</dimen>
 
     <dimen name="widget_tabs_button_horizontal_padding">4dp</dimen>
     <dimen name="widget_tabs_horizontal_padding">16dp</dimen>
     <dimen name="widget_apps_tabs_vertical_padding">6dp</dimen>
     <dimen name="widget_picker_landscape_tablet_left_right_margin">117dp</dimen>
     <dimen name="widget_picker_two_panels_left_right_margin">0dp</dimen>
+    <dimen name="widget_picker_header_app_title_font_size">16sp</dimen>
+    <integer name="widget_picker_header_app_title_font_weight">500</integer>
+    <dimen name="widget_picker_header_app_title_line_height">24sp</dimen>
+    <dimen name="widget_picker_header_app_subtitle_font_size">14sp</dimen>
+    <integer name="widget_picker_header_app_subtitle_font_weight">400</integer>
+    <dimen name="widget_picker_header_app_subtitle_line_height">20sp</dimen>
     <dimen name="widget_recommendations_table_vertical_padding">8dp</dimen>
     <!-- Bottom margin for the search and recommended widgets container without work profile -->
     <dimen name="search_and_recommended_widgets_container_bottom_margin">16dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 00b962e..6d99084 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -268,6 +268,10 @@
             @color/widget_picker_add_button_background_color_light</item>
         <item name="widgetPickerAddButtonTextColor">
             @color/widget_picker_add_button_text_color_light</item>
+        <item name="widgetCellTitleColor">
+            @color/widget_cell_title_color_light</item>
+        <item name="widgetCellSubtitleColor">
+            @color/widget_cell_subtitle_color_light</item>
     </style>
     <style name="WidgetContainerTheme.Dark" parent="AppTheme.Dark">
         <item name="android:colorEdgeEffect">?android:attr/textColorSecondary</item>
@@ -303,6 +307,10 @@
             @color/widget_picker_add_button_background_color_dark</item>
         <item name="widgetPickerAddButtonTextColor">
             @color/widget_picker_add_button_text_color_dark</item>
+        <item name="widgetCellTitleColor">
+            @color/widget_cell_title_color_dark</item>
+        <item name="widgetCellSubtitleColor">
+            @color/widget_cell_subtitle_color_dark</item>
     </style>
 
     <style name="FastScrollerPopup" parent="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle">
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java
index b46d7e2..b51e850 100644
--- a/src/com/android/launcher3/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher3/AppWidgetResizeFrame.java
@@ -136,6 +136,7 @@
     private final Rect mWidgetViewNewRect = new Rect();
     private final @Nullable LauncherAppWidgetHostView.CellChildViewPreLayoutListener
             mCellChildViewPreLayoutListener;
+    private final @NonNull OnLayoutChangeListener mWidgetViewLayoutListener;
 
     private int mXDown, mYDown;
 
@@ -177,6 +178,9 @@
         mDragAcrossTwoPanelOpacityMargin = mLauncher.getResources().getDimensionPixelSize(
                 R.dimen.resize_frame_invalid_drag_across_two_panel_opacity_margin);
         mDragLayerRelativeCoordinateHelper = new ViewGroupFocusHelper(mLauncher.getDragLayer());
+
+        mWidgetViewLayoutListener =
+                (v, l, t, r, b, oldL, oldT, oldR, oldB) -> setCornerRadiusFromWidget();
     }
 
     @Override
@@ -211,15 +215,6 @@
         DragLayer dl = launcher.getDragLayer();
         AppWidgetResizeFrame frame = (AppWidgetResizeFrame) launcher.getLayoutInflater()
                 .inflate(R.layout.app_widget_resize_frame, dl, false);
-        if (widget.hasEnforcedCornerRadius()) {
-            float enforcedCornerRadius = widget.getEnforcedCornerRadius();
-            ImageView imageView = frame.findViewById(R.id.widget_resize_frame);
-            Drawable d = imageView.getDrawable();
-            if (d instanceof GradientDrawable) {
-                GradientDrawable gd = (GradientDrawable) d.mutate();
-                gd.setCornerRadius(enforcedCornerRadius);
-            }
-        }
         frame.setupForWidget(widget, cellLayout, dl);
         ((DragLayer.LayoutParams) frame.getLayoutParams()).customPosition = true;
 
@@ -228,6 +223,18 @@
         frame.post(() -> frame.snapToWidget(false));
     }
 
+    private void setCornerRadiusFromWidget() {
+        if (mWidgetView != null && mWidgetView.hasEnforcedCornerRadius()) {
+            float enforcedCornerRadius = mWidgetView.getEnforcedCornerRadius();
+            ImageView imageView = findViewById(R.id.widget_resize_frame);
+            Drawable d = imageView.getDrawable();
+            if (d instanceof GradientDrawable) {
+                GradientDrawable gd = (GradientDrawable) d.mutate();
+                gd.setCornerRadius(enforcedCornerRadius);
+            }
+        }
+    }
+
     private void setupForWidget(LauncherAppWidgetHostView widgetView, CellLayout cellLayout,
             DragLayer dragLayer) {
         mCellLayout = cellLayout;
@@ -317,6 +324,9 @@
                 .log(LAUNCHER_WIDGET_RESIZE_STARTED);
 
         setOnKeyListener(this);
+
+        setCornerRadiusFromWidget();
+        mWidgetView.addOnLayoutChangeListener(mWidgetViewLayoutListener);
     }
 
     public boolean beginResizeIfPointInRegion(int x, int y) {
@@ -729,6 +739,7 @@
             mWidgetView.setLayoutTransition(null);
         }
         mDragLayer.removeView(this);
+        mWidgetView.removeOnLayoutChangeListener(mWidgetViewLayoutListener);
     }
 
     private void updateInvalidResizeEffect(CellLayout cellLayout, CellLayout pairedCellLayout,
diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
index 19c3ebe..ec45415 100644
--- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
+++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java
@@ -31,6 +31,7 @@
 import com.android.launcher3.ExtendedEditText;
 import com.android.launcher3.Utilities;
 import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
+import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.search.SearchAlgorithm;
 import com.android.launcher3.search.SearchCallback;
 import com.android.launcher3.views.ActivityContext;
@@ -143,7 +144,7 @@
 
     @Override
     public void onFocusChange(View view, boolean hasFocus) {
-        if (!hasFocus) {
+        if (!hasFocus && !FeatureFlags.ENABLE_DEVICE_SEARCH.get()) {
             mInput.hideKeyboard();
         }
     }
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index 6dcaf75..5dacfb0 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -29,6 +29,7 @@
 import android.animation.TimeInterpolator;
 import android.content.Context;
 import android.graphics.Bitmap;
+import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.text.TextUtils;
 import android.util.AttributeSet;
@@ -544,12 +545,47 @@
         if (mIsShowingAddButton) return;
         mIsShowingAddButton = true;
 
+        setupIconOrTextButton();
         mWidgetAddButton.setOnClickListener(callback);
         fadeThrough(/* hide= */ mWidgetTextContainer, /* show= */ mWidgetAddButton,
                 ADD_BUTTON_FADE_DURATION_MS, Interpolators.LINEAR);
     }
 
     /**
+     * Depending on the width of the cell, set up the add button to be icon-only or icon+text.
+     */
+    private void setupIconOrTextButton() {
+        String addText = getResources().getString(R.string.widget_add_button_label);
+        Rect textSize = new Rect();
+        mWidgetAddButton.getPaint().getTextBounds(addText, 0, addText.length(), textSize);
+        int startPadding = getResources()
+                .getDimensionPixelSize(R.dimen.widget_cell_add_button_start_padding);
+        int endPadding = getResources()
+                .getDimensionPixelSize(R.dimen.widget_cell_add_button_end_padding);
+        int drawableWidth = getResources()
+                .getDimensionPixelSize(R.dimen.widget_cell_add_button_drawable_width);
+        int drawablePadding = getResources()
+                .getDimensionPixelSize(R.dimen.widget_cell_add_button_drawable_padding);
+        int textButtonWidth = textSize.width() + startPadding + endPadding + drawableWidth
+                + drawablePadding;
+        if (textButtonWidth > getMeasuredWidth()) {
+            // Setup icon-only button
+            mWidgetAddButton.setText(null);
+            int startIconPadding = getResources()
+                    .getDimensionPixelSize(R.dimen.widget_cell_add_icon_button_start_padding);
+            mWidgetAddButton.setPaddingRelative(/* start= */ startIconPadding, /* top= */ 0,
+                    /* end= */ endPadding, /* bottom= */ 0);
+            mWidgetAddButton.setCompoundDrawablePadding(0);
+        } else {
+            // Setup icon + text button
+            mWidgetAddButton.setText(addText);
+            mWidgetAddButton.setPaddingRelative(/* start= */ startPadding, /* top= */ 0,
+                    /* end= */ endPadding, /* bottom= */ 0);
+            mWidgetAddButton.setCompoundDrawablePadding(drawablePadding);
+        }
+    }
+
+    /**
      * Hide tap to add button.
      */
     public void hideAddButton(boolean animate) {
diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java b/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java
index 03af0cb..6dbad5c 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java
@@ -58,12 +58,13 @@
 
     public WidgetsRecommendationTableLayout(Context context, AttributeSet attrs) {
         super(context, attrs);
-        // There are 1 row for title, 1 row for dimension and 2 rows for description.
+        // There are 1 row for title, 1 row for dimension and max 3 rows for description.
         mWidgetsRecommendationTableVerticalPadding = 2 * getResources()
                 .getDimensionPixelSize(R.dimen.widget_recommendations_table_vertical_padding);
         mWidgetCellVerticalPadding = 2 * getResources()
                 .getDimensionPixelSize(R.dimen.widget_cell_vertical_padding);
-        mWidgetCellTextViewsHeight = 4 * getResources().getDimension(R.dimen.widget_cell_font_size);
+        mWidgetCellTextViewsHeight =
+                getResources().getDimension(R.dimen.widget_cell_title_line_height);
     }
 
     /** Sets a {@link android.view.View.OnLongClickListener} for all widget cells in this table. */
diff --git a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java
index 108db6c..8c47332 100644
--- a/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java
+++ b/tests/multivalentTests/shared/com/android/launcher3/testing/shared/TestProtocol.java
@@ -179,7 +179,6 @@
     public static final String WIDGET_CONFIG_NULL_EXTRA_INTENT = "b/324419890";
     public static final String ACTIVITY_NOT_RESUMED_AFTER_BACK = "b/322823209";
     public static final String OVERVIEW_SELECT_TOOLTIP_MISALIGNED = "b/332485341";
-
     public static final String REQUEST_EMULATE_DISPLAY = "emulate-display";
     public static final String REQUEST_STOP_EMULATE_DISPLAY = "stop-emulate-display";
     public static final String REQUEST_IS_EMULATE_DISPLAY_RUNNING = "is-emulate-display-running";
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 99e15ba..115a6e6 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -98,7 +98,7 @@
 public abstract class AbstractLauncherUiTest<LAUNCHER_TYPE extends Launcher> {
 
     public static final long DEFAULT_ACTIVITY_TIMEOUT = TimeUnit.SECONDS.toMillis(10);
-    public static final long DEFAULT_BROADCAST_TIMEOUT_SECS = 5;
+    public static final long DEFAULT_BROADCAST_TIMEOUT_SECS = 10;
 
     public static final long DEFAULT_UI_TIMEOUT = TestUtil.DEFAULT_UI_TIMEOUT;
     private static final String TAG = "AbstractLauncherUiTest";
@@ -548,7 +548,7 @@
         public Intent blockingGetIntent() throws InterruptedException {
             Log.d(WIDGET_CONFIG_NULL_EXTRA_INTENT,
                     "AbstractLauncherUiTest.blockingGetIntent()");
-            latch.await(DEFAULT_BROADCAST_TIMEOUT_SECS, TimeUnit.SECONDS);
+            assertTrue("Timed Out", latch.await(DEFAULT_BROADCAST_TIMEOUT_SECS, TimeUnit.SECONDS));
             mTargetContext.unregisterReceiver(this);
             Log.d(WIDGET_CONFIG_NULL_EXTRA_INTENT, mIntent == null
                     ? "AbstractLauncherUiTest.onReceive(): mIntent NULL"
diff --git a/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java b/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java
index 8fc4481..d4e061a 100644
--- a/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java
+++ b/tests/src/com/android/launcher3/widget/picker/WidgetsListHeaderViewHolderBinderTest.java
@@ -31,6 +31,7 @@
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.os.UserHandle;
+import android.view.ContextThemeWrapper;
 import android.view.LayoutInflater;
 import android.widget.FrameLayout;
 import android.widget.TextView;
@@ -79,7 +80,8 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        mContext = new ActivityContextWrapper(getApplicationContext());
+        mContext = new ActivityContextWrapper(new ContextThemeWrapper(getApplicationContext(),
+                R.style.WidgetContainerTheme));
         mTestProfile = new InvariantDeviceProfile();
         mTestProfile.numRows = 5;
         mTestProfile.numColumns = 5;