Skip to content

Commit 55249c8

Browse files
committed
Removing checked state description text for accessibility from some widgets.
1. The framework was appending some text to convey the state of a a CheckedTextView or a RadioButton or a ToggleButton or a Switch but the checked property already conveys that information. It is responsibility of the screen reader developer to append the state text based on the checked property. This change is requested by a few screen reader developers. bug:5951683 Change-Id: Ieba6797770201155c48e37147ae375dfcb5238aa
1 parent 4b97257 commit 55249c8

File tree

5 files changed

+2
-65
lines changed

5 files changed

+2
-65
lines changed

core/java/android/widget/CheckedTextView.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,6 @@ public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
220220
event.setChecked(mChecked);
221221
}
222222

223-
@Override
224-
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
225-
super.onPopulateAccessibilityEvent(event);
226-
if (isChecked()) {
227-
event.getText().add(mContext.getString(R.string.radiobutton_selected));
228-
} else {
229-
event.getText().add(mContext.getString(R.string.radiobutton_not_selected));
230-
}
231-
}
232-
233223
@Override
234224
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
235225
super.onInitializeAccessibilityNodeInfo(info);

core/java/android/widget/RadioButton.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,6 @@ public void toggle() {
7777
}
7878
}
7979

80-
@Override
81-
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
82-
super.onPopulateAccessibilityEvent(event);
83-
if (isChecked()) {
84-
event.getText().add(mContext.getString(R.string.radiobutton_selected));
85-
} else {
86-
event.getText().add(mContext.getString(R.string.radiobutton_not_selected));
87-
}
88-
}
89-
9080
@Override
9181
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
9282
super.onInitializeAccessibilityEvent(event);

core/java/android/widget/Switch.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,17 +367,8 @@ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
367367
@Override
368368
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
369369
super.onPopulateAccessibilityEvent(event);
370-
if (isChecked()) {
371-
CharSequence text = mOnLayout.getText();
372-
if (TextUtils.isEmpty(text)) {
373-
text = mContext.getString(R.string.switch_on);
374-
}
375-
event.getText().add(text);
376-
} else {
377-
CharSequence text = mOffLayout.getText();
378-
if (TextUtils.isEmpty(text)) {
379-
text = mContext.getString(R.string.switch_off);
380-
}
370+
CharSequence text = isChecked() ? mOnLayout.getText() : mOffLayout.getText();
371+
if (!TextUtils.isEmpty(text)) {
381372
event.getText().add(text);
382373
}
383374
}

core/java/android/widget/ToggleButton.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,6 @@ protected void drawableStateChanged() {
153153
}
154154
}
155155

156-
@Override
157-
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
158-
super.onPopulateAccessibilityEvent(event);
159-
if (isChecked()) {
160-
event.getText().add(mContext.getString(R.string.togglebutton_pressed));
161-
} else {
162-
event.getText().add(mContext.getString(R.string.togglebutton_not_pressed));
163-
}
164-
}
165-
166156
@Override
167157
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
168158
super.onInitializeAccessibilityEvent(event);

core/res/res/values/strings.xml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,30 +3194,6 @@
31943194
<!-- Description of the button to decrement the DatePicker's year value. [CHAR LIMIT=NONE] -->
31953195
<string name="date_picker_decrement_year_button">Decrement year</string>
31963196

3197-
<!-- CheckBox - accessibility support -->
3198-
<!-- Description of the checked state of a CheckBox. [CHAR LIMIT=NONE] -->
3199-
<string name="checkbox_checked">checked</string>
3200-
<!-- Description of the not checked state of a CheckBox. [CHAR LIMIT=NONE] -->
3201-
<string name="checkbox_not_checked">not checked</string>
3202-
3203-
<!-- RadioButton/CheckedTextView - accessibility support -->
3204-
<!-- Description of the selected state of a RadioButton. [CHAR LIMIT=NONE] -->
3205-
<string name="radiobutton_selected">selected</string>
3206-
<!-- Description of the not selected state of a RadioButton. [CHAR LIMIT=NONE] -->
3207-
<string name="radiobutton_not_selected">not selected</string>
3208-
3209-
<!-- Switch - accessibility support -->
3210-
<!-- Description of the on state of a Switch. [CHAR LIMIT=NONE] -->
3211-
<string name="switch_on">on</string>
3212-
<!-- Description of the off state of a Switch. [CHAR LIMIT=NONE] -->
3213-
<string name="switch_off">off</string>
3214-
3215-
<!-- ToggleButton - accessibility support -->
3216-
<!-- Description of the pressed state of a ToggleButton. [CHAR LIMIT=NONE] -->
3217-
<string name="togglebutton_pressed">pressed</string>
3218-
<!-- Description of the not pressed state of a ToggleButton. [CHAR LIMIT=NONE] -->
3219-
<string name="togglebutton_not_pressed">not pressed</string>
3220-
32213197
<!-- KeyboardView - accessibility support -->
32223198
<!-- Description of the Alt button in a KeyboardView. [CHAR LIMIT=NONE] -->
32233199
<string name="keyboardview_keycode_alt">Alt</string>

0 commit comments

Comments
 (0)