I am working on an android app and testing accessibility. In our MainActivity we have a left nav DrawerView, and load various fragments with recycler views based on user's left nav choice.
When testing accessibility/talkback we noticed that if talk back is focused on an item in the currently loaded fragments recycler view, when the left nav is opened, it often keeps reading the item from the background fragment (meaning the drawer is open and in front of the fragment).
We are trying to get Accessibility to stop reading aloud what ever is the background and read the first view of the drawer layout when the drawer opens.
I added a call to clear focus onDrawer open like so, thinking it would then default to the first item in the drawer once it regains focus. The focus does fall to the first item in my drawer view as desired, but it keeps playing the background item until it is finished, and then finally reads the left nav item it is focused on.
@Override
public void onDrawerOpened(View drawerView) {
//Clear Current Focus to allow Drawer items to take
drawerView.bringToFront();
getCurrentFocus().clearFocus();
super.onDrawerOpened(drawerView);
I tried the same approach in onDrawerSlide as well as trying to interrupt talkback like so:
View focused = getCurrentFocus();
if (focused != null) {
((AccessibilityManager) focused.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE)).interrupt();
The log helped me insure I was never getting a null view for the current focus.
Anyone have any tips or solutions?