[DatePicker] Fixed day of week adapter localization for APIs before O

Resolves https://github.com/material-components/material-components-android/issues/1948

PiperOrigin-RevId: 350474335
This commit is contained in:
marianomartin 2021-01-06 22:44:02 -05:00 committed by ikim24
parent 74350dead6
commit bec2de92ac

View File

@ -86,8 +86,9 @@ class DaysOfWeekAdapter extends BaseAdapter {
(TextView) layoutInflater.inflate(R.layout.mtrl_calendar_day_of_week, parent, false);
}
calendar.set(Calendar.DAY_OF_WEEK, positionToDayOfWeek(position));
Locale locale = dayOfWeek.getResources().getConfiguration().locale;
dayOfWeek.setText(
calendar.getDisplayName(Calendar.DAY_OF_WEEK, CALENDAR_DAY_STYLE, Locale.getDefault()));
calendar.getDisplayName(Calendar.DAY_OF_WEEK, CALENDAR_DAY_STYLE, locale));
dayOfWeek.setContentDescription(
String.format(
parent.getContext().getString(R.string.mtrl_picker_day_of_week_column_header),