diff options
| author | 2017-06-01 19:44:42 +0000 | |
|---|---|---|
| committer | 2017-06-01 19:44:48 +0000 | |
| commit | f58fae54bfc2c560942e387a010368ccdb02dfd0 (patch) | |
| tree | c55dfddcada58140bc93239e6b51fcf5c1f9125c | |
| parent | 227e65d81887a81aa42da84d7bd7745ab53d6f07 (diff) | |
| parent | 59de4f30c071fadd2751fde82caf026891c130c2 (diff) | |
Merge "Keyguard: Fix date capitalization context" into oc-dev
3 files changed, 19 insertions, 9 deletions
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_status_area.xml b/packages/SystemUI/res-keyguard/layout/keyguard_status_area.xml index ed415b8efdac..7e664d0c2d5e 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_status_area.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_status_area.xml @@ -25,7 +25,8 @@ android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center"> - <TextClock android:id="@+id/date_view" + <com.android.systemui.statusbar.policy.DateView + android:id="@+id/date_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/clock_white" diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java index db1e8a9c112e..d214d5525655 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java @@ -37,6 +37,7 @@ import android.widget.TextView; import com.android.internal.util.ArrayUtils; import com.android.internal.widget.LockPatternUtils; import com.android.systemui.ChargingView; +import com.android.systemui.statusbar.policy.DateView; import java.util.Locale; @@ -48,7 +49,7 @@ public class KeyguardStatusView extends GridLayout { private final AlarmManager mAlarmManager; private TextView mAlarmStatusView; - private TextClock mDateView; + private DateView mDateView; private TextClock mClockView; private TextView mOwnerInfo; private ViewGroup mClockContainer; @@ -118,7 +119,6 @@ public class KeyguardStatusView extends GridLayout { mAlarmStatusView = findViewById(R.id.alarm_status); mDateView = findViewById(R.id.date_view); mClockView = findViewById(R.id.clock_view); - mDateView.setShowCurrentUserTime(true); mClockView.setShowCurrentUserTime(true); mClockView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext)); mOwnerInfo = findViewById(R.id.owner_info); @@ -154,8 +154,7 @@ public class KeyguardStatusView extends GridLayout { } public void refreshTime() { - mDateView.setFormat24Hour(Patterns.dateView); - mDateView.setFormat12Hour(Patterns.dateView); + mDateView.setDatePattern(Patterns.dateViewSkel); mClockView.setFormat12Hour(Patterns.clockView12); mClockView.setFormat24Hour(Patterns.clockView24); @@ -246,7 +245,7 @@ public class KeyguardStatusView extends GridLayout { // DateFormat.getBestDateTimePattern is extremely expensive, and refresh is called often. // This is an optimization to ensure we only recompute the patterns when the inputs change. private static final class Patterns { - static String dateView; + static String dateViewSkel; static String clockView12; static String clockView24; static String cacheKey; @@ -254,7 +253,7 @@ public class KeyguardStatusView extends GridLayout { static void update(Context context, boolean hasAlarm) { final Locale locale = Locale.getDefault(); final Resources res = context.getResources(); - final String dateViewSkel = res.getString(hasAlarm + dateViewSkel = res.getString(hasAlarm ? R.string.abbrev_wday_month_day_no_year_alarm : R.string.abbrev_wday_month_day_no_year); final String clockView12Skel = res.getString(R.string.clock_12hr_format); @@ -262,8 +261,6 @@ public class KeyguardStatusView extends GridLayout { final String key = locale.toString() + dateViewSkel + clockView12Skel + clockView24Skel; if (key.equals(cacheKey)) return; - dateView = DateFormat.getBestDateTimePattern(locale, dateViewSkel); - clockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel); // CLDR insists on adding an AM/PM indicator even though it wasn't in the skeleton // format. The following code removes the AM/PM indicator if we didn't want it. 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 dc33633dde53..74a30fa8094f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java @@ -23,6 +23,7 @@ import android.content.IntentFilter; import android.content.res.TypedArray; import android.icu.text.DateFormat; import android.icu.text.DisplayContext; +import android.text.TextUtils; import android.util.AttributeSet; import android.widget.TextView; @@ -115,4 +116,15 @@ public class DateView extends TextView { mLastText = text; } } + + public void setDatePattern(String pattern) { + if (TextUtils.equals(pattern, mDatePattern)) { + return; + } + mDatePattern = pattern; + mDateFormat = null; + if (isAttachedToWindow()) { + updateClock(); + } + } } |