Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63ce8e81 authored by Joe Onorato's avatar Joe Onorato
Browse files

Make the space between the time and the AM/PM smaller by putting preceding whitespace inside the

span.

Also cache the SimpleDateFormat object because those are relatively expensive.
parent ff58b577
Loading
Loading
Loading
Loading
+37 −24
Original line number Diff line number Diff line
@@ -88,6 +88,8 @@ public class StatusBarPolicy {

    // clock
    private Calendar mCalendar;
    private String mClockFormatString;
    private SimpleDateFormat mClockFormat;
    private IBinder mClockIcon;
    private IconData mClockData;

@@ -546,8 +548,12 @@ public class StatusBarPolicy {
            res = R.string.twelve_hour_time_format;
        }

        String format = mContext.getString(res);
        final char MAGIC1 = '\uEF00';
        final char MAGIC2 = '\uEF01';

        SimpleDateFormat sdf;
        String format = mContext.getString(res);
        if (!format.equals(mClockFormatString)) {
            /*
             * Search for an unquoted "a" in the format string, so we can
             * add dummy characters around it to let us find it again after
@@ -568,15 +574,22 @@ public class StatusBarPolicy {
                }
            }

        final char MAGIC1 = '\uEF00';
        final char MAGIC2 = '\uEF01';

            if (a >= 0) {
            format = format.substring(0, a) + MAGIC1 + "a" + MAGIC2 +
                     format.substring(a + 1);
                // Move a back so any whitespace before the AM/PM is also in the alternate size.
                final int b = a;
                while (a > 0 && Character.isWhitespace(format.charAt(a-1))) {
                    a--;
                }
                format = format.substring(0, a) + MAGIC1 + format.substring(a, b)
                        + "a" + MAGIC2 + format.substring(b + 1);
            }

        String result = new SimpleDateFormat(format).format(mCalendar.getTime());
            mClockFormat = sdf = new SimpleDateFormat(format);
            mClockFormatString = format;
        } else {
            sdf = mClockFormat;
        }
        String result = sdf.format(mCalendar.getTime());

        int magic1 = result.indexOf(MAGIC1);
        int magic2 = result.indexOf(MAGIC2);