Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANDROID-13687 Improve Snackbar accessibility #358

Merged
merged 6 commits into from
Jun 24, 2024

Conversation

jeslat
Copy link
Contributor

@jeslat jeslat commented May 27, 2024

🥅 What's the goal?

Improve Snackbar accessibility.

Old
The snackbar will get the focus when it is opened.

New
The snackbar should no get the focus when it is shown, it will have focus in the default A11y order.
The snackbar should announce the message following this logic:

  • Informative: should announce the message without interrupt the current Talkback announcement.
  • Critical: should announce the message interrupting the current Talkback announcement.

The main action will be spoken as a button with an optional custom content description.

The idea was not to introduce a breaking change with the content description, but after trying this version in android-messenger, for example in Java code, it is a breaking change.

🚧 How do we do it?

  • Provide options to add a custom content description to the main action.
  • Get accessibility focus when the snackbar is opened.
  • Change main action from TextView to Button to improve the talkback message.

☑️ Checks

  • I updated the documentation, including readmes and wikis. If this is a breaking change, tag the PR with "Breaking Change" label and remember to include breaking change migration guide in release notes where this version is released.

🧪 How can I test this?

  • Video (i have added some delay before the Snackbar display to be able to check the interruption):
demo_new_snackbar_behavior.mp4
  • After changing the TextView to a Button, I've verified that the snackbar maintains the same UI. You can verify with these screenshots the result:
Before After
drawing drawing
drawing drawing
drawing drawing
drawing drawing
drawing drawing
drawing drawing
  • Reviewed by Mistica design team

Copy link

📱 New catalog for testing generated: Download

@jeslat jeslat force-pushed the ANDROID-13687-snackbar-accessibility branch from 52d4530 to 969f455 Compare May 27, 2024 06:35
Copy link

📱 New catalog for testing generated: Download

@jeslat jeslat marked this pull request as ready for review May 27, 2024 07:04
Comment on lines 113 to 117
snackbar.addCallback(object : BaseCallback<Snackbar>() {
override fun onShown(transientBottomBar: Snackbar) {
transientBottomBar.view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
}
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to get the focus when it's opened

Comment on lines -82 to +88
constraintSet.setMargin(action.id, ConstraintSet.END, context.resources.getDimensionPixelSize(R.dimen.mistica_snackbar_padding_horizontal))
constraintSet.setMargin(action.id, ConstraintSet.END, context.resources.getDimensionPixelSize(R.dimen.mistica_snackbar_action_horizontal_margin))
constraintSet.setMargin(action.id, ConstraintSet.BOTTOM, context.resources.getDimensionPixelSize(R.dimen.mistica_snackbar_action_vertical_margin))
constraintSet.setMargin(action.id, ConstraintSet.TOP, context.resources.getDimensionPixelSize(R.dimen.mistica_snackbar_action_vertical_margin))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to adjust a bit the layout after changing to a Button

@jeslat jeslat requested review from a team, pmartinbTEF, juangardi21 and yceballost and removed request for a team May 27, 2024 07:06
@jeslat jeslat added the Breaking Change A change that is not retrocompatible label May 27, 2024
Copy link
Contributor

@juangardi21 juangardi21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏼

Copy link
Contributor

@pmartinbTEF pmartinbTEF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

Copy link

📱 New catalog for testing generated: Download

@jeslat jeslat marked this pull request as draft June 4, 2024 09:57
Copy link

📱 New catalog for testing generated: Download

Copy link

📱 New catalog for testing generated: Download

@haynlo haynlo marked this pull request as ready for review June 12, 2024 14:50
Copy link
Contributor

@pmartinbTEF pmartinbTEF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@juangardi21 juangardi21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@yceballost yceballost removed their request for review June 13, 2024 09:56
@yceballost yceballost requested a review from aweell June 13, 2024 09:56
Copy link

📱 New catalog for testing generated: Download

@aweell
Copy link

aweell commented Jun 14, 2024

LGTM, I have a question left:

What happens when is a persistent snackbar displayed and a sheet is opened? the snackbar would remain under the sheet?

@jeslat
Copy link
Contributor Author

jeslat commented Jun 24, 2024

LGTM, I have a question left:

What happens when is a persistent snackbar displayed and a sheet is opened? the snackbar would remain under the sheet?

@aweell right, the snack bar remains under the sheet. You can see it in this video:

Screen_recording_20240624_125029.mp4

Copy link

📱 New catalog for testing generated: Download

@jeslat jeslat merged commit 38f8064 into main Jun 24, 2024
5 of 6 checks passed
@jeslat jeslat deleted the ANDROID-13687-snackbar-accessibility branch June 24, 2024 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change A change that is not retrocompatible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants