6

Background

The CTOR of "ActionBarDrawerToggle" is as such:

public ActionBarDrawerToggle (Activity activity, DrawerLayout drawerLayout, int openDrawerContentDescRes, int closeDrawerContentDescRes)

or:

public ActionBarDrawerToggle (Activity activity, DrawerLayout drawerLayout, Toolbar toolbar, int openDrawerContentDescRes, int closeDrawerContentDescRes)

The documentation tells you about the strings parameters, that (here ) :

String resources must be provided to describe the open/close drawer actions for accessibility services.

The problem

I can't find a scenario that those strings are being used.

What I've tried

As opposed to action items, where I can see a toast each time I long click an item, here I couldn't find in which case I can see it.

The question

Why is it required? In which cases is it shown?

Is it like what's happening to ImageView ? If so, I'd still like to know when those strings are used and how (on both ImageView and here).

android developer
  • 114,585
  • 152
  • 739
  • 1,270

1 Answers1

9

Those are string resources for content descriptions. They are not displayed on screen, but accessibility services can use them to, for example, say aloud what the content is for users who are visually impaired using text-to-speech. That way you could have the device produce audio saying "drawer open" or "drawer closed" (or any other strings) when the drawer opens or closes, so blind users know what happened in the app.

Karakuri
  • 38,365
  • 12
  • 84
  • 104
  • How can I demonstrate it? Is it the same as was done for ImageView ? – android developer Jan 27 '15 at 16:59
  • 1
    What do you mean "as was done for ImageView"? This is an accessibility feature. Refer to the accessibility guide here: https://developer.android.com/guide/topics/ui/accessibility/index.html – Karakuri Jan 27 '15 at 17:09
  • ImageView has an attribute called "contentDescription" – android developer Jan 27 '15 at 18:55
  • All views have this attribute. – Karakuri Jan 27 '15 at 18:57
  • well, so far, Lint only complained about ImageView. – android developer Jan 27 '15 at 19:22
  • Not every view needs a content description. Things like TextViews and Buttons already have text that can be read aloud. ImageView has no textual content, so for visually impaired users, a content description is likely the only way they will know what content is there, hence the Android developers included a lint check for ImageView. – Karakuri Jan 27 '15 at 21:13
  • nice. thank you. you should edit the answer though. also, how do you test there the part of what I've written? – android developer Jan 28 '15 at 07:26
  • Turn on TalkBack. Place accessibility focus on the drawer state indicator (e.g. hamburger icon) and listen to what TalkBack speaks. Open the drawer. Check the indicator again. – alanv Mar 08 '15 at 08:26