Force Android TalkBack to stay inside one view hierarchy

Viewed 224

Accessibility help needed!
I have a drawer opening and I wish the TalkBack screen reader to stay inside this drawer until the user decides to close it.
I'm asking the android screen reader to move to the opened drawer using:

mDrawerView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED); 

And it works perfectly, the drawer is focused and the user can move with the screen reader next within the drawer.
The issue is, the drawer is not full screen and the user is not stopped on the end of the drawer, he keeps moving forward with the screen reader to controls below the drawer.
How can I force the reader to stay within the drawer limits?

This is easily achieved on iOS using:

drawerView.accessibilityViewIsModal = true
UIAccessibility.post(notification: .screenChanged, argument: drawerView)

By calling this on iOS the screen reader circulates the controls within the view hierarchy I provided.
Is there anything similar I can do with Android??

1 Answers

Up to August 30 2020 this is NOT POSSIBLE on Android!
The API 22 addition of:

android:accessibilityTraversalAfter

and

android:accessibilityTraversalBefore

Is not helping for such scenarios.

In certain cases you can block view hierarchies by setting:

setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);  

In my case the drawer was above the fragment so I could set to block accessibility on the entire fragment beneath, thus forcing the screen reader to remain within the drawer and cycle it's controls.

Upon closing the drawer I called:

setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);  

On the view of the fragment and the screen reader could continue traverse the fragment.

Related