Skip to content

Commit

Permalink
Privacy Guide: Aux button a11y fix
Browse files Browse the repository at this point in the history
- Standardise RadioButtonWithDescriptionAndAuxButton a11y behaviour.

Current Talkback speech:
- Radio button
  "<title>, <description> for Expand <auxButtonContentDescription>"
- Aux button
  "Expand <auxButtonContentDescription>"

New Talkback speech:
- Radio button
  "<title>, <description>"
- Aux button
  "Expand, Button for <title>"

(cherry picked from commit a9d741d)

Bug: 1446122
Change-Id: I4488b3f3427ffe9a0c6521c8779d17e7f8a25c1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4570621
Reviewed-by: Christian Dullweber <dullweber@chromium.org>
Commit-Queue: Rubin Deliallisi <rubindl@chromium.org>
Reviewed-by: Theresa Sullivan <twellington@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Cr-Original-Commit-Position: refs/heads/main@{#1150610}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4574907
Commit-Queue: Theresa Sullivan <twellington@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Rubin Deliallisi <rubindl@chromium.org>
Cr-Commit-Position: refs/branch-heads/5790@{#194}
Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
  • Loading branch information
Rubin Deliallisi authored and Chromium LUCI CQ committed May 31, 2023
1 parent 076fd8b commit 61aa067
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 43 deletions.
Expand Up @@ -175,19 +175,7 @@ private void setRadioButtonsVisibility(Params params) {
(RadioButtonWithDescriptionAndAuxButton) mViewHolder.findViewById(
R.id.block_third_party_with_aux);

String blockTPIncognitoCtxDescription = getResources().getString(
R.string.website_settings_category_cookie_block_third_party_incognito_title);
blockTPIncognitoBtnWithDescAndAux.setAuxButtonContentDescription(
getResources().getString(
R.string.accessibility_expand_button_with_target_description,
blockTPIncognitoCtxDescription));
blockTPIncognitoBtnWithDescAndAux.setVisibility(View.VISIBLE);

String blockTPCtxDescription = getResources().getString(
R.string.website_settings_category_cookie_block_third_party_title);
blockTPButtonWithDescAndAux.setAuxButtonContentDescription(getResources().getString(
R.string.accessibility_expand_button_with_target_description,
blockTPCtxDescription));
blockTPButtonWithDescAndAux.setVisibility(View.VISIBLE);

blockTPIncognitoBtnWithDescAndAux.setAuxButtonClickedListener(this);
Expand Down
Expand Up @@ -160,19 +160,7 @@ private void setRadioButtonsVisibility(Params params) {
(RadioButtonWithDescriptionAndAuxButton) mViewHolder.findViewById(
R.id.block_third_party_with_aux);

String blockTPIncognitoCtxDescription = getResources().getString(
R.string.website_settings_category_cookie_block_third_party_incognito_title);
blockTPIncognitoBtnWithDescAndAux.setAuxButtonContentDescription(
getResources().getString(
R.string.accessibility_expand_button_with_target_description,
blockTPIncognitoCtxDescription));
blockTPIncognitoBtnWithDescAndAux.setVisibility(View.VISIBLE);

String blockTPCtxDescription = getResources().getString(
R.string.website_settings_category_cookie_block_third_party_title);
blockTPButtonWithDescAndAux.setAuxButtonContentDescription(getResources().getString(
R.string.accessibility_expand_button_with_target_description,
blockTPCtxDescription));
blockTPButtonWithDescAndAux.setVisibility(View.VISIBLE);

blockTPIncognitoBtnWithDescAndAux.setAuxButtonClickedListener(this);
Expand Down
3 changes: 0 additions & 3 deletions components/browser_ui/strings/android/browser_ui_strings.grd
Expand Up @@ -353,9 +353,6 @@
<message name="IDS_ACCESSIBILITY_EXPAND_BUTTON" desc="Content description for the expand button in the expand_arrow_with_separator layout.">
Expand
</message>
<message name="IDS_ACCESSIBILITY_EXPAND_BUTTON_WITH_TARGET_DESCRIPTION" desc="Content description for the expand button in the RadioButtonWithDescriptionAndAuxButton.">
Expand <ph name="TARGET_DESCRIPTION">%1$s<ex>Block third-party cookies</ex></ph>
</message>

<message name="IDS_SELECTED_ITEMS" desc="Content description for a number indicating how many items are selected. [ICU Syntax]">
{NUM_SELECTED, plural,
Expand Down

This file was deleted.

Expand Up @@ -7,7 +7,6 @@
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageButton;

import androidx.annotation.VisibleForTesting;
Expand Down Expand Up @@ -95,6 +94,7 @@ public RadioButtonWithDescriptionAndAuxButton(Context context, AttributeSet attr
protected void setViewsInternal() {
super.setViewsInternal();
mAuxButton = findViewById(R.id.expand_arrow);
getPrimaryTextView().setLabelFor(mAuxButton.getId());
}

/**
Expand All @@ -116,12 +116,6 @@ public void setEnabled(boolean enabled) {
setAuxButtonEnabled(enabled);
}

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setLabeledBy(mAuxButton);
}

/**
* Sets the enabled state of the aux button alone. This can be used if you want the aux button
* to be enabled while the other child views are disabled or vice versa.
Expand All @@ -140,14 +134,6 @@ public void setAuxButtonClickedListener(OnAuxButtonClickedListener listener) {
mAuxButton.setOnClickListener(v -> mListener.onAuxButtonClicked(getId()));
}

/**
* Set the aux button content description.
* @param contentDescription for aux button, used for accessibility purposes.
*/
public void setAuxButtonContentDescription(String contentDescription) {
mAuxButton.setContentDescription(contentDescription);
}

/**
* @return the aux button living inside this widget.
*/
Expand Down

0 comments on commit 61aa067

Please sign in to comment.