7

I'm developing a simple app that is structured in Activities and Fragments, one of the requirements its to make it accessible so I did all the content decriptions, navigaction, focus, etc.

And it works great, except with fragments, if there is an activity that loads a fragment the talkback reads its content, then the user clicks on something and a detail fragment that could 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 keeps navigating talkback still remember the position of each element of the missing fragment.

Is there any way to clear the Accessibility list of events and force it to get it again? Accesibility manager does not seem to have any method for that.

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

-- EDITED -- Things that I've tried and did not work out.

Sending an event from the view creation in the fragment.

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

Interrupting all the pending texts on the onResume of the fragment.

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

Requesting the decorator view to register an event of window_content_change or window_state_change.

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

-- EDITED -- Made a DumpView Hierarchy and in there is no trace of the dismissed fragment, but talkback stills navigates it :(

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

Regards.

4

2 回答 2

2

https://medium.com/@guygriv/accessibility-and-fragment-transactions-1aef5596f9d4

我发现了这个,它很好地解决了问题而无需使用替换,

此链接描述了 Fragment BackStage 更改,检查添加的片段不是最后一个片段,然后将 Accessibility 设置为 IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS 以禁用隐藏片段可访问性,否则对于可见的片段将 Accessibility 设置为 IMPORTANT_FOR_ACCESSIBILITY_YEs

于 2020-01-20T21:07:25.587 回答
1

我发现下面的片段不会被读取的唯一方法是在片段事务中替换它们,这是一个缺点,因为您会丢失该片段的状态......

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

我将继续寻找如何正确地做到这一点。

于 2014-05-29T14:43:27.430 回答