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

Commit 7f97e54a authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "Switch does not append its state text to accessibility node infos."

parents 11e07818 78bcc15b
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -806,5 +806,16 @@ public class Switch extends CompoundButton {
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setClassName(Switch.class.getName());
        CharSequence switchText = isChecked() ? mTextOn : mTextOff;
        if (!TextUtils.isEmpty(switchText)) {
            CharSequence oldText = info.getText();
            if (TextUtils.isEmpty(oldText)) {
                info.setText(switchText);
            } else {
                StringBuilder newText = new StringBuilder();
                newText.append(oldText).append(' ').append(switchText);
                info.setText(newText);
            }
        }
    }
}