mirror of
https://github.com/material-components/material-components-android.git
synced 2026-01-20 20:12:52 +08:00
This replaces the use of `ViewCompat#add/removeAccessibilityAction` Both are valid strategies, but each call to `remove` or `add` triggers an accessibility event. Since this check is done in layout (originally to fix a11y scroll state) it's sending a high number of events that create noise for accessibility services. To avoid this, we move this code to the delegate `onInitialize` and `performAction` methods. Instead of the view dynamically adding and removing actions to itself, the node is initialized with actions only when an a11y service sends a request with a new node (likely due to some UI change). The flow here would look like: 1. UI is scrolled/page is loaded 2. TalkBack gets a scroll event/content change event 3. TalkBack requests new snapshot of the screen 4. ABL populates the node with the actions For a simple scroll, this change reduces the events from ~40 to ~10. We also add the Truth library for clearer assertions. PiperOrigin-RevId: 605333170