Android TalkBack and chunk stack
For an application I'm working on, I need to implement accessibility. Everything works fine except for one screen where I have fragments added to my work. Basically, the snippet above is the keypad for entering a password. This fragment is added using fragmentation.
The point is that the focus of the feedback is set on the elements of the lower fragment.
Do you know if there is a way to set feedback focus on a set fragment? I just want to "disable" the fragment from the bottom to get focus
Thank,
source to share
UPDATE
I figured out the solution. you can disable the availability of the first chunk prior to executing the chunk transaction.
rootView = inflater.inflate(R.layout.first_fragment, null, false);
rootView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
and now you are committing a fragment transaction. The second fragment will not flow focus to the first fragment.
Remember to turn on the availability of the first snippet if you go back to the first snippet.
if(rootView != null) {
rootView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
source to share
Take a look at the method representation. sendAccessibilityEvent
(AccessibilityEvent.TYPE_VIEW_FOCUSED). sendAccessibilityEvent
changes focus from Talkback. I don't know much about Talkback, pls read the link on SO @ When using TalkBack, what's the preferred way to alert the user when the content of the TextView has changed? ...
Good luck ...
source to share
Your problem is not "sending" the focus to the right place. Forcing focus around different locations is generally a bad idea and not available. Your problem is that you have items on the screen that are not visible but focus on TalkBack. You want to hide these items from TalkBack. In fact, you probably want to remove them entirely, but assume they should be on the screen. You can hide them from the accessibility service:
rootViewOfFragment.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
This will hide these views from TalkBack. This is a better solution than focusing on a specific element, as this is usually an accessibility violation in WCag 2.0. Although, if the elements on the screen are not completely hidden by your "top" fragment, that is also a violation and you should just leave things behind.
source to share