Creating a Comparable Experience
Creating a Comparable Experience
You should specify a content description for any UI widget that provides information to the user but
does not use text to do it (such as an image). If there is a widget that does not provide any value other
than decoration, you should explicitly tell TalkBack to ignore it by setting its content description to
null.
You might think, “If a user cannot see, why does he or she need to know whether there is an image?”
But you should not make assumptions about your users. More importantly, you should make sure a
user with a visual impairment gets the same amount of information and functionality as a user without
one. The overall experience and flow may be different, but all users should be able to get the same
functionality from the app.
Good accessibility design is not about reading out every single thing on the screen. Instead, it focuses
on comparable experiences. Which information and context are important?
Right now, the user experience related to the crime photo is limited. TalkBack will always announce
that the image is not set, even if an image is indeed set. To see this for yourself, press the camera button
and then double-tap anywhere on the screen to activate it. The camera app launches and TalkBack
announces, “Camera.” Capture a photo by pressing on the shutter button and then double-tapping
anywhere on the screen.
Accept the photo. (The steps will be different depending on which camera app you are using, but
remember that you will need to press to select a button and then double-tap anywhere to activate it.)
The crime details screen will appear with the updated photo. Press the photo to give it accessibility
focus. TalkBack announces, “Crime scene photo (not set).”
To provide more relevant information to TalkBack users, dynamically set the content description of the
ImageView in updatePhotoView().
Listing 19.4 Dynamically setting content description (CrimeFragment.java)
public class CrimeFragment extends Fragment {
...
private void updatePhotoView() {
if (mPhotoFile == null || !mPhotoFile.exists()) {
mPhotoView.setImageDrawable(null);
mPhotoView.setContentDescription(
getString(R.string.crime_photo_no_image_description));
} else {
...
mPhotoView.setImageBitmap(bitmap);
mPhotoView.setContentDescription(
getString(R.string.crime_photo_image_description));
}
}
}
Now, whenever the photo view is updated, updatePhotoView() will update the content description. If
mPhotoFile is empty, it will set the content description to indicate that there is no photo. Otherwise, it
will set the content description to indicate that a photo is present.