Commit b9652dfd authored by Michael Bestas's avatar Michael Bestas Committed by Luca Stefani

SystemUI: Add tunables for clock AM/PM style

Change-Id: I7f27f135ae0d1e731c936792f655c115f107d20c
parent 691fd21e
......@@ -63,6 +63,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
DarkReceiver, ConfigurationListener {
public static final String CLOCK_SECONDS = "clock_seconds";
public static final String CLOCK_STYLE = "lineagesystem:status_bar_am_pm";
private boolean mClockVisibleByPolicy = true;
private boolean mClockVisibleByUser = true;
......@@ -78,7 +79,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
private static final int AM_PM_STYLE_SMALL = 1;
private static final int AM_PM_STYLE_GONE = 2;
private final int mAmPmStyle;
private int mAmPmStyle = AM_PM_STYLE_GONE;
private final boolean mShowDark;
private boolean mShowSeconds;
private Handler mSecondsHandler;
......@@ -98,7 +99,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
R.styleable.Clock,
0, 0);
try {
mAmPmStyle = a.getInt(R.styleable.Clock_amPmStyle, AM_PM_STYLE_GONE);
mAmPmStyle = a.getInt(R.styleable.Clock_amPmStyle, mAmPmStyle);
mShowDark = a.getBoolean(R.styleable.Clock_showDark, true);
} finally {
a.recycle();
......@@ -121,7 +122,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
getContext().registerReceiverAsUser(mIntentReceiver, UserHandle.ALL, filter,
null, Dependency.get(Dependency.TIME_TICK_HANDLER));
Dependency.get(TunerService.class).addTunable(this, CLOCK_SECONDS);
Dependency.get(TunerService.class).addTunable(this, CLOCK_SECONDS, CLOCK_STYLE);
SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallbacks(this);
if (mShowDark) {
Dependency.get(DarkIconDispatcher.class).addDarkReceiver(this);
......@@ -197,7 +198,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
}
final void updateClock() {
if (mDemoMode) return;
if (mDemoMode || mCalendar == null) return;
mCalendar.setTimeInMillis(System.currentTimeMillis());
setText(getSmallTime());
setContentDescription(mContentDescriptionFormat.format(mCalendar.getTime()));
......@@ -208,6 +209,10 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
if (CLOCK_SECONDS.equals(key)) {
mShowSeconds = newValue != null && Integer.parseInt(newValue) != 0;
updateShowSeconds();
} else if (CLOCK_STYLE.equals(key)) {
mAmPmStyle = newValue == null ? AM_PM_STYLE_GONE : Integer.valueOf(newValue);
mClockFormatString = ""; // force refresh
updateClock();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment