diff options
author | Stephen Bird <sbird@cyngn.com> | 2016-06-13 15:17:04 -0700 |
---|---|---|
committer | Stephen Bird <sbird@cyngn.com> | 2016-07-28 10:56:36 -0700 |
commit | 65407c7d8a399ad9b37fd4b871462155f4384898 (patch) | |
tree | 3cef5e5cc345bccc019e0baef5c9b569792b55ba | |
parent | fdc1069ce5f040f1bf0610b48a5ab65ee15c9ef3 (diff) | |
download | android_packages_apps_LockClock-65407c7d8a399ad9b37fd4b871462155f4384898.tar.gz android_packages_apps_LockClock-65407c7d8a399ad9b37fd4b871462155f4384898.tar.bz2 android_packages_apps_LockClock-65407c7d8a399ad9b37fd4b871462155f4384898.zip |
AM/PM: Fix incorrect am/pm text
When rolling over from AM to PM (or vice versa) the text will
show the incorrect time eg:
At 12:00 AM the clock will still show 12:00 PM
At 12:00 PM the clock will show 12:00 AM
This switches our time period to the TextClock for >= API 17
so that we can get the correct time period. This also cleans up
the regular am/pm textview for devices < 17.
Change-Id: I09de23a1ea559a570d7cac5ffb7dbe9266f5fb40
Ticket: OPO-767
-rw-r--r-- | res/layout-v17/clock_panel.xml | 4 | ||||
-rw-r--r-- | res/values/strings.xml | 1 | ||||
-rw-r--r-- | src/com/cyanogenmod/lockclock/ClockWidgetService.java | 8 |
3 files changed, 10 insertions, 3 deletions
diff --git a/res/layout-v17/clock_panel.xml b/res/layout-v17/clock_panel.xml index 0e48a43..6be3eed 100644 --- a/res/layout-v17/clock_panel.xml +++ b/res/layout-v17/clock_panel.xml @@ -100,9 +100,11 @@ android:layout_gravity="center_horizontal|top" /> <!-- AM/PM --> - <TextView + <TextClock android:id="@+id/clock_ampm" style="@style/label_thin" + android:format12Hour="@string/widget_12_hours_format_ampm" + android:format24Hour="@null" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" diff --git a/res/values/strings.xml b/res/values/strings.xml index f17313c..2d02171 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -26,6 +26,7 @@ <string name="widget_12_hours_format_h" translatable="false">h</string> <string name="widget_12_hours_format_no_ampm_m" translatable="false">:mm</string> <string name="widget_12_hours_format_m" translatable="false">:mm<font size="15">aa</font></string> + <string name="widget_12_hours_format_ampm" translatable="false">a</string> <!-- java.text.SimpleDateFormat uses H for hours in the 0-23 range and android.text.format.DateFormat uses k for hours in the 0-23 range. diff --git a/src/com/cyanogenmod/lockclock/ClockWidgetService.java b/src/com/cyanogenmod/lockclock/ClockWidgetService.java index 9208cd3..ced9d8f 100644 --- a/src/com/cyanogenmod/lockclock/ClockWidgetService.java +++ b/src/com/cyanogenmod/lockclock/ClockWidgetService.java @@ -236,6 +236,8 @@ public class ClockWidgetService extends IntentService { String hours = new SimpleDateFormat(getHourFormat(), locale).format(now); String minutes = new SimpleDateFormat(getString(R.string.widget_12_hours_format_no_ampm_m), locale).format(now); + String amPM = new SimpleDateFormat(getString(R.string.widget_12_hours_format_ampm), + locale).format(now); // Hours if (Preferences.useBoldFontForHours(this)) { @@ -261,11 +263,14 @@ public class ClockWidgetService extends IntentService { } else { clockViews.setTextViewText(R.id.date, date); } + + if (!DateFormat.is24HourFormat(this) && Preferences.showAmPmIndicator(this)) { + clockViews.setTextViewText(R.id.clock_ampm, amPM); + } } private void refreshClockFont(RemoteViews clockViews, boolean smallWidget) { int color = Preferences.clockFontColor(this); - String amPM = new SimpleDateFormat("a", Locale.getDefault()).format(new Date()); // Hours if (Preferences.useBoldFontForHours(this)) { @@ -292,7 +297,6 @@ public class ClockWidgetService extends IntentService { // Show the AM/PM indicator if (!DateFormat.is24HourFormat(this) && Preferences.showAmPmIndicator(this)) { clockViews.setViewVisibility(R.id.clock_ampm, View.VISIBLE); - clockViews.setTextViewText(R.id.clock_ampm, amPM); clockViews.setTextColor(R.id.clock_ampm, color); } else { clockViews.setViewVisibility(R.id.clock_ampm, View.GONE); |