Loading packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +6 −0 Original line number Diff line number Diff line Loading @@ -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() { Loading Loading @@ -147,6 +151,7 @@ public class KeyguardClockSwitch extends RelativeLayout { mClockPlugin = plugin; mClockPlugin.setStyle(getPaint().getStyle()); mClockPlugin.setTextColor(getCurrentTextColor()); mClockPlugin.setDarkAmount(mDarkAmount); } /** Loading Loading @@ -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); } Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +6 −0 Original line number Diff line number Diff line Loading @@ -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() { Loading Loading @@ -147,6 +151,7 @@ public class KeyguardClockSwitch extends RelativeLayout { mClockPlugin = plugin; mClockPlugin.setStyle(getPaint().getStyle()); mClockPlugin.setTextColor(getCurrentTextColor()); mClockPlugin.setDarkAmount(mDarkAmount); } /** Loading Loading @@ -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); } Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -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); Loading