[Android] Using AutomationId prevents TalkBack screenreader accessibility #1529
Description
Description
When using the AutomationId
property on Android, apps end up almost completely inaccessible to users who use Android's TalkBack screenreader.
Xamarin.Forms "borrows" the ContentDescription
property on Android for Automation IDs. These IDs polute Android's TalkBack accessibility tree, making apps almost impossible to navigate.
This means you can support test automation or accessibility, not both. Our app needs to support both 😃
I can't find any easy way of working around this restriction, short of walking the Android view tree and setting ContentDescription
to null. Being unable to update AutomationId
once set also adds to the difficulty of working around this issue.
Potential solutions
1. Use another system for setting AutomationIDs
Probably a non-starter for backwards compatibility?
2. Monitor AccessibilityManager to see if accessibility is enabled
Assuming there’s no alternative property to use for setting IDs, one solution would be for Xamarin.Forms to use Android's AccessibilityManager
and check the IsTouchExplorationEnabled
property.
This is true when the TalkBack screen-reader is being used, and Forms could ignore AutomationId
and not set ContentDescription
. Forms should then also use an ITouchExplorationStateChangeListener
to monitor changes to this state.
Steps to Reproduce
- Create any element with an AutomationId set
- Go to that element on an Android device with TalkBack enabled
Expected Behavior
Element is ignored, or its actual content is read.
Actual Behavior
Element's AutomationId is read to the user.
Basic Information
- Version with issue: 2.5.0.121934
- Last known good version: none. Always happened since AutomationId supported.