diff options
5 files changed, 71 insertions, 3 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModelTest.kt index 47e1ee9c1b71..db1d5d91eb65 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModelTest.kt @@ -149,6 +149,42 @@ class PrimaryBouncerToGoneTransitionViewModelTest : SysuiTestCase() { values.forEach { assertThat(it).isEqualTo(1f) } } + @Test + fun notificationAlpha() = + testScope.runTest { + val values by collectValues(underTest.notificationAlpha) + runCurrent() + + keyguardTransitionRepository.sendTransitionSteps( + from = KeyguardState.PRIMARY_BOUNCER, + to = KeyguardState.GONE, + testScope, + ) + + assertThat(values[0]).isEqualTo(1f) + // Should fade to zero between here + assertThat(values[1]).isEqualTo(0f) + } + + @Test + fun notificationAlpha_leaveShadeOpen() = + testScope.runTest { + val values by collectValues(underTest.notificationAlpha) + runCurrent() + + sysuiStatusBarStateController.setLeaveOpenOnKeyguardHide(true) + + keyguardTransitionRepository.sendTransitionSteps( + from = KeyguardState.PRIMARY_BOUNCER, + to = KeyguardState.GONE, + testScope, + ) + + assertThat(values.size).isEqualTo(2) + // Shade stays open, and alpha should remain visible + values.forEach { assertThat(it).isEqualTo(1f) } + } + private fun step( value: Float, state: TransitionState = TransitionState.RUNNING diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt index 378ce52b4331..53f448826e80 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt @@ -60,6 +60,22 @@ constructor( private var leaveShadeOpen: Boolean = false private var willRunDismissFromKeyguard: Boolean = false + val notificationAlpha: Flow<Float> = + transitionAnimation.sharedFlow( + duration = 200.milliseconds, + onStart = { + leaveShadeOpen = statusBarStateController.leaveOpenOnKeyguardHide() + willRunDismissFromKeyguard = primaryBouncerInteractor.willRunDismissFromKeyguard() + }, + onStep = { + if (willRunDismissFromKeyguard || leaveShadeOpen) { + 1f + } else { + 1f - it + } + }, + ) + /** Bouncer container alpha */ val bouncerAlpha: Flow<Float> = if (featureFlags.isEnabled(Flags.REFACTOR_KEYGUARD_DISMISS_INTENT)) { @@ -94,6 +110,7 @@ constructor( } else { createLockscreenAlpha(primaryBouncerInteractor::willRunDismissFromKeyguard) } + private fun createLockscreenAlpha(willRunAnimationOnKeyguard: () -> Boolean): Flow<Float> { return transitionAnimation.sharedFlow( duration = 50.milliseconds, diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index d5bbaa5be53c..7b330b0f3803 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -1201,7 +1201,12 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump // Primary bouncer->Gone (ensures lockscreen content is not visible on successful auth) if (!migrateClocksToBlueprint()) { collectFlow(mView, mPrimaryBouncerToGoneTransitionViewModel.getLockscreenAlpha(), - setTransitionAlpha(mNotificationStackScrollLayoutController), mMainDispatcher); + setTransitionAlpha(mNotificationStackScrollLayoutController, + /* excludeNotifications=*/ true), mMainDispatcher); + collectFlow(mView, mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha(), + (Float alpha) -> { + mNotificationStackScrollLayoutController.setMaxAlphaForExpansion(alpha); + }, mMainDispatcher); } } @@ -4725,9 +4730,17 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private Consumer<Float> setTransitionAlpha( NotificationStackScrollLayoutController stackScroller) { + return setTransitionAlpha(stackScroller, /* excludeNotifications= */ false); + } + + private Consumer<Float> setTransitionAlpha( + NotificationStackScrollLayoutController stackScroller, + boolean excludeNotifications) { return (Float alpha) -> { mKeyguardStatusViewController.setAlpha(alpha); - stackScroller.setMaxAlphaForExpansion(alpha); + if (!excludeNotifications) { + stackScroller.setMaxAlphaForExpansion(alpha); + } if (keyguardBottomAreaRefactor()) { mKeyguardInteractor.setAlpha(alpha); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt index 052e35c44bbe..a15d829ade07 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt @@ -333,7 +333,7 @@ constructor( lockscreenToPrimaryBouncerTransitionViewModel.lockscreenAlpha, occludedToAodTransitionViewModel.lockscreenAlpha, occludedToLockscreenTransitionViewModel.lockscreenAlpha, - primaryBouncerToGoneTransitionViewModel.lockscreenAlpha, + primaryBouncerToGoneTransitionViewModel.notificationAlpha, primaryBouncerToLockscreenTransitionViewModel.lockscreenAlpha, ) diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java index 950a9dbc2ff3..fd7b1399d03f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java @@ -599,6 +599,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { // Primary Bouncer->Gone when(mPrimaryBouncerToGoneTransitionViewModel.getLockscreenAlpha()) .thenReturn(emptyFlow()); + when(mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha()) + .thenReturn(emptyFlow()); NotificationsKeyguardViewStateRepository notifsKeyguardViewStateRepository = new NotificationsKeyguardViewStateRepository(); |