Announce Your Actions: Making gesture actions accessible

Sep 5, 2018 3 min readOverflow
We’re working towards better accessibility for our Android apps here at Buffer. That’s why when we recently added a new feature to Reply, we took a little extra time to make sure it was accessible. This feature includes some swipe gestures: a user can swipe left or right on a item in a list of conversations to perform some action on that conversation.
Gif displaying swiping a list item to perform an action
This is great for quick management of the list, but leaves out people using TalkBack or who have motor impairments that may struggle with swipe gestures. TalkBack is an accessibility tool that people with low or no vision use. It traverses the screen, and reads aloud the elements so they can understand and navigate the app without sight. We try to keep in mind how our app interacts with this tool, and discovered that these swipe actions do not work well with it. When navigating the app this way, it does not allow for swiping. In this tutorial you can find out more about what TalkBack is and how you can try it out.This opened up an opportunity for a great conversation on how we could make this important feature accessible for more people. There were lots of great ideas shared on how we could provide other ways to access these actions. Adding a drop down menu to the item? Exposing the actions in the view after a user clicks into the conversation? We ultimately decided on showing the actions in a bottom sheet when a user long presses on the conversation. By default, this made the actions reachable for the people we were trying to solve this accessibility issue for.
Gif showing a long press on an item to display a sheet with action options
If you were to turn on TalkBack at this time to try it out, you’d discover we could still make improvements. When reaching a list item you would hear “Double tap to activate. Double tap and hold to long press.” Sure, the actions are now reachable, but that information isn’t very useful. What does it mean to activate? Why should I long press?
Screen with text "double tap to activate, double tap and hold to long press"
We knew we could use AccessibilityNode.addAction() to improve our accessibility announcements, so that’s what we did. This post by Ataul Munim was a great resource for figuring out how to implement this.To start off with, we had to create an AccessibilityDelegateCompat. This is where we can specify the announcement for each action, short or long click:
class ConversationAccessibilityDelegate : AccessibilityDelegateCompat() {

override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(host, info)

val click = AccessibilityNodeInfoCompat.AccessibilityActionCompat(
AccessibilityNodeInfo.ACTION_CLICK,
         // “Open conversation”
host.context.getString(R.string.description_open_conversation))
val longClick = AccessibilityNodeInfoCompat.AccessibilityActionCompat(
AccessibilityNodeInfo.ACTION_LONG_CLICK,
         // “Perform conversation action”
host.context.getString(R.string.description_perform_conversation_action)) 

info.addAction(click)
info.addAction(longClick)
}
}
In our RecyclerView.Adapter is where we decided to set these actions. Since it stays the same for all items, we added it to the onCreateViewHolder() method. The main thing to pay attention to here is the call to setAccessibilityDelegate(). This is where we pass in the view and an instance of the accessibility delegate:
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val itemView = createItemView(parent)
ViewCompat.setAccessibilityDelegate(itemView, ConversationAccessibilityDelegate())
return ConversationViewHolder(itemView)
}
Now when we run TalkBack again we hear “Double tap to open conversation. Double tap and hold to perform conversation action.” So much more informative than it was before! I hope you can use this in your apps to make them more informative and usable for people using TalkBack.
screen showing text "double tap to open conversation. double press and hold to perform conversation action"
We are always striving to make our apps more accessible. Feel free to let us know if you’ve noted something we can improve to make them easier to use for you!
Brought to you by

Try Buffer for free

140,000+ small businesses like yours use Buffer to build their brand on social media every month

Get started now

Related Articles

OverflowJul 12, 2024
How We're Preventing Breaking Changes in GraphQL APIs at Buffer — and Why It's Essential for Our Customers

As part of our commitment to transparency and building in public, Buffer engineer Joe Birch shares how we’re doing this for our own GraphQL API via the use of GitHub Actions.

OverflowDec 13, 2022
Highlighting Text Input with Jetpack Compose

We recently launched a new feature at Buffer, called Ideas. With Ideas, you can store all your best ideas, tweak them until they’re ready, and drop them straight into your Buffer queue. Now that Ideas has launched in our web and mobile apps, we have some time to share some learnings from the development of this feature. In this blog post, we’ll dive into how we added support for URL highlighting to the Ideas Composer on Android, using Jetpack Compose. We started adopting Jetpack Compose into ou

OverflowApr 18, 2022
Secure Access To Opensearch on AWS

With the surprising swap of Elasticsearch with Opensearch on AWS. Learn how the team at Buffer achieved secure access without AWS credentials.

140,000+ people like you use Buffer to build their brand on social media every month