diff options
2 files changed, 98 insertions, 31 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 9ca09ed6d70e..29c7633ca93e 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -97,6 +97,7 @@ import com.android.internal.policy.ScreenDecorationsUtils; import com.android.internal.policy.SystemBarUtils; import com.android.internal.util.LatencyTracker; import com.android.keyguard.ActiveUnlockConfig; +import com.android.keyguard.KeyguardClockSwitch.ClockSize; import com.android.keyguard.KeyguardStatusView; import com.android.keyguard.KeyguardStatusViewController; import com.android.keyguard.KeyguardUnfoldTransition; @@ -1415,19 +1416,10 @@ public final class NotificationPanelViewController extends PanelViewController { private void updateClockAppearance() { int userSwitcherPreferredY = mStatusBarHeaderHeightKeyguard; boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled(); - final boolean hasVisibleNotifications = mNotificationStackScrollLayoutController - .getVisibleNotificationCount() != 0 - || mMediaDataManager.hasActiveMediaOrRecommendation(); - boolean splitShadeWithActiveMedia = - mSplitShadeEnabled && mMediaDataManager.hasActiveMediaOrRecommendation(); boolean shouldAnimateClockChange = mScreenOffAnimationController.shouldAnimateClockChange(); - if ((hasVisibleNotifications && !mSplitShadeEnabled) - || (splitShadeWithActiveMedia && !mDozing)) { - mKeyguardStatusViewController.displayClock(SMALL, shouldAnimateClockChange); - } else { - mKeyguardStatusViewController.displayClock(LARGE, shouldAnimateClockChange); - } - updateKeyguardStatusViewAlignment(true /* animate */); + mKeyguardStatusViewController.displayClock(computeDesiredClockSize(), + shouldAnimateClockChange); + updateKeyguardStatusViewAlignment(/* animate= */true); int userSwitcherHeight = mKeyguardQsUserSwitchController != null ? mKeyguardQsUserSwitchController.getUserIconHeight() : 0; if (mKeyguardUserSwitcherController != null) { @@ -1436,7 +1428,7 @@ public final class NotificationPanelViewController extends PanelViewController { float expandedFraction = mScreenOffAnimationController.shouldExpandNotifications() ? 1.0f : getExpandedFraction(); - float darkamount = + float darkAmount = mScreenOffAnimationController.shouldExpandNotifications() ? 1.0f : mInterpolatedDarkAmount; @@ -1454,7 +1446,7 @@ public final class NotificationPanelViewController extends PanelViewController { mKeyguardStatusViewController.getLockscreenHeight(), userSwitcherHeight, userSwitcherPreferredY, - darkamount, mOverStretchAmount, + darkAmount, mOverStretchAmount, bypassEnabled, getUnlockedStackScrollerPadding(), computeQsExpansionFraction(), mDisplayTopInset, @@ -1486,6 +1478,34 @@ public final class NotificationPanelViewController extends PanelViewController { updateClock(); } + @ClockSize + private int computeDesiredClockSize() { + if (mSplitShadeEnabled) { + return computeDesiredClockSizeForSplitShade(); + } + return computeDesiredClockSizeForSingleShade(); + } + + @ClockSize + private int computeDesiredClockSizeForSingleShade() { + if (hasVisibleNotifications()) { + return SMALL; + } + return LARGE; + } + + @ClockSize + private int computeDesiredClockSizeForSplitShade() { + // Media is not visible to the user on AOD. + boolean isMediaVisibleToUser = + mMediaDataManager.hasActiveMediaOrRecommendation() && !isOnAod(); + if (isMediaVisibleToUser) { + // When media is visible, it overlaps with the large clock. Use small clock instead. + return SMALL; + } + return LARGE; + } + private void updateKeyguardStatusViewAlignment(boolean animate) { boolean shouldBeCentered = shouldKeyguardStatusViewBeCentered(); if (mStatusViewCentered != shouldBeCentered) { @@ -1512,12 +1532,35 @@ public final class NotificationPanelViewController extends PanelViewController { } private boolean shouldKeyguardStatusViewBeCentered() { - boolean hasVisibleNotifications = mNotificationStackScrollLayoutController + if (mSplitShadeEnabled) { + return shouldKeyguardStatusViewBeCenteredInSplitShade(); + } + return true; + } + + private boolean shouldKeyguardStatusViewBeCenteredInSplitShade() { + if (!hasVisibleNotifications()) { + // No notifications visible. It is safe to have the clock centered as there will be no + // overlap. + return true; + } + if (hasPulsingNotifications()) { + // Pulsing notification appears on the right. Move clock left to avoid overlap. + return false; + } + // "Visible" notifications are actually not visible on AOD (unless pulsing), so it is safe + // to center the clock without overlap. + return isOnAod(); + } + + private boolean isOnAod() { + return mDozing && mDozeParameters.getAlwaysOn(); + } + + private boolean hasVisibleNotifications() { + return mNotificationStackScrollLayoutController .getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMediaOrRecommendation(); - boolean isOnAod = mDozing && mDozeParameters.getAlwaysOn(); - return !mSplitShadeEnabled || !hasVisibleNotifications || isOnAod - || hasPulsingNotifications(); } /** @@ -3789,6 +3832,8 @@ public final class NotificationPanelViewController extends PanelViewController { mAnimateNextPositionUpdate = false; } mNotificationStackScrollLayoutController.setPulsing(pulsing, animatePulse); + + updateKeyguardStatusViewAlignment(/* animate= */ true); } public void setAmbientIndicationTop(int ambientIndicationTop, boolean ambientTextVisible) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index 32fa6e45bc37..7d28871e340c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -905,7 +905,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { setDozing(/* dozing= */ true, /* dozingAlwaysOn= */ true); - assertThat(isKeyguardStatusViewCentered()).isTrue(); + assertKeyguardStatusViewCentered(); } @Test @@ -916,7 +916,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { setDozing(/* dozing= */ true, /* dozingAlwaysOn= */ false); - assertThat(isKeyguardStatusViewCentered()).isFalse(); + assertKeyguardStatusViewNotCentered(); } @Test @@ -927,19 +927,19 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true); - assertThat(isKeyguardStatusViewCentered()).isFalse(); + assertKeyguardStatusViewNotCentered(); } @Test - public void keyguardStatusView_splitShade_pulsing_isCentered() { + public void keyguardStatusView_splitShade_pulsing_isNotCentered() { when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); when(mNotificationListContainer.hasPulsingNotifications()).thenReturn(true); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); - setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true); + setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ false); - assertThat(isKeyguardStatusViewCentered()).isFalse(); + assertKeyguardStatusViewNotCentered(); } @Test @@ -949,9 +949,9 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); - setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ true); + setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ false); - assertThat(isKeyguardStatusViewCentered()).isFalse(); + assertKeyguardStatusViewNotCentered(); } @Test @@ -964,7 +964,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { mStatusBarStateController.setState(KEYGUARD); setDozing(/* dozing= */ false, /* dozingAlwaysOn= */ false); - assertThat(isKeyguardStatusViewCentered()).isFalse(); + assertKeyguardStatusViewCentered(); } @Test @@ -1209,7 +1209,8 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { } @Test - public void testSwitchesToBigClockInSplitShadeOnAod() { + public void clockSize_mediaShowing_inSplitShade_onAod_isLarge() { + when(mDozeParameters.getAlwaysOn()).thenReturn(true); mStatusBarStateController.setState(KEYGUARD); enableSplitShade(/* enabled= */ true); when(mMediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true); @@ -1217,10 +1218,25 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { clearInvocations(mKeyguardStatusViewController); mNotificationPanelViewController.setDozing(/* dozing= */ true, /* animate= */ false); + verify(mKeyguardStatusViewController).displayClock(LARGE, /* animate= */ true); } @Test + public void clockSize_mediaShowing_inSplitShade_screenOff_notAod_isSmall() { + when(mDozeParameters.getAlwaysOn()).thenReturn(false); + mStatusBarStateController.setState(KEYGUARD); + enableSplitShade(/* enabled= */ true); + when(mMediaDataManager.hasActiveMediaOrRecommendation()).thenReturn(true); + when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(2); + clearInvocations(mKeyguardStatusViewController); + + mNotificationPanelViewController.setDozing(/* dozing= */ true, /* animate= */ false); + + verify(mKeyguardStatusViewController).displayClock(SMALL, /* animate= */ true); + } + + @Test public void testSwitchesToBigClockInSplitShadeOnAodAnimateDisabled() { when(mScreenOffAnimationController.shouldAnimateClockChange()).thenReturn(false); mStatusBarStateController.setState(KEYGUARD); @@ -1547,9 +1563,15 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { ); } - private boolean isKeyguardStatusViewCentered() { + private void assertKeyguardStatusViewCentered() { + mNotificationPanelViewController.updateResources(); + assertThat(getConstraintSetLayout(R.id.keyguard_status_view).endToEnd).isAnyOf( + ConstraintSet.PARENT_ID, ConstraintSet.UNSET); + } + + private void assertKeyguardStatusViewNotCentered() { mNotificationPanelViewController.updateResources(); - return getConstraintSetLayout(R.id.keyguard_status_view).endToEnd - == ConstraintSet.PARENT_ID; + assertThat(getConstraintSetLayout(R.id.keyguard_status_view).endToEnd).isEqualTo( + R.id.qs_edge_guideline); } } |