From 776922d543bdfc3f8d30d5e829acec3efac398e3 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Fri, 10 Jun 2016 13:07:52 -0700 Subject: [PATCH] Correclty capitalize Date in status bar panel Use ICU's DateFormat and set the appropriate context to get correclty capitalized dates in languages where dates are not always capitalized. Change-Id: I0e99db4e14762b32833e8c0c7a59e4762c57116d Fixes: 29064624 --- .../android/systemui/statusbar/policy/DateView.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java index 186005cc21627..a92422a66a221 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java @@ -21,7 +21,8 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.res.TypedArray; -import android.text.format.DateFormat; +import android.icu.text.DateFormat; +import android.icu.text.DisplayContext; import android.util.AttributeSet; import android.widget.TextView; @@ -36,7 +37,7 @@ public class DateView extends TextView { private final Date mCurrentTime = new Date(); - private SimpleDateFormat mDateFormat; + private DateFormat mDateFormat; private String mLastText; private String mDatePattern; @@ -100,8 +101,9 @@ public class DateView extends TextView { protected void updateClock() { if (mDateFormat == null) { final Locale l = Locale.getDefault(); - final String fmt = DateFormat.getBestDateTimePattern(l, mDatePattern); - mDateFormat = new SimpleDateFormat(fmt, l); + DateFormat format = DateFormat.getInstanceForSkeleton(mDatePattern, l); + format.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE); + mDateFormat = format; } mCurrentTime.setTime(System.currentTimeMillis());