Accessibility improvements
Update content description of custom options and cancel button,
increase touch target size for color options and make the preview
cards focusable as a group to improve Talkback navigability.
Fixes: 130385136
Fixes: 130393177
Fixes: 130401317
Fixes: 130391709
Change-Id: Ia3b393e9ca676288e064d402761a44753c681a75
diff --git a/res/layout/theme_color_option.xml b/res/layout/theme_color_option.xml
index fbede9f..0b7ca9e 100644
--- a/res/layout/theme_color_option.xml
+++ b/res/layout/theme_color_option.xml
@@ -17,7 +17,8 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:layout_marginHorizontal="10dp">
+ android:layout_marginHorizontal="6dp"
+ android:paddingHorizontal="4dp">
<ImageView
android:id="@+id/option_tile"
diff --git a/res/layout/theme_preview_card.xml b/res/layout/theme_preview_card.xml
index c1e63de..277a739 100644
--- a/res/layout/theme_preview_card.xml
+++ b/res/layout/theme_preview_card.xml
@@ -26,7 +26,9 @@
<FrameLayout
android:id="@+id/theme_preview_card_background"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:focusable="true">
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -52,7 +54,7 @@
<FrameLayout
android:id="@+id/theme_preview_card_body_container"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="0dp"
android:layout_marginHorizontal="8dp"
android:layout_weight="1"/>
diff --git a/src/com/android/customization/model/theme/custom/ColorOptionsProvider.java b/src/com/android/customization/model/theme/custom/ColorOptionsProvider.java
index dd61f00..07a876b 100644
--- a/src/com/android/customization/model/theme/custom/ColorOptionsProvider.java
+++ b/src/com/android/customization/model/theme/custom/ColorOptionsProvider.java
@@ -18,17 +18,17 @@
import static com.android.customization.model.ResourceConstants.ACCENT_COLOR_DARK_NAME;
import static com.android.customization.model.ResourceConstants.ACCENT_COLOR_LIGHT_NAME;
import static com.android.customization.model.ResourceConstants.ANDROID_PACKAGE;
+import static com.android.customization.model.ResourceConstants.ICONS_FOR_PREVIEW;
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_ANDROID_THEME;
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_COLOR;
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_ICON_ANDROID;
-import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_ICON_SYSUI;
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SHAPE;
import static com.android.customization.model.ResourceConstants.PATH_SIZE;
-import static com.android.customization.model.ResourceConstants.ICONS_FOR_PREVIEW;
import static com.android.customization.model.ResourceConstants.SYSUI_PACKAGE;
import static com.android.customization.model.theme.custom.ThemeComponentOption.ColorOption.COLOR_TILES_ICON_IDS;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
@@ -44,6 +44,7 @@
import com.android.customization.model.ResourceConstants;
import com.android.customization.model.theme.OverlayManagerCompat;
import com.android.customization.model.theme.custom.ThemeComponentOption.ColorOption;
+import com.android.wallpaper.R;
import java.util.ArrayList;
import java.util.List;
@@ -104,8 +105,9 @@
int darkColor = overlayRes.getColor(
overlayRes.getIdentifier(ACCENT_COLOR_DARK_NAME, "color", overlayPackage),
null);
-
- ColorOption option = new ColorOption(overlayPackage, lightColor, darkColor);
+ PackageManager pm = mContext.getPackageManager();
+ String label = pm.getApplicationInfo(overlayPackage, 0).loadLabel(pm).toString();
+ ColorOption option = new ColorOption(overlayPackage, label, lightColor, darkColor);
option.setPreviewIcons(previewIcons);
option.setShapeDrawable(shape);
mOptions.add(option);
@@ -136,7 +138,8 @@
darkColor = system.getColor(
system.getIdentifier(ACCENT_COLOR_DARK_NAME, "color", ANDROID_PACKAGE), null);
}
- ColorOption option = new ColorOption(null, lightColor, darkColor);
+ ColorOption option = new ColorOption(null,
+ mContext.getString(R.string.default_theme_title), lightColor, darkColor);
option.setPreviewIcons(previewIcons);
option.setShapeDrawable(shape);
mOptions.add(option);
diff --git a/src/com/android/customization/model/theme/custom/ShapeOptionsProvider.java b/src/com/android/customization/model/theme/custom/ShapeOptionsProvider.java
index ccd8679..112ed43 100644
--- a/src/com/android/customization/model/theme/custom/ShapeOptionsProvider.java
+++ b/src/com/android/customization/model/theme/custom/ShapeOptionsProvider.java
@@ -23,6 +23,7 @@
import static com.android.customization.model.ResourceConstants.PATH_SIZE;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
@@ -72,7 +73,10 @@
Path path = loadPath(mContext.getPackageManager()
.getResourcesForApplication(overlayPackage), overlayPackage);
ShapeDrawable shapeDrawable = createShapeDrawable(path);
- mOptions.add(new ShapeOption(overlayPackage, shapeDrawable, getShapedIcons(path)));
+ PackageManager pm = mContext.getPackageManager();
+ String label = pm.getApplicationInfo(overlayPackage, 0).loadLabel(pm).toString();
+ mOptions.add(new ShapeOption(overlayPackage, label, shapeDrawable,
+ getShapedIcons(path)));
} catch (NameNotFoundException | NotFoundException e) {
Log.w(TAG, String.format("Couldn't load shape overlay %s, will skip it",
overlayPackage), e);
@@ -84,7 +88,8 @@
Resources system = Resources.getSystem();
Path path = loadPath(system, ANDROID_PACKAGE);
ShapeDrawable shapeDrawable = createShapeDrawable(path);
- mOptions.add(new ShapeOption(null, shapeDrawable, getShapedIcons(path)));
+ mOptions.add(new ShapeOption(null, mContext.getString(R.string.default_theme_title),
+ shapeDrawable, getShapedIcons(path)));
}
private ShapeDrawable createShapeDrawable(Path path) {
diff --git a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
index 1659d09..9aef1e5 100644
--- a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
+++ b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
@@ -103,6 +103,7 @@
public void bindThumbnailTile(View view) {
((TextView) view.findViewById(R.id.thumbnail_text)).setTypeface(
mHeadlineFont);
+ view.setContentDescription(mLabel);
}
@Override
@@ -154,6 +155,7 @@
icon.setTint(res.getColor(R.color.icon_thumbnail_color, null));
((ImageView) view.findViewById(R.id.option_icon)).setImageDrawable(
icon);
+ view.setContentDescription(mLabel);
}
@Override
@@ -245,9 +247,12 @@
*/
private Drawable mShapeDrawable;
- ColorOption(String packageName, @ColorInt int lightColor,
+ private String mLabel;
+
+ ColorOption(String packageName, String label, @ColorInt int lightColor,
@ColorInt int darkColor) {
addOverlayPackage(OVERLAY_CATEGORY_COLOR, packageName);
+ mLabel = label;
mColorAccentLight = lightColor;
mColorAccentDark = darkColor;
}
@@ -256,6 +261,7 @@
public void bindThumbnailTile(View view) {
int color = resolveColor(view.getResources());
((ImageView) view.findViewById(R.id.option_tile)).getDrawable().setTint(color);
+ view.setContentDescription(mLabel);
}
private int resolveColor(Resources res) {
@@ -355,13 +361,16 @@
private final LayerDrawable mShape;
private final List<Drawable> mAppIcons;
+ private final String mLabel;
private int[] mShapeIconIds = {
R.id.shape_preview_icon_0, R.id.shape_preview_icon_1, R.id.shape_preview_icon_2,
R.id.shape_preview_icon_3, R.id.shape_preview_icon_4, R.id.shape_preview_icon_5
};
- ShapeOption(String packageName, Drawable shapeDrawable, List<Drawable> appIcons) {
+ ShapeOption(String packageName, String label, Drawable shapeDrawable,
+ List<Drawable> appIcons) {
addOverlayPackage(OVERLAY_CATEGORY_SHAPE, packageName);
+ mLabel = label;
mAppIcons = appIcons;
Drawable background = shapeDrawable.getConstantState().newDrawable();
Drawable foreground = shapeDrawable.getConstantState().newDrawable();
@@ -387,6 +396,7 @@
foreground.setTint(res.getColor(R.color.shape_option_tile_foreground_color, theme));
thumb.setImageDrawable(mShape);
+ view.setContentDescription(mLabel);
}
@Override
diff --git a/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java b/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
index 3ee29b0..801bb0c 100644
--- a/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
@@ -106,6 +106,7 @@
setUpToolbar(view, R.menu.custom_theme_editor_menu);
}
mToolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_close_24px, null));
+ mToolbar.setNavigationContentDescription(R.string.cancel);
mToolbar.setNavigationOnClickListener(v -> mHost.cancel());
mOptionsContainer = view.findViewById(R.id.options_container);
mPreviewCard = view.findViewById(R.id.component_preview_card);