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

Commit 79115838 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Initialize dark amount when a new plugin is connected."

parents 8235d512 58f23158
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -55,6 +55,10 @@ public class KeyguardClockSwitch extends RelativeLayout {
     * Consumer that accepts the a new ClockPlugin implementation when the Extension reloads.
     */
    private final Consumer<ClockPlugin> mClockPluginConsumer = plugin -> setClockPlugin(plugin);
    /**
     * Maintain state so that a newly connected plugin can be initialized.
     */
    private float mDarkAmount;

    private final StatusBarStateController.StateListener mStateListener =
            new StatusBarStateController.StateListener() {
@@ -147,6 +151,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
        mClockPlugin = plugin;
        mClockPlugin.setStyle(getPaint().getStyle());
        mClockPlugin.setTextColor(getCurrentTextColor());
        mClockPlugin.setDarkAmount(mDarkAmount);
    }

    /**
@@ -208,6 +213,7 @@ public class KeyguardClockSwitch extends RelativeLayout {
     * @param darkAmount Amount of transition to doze: 1f for doze and 0f for awake.
     */
    public void setDarkAmount(float darkAmount) {
        mDarkAmount = darkAmount;
        if (mClockPlugin != null) {
            mClockPlugin.setDarkAmount(darkAmount);
        }
+11 −0
Original line number Diff line number Diff line
@@ -131,6 +131,17 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {
        assertThat(plugin1.getView().getParent()).isNull();
    }

    @Test
    public void onPluginConnected_darkAmountInitialized() {
        // GIVEN that the dark amount has already been set
        mKeyguardClockSwitch.setDarkAmount(0.5f);
        // WHEN a plugin is connected
        ClockPlugin plugin = mock(ClockPlugin.class);
        mKeyguardClockSwitch.getClockPluginConsumer().accept(plugin);
        // THEN dark amount should be initalized on the plugin.
        verify(plugin).setDarkAmount(0.5f);
    }

    @Test
    public void onPluginDisconnected_showDefaultClock() {
        ClockPlugin plugin = mock(ClockPlugin.class);