-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add isAccessibilityServiceEnabled
#31396
feat: add isAccessibilityServiceEnabled
#31396
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
google-java-format
found some issues. See https://github.com/google/google-java-format
@@ -46,6 +46,17 @@ public void onTouchExplorationStateChanged(boolean enabled) { | |||
} | |||
} | |||
|
|||
// Android can listen for accessibility service enable with `accessibilityStateChange`, but `accessibilityState` conflicts with React Native props and confuses developers. Therefore, the name `accessibilityServiceChange` is used here instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google-java-format
suggested changes:
@@ -49 +49,3 @@
- // Android can listen for accessibility service enable with `accessibilityStateChange`, but `accessibilityState` conflicts with React Native props and confuses developers. Therefore, the name `accessibilityServiceChange` is used here instead.
+ // Android can listen for accessibility service enable with `accessibilityStateChange`, but
+ // `accessibilityState` conflicts with React Native props and confuses developers. Therefore, the
+ // name `accessibilityServiceChange` is used here instead.
} | ||
} | ||
} | ||
|
||
@Override | ||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
google-java-format
suggested changes:
@@ -176,2 +178 @@
- mAccessibilityManager.addAccessibilityStateChangeListener(
- mAccessibilityServiceChangeListener);
+ mAccessibilityManager.addAccessibilityStateChangeListener(mAccessibilityServiceChangeListener);
Base commit: 61e1b6f |
Thank you for submitting this @grgr-dkrk! I've added your PR to the Improved React Native Accessibility board. Thank you for your contribution to a more accessible React Native. |
@@ -33,6 +33,7 @@ type AccessibilityEventDefinitions = { | |||
change: [boolean], // screenReaderChanged | |||
reduceMotionChanged: [boolean], | |||
screenReaderChanged: [boolean], | |||
accessibilityServiceChanged: [boolean], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this event is only supported on Android, we should mark that (perhaps by adding a new type AccessibilityEventDefinitionsAndroid
like iOS has.
This is interesting - so this listens for any change? cc @blavalla I know we discussed this a bit, would the potential use case for this be to listen for changes so as to be able to update the layout (or similar) if, for example, TalkBack was turned on/off? So you'd need to listen for changes, and then check if TalkBack is on with another function call. |
Yeah, thats the general idea. Although we already have a method specifically for talkback with |
PR build artifact for ccc99be is ready. |
Base commit: 61e1b6f |
PR build artifact for 1e641c1 is ready. |
@grgr-dkrk Can we update the title since the API is And similarly, could you also create some documentation for this API in |
@lunaleaps has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
isAccessibilityStateEnabled
isAccessibilityServiceEnabled
I'll deal with it as soon as possible. Thanks! |
@lunaleaps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some additional clarification requested.
* Returns a promise which resolves to a boolean. | ||
* The result is `true` when any service is enabled and `false` otherwise. | ||
* | ||
* See https://reactnative.dev/docs/accessibilityinfo.html#isAccessibilityServiceEnabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point by @philIip that this comment should also mention that it's an Android only feature
Small comments, I can also add if you're okay with the suggested change, otherwise looks good. Just want to get more experienced Android eyes on this as well internally! |
PR build artifact for ab66bd2 is ready. |
@lunaleaps has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@lunaleaps merged this pull request in c8b83d4. |
Summary
fix #30863
This PR adds
isAccessibilityServiceEnabled
to get if accessibility services are enabled on Android.Changelog
[Android] [Added] - Added
isAccessibilityServiceEnabled
to get if accessibility services are enabledTest Plan