Fade NSSL with brightness slider
This fix only applies for the migrate clocks flag, and explicitly
does not work for scene container. Basically, a temporary shim.
Fixes: 346298008
Test: atest KeyguardRepositoryImplTest
Test: manual - use brightness slider in split shade
Flag: com.android.systemui.migrate_clocks_to_blueprint
Change-Id: Ie80e45dea9900dcdd5f443284e5bc3633eed6f99
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryImplTest.kt
index 5dac37a..48caf3e 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryImplTest.kt
@@ -140,6 +140,27 @@
}
@Test
+ fun panelAlpha() =
+ testScope.runTest {
+ assertThat(underTest.panelAlpha.value).isEqualTo(1f)
+
+ underTest.setPanelAlpha(0.1f)
+ assertThat(underTest.panelAlpha.value).isEqualTo(0.1f)
+
+ underTest.setPanelAlpha(0.2f)
+ assertThat(underTest.panelAlpha.value).isEqualTo(0.2f)
+
+ underTest.setPanelAlpha(0.3f)
+ assertThat(underTest.panelAlpha.value).isEqualTo(0.3f)
+
+ underTest.setPanelAlpha(0.5f)
+ assertThat(underTest.panelAlpha.value).isEqualTo(0.5f)
+
+ underTest.setPanelAlpha(1.0f)
+ assertThat(underTest.panelAlpha.value).isEqualTo(1f)
+ }
+
+ @Test
fun topClippingBounds() =
testScope.runTest {
assertThat(underTest.topClippingBounds.value).isNull()
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
index d508b2b..cdf3b06 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt
@@ -78,6 +78,8 @@
val keyguardAlpha: StateFlow<Float>
+ val panelAlpha: MutableStateFlow<Float>
+
/**
* Observable for whether the keyguard is showing.
*
@@ -250,6 +252,9 @@
/** Sets the current amount of alpha that should be used for rendering the keyguard. */
fun setKeyguardAlpha(alpha: Float)
+ /** Temporary shim for fading out content when the brightness slider is used */
+ fun setPanelAlpha(alpha: Float)
+
/** Whether the device is actively dreaming */
fun setDreaming(isDreaming: Boolean)
@@ -338,6 +343,8 @@
private val _keyguardAlpha = MutableStateFlow(1f)
override val keyguardAlpha = _keyguardAlpha.asStateFlow()
+ override val panelAlpha: MutableStateFlow<Float> = MutableStateFlow(1f)
+
private val _clockShouldBeCentered = MutableStateFlow(true)
override val clockShouldBeCentered: Flow<Boolean> = _clockShouldBeCentered.asStateFlow()
@@ -659,6 +666,10 @@
_keyguardAlpha.value = alpha
}
+ override fun setPanelAlpha(alpha: Float) {
+ panelAlpha.value = alpha
+ }
+
override fun setDreaming(isDreaming: Boolean) {
this.isDreaming.value = isDreaming
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt
index ef96be0..ab1194e 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt
@@ -321,6 +321,10 @@
@Deprecated("Use the relevant TransitionViewModel")
val keyguardAlpha: Flow<Float> = repository.keyguardAlpha
+ /** Temporary shim for fading out content when the brightness slider is used */
+ @Deprecated("SceneContainer uses NotificationStackAppearanceInteractor")
+ val panelAlpha: StateFlow<Float> = repository.panelAlpha.asStateFlow()
+
/**
* When the lockscreen can be dismissed, emit an alpha value as the user swipes up. This is
* useful just before the code commits to moving to GONE.
@@ -458,6 +462,10 @@
repository.setKeyguardAlpha(alpha)
}
+ fun setPanelAlpha(alpha: Float) {
+ repository.setPanelAlpha(alpha)
+ }
+
fun setAnimateDozingTransitions(animate: Boolean) {
repository.setAnimateDozingTransitions(animate)
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
index 262befc..d193286 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
@@ -484,7 +484,9 @@
private float mBottomAreaShadeAlpha;
final ValueAnimator mBottomAreaShadeAlphaAnimator;
private final AnimatableProperty mPanelAlphaAnimator = AnimatableProperty.from("panelAlpha",
- NotificationPanelView::setPanelAlphaInternal,
+ (view, alpha) -> {
+ setAlphaInternal(alpha);
+ },
NotificationPanelView::getCurrentPanelAlpha,
R.id.panel_alpha_animator_tag, R.id.panel_alpha_animator_start_tag,
R.id.panel_alpha_animator_end_tag);
@@ -3075,6 +3077,11 @@
}
}
+ private void setAlphaInternal(float alpha) {
+ mKeyguardInteractor.setPanelAlpha(alpha / 255f);
+ mView.setPanelAlphaInternal(alpha);
+ }
+
@Override
public void setAlphaChangeAnimationEndAction(Runnable r) {
mPanelAlphaEndAction = r;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
index 6a3055f..d984685 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
@@ -68,7 +68,6 @@
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dump.DumpManager;
-import com.android.systemui.keyguard.MigrateClocksToBlueprint;
import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository;
import com.android.systemui.keyguard.shared.model.KeyguardState;
import com.android.systemui.keyguard.shared.model.TransitionStep;
@@ -1320,7 +1319,10 @@
updateAlpha();
}
- void setMaxAlphaFromView(float alpha) {
+ /**
+ * Max alpha from the containing view. Used by brightness slider as an example.
+ */
+ public void setMaxAlphaFromView(float alpha) {
mMaxAlphaFromView = alpha;
updateAlpha();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt
index cf5366b..497ffca 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt
@@ -154,6 +154,14 @@
}
}
+ if (!SceneContainerFlag.isEnabled) {
+ launch {
+ // For when the entire view should fade, such as with the brightness
+ // slider
+ viewModel.panelAlpha.collect { controller.setMaxAlphaFromView(it) }
+ }
+ }
+
if (communalHub()) {
launch {
viewModel.glanceableHubAlpha.collect {
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 1fc2821..fbc9e1c 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
@@ -470,6 +470,8 @@
}
.dumpWhileCollecting("isTransitioningToHiddenKeyguard")
+ val panelAlpha = keyguardInteractor.panelAlpha
+
fun keyguardAlpha(viewState: ViewStateAccessor): Flow<Float> {
// All transition view models are mututally exclusive, and safe to merge
val alphaTransitions =
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
index 2d100f0..dca531a 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt
@@ -119,6 +119,8 @@
private val _keyguardAlpha = MutableStateFlow(1f)
override val keyguardAlpha: StateFlow<Float> = _keyguardAlpha
+ override val panelAlpha: MutableStateFlow<Float> = MutableStateFlow(1f)
+
override val lastRootViewTapPosition: MutableStateFlow<Point?> = MutableStateFlow(null)
override val ambientIndicationVisible: MutableStateFlow<Boolean> = MutableStateFlow(false)
@@ -259,6 +261,10 @@
_keyguardAlpha.value = alpha
}
+ override fun setPanelAlpha(alpha: Float) {
+ panelAlpha.value = alpha
+ }
+
fun setIsEncryptedOrLockdown(value: Boolean) {
_isEncryptedOrLockdown.value = value
}