summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/CommunalHostViewController.java25
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/CommunalStateController.java46
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java8
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/communal/CommunalHostViewControllerTest.java21
4 files changed, 94 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/communal/CommunalHostViewController.java b/packages/SystemUI/src/com/android/systemui/communal/CommunalHostViewController.java
index cb0c2827c7a5..320c2ea5ba78 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/CommunalHostViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/communal/CommunalHostViewController.java
@@ -53,6 +53,8 @@ public class CommunalHostViewController extends ViewController<CommunalHostView>
private final StatusBarStateController mStatusBarStateController;
private WeakReference<CommunalSource> mLastSource;
private int mState;
+ private float mQsExpansion;
+ private float mShadeExpansion;
@Retention(RetentionPolicy.RUNTIME)
@IntDef({STATE_KEYGUARD_SHOWING, STATE_DOZING, STATE_BOUNCER_SHOWING, STATE_KEYGUARD_OCCLUDED})
@@ -264,4 +266,27 @@ public class CommunalHostViewController extends ViewController<CommunalHostView>
mLastSource = source;
showSource();
}
+
+ /**
+ * Invoked when the quick settings is expanded.
+ * @param expansionFraction the percentage the QS shade has been expanded.
+ */
+ public void updateQsExpansion(float expansionFraction) {
+ mQsExpansion = expansionFraction;
+ updateCommunalViewOccluded();
+ }
+
+ /**
+ * Invoked when the main shade is expanded.
+ * @param shadeExpansion the percentage the main shade has expanded.
+ */
+ public void updateShadeExpansion(float shadeExpansion) {
+ mShadeExpansion = shadeExpansion;
+ updateCommunalViewOccluded();
+ }
+
+ private void updateCommunalViewOccluded() {
+ mCommunalStateController.setCommunalViewOccluded(
+ mQsExpansion > 0.0f || mShadeExpansion > 0.0f);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/communal/CommunalStateController.java b/packages/SystemUI/src/com/android/systemui/communal/CommunalStateController.java
index e5385ec1543f..c72f5422b1f5 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/CommunalStateController.java
+++ b/packages/SystemUI/src/com/android/systemui/communal/CommunalStateController.java
@@ -34,6 +34,7 @@ import javax.inject.Inject;
public class CommunalStateController implements
CallbackController<CommunalStateController.Callback> {
private final ArrayList<Callback> mCallbacks = new ArrayList<>();
+ private boolean mCommunalViewOccluded;
private boolean mCommunalViewShowing;
/**
@@ -45,6 +46,12 @@ public class CommunalStateController implements
*/
default void onCommunalViewShowingChanged() {
}
+
+ /**
+ * Called when the occlusion of the communal view changes.
+ */
+ default void onCommunalViewOccludedChanged() {
+ }
}
@VisibleForTesting
@@ -57,13 +64,32 @@ public class CommunalStateController implements
* @param communalViewShowing {@code true} if the view is showing, {@code false} otherwise.
*/
public void setCommunalViewShowing(boolean communalViewShowing) {
- if (mCommunalViewShowing != communalViewShowing) {
- mCommunalViewShowing = communalViewShowing;
+ if (mCommunalViewShowing == communalViewShowing) {
+ return;
+ }
+
+ mCommunalViewShowing = communalViewShowing;
+
+ final ArrayList<Callback> callbacks = new ArrayList<>(mCallbacks);
+ for (Callback callback : callbacks) {
+ callback.onCommunalViewShowingChanged();
+ }
+ }
- final ArrayList<Callback> callbacks = new ArrayList<>(mCallbacks);
- for (Callback callback : callbacks) {
- callback.onCommunalViewShowingChanged();
- }
+ /**
+ * Sets whether the communal view is occluded (but otherwise still showing).
+ * @param communalViewOccluded {@code true} if the view is occluded, {@code false} otherwise.
+ */
+ public void setCommunalViewOccluded(boolean communalViewOccluded) {
+ if (mCommunalViewOccluded == communalViewOccluded) {
+ return;
+ }
+
+ mCommunalViewOccluded = communalViewOccluded;
+
+ ArrayList<Callback> callbacks = new ArrayList<>(mCallbacks);
+ for (int i = 0; i < callbacks.size(); i++) {
+ callbacks.get(i).onCommunalViewOccludedChanged();
}
}
@@ -75,6 +101,14 @@ public class CommunalStateController implements
return mCommunalViewShowing;
}
+ /**
+ * Returns whether the communal view is occluded.
+ * @return {@code true} if the view is occluded, {@code false} otherwise.
+ */
+ public boolean getCommunalViewOccluded() {
+ return mCommunalViewOccluded;
+ }
+
@Override
public void addCallback(@NonNull Callback callback) {
Objects.requireNonNull(callback, "Callback must not be null. b/128895449");
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index 08f0fd84b705..e1dac45f97de 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -2414,6 +2414,10 @@ public class NotificationPanelViewController extends PanelViewController {
setQSClippingBounds();
mNotificationStackScrollLayoutController.setQsExpansionFraction(qsExpansionFraction);
mDepthController.setQsPanelExpansion(qsExpansionFraction);
+
+ if (mCommunalViewController != null) {
+ mCommunalViewController.updateQsExpansion(qsExpansionFraction);
+ }
}
private void onStackYChanged(boolean shouldAnimate) {
@@ -2752,6 +2756,10 @@ public class NotificationPanelViewController extends PanelViewController {
}
mTransitionToFullShadeQSPosition = position;
updateQsExpansion();
+
+ if (mCommunalViewController != null) {
+ mCommunalViewController.updateShadeExpansion(mTransitioningToFullShadeProgress);
+ }
}
/**
diff --git a/packages/SystemUI/tests/src/com/android/systemui/communal/CommunalHostViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/communal/CommunalHostViewControllerTest.java
index 03d26bed725e..990637955b24 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/communal/CommunalHostViewControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/communal/CommunalHostViewControllerTest.java
@@ -159,6 +159,27 @@ public class CommunalHostViewControllerTest extends SysuiTestCase {
}
@Test
+ public void testReportOcclusion() {
+ // Ensure CommunalHostViewController reports view occluded when either the QS or Shade is
+ // expanded.
+ mController.updateShadeExpansion(0);
+ verify(mCommunalStateController).setCommunalViewOccluded(false);
+ clearInvocations(mCommunalStateController);
+ mController.updateQsExpansion(.5f);
+ verify(mCommunalStateController).setCommunalViewOccluded(true);
+ clearInvocations(mCommunalStateController);
+ mController.updateShadeExpansion(.7f);
+ verify(mCommunalStateController).setCommunalViewOccluded(true);
+ clearInvocations(mCommunalStateController);
+ mController.updateShadeExpansion(0);
+ verify(mCommunalStateController).setCommunalViewOccluded(true);
+ clearInvocations(mCommunalStateController);
+ mController.updateQsExpansion(0f);
+ verify(mCommunalStateController).setCommunalViewOccluded(false);
+ clearInvocations(mCommunalStateController);
+ }
+
+ @Test
public void testCommunalStateControllerHideNotified() {
ArgumentCaptor<KeyguardUpdateMonitorCallback> callbackCapture =
ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback.class);