Add widget description to WidgetCell
Full picker: https://screenshot.googleplex.com/8Dij79K8Pq2KWdm.png
Bottom picker: https://screenshot.googleplex.com/5f9TLra49dYJjLB.png
Test: Manually launch full and bottom widget pickers and observe
description is only shown for widgets but not shortcut.
Bug: 179797520
Change-Id: I5bfde056906a4a0f4fff9bc9a488f808365173b3
diff --git a/res/layout/widget_cell_content.xml b/res/layout/widget_cell_content.xml
index c3e37e9..65a49ab 100644
--- a/res/layout/widget_cell_content.xml
+++ b/res/layout/widget_cell_content.xml
@@ -50,4 +50,14 @@
android:textSize="14sp"
android:alpha="0.8" />
+ <TextView
+ android:id="@+id/widget_description"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:textSize="12sp"
+ android:maxLines="2"
+ android:ellipsize="end"
+ android:fadingEdge="horizontal" />
+
</merge>
\ No newline at end of file
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index c6593f8..8c315fd 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -16,6 +16,8 @@
package com.android.launcher3.widget;
+import static com.android.launcher3.Utilities.ATLEAST_S;
+
import android.content.Context;
import android.graphics.Bitmap;
import android.os.CancellationSignal;
@@ -67,6 +69,7 @@
private WidgetImageView mWidgetImage;
private TextView mWidgetName;
private TextView mWidgetDims;
+ private TextView mWidgetDescription;
protected WidgetItem mItem;
@@ -114,9 +117,10 @@
protected void onFinishInflate() {
super.onFinishInflate();
- mWidgetImage = (WidgetImageView) findViewById(R.id.widget_preview);
- mWidgetName = ((TextView) findViewById(R.id.widget_name));
- mWidgetDims = ((TextView) findViewById(R.id.widget_dims));
+ mWidgetImage = findViewById(R.id.widget_preview);
+ mWidgetName = findViewById(R.id.widget_name);
+ mWidgetDims = findViewById(R.id.widget_dims);
+ mWidgetDescription = findViewById(R.id.widget_description);
}
/**
@@ -130,6 +134,8 @@
mWidgetImage.setBitmap(null, null);
mWidgetName.setText(null);
mWidgetDims.setText(null);
+ mWidgetDescription.setText(null);
+ mWidgetDescription.setVisibility(GONE);
mPreviewWidth = mPreviewHeight = mPresetPreviewSize;
if (mActiveRequest != null) {
@@ -145,8 +151,17 @@
mItem.spanX, mItem.spanY));
mWidgetDims.setContentDescription(getContext().getString(
R.string.widget_accessible_dims_format, mItem.spanX, mItem.spanY));
- mWidgetPreviewLoader = loader;
+ if (ATLEAST_S && mItem.widgetInfo != null) {
+ CharSequence description = mItem.widgetInfo.loadDescription(getContext());
+ if (description != null && description.length() > 0) {
+ mWidgetDescription.setText(description);
+ mWidgetDescription.setVisibility(VISIBLE);
+ } else {
+ mWidgetDescription.setVisibility(GONE);
+ }
+ }
+ mWidgetPreviewLoader = loader;
if (item.activityInfo != null) {
setTag(new PendingAddShortcutInfo(item.activityInfo));
} else {