miguely 1a17221ee3 Fix accessibility focus on the back layer and the content layer.
Problem 1. The back layer contains all views for an expanded experience, even
if they are hidden behind the content layer, this makes them accessible through
Talkback when the back layer is collapsed when all views outside of
CollapsedBackLayerContents must be for all intents and purposes disabled. They
still need to remain visible to accomodate for semi transparent views, so
changing their visibility to GONE is not an option.

Solution: Add ChildViewAccessibilityHelper that keeps track of the
importantForAccessibility property for subviews of the BackLayer and overrides
them to IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDENTS when collapsed and then
reverts them to their original values when the back layer is expanded.

- Caveat: This new object has to implement ViewGroup.OnHierarchyChangeListener
so it can remove mappings for removed views, this way guaranteeing there is no
memory leak. This also means users of BackLayerLayout MUST NOT set their own
OnHierarchyChangeListener.

- Caveat 2: this new object does not modify any CollapsedBackLayerContents,
since views in that subview must still be accessible when collapsed.

Problem 2. When the backlayer expands, the content layer remains active through
accessibility services, we want to completely disable it. Furthermore a content
description needs to be set on the content layer view that may not match what
it already has.

Solution: Add ContentViewAccessibilityPropertiesHelper that overrides the
content layer's contentDescription, importantForAccessibility and focusable
properties (and reverts them once the back layer is collapsed), and reuses the
ChildViewAccessibilityHelper to make its child views not focusable.

Tested: Sadly this is too hard to test on Espresso, I tested this manually, I'm
trying to find a way to test them automatically.
PiperOrigin-RevId: 164661912
2017-09-21 14:21:44 -04:00
..