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

Commit 55249c86 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

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
parent 4b972579
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -220,16 +220,6 @@ public class CheckedTextView extends TextView implements Checkable {
        event.setChecked(mChecked);
    }

    @Override
    public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
        super.onPopulateAccessibilityEvent(event);
        if (isChecked()) {
            event.getText().add(mContext.getString(R.string.radiobutton_selected));
        } else {
            event.getText().add(mContext.getString(R.string.radiobutton_not_selected));
        }
    }

    @Override
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
+0 −10
Original line number Diff line number Diff line
@@ -77,16 +77,6 @@ public class RadioButton extends CompoundButton {
        }
    }

    @Override
    public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
        super.onPopulateAccessibilityEvent(event);
        if (isChecked()) {
            event.getText().add(mContext.getString(R.string.radiobutton_selected));
        } else {
            event.getText().add(mContext.getString(R.string.radiobutton_not_selected));
        }
    }

    @Override
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
        super.onInitializeAccessibilityEvent(event);
+2 −11
Original line number Diff line number Diff line
@@ -367,17 +367,8 @@ public class Switch extends CompoundButton {
    @Override
    public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
        super.onPopulateAccessibilityEvent(event);
        if (isChecked()) {
            CharSequence text = mOnLayout.getText();
            if (TextUtils.isEmpty(text)) {
                text = mContext.getString(R.string.switch_on);
            }
            event.getText().add(text);
        } else {
            CharSequence text = mOffLayout.getText();
            if (TextUtils.isEmpty(text)) {
                text = mContext.getString(R.string.switch_off);
            }
        CharSequence text = isChecked() ? mOnLayout.getText() : mOffLayout.getText();
        if (!TextUtils.isEmpty(text)) {
            event.getText().add(text);
        }
    }
+0 −10
Original line number Diff line number Diff line
@@ -153,16 +153,6 @@ public class ToggleButton extends CompoundButton {
        }
    }

    @Override
    public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
        super.onPopulateAccessibilityEvent(event);
        if (isChecked()) {
            event.getText().add(mContext.getString(R.string.togglebutton_pressed));
        } else {
            event.getText().add(mContext.getString(R.string.togglebutton_not_pressed));
        }
    }

    @Override
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
        super.onInitializeAccessibilityEvent(event);
+0 −24
Original line number Diff line number Diff line
@@ -3194,30 +3194,6 @@
    <!-- Description of the button to decrement the DatePicker's year value. [CHAR LIMIT=NONE] -->
    <string name="date_picker_decrement_year_button">Decrement year</string>

    <!-- CheckBox - accessibility support -->
    <!-- Description of the checked state of a CheckBox. [CHAR LIMIT=NONE] -->
    <string name="checkbox_checked">checked</string>
    <!-- Description of the not checked state of a CheckBox. [CHAR LIMIT=NONE] -->
    <string name="checkbox_not_checked">not checked</string>

    <!-- RadioButton/CheckedTextView - accessibility support -->
    <!-- Description of the selected state of a RadioButton. [CHAR LIMIT=NONE] -->
    <string name="radiobutton_selected">selected</string>
    <!-- Description of the not selected state of a RadioButton. [CHAR LIMIT=NONE] -->
    <string name="radiobutton_not_selected">not selected</string>

    <!-- Switch - accessibility support -->
    <!-- Description of the on state of a Switch. [CHAR LIMIT=NONE] -->
    <string name="switch_on">on</string>
    <!-- Description of the off state of a Switch. [CHAR LIMIT=NONE] -->
    <string name="switch_off">off</string>

    <!-- ToggleButton - accessibility support -->
    <!-- Description of the pressed state of a ToggleButton. [CHAR LIMIT=NONE] -->
    <string name="togglebutton_pressed">pressed</string>
    <!-- Description of the not pressed state of a ToggleButton. [CHAR LIMIT=NONE] -->
    <string name="togglebutton_not_pressed">not pressed</string>

    <!-- KeyboardView - accessibility support -->
    <!-- Description of the Alt button in a KeyboardView. [CHAR LIMIT=NONE] -->
    <string name="keyboardview_keycode_alt">Alt</string>