trackr icon indicating copy to clipboard operation
trackr copied to clipboard

TalkBack focuses on obscured views of the list pane when the details pane is open.

Open illarionov opened this issue 3 years ago • 0 comments

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:

Screenshot_20210912-023246_Trackr_2

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.

illarionov avatar Sep 12 '21 00:09 illarionov