19
Accessibility

In this chapter you will make CriminalIntent more accessible. An accessible app is usable by anyone, regardless of any impairments in vision, mobility, or hearing. These impairments may be permanent, but they could also be temporary or situational: Dilated eyes after an eye exam can make focusing difficult. Greasy hands while cooking may mean you do not want to touch the screen. And if you are at a loud concert, the music drowns out any sounds made by your device. The more accessible an app is, the more pleasant it is to use for everyone.

Making an app fully accessible is a tall order. But that is no excuse not to try. In this chapter, you will take some steps to make CriminalIntent more usable for people with a visual impairment. This is a good place to begin learning about accessibility issues and accessible app design.

The changes you make in this chapter will not alter the appearance of the app. Instead, the changes will make your app easier to explore with TalkBack.

TalkBack

TalkBack is an Android screen reader made by Google. It speaks out the contents of a screen based on what the user is doing.

TalkBack works because it is an accessibility service, which is a special component that can read information from the screen (no matter which app you are using). Anyone can write their own accessibility service, but TalkBack is the most popular.

To use TalkBack, you need an Android device. (Unfortunately, the emulator does not have TalkBack.) Make sure the device’s sound output is not muted – but you may want to grab headphones, because once TalkBack is enabled the device will do a lot of “talking.”

To enable TalkBack, launch Settings and press Accessibility. Press on TalkBack under the Services heading. Then press the switch near the top right of the screen to turn TalkBack on (Figure 19.1).

Figure 19.1  TalkBack settings screen

Screenshot shows TalkBack screen in Android. The status of Talkback is shown of by a rollover button.

Android presents a dialog asking for permission to access certain information, such as observing the user’s actions, and to alter certain settings, such as turning on Explore by Touch (Figure 19.2). Press OK.

Figure 19.2  Giving TalkBack permission

Screenshot shows TalkBack screen in Android. A popup message, Use Talkback is shown. The Cancel and OK buttons are placed below.

The label to the left of the toggle switch at the top of the screen now says On. (If this is your first time using TalkBack on the device, you will be brought through a tutorial at this point.) Exit the menu by pressing the Up button in the toolbar.

You will notice something different right away. A green outline appears around the Up button (Figure 19.3) and the device speaks: “Navigate Up button. Double-tap to activate.”

Figure 19.3  TalkBack enabled

Screenshot shows TalkBack screen in Android. The backward arrow on the title bar is highlighted. Chat bubble reads, Navigate Up button. Double tap to activate.

(Although “press” is the usual terminology for Android devices, TalkBack uses “tap.” Also, TalkBack uses double-taps, which are not commonly used in Android.)

The green outline indicates which UI element has accessibility focus. Only one UI element can have accessibility focus at a time. When a UI element receives focus, TalkBack will provide information about that element.

When TalkBack is enabled, a single press (or “tap”) gives an element accessibility focus. Double-tapping anywhere on the screen activates the element. So double-tapping when the Up button has focus navigates up, double-tapping when a checkbox has focus toggles its check state, etc. (Also, if your device locks, you can unlock it by pressing the lock icon and then double-tapping anywhere on the screen.)

Explore by Touch

By turning TalkBack on, you have also enabled TalkBack’s Explore by Touch mode. This means the device will speak information about the item immediately after it is pressed. (This assumes that the item pressed specifies information TalkBack can read, which you will learn more about shortly.)

Leave the Up button selected with accessibility focus. Double-tap anywhere on the screen. The device returns you to the Accessibility menu and TalkBack announces information about what is showing: “Accessibility.”

Android framework widgets, such as Toolbar, RecyclerView, ListView, and Button, have basic TalkBack support built in. You should use framework widgets as much as possible so you can leverage the accessibility work that has already been done for those widgets. It is possible to properly respond to accessibility events for custom widgets, but that is beyond the scope of this book.

To scroll the list, hold two fingers on the screen and drag them up or down. Depending on the length of the list, you will hear tones that change as you scroll. These tones are earcons, sounds used to give meta information about the interaction.

Linear navigation by swiping

Imagine what it must be like to explore an app by touch for the first time. You would not know where things are located. What if the only way to learn what was on the screen was to press all around until you landed on an element that TalkBack could read? You might end up pressing on the same thing multiple times and, worse, you might miss elements altogether.

Luckily, there is a way to explore the UI linearly, and in fact this is the more common way to use TalkBack: Swiping right moves accessibility focus to the next item on the screen. Swiping left moves accessibility focus to the previous item on the screen. This allows the user to walk through each item on the screen in a linear fashion, rather than trial-and-error poking around in hopes of landing on something meaningful.

Try it out for yourself. Launch CriminalIntent and go to the crime list screen. Press on the toolbar title to give it accessibility focus. The device reads out, “CriminalIntent” (Figure 19.4).

Figure 19.4  Title selected

Screenshot shows CriminalIntent app screen in Android.

Now swipe right. Accessibility focus moves to the new crime button in the toolbar. TalkBack announces, “New crime. Double-tap to activate. Double-tap and hold to long-press.” For framework widgets, such as menu items and buttons, TalkBack will read the visible text content displayed on the widget by default. The new crime menu item, however, is just an icon and does not have any visible text. In this case, TalkBack looks for other information that it has available. You specified a title in your menu XML, and that is what TalkBack reads to the user. TalkBack will also provide details about actions the user can take on the widget and sometimes information about what kind of widget it is.

Figure 19.5  New crime button selected

Screenshot shows CriminalIntent app screen in Android.

Swipe right again, and TalkBack reads information about the SHOW SUBTITLE menu button. Swipe right a third time; accessibility focus moves to the first crime in the list. Swipe left, and focus moves back to the SHOW SUBTITLE menu button. Android does its best to move accessibility focus in an order that makes sense.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.0.157