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

Unverified Commit 09924a8e authored by Michael Bestas's avatar Michael Bestas
Browse files

SystemUI: Add tunables for clock AM/PM style



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

Change-Id: I7f27f135ae0d1e731c936792f655c115f107d20c
Signed-off-by: default avatarVolodymyr Zhdanov <wight554@gmail.com>
parent 8dfc4272
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ import com.android.systemui.statusbar.policy.ConfigurationController.Configurati
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;

import lineageos.providers.LineageSettings;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
@@ -69,6 +71,8 @@ public class Clock extends TextView implements
        DarkReceiver, ConfigurationListener {

    public static final String CLOCK_SECONDS = "clock_seconds";
    private static final String CLOCK_STYLE =
            "lineagesystem:" + LineageSettings.System.STATUS_BAR_AM_PM;
    private static final String CLOCK_SUPER_PARCELABLE = "clock_super_parcelable";
    private static final String CURRENT_USER_ID = "current_user_id";
    private static final String VISIBLE_BY_POLICY = "visible_by_policy";
@@ -95,7 +99,7 @@ public class Clock extends TextView implements
    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 boolean mShowSeconds;
    private Handler mSecondsHandler;

@@ -118,7 +122,7 @@ public class Clock extends TextView implements
                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);
            mNonAdaptedColor = getCurrentTextColor();
        } finally {
            a.recycle();
@@ -185,7 +189,7 @@ public class Clock extends TextView implements
            // The receiver will return immediately if the view does not have a Handler yet.
            mBroadcastDispatcher.registerReceiverWithHandler(mIntentReceiver, filter,
                    Dependency.get(Dependency.TIME_TICK_HANDLER), UserHandle.ALL);
            Dependency.get(TunerService.class).addTunable(this, CLOCK_SECONDS);
            Dependency.get(TunerService.class).addTunable(this, CLOCK_SECONDS, CLOCK_STYLE);
            mCommandQueue.addCallback(this);
            mCurrentUserTracker.startTracking();
            mCurrentUserId = mCurrentUserTracker.getCurrentUserId();
@@ -282,7 +286,7 @@ public class Clock extends TextView implements
    }

    final void updateClock() {
        if (mDemoMode) return;
        if (mDemoMode || mCalendar == null) return;
        mCalendar.setTimeInMillis(System.currentTimeMillis());
        setText(getSmallTime());
        setContentDescription(mContentDescriptionFormat.format(mCalendar.getTime()));
@@ -293,6 +297,10 @@ public class Clock extends TextView implements
        if (CLOCK_SECONDS.equals(key)) {
            mShowSeconds = TunerService.parseIntegerSwitch(newValue, false);
            updateShowSeconds();
        } else if (CLOCK_STYLE.equals(key)) {
            mAmPmStyle = TunerService.parseInteger(newValue, AM_PM_STYLE_GONE);
            mClockFormatString = ""; // force refresh
            updateClock();
        }
    }