From 85486d1c2c3c3ff47fd9c459d9f689df3e1bc605 Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Mon, 28 Jun 2021 13:00:13 +0100 Subject: [PATCH] Set the widget preview title a11y text to "{widget name} widget" Fix: 187376680 Test: Manual Change-Id: I211d8e2b437091808d1f5a764075af4c3832ef48 --- res/values/strings.xml | 3 +++ src/com/android/launcher3/widget/WidgetCell.java | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 4f4a38907a..ddd838dbf9 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -55,6 +55,9 @@ %1$d \u00d7 %2$d %1$d wide by %2$d high + + %1$s widget Touch & hold the widget to move it around the Home screen diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java index 91529be30b..a52adf673d 100644 --- a/src/com/android/launcher3/widget/WidgetCell.java +++ b/src/com/android/launcher3/widget/WidgetCell.java @@ -180,14 +180,17 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener { public void applyFromCellItem(WidgetItem item, WidgetPreviewLoader loader) { applyPreviewOnAppWidgetHostView(item); + Context context = getContext(); mItem = item; mWidgetName.setText(mItem.label); - mWidgetDims.setText(getContext().getString(R.string.widget_dims_format, + mWidgetName.setContentDescription( + context.getString(R.string.widget_preview_context_description, mItem.label)); + mWidgetDims.setText(context.getString(R.string.widget_dims_format, mItem.spanX, mItem.spanY)); - mWidgetDims.setContentDescription(getContext().getString( + mWidgetDims.setContentDescription(context.getString( R.string.widget_accessible_dims_format, mItem.spanX, mItem.spanY)); if (ATLEAST_S && mItem.widgetInfo != null) { - CharSequence description = mItem.widgetInfo.loadDescription(getContext()); + CharSequence description = mItem.widgetInfo.loadDescription(context); if (description != null && description.length() > 0) { mWidgetDescription.setText(description); mWidgetDescription.setVisibility(VISIBLE); @@ -238,6 +241,7 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener { NavigableAppWidgetHostView appWidgetHostViewPreview, LauncherAppWidgetProviderInfo providerInfo, @Nullable RemoteViews remoteViews) { + appWidgetHostViewPreview.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); appWidgetHostViewPreview.setAppWidget(/* appWidgetId= */ -1, providerInfo); Rect padding; DeviceProfile deviceProfile = mActivity.getDeviceProfile();