Commit fb0f3aa4 authored by finnur's avatar finnur Committed by Commit bot

Fix accessibility problem for ExpandablePreferenceGroup.

BUG=467552

Review URL: https://codereview.chromium.org/1032353004

Cr-Commit-Position: refs/heads/master@{#322549}
parent 199ed75c
......@@ -25,8 +25,11 @@ import java.util.Locale;
* A preference category that accepts clicks for toggling on/off.
*/
public class ExpandablePreferenceGroup extends PreferenceGroup {
private Drawable mDrawable = null;
private ImageView mImageView = null;
private Drawable mDrawable;
private ImageView mImageView;
// Whether the PreferenceGroup is in an expanded or collapsed state.
private boolean mExpanded;
public ExpandablePreferenceGroup(Context context, AttributeSet attrs) {
super(context, attrs, android.R.attr.preferenceStyle);
......@@ -63,6 +66,10 @@ public class ExpandablePreferenceGroup extends PreferenceGroup {
setTitle(spannable);
}
public void setExpanded(boolean expanded) {
mExpanded = expanded;
}
@Override
public void setIcon(Drawable drawable) {
mDrawable = drawable;
......@@ -74,5 +81,11 @@ public class ExpandablePreferenceGroup extends PreferenceGroup {
super.onBindView(view);
mImageView = (ImageView) view.findViewById(R.id.expando);
if (mDrawable != null) mImageView.setImageDrawable(mDrawable);
// For accessibility, read out the whole title and whether the group is collapsed/expanded.
String description = getTitle() + getContext().getResources().getString(mExpanded
? R.string.accessibility_expanded_group
: R.string.accessibility_collapsed_group);
view.setContentDescription(description);
}
}
......@@ -243,6 +243,7 @@ public class WebsitePreferences extends PreferenceFragment
allowedGroup.setGroupTitle(resourceId, numAllowed);
TintedDrawable icon = TintedDrawable.constructTintedDrawable(getResources(),
mAllowListExpanded ? R.drawable.ic_expand : R.drawable.ic_collapse);
allowedGroup.setExpanded(mAllowListExpanded);
allowedGroup.setIcon(icon);
}
......@@ -259,6 +260,7 @@ public class WebsitePreferences extends PreferenceFragment
blockedGroup.setGroupTitle(R.string.website_settings_blocked_group_heading, numBlocked);
TintedDrawable icon = TintedDrawable.constructTintedDrawable(getResources(),
mBlockListExpanded ? R.drawable.ic_expand : R.drawable.ic_collapse);
blockedGroup.setExpanded(mBlockListExpanded);
blockedGroup.setIcon(icon);
}
......
......@@ -474,6 +474,12 @@ For example, some websites may respond to this request by showing you ads that a
<message name="IDS_WEBSITE_SETTINGS_EXCEPTIONS_GROUP_HEADING" desc="The heading for a list of websites that have been granted an exception to access a particular permission, e.g. to access the user's location.">
Exceptions
</message>
<message name="IDS_ACCESSIBILITY_EXPANDED_GROUP" desc="The accessibility text to read when the selected widget is expanded.">
Expanded - click to collapse.
</message>
<message name="IDS_ACCESSIBILITY_COLLAPSED_GROUP" desc="The accessibility text to read when the selected widget is collapsed.">
Collapsed - click to expand.
</message>
<message name="IDS_WEBSITE_SETTINGS_CATEGORY_BLOCK_ALL" desc="Summary text explaining that a permission is blocked for all sites.">
Block all sites
</message>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment