summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robert Snoeberger <snoeberger@google.com> 2018-12-20 12:46:17 -0500
committer Robert Snoeberger <snoeberger@google.com> 2018-12-20 13:20:39 -0500
commit6a0140ab959f85f69539c5d3adf8bc56c66d0a41 (patch)
tree22a2de8ca17b2de51815247609412e21b94c29ca
parent6fa14abad36ed3197df467831dc3e018b05ec635 (diff)
Add container for big clock behind NSSL and KeyguardStatusView.
Bug: 120497585 Test: Added tests to KeyguardClockSwitchTest, pass locally. Change-Id: Icc1199a67b9a4728e4d0f0b50ea98f5221de904d
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockPlugin.java7
-rw-r--r--packages/SystemUI/res/layout/status_bar_expanded.xml6
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java53
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java7
-rw-r--r--packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java39
5 files changed, 98 insertions, 14 deletions
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockPlugin.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockPlugin.java
index 6135aebb0587..ac6904300f71 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockPlugin.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockPlugin.java
@@ -36,6 +36,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.
*/
diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml
index 2674f07c21e4..75c0ec3ced43 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded.xml
@@ -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" />
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
index 22a23a8f8a21..570d351a8b71 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java
@@ -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.
@@ -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();
+ 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);
- if (!plugin.shouldShowStatusArea()) {
- mKeyguardStatusArea.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
@@ -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);
}
@@ -104,6 +113,20 @@ public class KeyguardClockSwitch extends RelativeLayout {
}
/**
+ * 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.
*/
public void setStyle(Style style) {
@@ -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;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index c7e4d340b7d8..c0909e3e5bd2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -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;
@@ -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;
@@ -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);
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java
index fb2ceac4b810..415060244243 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchTest.java
@@ -107,6 +107,25 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {
}
@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);
PluginListener listener = mKeyguardClockSwitch.getClockPluginListener();
@@ -146,6 +165,26 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {
}
@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);
PluginListener listener = mKeyguardClockSwitch.getClockPluginListener();