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

Commit 78bcc15b authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

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

1. Switch was not populating the state on/off test in accessibility
   node infos. It apparently has two texts, the state one and the
   one it inherits from TextView.

bug:6213278

Change-Id: I9c6b1798a8b3230cfb6755cc5b088c320d991642
parent f21bea24
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);
            }
        }
    }
}