Announce the date for accessibility using EMMMMdy format
Which for en_US would be something like "Friday August 5th 2016" but may be re-ordered for other locales. Dates are hard. Bug: 30682782 Change-Id: I015d293526592add27ce8fada12cd58bcc274ccf
This commit is contained in:
@@ -65,6 +65,8 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate {
|
||||
|
||||
private SimpleDateFormat mYearFormat;
|
||||
private SimpleDateFormat mMonthDayFormat;
|
||||
private SimpleDateFormat mAccessibilityEventFormat;
|
||||
|
||||
|
||||
// Top-level container.
|
||||
private ViewGroup mContainer;
|
||||
@@ -307,6 +309,9 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate {
|
||||
mMonthDayFormat.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
|
||||
mYearFormat = new SimpleDateFormat("y", locale);
|
||||
|
||||
// Clear out the lazily-initialized accessibility event formatter.
|
||||
mAccessibilityEventFormat = null;
|
||||
|
||||
// Update the header text.
|
||||
onCurrentDateChanged(false);
|
||||
}
|
||||
@@ -586,7 +591,12 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate {
|
||||
|
||||
@Override
|
||||
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||
event.getText().add(mCurrentDate.getTime().toString());
|
||||
if (mAccessibilityEventFormat == null) {
|
||||
final String pattern = DateFormat.getBestDateTimePattern(mCurrentLocale, "EMMMMdy");
|
||||
mAccessibilityEventFormat = new SimpleDateFormat(pattern);
|
||||
}
|
||||
final CharSequence text = mAccessibilityEventFormat.format(mCurrentDate.getTime());
|
||||
event.getText().add(text);
|
||||
}
|
||||
|
||||
public CharSequence getAccessibilityClassName() {
|
||||
|
||||
Reference in New Issue
Block a user