Support grouped focus for switch (#40739)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40739

Adding support for grouped accessibility focus on switch.  This is when the switch itself shouldn't be directly focusable.  Instead, the parent element should be focusable, including announcing the switch role and state changes, e.g. "on" and "off".

Fix this issue in a couple ways:
1. Make sure to set the proper role for switch in FbReactSwitchCompat.java.
2. Set the state description in SwitchCompat.java so that uses the correct announcement of "off" and "on" instead of "checked" and "unchecked".

Reviewed By: blavalla

Differential Revision: D50068169

fbshipit-source-id: 0c4133377f7a29da9cadb730399bdbedd58c26ae
This commit is contained in:
Carmen Krol
2023-10-09 13:51:09 -07:00
committed by Facebook GitHub Bot
parent ec1de61946
commit 06c295c58f
@@ -629,11 +629,6 @@ public class ReactAccessibilityDelegate extends ExploreByTouchHelper {
final boolean boolValue = value.asBoolean();
info.setCheckable(true);
info.setChecked(boolValue);
if (info.getClassName().equals(AccessibilityRole.getValue(AccessibilityRole.SWITCH))) {
info.setStateDescription(
context.getString(
boolValue ? R.string.state_on_description : R.string.state_off_description));
}
}
}
}