material-components/material-components-android

[Slider] Add new attributes for better accessibility support

开放

#2,773 创建于 2022年6月23日

 (0 条评论) (2 个反应) (0 位负责人)Java (3,023 个派生)batch import
Good First IssueIssue: AccessibilityWidget: Sliderfeature request

仓库指标

星标
 (15,910 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Slider does not provide enough configuration parameters for:

  1. Increment / decrement step value configuration for a11y mode - it's hardcoded to 20 percents https://github.com/material-components/material-components-android/blob/3fdfb6e230767138849edf858c13da1bf1d3f90b/lib/java/com/google/android/material/slider/BaseSlider.java#L2491

private float calculateStepIncrement(int stepFactor)

  1. There is no VoiceOver response on the value change event. We need to add annonceForAccessibility method call while the slider value is changed after some user interaction.

Solution:

  1. Add the following attributes:

accessibilityStepValue - should be used to determine a step, for which the value of the slider should be changed while the user performs AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD or AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD actions:

https://github.com/material-components/material-components-android/blob/3fdfb6e230767138849edf858c13da1bf1d3f90b/lib/java/com/google/android/material/slider/BaseSlider.java#L2491

private float calculateStepIncrement(int stepFactor)


Those parameters could be used for a proper a11y message creation - e.g.

annonceForAccessibility("Volume value incremented to 65 percent")
annonceForAccessibility("Temperature value decremented to 45 degrees")

Where "Volume", "Temperature" is accessibilityParameterName

And "percent", "degrees" is accessibilityUnitName

Describe alternatives you've considered There are no alternatives for a slider step value configuration while we a dealing with a continuous slider, not the range slider.

Also, there is no message from a TalkBack when the user changes the slider value with swipe up or down.

In order to get the current slider value after a swipe user needs to perform one more tap - in order to force TalkBack to announce the updated slider value.

Additional context This feature will simplify slider interaction for people with visual disabilities and will provide a much simpler API for Android Apps developers.

贡献者指南