a11y: Make images optional for single choice list view dialog

This makes `ItemInfoArrayAdapter.ItemInfo` support text-only choices. It
is to better accommodate the new dialogs.

Bug: b/389991440
Flag: com.android.settings.accessibility.enable_magnification_cursor_following_dialog
Test: None
Change-Id: If7514631a72631cf0fce85623fe30c8261f678c9
This commit is contained in:
Yongshun Liu
2025-01-14 21:53:22 +00:00
parent fb66888ab5
commit 09b11ff3d3

View File

@@ -60,12 +60,17 @@ public class ItemInfoArrayAdapter<T extends ItemInfoArrayAdapter.ItemInfo> exten
summary.setVisibility(View.GONE);
}
final ImageView image = root.findViewById(R.id.image);
image.setImageResource(item.mDrawableId);
if (getContext().getResources().getConfiguration().getLayoutDirection()
== View.LAYOUT_DIRECTION_LTR) {
image.setScaleType(ImageView.ScaleType.FIT_START);
if (item.mDrawableId == null) {
image.setVisibility(View.GONE);
} else {
image.setScaleType(ImageView.ScaleType.FIT_END);
image.setVisibility(View.VISIBLE);
image.setImageResource(item.mDrawableId);
if (getContext().getResources().getConfiguration().getLayoutDirection()
== View.LAYOUT_DIRECTION_LTR) {
image.setScaleType(ImageView.ScaleType.FIT_START);
} else {
image.setScaleType(ImageView.ScaleType.FIT_END);
}
}
return root;
}
@@ -78,11 +83,12 @@ public class ItemInfoArrayAdapter<T extends ItemInfoArrayAdapter.ItemInfo> exten
public final CharSequence mTitle;
@Nullable
public final CharSequence mSummary;
@Nullable
@DrawableRes
public final int mDrawableId;
public final Integer mDrawableId;
public ItemInfo(@NonNull CharSequence title, @Nullable CharSequence summary,
@DrawableRes int drawableId) {
@Nullable @DrawableRes Integer drawableId) {
mTitle = title;
mSummary = summary;
mDrawableId = drawableId;