Loading packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt +16 −7 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import com.android.systemui.notifications.ui.composable.Notifications.Transition import com.android.systemui.notifications.ui.composable.Notifications.TransitionThresholds.EXPANSION_FOR_MAX_SCRIM_ALPHA import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.ui.composable.ShadeHeader import com.android.systemui.statusbar.notification.stack.shared.model.StackRounding import com.android.systemui.statusbar.notification.stack.ui.viewbinder.NotificationStackAppearanceViewBinder.SCRIM_CORNER_RADIUS import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel import kotlin.math.roundToInt Loading Loading @@ -156,6 +157,8 @@ fun SceneScope.NotificationScrollingStack( val contentHeight = viewModel.intrinsicContentHeight.collectAsState() val stackRounding = viewModel.stackRounding.collectAsState() // the offset for the notifications scrim. Its upper bound is 0, and its lower bound is // calculated in minScrimOffset. The scrim is the same height as the screen minus the // height of the Shade Header, and at rest (scrimOffset = 0) its top bound is at maxScrimStartY. Loading Loading @@ -226,12 +229,7 @@ fun SceneScope.NotificationScrollingStack( { expansionFraction }, layoutState.isTransitioningBetween(Scenes.Gone, Scenes.Shade) ) .let { RoundedCornerShape( topStart = it, topEnd = it, ) } .let { stackRounding.value.toRoundedCornerShape(it) } clip = true } ) { Loading Loading @@ -367,7 +365,7 @@ private fun calculateCornerRadius( lerp( start = screenCornerRadius.value, stop = SCRIM_CORNER_RADIUS, fraction = (expansionFraction() / EXPANSION_FOR_MAX_CORNER_RADIUS).coerceAtMost(1f), fraction = (expansionFraction() / EXPANSION_FOR_MAX_CORNER_RADIUS).coerceIn(0f, 1f), ) .dp } else { Loading @@ -394,5 +392,16 @@ private fun Modifier.debugBackground( this } fun StackRounding.toRoundedCornerShape(radius: Dp): RoundedCornerShape { val topRadius = if (roundTop) radius else 0.dp val bottomRadius = if (roundBottom) radius else 0.dp return RoundedCornerShape( topStart = topRadius, topEnd = topRadius, bottomStart = bottomRadius, bottomEnd = bottomRadius, ) } private const val TAG = "FlexiNotifs" private val DEBUG_COLOR = Color(1f, 0f, 0f, 0.2f) packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationStackAppearanceIntegrationTest.kt +4 −11 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic Loading @@ -31,6 +30,7 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationStackAppearanceViewModel import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationsPlaceholderViewModel import com.android.systemui.testKosmos Loading Loading @@ -64,7 +64,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { @Test fun updateBounds() = testScope.runTest { val bounds by collectLastValue(appearanceViewModel.stackBounds) val clipping by collectLastValue(appearanceViewModel.stackClipping) val top = 200f val left = 0f Loading @@ -76,15 +76,8 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { right = right, bottom = bottom ) assertThat(bounds) .isEqualTo( NotificationContainerBounds( left = left, top = top, right = right, bottom = bottom ) ) assertThat(clipping?.bounds) .isEqualTo(StackBounds(left = left, top = top, right = right, bottom = bottom)) } @Test Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractorTest.kt +4 −6 Original line number Diff line number Diff line Loading @@ -19,10 +19,10 @@ package com.android.systemui.statusbar.notification.stack.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Test Loading @@ -43,19 +43,17 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() { val stackBounds by collectLastValue(underTest.stackBounds) val bounds1 = NotificationContainerBounds( StackBounds( top = 100f, bottom = 200f, isAnimated = true, ) underTest.setStackBounds(bounds1) assertThat(stackBounds).isEqualTo(bounds1) val bounds2 = NotificationContainerBounds( StackBounds( top = 200f, bottom = 300f, isAnimated = false, ) underTest.setStackBounds(bounds2) assertThat(stackBounds).isEqualTo(bounds2) Loading @@ -65,7 +63,7 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() { fun setStackBounds_withImproperBounds_throwsException() = testScope.runTest { underTest.setStackBounds( NotificationContainerBounds( StackBounds( top = 100f, bottom = 99f, ) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.keyguard.domain.interactor.keyguardInteractor import com.android.systemui.statusbar.notification.stack.domain.interactor.notificationStackAppearanceInteractor import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Test Loading @@ -36,9 +37,9 @@ class NotificationsPlaceholderViewModelTest : SysuiTestCase() { fun onBoundsChanged_setsNotificationContainerBounds() { underTest.onBoundsChanged(left = 5f, top = 5f, right = 5f, bottom = 5f) assertThat(kosmos.keyguardInteractor.notificationContainerBounds.value) .isEqualTo(NotificationContainerBounds(left = 5f, top = 5f, right = 5f, bottom = 5f)) .isEqualTo(NotificationContainerBounds(top = 5f, bottom = 5f)) assertThat(kosmos.notificationStackAppearanceInteractor.stackBounds.value) .isEqualTo(NotificationContainerBounds(left = 5f, top = 5f, right = 5f, bottom = 5f)) .isEqualTo(StackBounds(left = 5f, top = 5f, right = 5f, bottom = 5f)) } @Test fun onContentTopChanged_setsContentTop() { Loading packages/SystemUI/src/com/android/systemui/common/shared/model/NotificationContainerBounds.kt +0 −4 Original line number Diff line number Diff line Loading @@ -18,12 +18,8 @@ package com.android.systemui.common.shared.model /** Models the bounds of the notification container. */ data class NotificationContainerBounds( /** The position of the left of the container in its window coordinate system, in pixels. */ val left: Float = 0f, /** The position of the top of the container in its window coordinate system, in pixels. */ val top: Float = 0f, /** The position of the right of the container in its window coordinate system, in pixels. */ val right: Float = 0f, /** The position of the bottom of the container in its window coordinate system, in pixels. */ val bottom: Float = 0f, /** Whether any modifications to top/bottom should be smoothly animated. */ Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt +16 −7 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ import com.android.systemui.notifications.ui.composable.Notifications.Transition import com.android.systemui.notifications.ui.composable.Notifications.TransitionThresholds.EXPANSION_FOR_MAX_SCRIM_ALPHA import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.ui.composable.ShadeHeader import com.android.systemui.statusbar.notification.stack.shared.model.StackRounding import com.android.systemui.statusbar.notification.stack.ui.viewbinder.NotificationStackAppearanceViewBinder.SCRIM_CORNER_RADIUS import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel import kotlin.math.roundToInt Loading Loading @@ -156,6 +157,8 @@ fun SceneScope.NotificationScrollingStack( val contentHeight = viewModel.intrinsicContentHeight.collectAsState() val stackRounding = viewModel.stackRounding.collectAsState() // the offset for the notifications scrim. Its upper bound is 0, and its lower bound is // calculated in minScrimOffset. The scrim is the same height as the screen minus the // height of the Shade Header, and at rest (scrimOffset = 0) its top bound is at maxScrimStartY. Loading Loading @@ -226,12 +229,7 @@ fun SceneScope.NotificationScrollingStack( { expansionFraction }, layoutState.isTransitioningBetween(Scenes.Gone, Scenes.Shade) ) .let { RoundedCornerShape( topStart = it, topEnd = it, ) } .let { stackRounding.value.toRoundedCornerShape(it) } clip = true } ) { Loading Loading @@ -367,7 +365,7 @@ private fun calculateCornerRadius( lerp( start = screenCornerRadius.value, stop = SCRIM_CORNER_RADIUS, fraction = (expansionFraction() / EXPANSION_FOR_MAX_CORNER_RADIUS).coerceAtMost(1f), fraction = (expansionFraction() / EXPANSION_FOR_MAX_CORNER_RADIUS).coerceIn(0f, 1f), ) .dp } else { Loading @@ -394,5 +392,16 @@ private fun Modifier.debugBackground( this } fun StackRounding.toRoundedCornerShape(radius: Dp): RoundedCornerShape { val topRadius = if (roundTop) radius else 0.dp val bottomRadius = if (roundBottom) radius else 0.dp return RoundedCornerShape( topStart = topRadius, topEnd = topRadius, bottomStart = bottomRadius, bottomEnd = bottomRadius, ) } private const val TAG = "FlexiNotifs" private val DEBUG_COLOR = Color(1f, 0f, 0f, 0.2f)
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationStackAppearanceIntegrationTest.kt +4 −11 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.Flags import com.android.systemui.flags.fakeFeatureFlagsClassic Loading @@ -31,6 +30,7 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationStackAppearanceViewModel import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationsPlaceholderViewModel import com.android.systemui.testKosmos Loading Loading @@ -64,7 +64,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { @Test fun updateBounds() = testScope.runTest { val bounds by collectLastValue(appearanceViewModel.stackBounds) val clipping by collectLastValue(appearanceViewModel.stackClipping) val top = 200f val left = 0f Loading @@ -76,15 +76,8 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() { right = right, bottom = bottom ) assertThat(bounds) .isEqualTo( NotificationContainerBounds( left = left, top = top, right = right, bottom = bottom ) ) assertThat(clipping?.bounds) .isEqualTo(StackBounds(left = left, top = top, right = right, bottom = bottom)) } @Test Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/NotificationStackAppearanceInteractorTest.kt +4 −6 Original line number Diff line number Diff line Loading @@ -19,10 +19,10 @@ package com.android.systemui.statusbar.notification.stack.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runTest import org.junit.Test Loading @@ -43,19 +43,17 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() { val stackBounds by collectLastValue(underTest.stackBounds) val bounds1 = NotificationContainerBounds( StackBounds( top = 100f, bottom = 200f, isAnimated = true, ) underTest.setStackBounds(bounds1) assertThat(stackBounds).isEqualTo(bounds1) val bounds2 = NotificationContainerBounds( StackBounds( top = 200f, bottom = 300f, isAnimated = false, ) underTest.setStackBounds(bounds2) assertThat(stackBounds).isEqualTo(bounds2) Loading @@ -65,7 +63,7 @@ class NotificationStackAppearanceInteractorTest : SysuiTestCase() { fun setStackBounds_withImproperBounds_throwsException() = testScope.runTest { underTest.setStackBounds( NotificationContainerBounds( StackBounds( top = 100f, bottom = 99f, ) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.keyguard.domain.interactor.keyguardInteractor import com.android.systemui.statusbar.notification.stack.domain.interactor.notificationStackAppearanceInteractor import com.android.systemui.statusbar.notification.stack.shared.model.StackBounds import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import org.junit.Test Loading @@ -36,9 +37,9 @@ class NotificationsPlaceholderViewModelTest : SysuiTestCase() { fun onBoundsChanged_setsNotificationContainerBounds() { underTest.onBoundsChanged(left = 5f, top = 5f, right = 5f, bottom = 5f) assertThat(kosmos.keyguardInteractor.notificationContainerBounds.value) .isEqualTo(NotificationContainerBounds(left = 5f, top = 5f, right = 5f, bottom = 5f)) .isEqualTo(NotificationContainerBounds(top = 5f, bottom = 5f)) assertThat(kosmos.notificationStackAppearanceInteractor.stackBounds.value) .isEqualTo(NotificationContainerBounds(left = 5f, top = 5f, right = 5f, bottom = 5f)) .isEqualTo(StackBounds(left = 5f, top = 5f, right = 5f, bottom = 5f)) } @Test fun onContentTopChanged_setsContentTop() { Loading
packages/SystemUI/src/com/android/systemui/common/shared/model/NotificationContainerBounds.kt +0 −4 Original line number Diff line number Diff line Loading @@ -18,12 +18,8 @@ package com.android.systemui.common.shared.model /** Models the bounds of the notification container. */ data class NotificationContainerBounds( /** The position of the left of the container in its window coordinate system, in pixels. */ val left: Float = 0f, /** The position of the top of the container in its window coordinate system, in pixels. */ val top: Float = 0f, /** The position of the right of the container in its window coordinate system, in pixels. */ val right: Float = 0f, /** The position of the bottom of the container in its window coordinate system, in pixels. */ val bottom: Float = 0f, /** Whether any modifications to top/bottom should be smoothly animated. */ Loading