Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Accessible Android Apps (Detroit Labs)

Stuart Kent
January 25, 2018

Building Accessible Android Apps (Detroit Labs)

Detroit Labs has committed to building more accessible applications in 2018. This internal talk goes beyond the "how" and recommends tools, processes, and practices that make it easier to build accessibility into your Android apps.

Stuart Kent

January 25, 2018
Tweet

More Decks by Stuart Kent

Other Decks in Technology

Transcript

  1. This Talk • Why Accessibility • Why Me • What

    • Tools • Process • Practice
  2. Why Accessibility • 57 million with a disability1 • 8

    million with vision difficulty • 323 million with "situational disabilities": • occupied hand • noisy room • sunny day 1 https://www.census.gov/newsroom/releases/pdf/cb12ff-16_disabilities.pdf
  3. Dev guidelines • Material Design -> Usability -> Accessibility •

    android.com Accessibility API Guide + many more if you need to comply with Actual Laws
  4. Dev goals 1. High contrast 2. Avoid color-only/sound-only cues 3.

    Graceful scaling 4. Large touch targets 5. Access!
  5. Dev goals 1. High contrast 2. Avoid color-only/sound-only cues 3.

    Graceful scaling 4. Large touch targets 5. Access! 6. Appropriate view grouping/ordering/labeling
  6. Material Cue What? Third party Android app that overlays apps

    with material grids Checks: • Touch targets, sorta
  7. Espresso What? • Android's (clear box) UI testing framework •

    AccessibilityChecks .enable() .setRunChecksFromRootView(true); Checks: • ?
  8. Espresso Links: • Espresso setup instructions • Enabling Espresso's accessibility

    checks • List of all Espresso accessibility checks (currently broken)
  9. TalkBack What? Android's built-in screen reader (an AccessibilityService). Checks: •

    Access (unique!) • Element grouping/ordering/labeling (unique!)
  10. Aside: AccessibilityService • Base class for all accessibility services •

    Implementations: • Register for single app/entire system • Receive all AccessibilityEvents issued by views • Do something with these events
  11. TalkBack • Toggle by holding volume up+down for 3 seconds2

    2 See https://support.google.com/accessibility/android/answer/6006966 if this doesn't work.
  12. TalkBack • Toggle by holding volume up+down for 3 seconds2

    • Touches are "hijacked" 2 See https://support.google.com/accessibility/android/answer/6006966 if this doesn't work.
  13. TalkBack • Toggle by holding volume up+down for 3 seconds2

    • Touches are "hijacked" • One finger → two fingers for gestures (e.g. scroll) 2 See https://support.google.com/accessibility/android/answer/6006966 if this doesn't work.
  14. TalkBack • Toggle by holding volume up+down for 3 seconds2

    • Touches are "hijacked" • One finger → two fingers for gestures (e.g. scroll) • View descriptions are read on selection 2 See https://support.google.com/accessibility/android/answer/6006966 if this doesn't work.
  15. Process "When we started building responsive sites we quickly realized

    how inefficient it would be to build a desktop-only site and "add responsiveness" later." "Accessibility is the same: When you plan for accessibility and build it in from the beginning, the resulting product is better and the effort is much lower."3 3 https://www.viget.com/articles/how-to-implement-accessibility-in-agency-projects-part-2/
  16. Consistency: style guides • Produced by designers, for developers •

    Translate to reusable themes/styles/dimensions
  17. Process 1. Learn measurement tools & techniques 2. Promote consistency

    3. Audit new designs 4. Enable simple automatic checks
  18. Simple automatic checks: Gnag • Maintained by Bryan Kelly •

    Wraps major code quality tools, including Android Lint • ./gradlew gnagCheck locally • ./gradlew gnagReport on CI
  19. Simple automatic checks: Gnag buildscript { repositories { jcenter() }

    dependencies { classpath 'com.btkelly:gnag:2.0.0' } } apply plugin: 'gnag' gnag.github { repoName 'detroit-labs/gains-android' } android.lintOptions { error 'ContentDescription', 'LabelFor' }
  20. Process 1. Learn measurement tools & techniques 2. Promote consistency

    3. Audit new designs 4. Enable simple automatic checks 5. Prepare diverse test environments
  21. Process 1. Learn measurement tools & techniques 2. Promote consistency

    3. Audit new designs 4. Enable simple automatic checks 5. Prepare diverse test environments 6. Perform complex manual checks (TalkBack) routinely
  22. PR template? ✅ Focus order/grouping is correct on changed screens

    ✅ Important elements are focusable ✅ Unimportant elements are not focusable ✅ Changed touch targets are at least 48dp x 48dp ✅ Changed images have appropriate descriptions ✅ Changed buttons have appropriate dynamic descriptions ✅ Changed screens adjust appropriately for tiny/huge fonts
  23. Practice: Scaling • sp over dp for text, always •

    Test on a tiny AVD with huge font (scrolling)
  24. Practice: Scaling • sp over dp for text, always •

    Test on a tiny AVD with huge font (scrolling) • Choose match_parent over wrap_content for widths when possible
  25. Practice: Static Labels • Defaults to text if available (TextView,

    Button, etc.) • Don't include view type in label • Require android:contentDescription or android:importantForAccessibility for all images/ image buttons/FABs • Make sure list item descriptions contain identifying information
  26. Practice: Dynamic Labels • Set contentDescription to @null for and

    use corresponding Java APIs on change (View.setContentDescription)
  27. Practice: Ordering • android:nextFocusForward and android:nextFocusBack are used by TalkBack

    • android:nextFocusLeft, android:nextFocusRight, android:nextFocusDown, and android:nextFocusUp are not (may be by other services?) • Also: android:accessibilityTraversalBefore (API 22+)
  28. Practice: Grouping • Group logically-related views together for simpler traversal

    • Set android:focusable="true" on the parent view • (Usually also want android:focusableInTouchMode="false")
  29. Practice: Grouping • Group logically-related views together for simpler traversal

    • Set android:focusable="true" on the parent view • (Usually also want android:focusableInTouchMode="false") • Setting a contentDescription on the parent view implies both of the above
  30. Practice: Titles • Activity labels are read on start •

    Application label is read on the overview screen
  31. Practice: Custom Views • Official guide • Multiple methods to

    override to populate appropriate info: • dispatchPopulateAccessibilityEvent • onPopulateAccessibilityEvent • onInitializeAccessibilityEvent • onInitializeAccessibilityNodeInfo
  32. Excellent Resources • Kelly Shuster: Android Is For Everyone (slides,

    video) • David Truxall: Accessibility in Android (slides, post) • Victoria Gonda: Android Accessibility Tutorial (article) • Instacart: A Month of Android Accessibility (article)