Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockPlugin.java +7 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,13 @@ public interface ClockPlugin extends Plugin { */ View getView(); /** * Get clock view for a large clock that appears behind NSSL. */ default View getBigClockView() { return null; } /** * Set clock paint style. * @param style The new style to set in the paint. Loading packages/SystemUI/res/layout/status_bar_expanded.xml +6 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,12 @@ android:layout_height="match_parent" android:background="@android:color/transparent" > <FrameLayout android:id="@+id/big_clock_container" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" /> <include layout="@layout/keyguard_status_view" android:visibility="gone" /> Loading packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +40 −13 Original line number Diff line number Diff line Loading @@ -35,7 +35,11 @@ public class KeyguardClockSwitch extends RelativeLayout { /** * Frame for default and custom clock. */ private FrameLayout mClockFrame; private FrameLayout mSmallClockFrame; /** * Container for big custom clock. */ private ViewGroup mBigClockContainer; /** * Status area (date and other stuff) shown below the clock. Plugin can decide whether * or not to show it below the alternate clock. Loading @@ -46,22 +50,27 @@ public class KeyguardClockSwitch extends RelativeLayout { new PluginListener<ClockPlugin>() { @Override public void onPluginConnected(ClockPlugin plugin, Context pluginContext) { View view = plugin.getView(); if (view != null) { disconnectPlugin(); View smallClockView = plugin.getView(); if (smallClockView != null) { // For now, assume that the most recently connected plugin is the // selected clock face. In the future, the user should be able to // pick a clock face from the available plugins. mClockPlugin = plugin; mClockFrame.addView(view, -1, mSmallClockFrame.addView(smallClockView, -1, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); initPluginParams(); mClockView.setVisibility(View.GONE); } View bigClockView = plugin.getBigClockView(); if (bigClockView != null && mBigClockContainer != null) { mBigClockContainer.addView(bigClockView); mBigClockContainer.setVisibility(View.VISIBLE); } if (!plugin.shouldShowStatusArea()) { mKeyguardStatusArea.setVisibility(View.GONE); } } mClockPlugin = plugin; } @Override Loading @@ -86,7 +95,7 @@ public class KeyguardClockSwitch extends RelativeLayout { protected void onFinishInflate() { super.onFinishInflate(); mClockView = findViewById(R.id.default_clock_view); mClockFrame = findViewById(R.id.clock_view); mSmallClockFrame = findViewById(R.id.clock_view); mKeyguardStatusArea = findViewById(R.id.keyguard_status_area); } Loading @@ -103,6 +112,20 @@ public class KeyguardClockSwitch extends RelativeLayout { Dependency.get(PluginManager.class).removePluginListener(mClockPluginListener); } /** * Set container for big clock face appearing behind NSSL and KeyguardStatusView. */ public void setBigClockContainer(ViewGroup container) { if (mClockPlugin != null && container != null) { View bigClockView = mClockPlugin.getBigClockView(); if (bigClockView != null) { container.addView(bigClockView); container.setVisibility(View.VISIBLE); } } mBigClockContainer = container; } /** * It will also update plugin setStyle if plugin is connected. */ Loading Loading @@ -199,9 +222,13 @@ public class KeyguardClockSwitch extends RelativeLayout { private void disconnectPlugin() { if (mClockPlugin != null) { View view = mClockPlugin.getView(); if (view != null) { mClockFrame.removeView(view); View smallClockView = mClockPlugin.getView(); if (smallClockView != null) { mSmallClockFrame.removeView(smallClockView); } if (mBigClockContainer != null) { mBigClockContainer.removeAllViews(); mBigClockContainer.setVisibility(View.GONE); } mClockPlugin = null; } Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +6 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.widget.FrameLayout; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.keyguard.KeyguardClockSwitch; import com.android.keyguard.KeyguardStatusView; import com.android.systemui.DejankUtils; import com.android.systemui.Dependency; Loading Loading @@ -133,7 +134,7 @@ public class NotificationPanelView extends PanelView implements public static final int FLING_COLLAPSE = 1; /** * Fing until QS is completely hidden. * Fling until QS is completely hidden. */ public static final int FLING_HIDE = 2; Loading Loading @@ -359,6 +360,10 @@ public class NotificationPanelView extends PanelView implements mKeyguardStatusBar = findViewById(R.id.keyguard_header); mKeyguardStatusView = findViewById(R.id.keyguard_status_view); KeyguardClockSwitch keyguardClockSwitch = findViewById(R.id.keyguard_clock_container); ViewGroup bigClockContainer = findViewById(R.id.big_clock_container); keyguardClockSwitch.setBigClockContainer(bigClockContainer); mNotificationContainerParent = findViewById(R.id.notification_container_parent); mNotificationStackScroller = findViewById(R.id.notification_stack_scroller); mNotificationStackScroller.setOnHeightChangedListener(this); Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java +39 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,25 @@ public class KeyguardClockSwitchTest extends SysuiTestCase { assertThat(plugin.getView().getParent()).isEqualTo(mClockContainer); } @Test public void onPluginConnected_showPluginBigClock() { // GIVEN that the container for the big clock has visibility GONE FrameLayout bigClockContainer = new FrameLayout(getContext()); bigClockContainer.setVisibility(GONE); mKeyguardClockSwitch.setBigClockContainer(bigClockContainer); // AND the plugin returns a view for the big clock ClockPlugin plugin = mock(ClockPlugin.class); TextClock pluginView = new TextClock(getContext()); when(plugin.getBigClockView()).thenReturn(pluginView); PluginListener listener = mKeyguardClockSwitch.getClockPluginListener(); // WHEN the plugin is connected listener.onPluginConnected(plugin, null); // THEN the big clock container is visible and it is the parent of the // big clock view. assertThat(bigClockContainer.getVisibility()).isEqualTo(VISIBLE); assertThat(pluginView.getParent()).isEqualTo(bigClockContainer); } @Test public void onPluginConnected_nullView() { ClockPlugin plugin = mock(ClockPlugin.class); Loading Loading @@ -145,6 +164,26 @@ public class KeyguardClockSwitchTest extends SysuiTestCase { assertThat(plugin.getView().getParent()).isNull(); } @Test public void onPluginDisconnected_hidePluginBigClock() { // GIVEN that the big clock container is visible FrameLayout bigClockContainer = new FrameLayout(getContext()); bigClockContainer.setVisibility(VISIBLE); mKeyguardClockSwitch.setBigClockContainer(bigClockContainer); // AND the plugin returns a view for the big clock ClockPlugin plugin = mock(ClockPlugin.class); TextClock pluginView = new TextClock(getContext()); when(plugin.getBigClockView()).thenReturn(pluginView); PluginListener listener = mKeyguardClockSwitch.getClockPluginListener(); listener.onPluginConnected(plugin, null); // WHEN the plugin is disconnected listener.onPluginDisconnected(plugin); // THEN the big lock container is GONE and the big clock view doesn't have // a parent. assertThat(bigClockContainer.getVisibility()).isEqualTo(GONE); assertThat(pluginView.getParent()).isNull(); } @Test public void onPluginDisconnected_nullView() { ClockPlugin plugin = mock(ClockPlugin.class); Loading Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockPlugin.java +7 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,13 @@ public interface ClockPlugin extends Plugin { */ View getView(); /** * Get clock view for a large clock that appears behind NSSL. */ default View getBigClockView() { return null; } /** * Set clock paint style. * @param style The new style to set in the paint. Loading
packages/SystemUI/res/layout/status_bar_expanded.xml +6 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,12 @@ android:layout_height="match_parent" android:background="@android:color/transparent" > <FrameLayout android:id="@+id/big_clock_container" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" /> <include layout="@layout/keyguard_status_view" android:visibility="gone" /> Loading
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +40 −13 Original line number Diff line number Diff line Loading @@ -35,7 +35,11 @@ public class KeyguardClockSwitch extends RelativeLayout { /** * Frame for default and custom clock. */ private FrameLayout mClockFrame; private FrameLayout mSmallClockFrame; /** * Container for big custom clock. */ private ViewGroup mBigClockContainer; /** * Status area (date and other stuff) shown below the clock. Plugin can decide whether * or not to show it below the alternate clock. Loading @@ -46,22 +50,27 @@ public class KeyguardClockSwitch extends RelativeLayout { new PluginListener<ClockPlugin>() { @Override public void onPluginConnected(ClockPlugin plugin, Context pluginContext) { View view = plugin.getView(); if (view != null) { disconnectPlugin(); View smallClockView = plugin.getView(); if (smallClockView != null) { // For now, assume that the most recently connected plugin is the // selected clock face. In the future, the user should be able to // pick a clock face from the available plugins. mClockPlugin = plugin; mClockFrame.addView(view, -1, mSmallClockFrame.addView(smallClockView, -1, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); initPluginParams(); mClockView.setVisibility(View.GONE); } View bigClockView = plugin.getBigClockView(); if (bigClockView != null && mBigClockContainer != null) { mBigClockContainer.addView(bigClockView); mBigClockContainer.setVisibility(View.VISIBLE); } if (!plugin.shouldShowStatusArea()) { mKeyguardStatusArea.setVisibility(View.GONE); } } mClockPlugin = plugin; } @Override Loading @@ -86,7 +95,7 @@ public class KeyguardClockSwitch extends RelativeLayout { protected void onFinishInflate() { super.onFinishInflate(); mClockView = findViewById(R.id.default_clock_view); mClockFrame = findViewById(R.id.clock_view); mSmallClockFrame = findViewById(R.id.clock_view); mKeyguardStatusArea = findViewById(R.id.keyguard_status_area); } Loading @@ -103,6 +112,20 @@ public class KeyguardClockSwitch extends RelativeLayout { Dependency.get(PluginManager.class).removePluginListener(mClockPluginListener); } /** * Set container for big clock face appearing behind NSSL and KeyguardStatusView. */ public void setBigClockContainer(ViewGroup container) { if (mClockPlugin != null && container != null) { View bigClockView = mClockPlugin.getBigClockView(); if (bigClockView != null) { container.addView(bigClockView); container.setVisibility(View.VISIBLE); } } mBigClockContainer = container; } /** * It will also update plugin setStyle if plugin is connected. */ Loading Loading @@ -199,9 +222,13 @@ public class KeyguardClockSwitch extends RelativeLayout { private void disconnectPlugin() { if (mClockPlugin != null) { View view = mClockPlugin.getView(); if (view != null) { mClockFrame.removeView(view); View smallClockView = mClockPlugin.getView(); if (smallClockView != null) { mSmallClockFrame.removeView(smallClockView); } if (mBigClockContainer != null) { mBigClockContainer.removeAllViews(); mBigClockContainer.setVisibility(View.GONE); } mClockPlugin = null; } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +6 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import android.widget.FrameLayout; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.keyguard.KeyguardClockSwitch; import com.android.keyguard.KeyguardStatusView; import com.android.systemui.DejankUtils; import com.android.systemui.Dependency; Loading Loading @@ -133,7 +134,7 @@ public class NotificationPanelView extends PanelView implements public static final int FLING_COLLAPSE = 1; /** * Fing until QS is completely hidden. * Fling until QS is completely hidden. */ public static final int FLING_HIDE = 2; Loading Loading @@ -359,6 +360,10 @@ public class NotificationPanelView extends PanelView implements mKeyguardStatusBar = findViewById(R.id.keyguard_header); mKeyguardStatusView = findViewById(R.id.keyguard_status_view); KeyguardClockSwitch keyguardClockSwitch = findViewById(R.id.keyguard_clock_container); ViewGroup bigClockContainer = findViewById(R.id.big_clock_container); keyguardClockSwitch.setBigClockContainer(bigClockContainer); mNotificationContainerParent = findViewById(R.id.notification_container_parent); mNotificationStackScroller = findViewById(R.id.notification_stack_scroller); mNotificationStackScroller.setOnHeightChangedListener(this); Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java +39 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,25 @@ public class KeyguardClockSwitchTest extends SysuiTestCase { assertThat(plugin.getView().getParent()).isEqualTo(mClockContainer); } @Test public void onPluginConnected_showPluginBigClock() { // GIVEN that the container for the big clock has visibility GONE FrameLayout bigClockContainer = new FrameLayout(getContext()); bigClockContainer.setVisibility(GONE); mKeyguardClockSwitch.setBigClockContainer(bigClockContainer); // AND the plugin returns a view for the big clock ClockPlugin plugin = mock(ClockPlugin.class); TextClock pluginView = new TextClock(getContext()); when(plugin.getBigClockView()).thenReturn(pluginView); PluginListener listener = mKeyguardClockSwitch.getClockPluginListener(); // WHEN the plugin is connected listener.onPluginConnected(plugin, null); // THEN the big clock container is visible and it is the parent of the // big clock view. assertThat(bigClockContainer.getVisibility()).isEqualTo(VISIBLE); assertThat(pluginView.getParent()).isEqualTo(bigClockContainer); } @Test public void onPluginConnected_nullView() { ClockPlugin plugin = mock(ClockPlugin.class); Loading Loading @@ -145,6 +164,26 @@ public class KeyguardClockSwitchTest extends SysuiTestCase { assertThat(plugin.getView().getParent()).isNull(); } @Test public void onPluginDisconnected_hidePluginBigClock() { // GIVEN that the big clock container is visible FrameLayout bigClockContainer = new FrameLayout(getContext()); bigClockContainer.setVisibility(VISIBLE); mKeyguardClockSwitch.setBigClockContainer(bigClockContainer); // AND the plugin returns a view for the big clock ClockPlugin plugin = mock(ClockPlugin.class); TextClock pluginView = new TextClock(getContext()); when(plugin.getBigClockView()).thenReturn(pluginView); PluginListener listener = mKeyguardClockSwitch.getClockPluginListener(); listener.onPluginConnected(plugin, null); // WHEN the plugin is disconnected listener.onPluginDisconnected(plugin); // THEN the big lock container is GONE and the big clock view doesn't have // a parent. assertThat(bigClockContainer.getVisibility()).isEqualTo(GONE); assertThat(pluginView.getParent()).isNull(); } @Test public void onPluginDisconnected_nullView() { ClockPlugin plugin = mock(ClockPlugin.class); Loading