Skip to content

Commit 1e9e1fe

Browse files
tobitegeateek-ujjawal
authored andcommitted
FW_Base - Fix clock seconds display with am/pm
Instead of just adding seconds to the resulting timestamp, replace within the dateformat itself the minutes together with the seconds. Change-Id: Ibdc6f085e43d468398d398e39fcb5efa448169b6 Signed-off-by: W4TCH0UT <[email protected]> Conflicts: packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java
1 parent 27b2441 commit 1e9e1fe

File tree

1 file changed

+9
-8
lines changed
  • packages/SystemUI/src/com/android/systemui/statusbar/policy

1 file changed

+9
-8
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ private final CharSequence getSmallTime() {
204204

205205
SimpleDateFormat sdf;
206206
String format = is24 ? d.timeFormat24 : d.timeFormat12;
207+
208+
// replace seconds directly in format, not in result
209+
if (Settings.System.getInt(mContext.getContentResolver(),
210+
Settings.System.CLOCK_USE_SECOND, 0) == 1) {
211+
String temp = format;
212+
format = temp.replaceFirst("mm","mm:ss");
213+
}
214+
207215
if (!format.equals(mClockFormatString)) {
208216
/*
209217
* Search for an unquoted "a" in the format string, so we can
@@ -249,21 +257,14 @@ private final CharSequence getSmallTime() {
249257
String clockDateFormat = Settings.System.getString(mContext.getContentResolver(),
250258
Settings.System.STATUS_BAR_DATE_FORMAT);
251259

252-
mShowClockSeconds = Settings.System.getInt(mContext.getContentResolver(),
253-
Settings.System.CLOCK_USE_SECOND, 0) == 1;
254-
if (mShowClockSeconds) {
255-
String temp = result;
256-
result = String.format("%s:%02d", temp, new GregorianCalendar().get(Calendar.SECOND));
257-
}
258-
259260
if (clockDateFormat == null || clockDateFormat.isEmpty()) {
260261
// Set dateString to short uppercase Weekday (Default for AOKP) if empty
261262
dateString = DateFormat.format("EEE", now) + " ";
262263
} else {
263264
dateString = DateFormat.format(clockDateFormat, now) + " ";
264265
}
265266
if (mClockDateStyle == CLOCK_DATE_STYLE_LOWERCASE) {
266-
// When Date style is small, convert date to uppercase
267+
// When Date style is small, convert date to lowercase
267268
result = dateString.toString().toLowerCase() + result;
268269
} else if (mClockDateStyle == CLOCK_DATE_STYLE_UPPERCASE) {
269270
result = dateString.toString().toUpperCase() + result;

0 commit comments

Comments
 (0)