简体   繁体   中英

Accessibility Talk back Will not Interrupt

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?

I couldn't understand if when the left nav is opened it gets the focus and only the TalkBack continues behind or the focus as is stays behind..

If the nav gets the focus and its only a TalkBack issue than put the following attribute on the element that gets the initial focus at the nav -

android:accessibilityLiveRegion="assertive"

This will make the TalkBack stop the previous reading session and make the new focus start reading.

Now if the issue is that you don't even get the focus there because is stays behind, add this post function that calls for the focus to the specific view you want to gain once nav opens. Put it in the onClick that opens the nav so it will initiate it once opens -

myCustomView.post(new Runnable() {
    @Override
    public void run() {
        myCustomView.requestFocus();
        myCustomView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
    }
});

Hope this help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM