Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10b63aef authored by Santiago Etchebehere's avatar Santiago Etchebehere
Browse files

More accessibility improvements

Add missing content description and increase tap target sizes.

Fixes: 129216367
Fixes: 129226741
Fixes: 129216366
Change-Id: I0692891f720cfd963fc58a834d43ff7c9d5ad157
parent 040bfe26
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@
    xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/FullContentPreviewCard"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    android:layout_height="match_parent"
    android:focusable="true">

    <ImageView
        android:id="@+id/clock_preview_image"
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_centerVertical="true"
                android:minHeight="@dimen/min_taptarget_height"
                android:text="@string/keep_my_wallpaper"/>
            <Button
                android:id="@+id/apply_button"
+2 −0
Original line number Diff line number Diff line
@@ -87,4 +87,6 @@

    <!-- For a corner radius of this size or larger, we'll preview a rounded qsb widget. -->
    <dimen name="roundCornerThreshold">16dp</dimen>

    <dimen name="min_taptarget_height">48dp</dimen>
</resources>
+6 −0
Original line number Diff line number Diff line
@@ -60,6 +60,9 @@
    <!-- Sample text used to show a preview of a selected font [CHAR LIMIT=3] -->
    <string name="theme_font_example">ABC</string>

    <!-- Content description for previewing a style, describing each of their components. [CHAR_LIMIT=NONE] -->
    <string name="theme_description">Font: <xliff:g name="font_name">%1$s</xliff:g>, icons: <xliff:g name="icon_name">%2$s</xliff:g>, shape: <xliff:g name="shape_name">%3$s</xliff:g>, color: <xliff:g name="color_name">%4$s</xliff:g> </string>

    <!-- Plus sign used to indicate that the user can add a custom theme -->
    <string name="add_custom_theme" translatable="false">+</string>

@@ -167,4 +170,7 @@
        instead of their customly defined one. The button dismisses the dialog and goes back to the
        previous screen. [CHAR_LIMIT=16]  -->
    <string name="no_thanks">No, thanks</string>

    <!-- Content description for a screen showing the preview of a clock face. [CHAR_LIMIT=NONE] -->
    <string name="clock_preview_content_description"><xliff:g name="clock_name">%1$s</xliff:g> clock preview</string>
</resources>
+37 −1
Original line number Diff line number Diff line
@@ -15,9 +15,14 @@
 */
package com.android.customization.model.theme;

import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_COLOR;
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_FONT;
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_ICON_ANDROID;
import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SHAPE;
import static com.android.customization.model.ResourceConstants.PATH_SIZE;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Path;
@@ -40,6 +45,7 @@ import androidx.core.graphics.PathParser;

import com.android.customization.model.CustomizationManager;
import com.android.customization.model.CustomizationOption;
import com.android.customization.model.theme.custom.CustomTheme;
import com.android.customization.widget.DynamicAdaptiveIconDrawable;
import com.android.wallpaper.R;
import com.android.wallpaper.asset.Asset;
@@ -72,6 +78,7 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> {
    @Nullable private final WallpaperInfo mWallpaperInfo;
    private WallpaperInfo mOverrideWallpaper;
    private Asset mOverrideWallpaperAsset;
    private CharSequence mContentDescription;

    protected ThemeBundle(String title, Map<String, String> overlayPackages,
            boolean isDefault, @Nullable WallpaperInfo wallpaperInfo,
@@ -106,6 +113,7 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> {
            ((ImageView) view.findViewById(R.id.theme_option_icon)).setImageDrawable(
                    icon);
        }
        view.setContentDescription(getContentDescription(view.getContext()));
    }

    @Override
@@ -204,6 +212,35 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> {
        }
    }

    protected CharSequence getContentDescription(Context context) {
        if (mContentDescription == null) {
            CharSequence defaultName = context.getString(R.string.default_theme_title);
            if (isDefault()) {
                mContentDescription = defaultName;
            } else {
                PackageManager pm = context.getPackageManager();
                CharSequence fontName = getOverlayName(pm, OVERLAY_CATEGORY_FONT);
                CharSequence iconName = getOverlayName(pm, OVERLAY_CATEGORY_ICON_ANDROID);
                CharSequence shapeName = getOverlayName(pm, OVERLAY_CATEGORY_SHAPE);
                CharSequence colorName = getOverlayName(pm, OVERLAY_CATEGORY_COLOR);
                mContentDescription = context.getString(R.string.theme_description,
                        TextUtils.isEmpty(fontName) ? defaultName : fontName,
                        TextUtils.isEmpty(iconName) ? defaultName : iconName,
                        TextUtils.isEmpty(shapeName) ? defaultName : shapeName,
                        TextUtils.isEmpty(colorName) ? defaultName : colorName);
            }
        }
        return mContentDescription;
    }

    private CharSequence getOverlayName(PackageManager pm, String overlayCategoryFont) {
        try {
            return pm.getApplicationInfo(
                    mPackagesByCategory.get(overlayCategoryFont), 0).loadLabel(pm);
        } catch (PackageManager.NameNotFoundException e) {
            return "";
        }
    }

    public static class PreviewInfo {
        public final Typeface bodyFontFamily;
@@ -259,7 +296,6 @@ public class ThemeBundle implements CustomizationOption<ThemeBundle> {
        protected Map<String, String> mPackages = new HashMap<>();
        private List<Drawable> mAppIcons = new ArrayList<>();


        public ThemeBundle build(Context context) {
            return new ThemeBundle(mTitle, mPackages, mIsDefault, mWallpaperInfo,
                    createPreviewInfo(context));
Loading