Android P Accessibility for devs

Android P Accessibility for Devs

by Saleem Ur Rahman @saleem4Rahman. In this article Saleem will be looking at the new features that Google has implemented in Android P for developers to make their apps more accessible.

Improvement to Navigation

Screen readers are often misunderstood as being just that. Actually a more correct term is screen reading and navigators. This a core part of how the software is used. So in Android P navigating from one part of the screen to another part in an app’s user interface has been improved. This is because new attributes has been added in Android P that help TalkBack users to navigate more intuitively. For example, in a news app or any UI with a heading structure, a screen reader could navigate users directly from one category to the next. This is common in desktop screen readers like JAWS/NVDA and means the user will not have to wade thru lots of content to get where they want to go.

Heading-based Navigation

This sort of heading based navigation is common in desktops and comes in handy when there are apps that display logical content views.

Practical Tip: Set the new android:accessibilityHeading attribute to true for the instances of View that represent those headers. This allows TalkBack users to navigate from one heading to the next.

Managing group navigation and output

In earlier Android version, each inner view object needed to be marked as non-focusable and the group containing them as focusable. This is logical from a dev perspective as the view object can be used as a container, allowing the user to focus on the content. However this did have a negative impact on keyboard navigation, as the View could be marked as focusable adding more steps for a keyboard navigation user.

Practical Tip: In Android P, you can now use the new android:screenReaderFocusable attribute in place of the android:focusable attribute. This is useful where making a View object focusable may have un wanted effects for keyboard only users.. Screen readers should focus on all elements that have set either android:screenReaderFocusable or android:focusable to true.

New Accessibility Pane Titles

Before we look at the new Accessibility Pane title – we need to understand what are ‘Accessibility Services’. Accessibility services – are the helpers in Android that allow users with disabilities use the AT that comes bundled with Android devices and apps. They run in the background and receive callbacks by the system when AccessibilityEvents are fired. So in effect they help manage the interaction between the user, AT and the OS.

Before Android P – accessibility services could not tell easily when a specific section of the screen had updated, such as during fragment transitions.

NOTE: The term ‘Fragment Transistions’ relates to the an API for animating between different UI states in an application. This has to be managed in a way that works with the OS Accessibility services and Talkback or other AT.

In Android P, sections now have titles called accessibility pane titles. Accessibility services will not receive changes to those titles, that allows the user to get more detailed information about what has changed in the UI.

Practical Tip: : To specify the title of any section, use the new android:accessibilityPaneTitle attribute. You can update a UI section that dynamically using setAccessibilityPaneTitle(). This will help you manage different states/views in your app and help to give the user greater context.

Managing Window changes

Previous to Android P, updates to apps windows were hard to track when an app redraws multiple windows at the same time. In Android P now it is much easier to track various windows.

The getSource() method returns the root view of the window associated with each event for each window via a TYPE_WINDOWS_CHANGED event. You can use the getWindowChanges() and getContentChangeTypes() methods to track window changes.

To help the ‘helpers’ (a la Accessibility Services) when an app understands the accessibility pane titles for the various Views, as well as their current state – the Accessibility service can track when the UI updates.