am dc70340d
: Merge "Enable time format localization in keyguard" into klp-dev
* commit 'dc70340d48eeddf4aa92a4d199179cde269c5bd4': Enable time format localization in keyguard
This commit is contained in:
@ -15,6 +15,12 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||||
<!-- String matching the lock screen format for displaying the date. -->
|
<!-- Skeleton string format for displaying the date. -->
|
||||||
<string name="abbrev_wday_month_day_no_year">EEEMMMMd</string>
|
<string name="abbrev_wday_month_day_no_year">EEEMMMMd</string>
|
||||||
|
|
||||||
|
<!-- Skeleton string format for displaying the time in 12-hour format. -->
|
||||||
|
<string name="clock_12hr_format">hm</string>
|
||||||
|
|
||||||
|
<!-- Skeleton string format for displaying the time in 24-hour format. -->
|
||||||
|
<string name="clock_24hr_format">Hm</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package com.android.keyguard;
|
package com.android.keyguard;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@ -39,6 +40,7 @@ public class KeyguardStatusView extends GridLayout {
|
|||||||
|
|
||||||
private TextView mAlarmStatusView;
|
private TextView mAlarmStatusView;
|
||||||
private TextClock mDateView;
|
private TextClock mDateView;
|
||||||
|
private TextClock mClockView;
|
||||||
|
|
||||||
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
||||||
|
|
||||||
@ -88,6 +90,7 @@ public class KeyguardStatusView extends GridLayout {
|
|||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
mAlarmStatusView = (TextView) findViewById(R.id.alarm_status);
|
mAlarmStatusView = (TextView) findViewById(R.id.alarm_status);
|
||||||
mDateView = (TextClock) findViewById(R.id.date_view);
|
mDateView = (TextClock) findViewById(R.id.date_view);
|
||||||
|
mClockView = (TextClock) findViewById(R.id.clock_view);
|
||||||
mLockPatternUtils = new LockPatternUtils(getContext());
|
mLockPatternUtils = new LockPatternUtils(getContext());
|
||||||
final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
|
final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
|
||||||
setEnableMarquee(screenOn);
|
setEnableMarquee(screenOn);
|
||||||
@ -95,10 +98,27 @@ public class KeyguardStatusView extends GridLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void refresh() {
|
protected void refresh() {
|
||||||
final String fmt = DateFormat.getBestDateTimePattern(Locale.getDefault(),
|
Resources res = mContext.getResources();
|
||||||
mContext.getResources().getString(R.string.abbrev_wday_month_day_no_year));
|
Locale locale = Locale.getDefault();
|
||||||
mDateView.setFormat24Hour(fmt);
|
final String dateFormat = DateFormat.getBestDateTimePattern(locale,
|
||||||
mDateView.setFormat12Hour(fmt);
|
res.getString(R.string.abbrev_wday_month_day_no_year));
|
||||||
|
|
||||||
|
mDateView.setFormat24Hour(dateFormat);
|
||||||
|
mDateView.setFormat12Hour(dateFormat);
|
||||||
|
|
||||||
|
// 12-hour clock.
|
||||||
|
// 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.
|
||||||
|
final String clock12skel = res.getString(R.string.clock_12hr_format);
|
||||||
|
String clock12hr = DateFormat.getBestDateTimePattern(locale, clock12skel);
|
||||||
|
clock12hr = clock12skel.contains("a") ? clock12hr : clock12hr.replaceAll("a", "").trim();
|
||||||
|
mClockView.setFormat12Hour(clock12hr);
|
||||||
|
|
||||||
|
// 24-hour clock
|
||||||
|
final String clock24skel = res.getString(R.string.clock_24hr_format);
|
||||||
|
final String clock24hr = DateFormat.getBestDateTimePattern(locale, clock24skel);
|
||||||
|
mClockView.setFormat24Hour(clock24hr);
|
||||||
|
|
||||||
refreshAlarmStatus();
|
refreshAlarmStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user