Avoiding TalkBack from reading a missing piece

I am developing a simple application that is structured in the Actions and Fragments section, one of the requirements to make it accessible, so I made all the content descriptions, navigation, focus, etc.

And it works fine, except with fragments, if there is activity that loads the fragment, and talkback reads its contents, then the user clicks on something and a detail fragment that can be added on top of the stack.

FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); audios = AudiosListFragment.newInstance(params); ft.add(R.id.audios_fragment_holder, audios); ft.commit(); 

If the user continues navigation, they still remember the position of each element of the missing fragment.

Is there a way to clear the accessibility list of events and get it to get it again? The accessibility manager has no method for this.

 AccessibilityManager manager = (AccessibilityManager) getActivity().getSystemService(Context.ACCESSIBILITY_SERVICE); manager.getAccessibilityServiceList(); 

- EDITED - Things I tried and didn't work.

Sending an event from creating a view in a fragment.

  AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); AccessibilityDelegate delegate = new AccessibilityDelegate(); v.setAccessibilityDelegate(delegate); delegate.dispatchPopulateAccessibilityEvent(container, event); 

Interrupt all pending texts in the onResume fragment.

  AccessibilityManager mgr = (AccessibilityManager) getActivity().getSystemService(Context.ACCESSIBILITY_SERVICE); mgr.interrupt(); 

A decorator view request for registering a window_content_change or window_state_change event.

  getWindow().getDecorView() .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); 

- EDITED - Created a DumpView hierarchy, and there are no traces of the discarded fragment in it, but in the speech playback mode it moves: (

Thanks, I hope someone can shed some light on this issue :)

Sincerely.

+6
source share
1 answer

The only way I found to prevent the fragments from being read below replaces them with fragment transactions, which is a disadvantage because you are losing the state of this fragment ...

 FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); BookDetailFragment book = BookDetailFragment.newInstance(id); ft.replace(R.id.books_fragment_holder, book); ft.addToBackStack(BookDetailFragment.TAG); ft.commit(); 

I will continue to monitor how to do this correctly.

0
source

Source: https://habr.com/ru/post/969545/


All Articles