-
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
1/n Adding Android support for Accessibility TtsSpan API - Support for accessibilitySpan and accessibilityLabel props in nested Text #35130
Conversation
Base commit: 23607ae |
Base commit: ac54a5b |
PR build artifact for 48a01d0 is ready. |
PR build artifact for 48a01d0 is ready. |
Notes "The Screenreader stops reading the span text when the focus moves on the AccessibilityLink. The issue may be connected to the latest changes. incompatible types: CharSequence cannot be converted to SpannableString spannableDescription = text.subSequence(start, end); The start and end of the AccessibilityLink need to be updated after changing the length of the string. Complete the functionality and fix all the compile errors" "facebook#35130 (comment) https://github.com/fabriziobertoglio1987/react-native/blob/48a01d006a45c49018d8c3860f40b696b1aa7269/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java#L600"
PR build artifact for 08d6f43 is ready. |
PR build artifact for 08d6f43 is ready. |
PR build artifact for 145303e is ready. |
PR build artifact for 145303e is ready. |
PR build artifact for f66e914 is ready. |
PR build artifact for f66e914 is ready. |
terminating with uncaught exception of type std::length_error: vector (screenshot1, screenshot2) https://www.icloud.com/iclouddrive/0a4Urx1Av554xzHH1hh3YHy9A#first_screenshot https://stackoverflow.com/a/1183709/7295772
PR build artifact for f5a3b49 is ready. |
PR build artifact for f5a3b49 is ready. |
2023-02-07.19-57-32.mp4 |
P type task |
Main Branch - accessibilityLabel not supported on Nested Text
2023-02-08.12-28-37.mp4PR Branch - accessibilityLabel supported on Nested Text
2023-02-08.12-46-05.mp4 |
P type task |
P type task |
P type task |
Thanks a lot for the code review @NickGerleman. 🙏 |
|
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This PR was closed because it has been stalled for 7 days with no activity. |
Summary
Adding accessibilityUnit prop for Nested Texts and accessibilityRoles for different types of TtsSpans
An explanation of the use case is as follows:
Support for more TYPE_DATE, ELECTRONIC, FRACTION, TIME, DECIMAL, DIGITS, MONEY to be added in upcoming PRs (2/n).
Investigating the implementation of TextAttributesProps on Android and Fabric CPP.
Nested Text components are represented on Android as TextView spans. Their props are passed from the React Text component through CPP to the JAVA ReactAndroid API using TextAttributes. The accessibilityUnit is saved in Fabric attributedstring and retrieved from ReactAndroid TextLayoutManagerMapBuffer.
Background or Foreground color, custom letter spacing, and other text attributes for nested text are retrieved from TextLayoutManagerMapBuffer using the key FR_KEY_TEXT_ATTRIBUTES and represented on android using TextView spans.
The TextAttributes saved in FR_KEY_TEXT_ATTRIBUTES are sent from Javascript to ReactAndroid using the NDK Fabric CPP API, which uses Java Native Interface to share data between JavaScript, CPP, and Java without JSON serialization (bridge).
CPP configurations from fabOnReact#3
Adds the accessibilityLabel to fabric TextAttributes CPP and Java API (part of PR #35130 Adding support for Android Accessibility TtsSpan API). Implementing the above functionality requires adding a new prop to the react-native API responsible for managing attributes of nested Text.
Decreasing fragmentation with web, using aria-label instead of accessibilityUnit (2-10th February)
This PR fixes #30849
Additional Notes
Text/ParagraphAttributes, TextLayoutManagerMapBuffer, ReactStyleDiffs are built using MapBuffers. SurfaceMountingManager uses by default ReactMapBufferViewManager.kt or in alternative the corresponding ReactViewManager. In the case of a controlled TextInput. The TextInput replaces the typed value (
Gffd. G
) with the new value (Gffd._____G
). The new props are sent to the ReactEditTextViewManager using the ReactStyleDiffMap. ReactMapBufferViewManager.kt is not used.Changelog
[Android] [Added] - 1/n Adding Android support for Accessibility TtsSpan API - Support for accessibilitySpan and accessibilityLabel props in nested Text
Test Plan
12 January 2023 Updated Tests #35130 (comment)
7 February 2023 Comparision with VoiceOver + Safari #35130 (comment)
7 February 2023 iOS Tests #35130 (comment)
8 February 2023 Testing aria-label on nested text #35130 (comment)
Old Video Tests
#35130 (comment)
2022-10-29.14-23-10.mp4
as showcased in this example, this solution also works with nested text. The text announced in the example below is a random text just to verify that the solution works without problems.
2022-10-28.21-35-42.mp4