Skip to content

Commit c06ef1b

Browse files
paulfthomasdsn5ft
authored andcommitted
[DatePicker][a11y] Properly announce the change of selection between year/day
PiperOrigin-RevId: 675901350
1 parent c08ee83 commit c06ef1b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/java/com/google/android/material/datepicker/MaterialCalendar.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,12 @@ void setSelector(CalendarSelector selector) {
395395
void toggleVisibleSelector() {
396396
if (calendarSelector == CalendarSelector.YEAR) {
397397
setSelector(CalendarSelector.DAY);
398+
recyclerView.announceForAccessibility(
399+
getString(R.string.mtrl_picker_toggled_to_day_selection));
398400
} else if (calendarSelector == CalendarSelector.DAY) {
399401
setSelector(CalendarSelector.YEAR);
402+
yearSelector.announceForAccessibility(
403+
getString(R.string.mtrl_picker_toggled_to_year_selection));
400404
}
401405
}
402406

lib/java/com/google/android/material/datepicker/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
<string name="mtrl_picker_a11y_next_month" description="a11y string to indicate this button moves the calendar to the next month [CHAR_LIMIT=NONE]">Change to next month</string>
4747
<string name="mtrl_picker_toggle_to_year_selection" description="a11y string to indicate this button switches the user to choosing a year [CHAR_LIMIT=NONE]">Tap to switch to year view</string>
4848
<string name="mtrl_picker_toggle_to_day_selection" description="a11y string to indicate this button switches the user to choosing a day [CHAR_LIMIT=NONE]">Tap to switch to Calendar view</string>
49+
<string name="mtrl_picker_toggled_to_year_selection" description="a11y string to indicate this view switched the user to choosing a year [CHAR_LIMIT=NONE]">Switched to year view</string>
50+
<string name="mtrl_picker_toggled_to_day_selection" description="a11y string to indicate this view switched the user to choosing a day [CHAR_LIMIT=NONE]">Switched to Calendar view</string>
4951
<string name="mtrl_picker_day_of_week_column_header" description="a11y string to indicate this is a header for a column of days for one day of the week (e.g., Monday) [CHAR_LIMIT=NONE]">%1$s</string>
5052
<string name="mtrl_picker_announce_current_selection" description="a11y string read on selection change to indicate the new selection [CHAR_LIMIT=NONE]">Current selection: %1$s</string>
5153
<string name="mtrl_picker_announce_current_range_selection" description="a11y string read on range selection change to indicate the new selection [CHAR_LIMIT=NONE]">Start date selection: %1$s – End date selection: %2$s</string>

0 commit comments

Comments
 (0)