Settings: Ensure zen day-of-week formats use current locale.

Don't share SimpleDateFormat instances per-process, convert to
per-instance to ensure we're always using the current locale.

Updated version of:
  https://android-review.googlesource.com/#/c/147246/

Change-Id: Id464c35035c1de0a7894e5e19b57934f77df9769
This commit is contained in:
John Spurlock
2015-04-23 20:28:58 -04:00
parent 1049f4d81b
commit 4f8d4f0d2b
3 changed files with 10 additions and 7 deletions

View File

@@ -41,8 +41,9 @@ public class ZenModeScheduleDaysSelection extends ScrollView {
Calendar.FRIDAY,
Calendar.SATURDAY,
};
private static final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("EEEE");
// per-instance to ensure we're always using the current locale
private final SimpleDateFormat mDayFormat = new SimpleDateFormat("EEEE");
private final SparseBooleanArray mDays = new SparseBooleanArray();
private final LinearLayout mLayout;
@@ -66,7 +67,7 @@ public class ZenModeScheduleDaysSelection extends ScrollView {
final CheckBox checkBox = (CheckBox) inflater.inflate(R.layout.zen_schedule_rule_day,
this, false);
c.set(Calendar.DAY_OF_WEEK, day);
checkBox.setText(DAY_FORMAT.format(c.getTime()));
checkBox.setText(mDayFormat.format(c.getTime()));
checkBox.setChecked(mDays.get(day));
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override