diff --git a/quickstep/src/com/android/launcher3/WidgetPickerActivity.java b/quickstep/src/com/android/launcher3/WidgetPickerActivity.java
index 7235b63674..89840866c9 100644
--- a/quickstep/src/com/android/launcher3/WidgetPickerActivity.java
+++ b/quickstep/src/com/android/launcher3/WidgetPickerActivity.java
@@ -44,7 +44,6 @@ import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.util.ComponentKey;
-import com.android.launcher3.widget.BaseWidgetSheet;
import com.android.launcher3.widget.WidgetCell;
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
import com.android.launcher3.widget.model.WidgetsListContentEntry;
@@ -80,6 +79,15 @@ public class WidgetPickerActivity extends BaseActivity {
*
This allows widget picker to exclude existing widgets from suggestions.
*/
private static final String EXTRA_ADDED_APP_WIDGETS = "added_app_widgets";
+ /**
+ * Intent extra for the string representing the title displayed within the picker header.
+ */
+ private static final String EXTRA_PICKER_TITLE = "picker_title";
+ /**
+ * Intent extra for the string representing the description displayed within the picker header.
+ */
+ private static final String EXTRA_PICKER_DESCRIPTION = "picker_description";
+
/**
* A unique identifier of the surface hosting the widgets;
* "widgets" is reserved for home screen surface.
@@ -108,6 +116,10 @@ public class WidgetPickerActivity extends BaseActivity {
// Widgets existing on the host surface.
@NonNull
private List mAddedWidgets = new ArrayList<>();
+ @Nullable
+ private String mTitle;
+ @Nullable
+ private String mDescription;
/** A set of user ids that should be filtered out from the selected widgets. */
@NonNull
@@ -137,6 +149,9 @@ public class WidgetPickerActivity extends BaseActivity {
}
private void parseIntentExtras() {
+ mTitle = getIntent().getStringExtra(EXTRA_PICKER_TITLE);
+ mDescription = getIntent().getStringExtra(EXTRA_PICKER_DESCRIPTION);
+
// A value of 0 for either size means that no filtering will occur in that dimension. If
// both values are 0, then no size filtering will occur.
mDesiredWidgetWidth =
@@ -241,7 +256,7 @@ public class WidgetPickerActivity extends BaseActivity {
/** Updates the model with widgets, applies filters and launches the widgets sheet once
* widgets are available */
private void refreshAndBindWidgets() {
- MODEL_EXECUTOR.getHandler().postDelayed(() -> {
+ MODEL_EXECUTOR.execute(() -> {
LauncherAppState app = LauncherAppState.getInstance(this);
mModel.update(app, null);
final List allWidgets =
@@ -271,7 +286,7 @@ public class WidgetPickerActivity extends BaseActivity {
mUiSurface, allWidgetItems);
mWidgetPredictionsRequester.request(mAddedWidgets, this::bindRecommendedWidgets);
}
- }, mDeviceProfile.bottomSheetOpenDuration);
+ });
}
private void bindWidgets(List widgets) {
@@ -280,7 +295,8 @@ public class WidgetPickerActivity extends BaseActivity {
private void openWidgetsSheet() {
MAIN_EXECUTOR.execute(() -> {
- BaseWidgetSheet widgetSheet = WidgetsFullSheet.show(this, true);
+ WidgetsFullSheet widgetSheet = WidgetsFullSheet.show(this, true);
+ widgetSheet.mayUpdateTitleAndDescription(mTitle, mDescription);
widgetSheet.disableNavBarScrim(true);
widgetSheet.addOnCloseListener(this::finish);
});
diff --git a/res/layout/widgets_two_pane_sheet.xml b/res/layout/widgets_two_pane_sheet.xml
index bb2b7bd744..ce5eed93ee 100644
--- a/res/layout/widgets_two_pane_sheet.xml
+++ b/res/layout/widgets_two_pane_sheet.xml
@@ -48,20 +48,23 @@
android:textSize="24sp" />
+ android:lineHeight="20sp"
+ android:textSize="14sp" />
+ android:layout_below="@id/widget_picker_description">
+
+
@android:color/system_neutral1_700
@android:color/system_neutral1_100
+
+ @android:color/system_neutral2_200
@android:color/system_neutral1_100
diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml
index fa87221f52..727036680d 100644
--- a/res/values-v31/colors.xml
+++ b/res/values-v31/colors.xml
@@ -75,6 +75,8 @@
@android:color/system_neutral1_900
+
+ @android:color/system_neutral2_700
@android:color/system_neutral1_900
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index be8b2e13d9..e4e047e1bb 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -61,6 +61,7 @@
+
diff --git a/res/values/colors.xml b/res/values/colors.xml
index ce8096404b..8fa1992377 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -104,6 +104,7 @@
#EFEDED
#FAF9F8
#1F1F1F
+ #4C4D50
#1F1F1F
#444746
#C2E7FF
@@ -123,6 +124,7 @@
#1F2020
#393939
#E3E3E3
+ #CCCDCF
#E3E3E3
#C4C7C5
#004A77
diff --git a/res/values/styles.xml b/res/values/styles.xml
index ae3d3b3e11..f7273a03c7 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -243,6 +243,7 @@
-
@color/widget_picker_secondary_surface_color_light
- @color/widget_picker_title_color_light
+ - @color/widget_picker_description_color_light
-
@color/widget_picker_header_app_title_color_light
-
@@ -282,6 +283,7 @@
@color/widget_picker_secondary_surface_color_dark
-
@color/widget_picker_title_color_dark
+ - @color/widget_picker_description_color_dark
-
@color/widget_picker_header_app_title_color_dark
-
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index fd15677ab7..2e36583b74 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -679,6 +679,18 @@ public class WidgetsFullSheet extends BaseWidgetSheet
return sheet;
}
+ /**
+ * Updates the widget picker's title and description in the header to the provided values (if
+ * present).
+ */
+ public void mayUpdateTitleAndDescription(@Nullable String title,
+ @Nullable String descriptionRes) {
+ if (title != null) {
+ mHeaderTitle.setText(title);
+ }
+ // Full sheet doesn't support a description.
+ }
+
@Override
public void saveHierarchyState(SparseArray sparseArray) {
Bundle bundle = new Bundle();
diff --git a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
index 840d98a271..5b7bbc21f1 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java
@@ -36,6 +36,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ScrollView;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -60,9 +61,6 @@ import java.util.List;
* Popup for showing the full list of available widgets with a two-pane layout.
*/
public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
-
- private static final int PERSONAL_TAB = 0;
- private static final int WORK_TAB = 1;
private static final int MINIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP = 268;
private static final int MAXIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP = 395;
private static final String SUGGESTIONS_PACKAGE_NAME = "widgets_list_suggestions_entry";
@@ -83,6 +81,7 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
private int mActivePage = -1;
@Nullable
private PackageUserKey mSelectedHeader;
+ private TextView mHeaderDescription;
public WidgetsTwoPaneSheet(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
@@ -126,6 +125,8 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
newPage -> mRecommendationsCurrentPage = newPage);
mHeaderTitle = mContent.findViewById(R.id.title);
+ mHeaderDescription = mContent.findViewById(R.id.widget_picker_description);
+
mRightPane = mContent.findViewById(R.id.right_pane);
mRightPaneScrollView = mContent.findViewById(R.id.right_pane_scroll_view);
mRightPaneScrollView.setOverScrollMode(View.OVER_SCROLL_NEVER);
@@ -140,6 +141,17 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
mFastScroller.setVisibility(GONE);
}
+ @Override
+ public void mayUpdateTitleAndDescription(@Nullable String title, @Nullable String description) {
+ if (title != null) {
+ mHeaderTitle.setText(title);
+ }
+ if (description != null) {
+ mHeaderDescription.setText(description);
+ mHeaderDescription.setVisibility(VISIBLE);
+ }
+ }
+
@Override
protected int getTabletHorizontalMargin(DeviceProfile deviceProfile) {
if (enableCategorizedWidgetSuggestions()) {
@@ -371,9 +383,10 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet {
protected void updateRecyclerViewVisibility(AdapterHolder adapterHolder) {
// The first item is always an empty space entry. Look for any more items.
boolean isWidgetAvailable = adapterHolder.mWidgetsListAdapter.hasVisibleEntries();
-
- mRightPane.setVisibility(isWidgetAvailable ? VISIBLE : GONE);
-
+ if (!isWidgetAvailable) {
+ mRightPane.removeAllViews();
+ mRightPane.addView(mNoWidgetsView);
+ }
super.updateRecyclerViewVisibility(adapterHolder);
}