trackr
trackr copied to clipboard
TalkBack focuses on obscured views of the list pane when the details pane is open.
Android 11, Samsung SM-G770F/DS, TalkBack 12.5.01.2
Open task detail from the task list screen and explore the opened screen with TalkBack turned on. Besides the elements of the details page, TalkBack will also focus on the hidden views of the task list screen:
i think this is a bug in SlidingPaneLayout library. Until it is fixed, as a workaround we can set importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
on the hidden pane of the SlidingPaneLayout. Something like this:
--- a/app/src/main/java/com/example/android/trackr/ui/BaseTwoPaneFragment.kt
slidingPaneLayout.addPanelSlideListener(SlidingPaneAccessibilityHandler(slidingPaneLayout))
internal class SlidingPaneAccessibilityHandler(private val slidingPaneLayout: SlidingPaneLayout) : PanelSlideListener {
private val listPaneContent by lazy(NONE) {
slidingPaneLayout.findViewById<ViewGroup>(R.id.list_pane)[0]
}
init {
slidingPaneLayout.doOnLayout {
syncState()
}
}
private fun syncState() {
val mode = if (slidingPaneLayout.isSlideable && slidingPaneLayout.isOpen) {
View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
} else {
View.IMPORTANT_FOR_ACCESSIBILITY_AUTO
}
listPaneContent.importantForAccessibility = mode
}
override fun onPanelOpened(panel: View) {
syncState()
}
override fun onPanelClosed(panel: View) {
syncState()
}
override fun onPanelSlide(panel: View, slideOffset: Float) {
// empty
}
}
This snippet fixes the problem.