Merge "Announce the date for accessibility using EMMMMdy format" into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8ecc7f7303
@@ -65,6 +65,8 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate {
|
|||||||
|
|
||||||
private SimpleDateFormat mYearFormat;
|
private SimpleDateFormat mYearFormat;
|
||||||
private SimpleDateFormat mMonthDayFormat;
|
private SimpleDateFormat mMonthDayFormat;
|
||||||
|
private SimpleDateFormat mAccessibilityEventFormat;
|
||||||
|
|
||||||
|
|
||||||
// Top-level container.
|
// Top-level container.
|
||||||
private ViewGroup mContainer;
|
private ViewGroup mContainer;
|
||||||
@@ -307,6 +309,9 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate {
|
|||||||
mMonthDayFormat.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
|
mMonthDayFormat.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
|
||||||
mYearFormat = new SimpleDateFormat("y", locale);
|
mYearFormat = new SimpleDateFormat("y", locale);
|
||||||
|
|
||||||
|
// Clear out the lazily-initialized accessibility event formatter.
|
||||||
|
mAccessibilityEventFormat = null;
|
||||||
|
|
||||||
// Update the header text.
|
// Update the header text.
|
||||||
onCurrentDateChanged(false);
|
onCurrentDateChanged(false);
|
||||||
}
|
}
|
||||||
@@ -586,7 +591,12 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
|
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() {
|
public CharSequence getAccessibilityClassName() {
|
||||||
|
|||||||
Reference in New Issue
Block a user