Loading packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/layout/LockscreenSceneLayout.kt +93 −35 Original line number Diff line number Diff line Loading @@ -72,8 +72,8 @@ interface LockscreenLayoutViewModel { * `false` if only heads-up notifications are showing). */ val isNotificationsVisible: Boolean /** Whether the ambient indication UI should currently be showing. */ val isAmbientIndicationVisible: Boolean /** Whether udfps is supported. */ val isUdfpsSupported: Boolean /** Amount of horizontal translation that should be applied to elements in the scene. */ val unfoldTranslations: UnfoldTranslations } Loading Loading @@ -222,13 +222,25 @@ fun LockscreenSceneLayout( } } /** Convenience function to draw the bottom area without needing to pass a lot of parameters. */ /** * Convenience function to draw the ambient indication without needing to pass a lot of * parameters. */ @Composable fun bottomArea(modifier: Modifier = Modifier) { BottomArea( startShortcut = startShortcut, isAmbientIndicationVisible = viewModel.isAmbientIndicationVisible, fun ambientIndication(modifier: Modifier = Modifier) { AmbientIndication( ambientIndication = ambientIndication, modifier = modifier.navigationBarsPadding(), ) } /** * Convenience function to draw the shortcut area without needing to pass a lot of parameters. */ @Composable fun shortcutArea(modifier: Modifier = Modifier) { ShortcutArea( startShortcut = startShortcut, bottomIndication = bottomIndication, endShortcut = endShortcut, unfoldTranslations = viewModel.unfoldTranslations, Loading @@ -255,19 +267,38 @@ fun LockscreenSceneLayout( Box(Modifier.graphicsLayer { translationX = viewModel.unfoldTranslations.end }) { largeClock() } bottomArea() if (viewModel.isUdfpsSupported) { lockIcon() ambientIndication() } else { ambientIndication() lockIcon() } shortcutArea() settingsMenu() }, modifier = modifier, ) { measurables, constraints -> check(measurables.size == 6) check(measurables.size == 7) val statusBarMeasurable = measurables[0] val contentColumnMeasurable = measurables[1] val largeClockMeasurable = measurables[2] val bottomAreaMeasurable = measurables[3] val lockIconMeasurable = measurables[4] val settingsMenuMeasurable = measurables[5] val ambientIndicationMeasurable = if (viewModel.isUdfpsSupported) { measurables[4] } else { measurables[3] } val lockIconMeasurable = if (viewModel.isUdfpsSupported) { measurables[3] } else { measurables[4] } val shortcutAreaMeasurable = measurables[5] val settingsMenuMeasurable = measurables[6] val statusBarPlaceable = statusBarMeasurable.measure(constraints = Constraints.fixedWidth(constraints.maxWidth)) Loading Loading @@ -349,8 +380,15 @@ fun LockscreenSceneLayout( else -> null } val bottomAreaPlaceable = bottomAreaMeasurable.measure(constraints = Constraints.fixedWidth(constraints.maxWidth)) val ambientIndicationPlaceable = ambientIndicationMeasurable.measure( constraints = Constraints.fixedWidth(constraints.maxWidth) ) val shortcutAreaPlaceable = shortcutAreaMeasurable.measure( constraints = Constraints.fixedWidth(constraints.maxWidth) ) val settingsMenuPleaceable = settingsMenuMeasurable.measure(constraints) Loading Loading @@ -389,8 +427,25 @@ fun LockscreenSceneLayout( }, ) bottomAreaPlaceable.place(0, constraints.maxHeight - bottomAreaPlaceable.measuredHeight) if (viewModel.isUdfpsSupported) { lockIconPlaceable.place(x = lockIconBounds.left, y = lockIconBounds.top) ambientIndicationPlaceable.place( 0, constraints.maxHeight - ambientIndicationPlaceable.measuredHeight, ) } else { ambientIndicationPlaceable.place( 0, constraints.maxHeight - ambientIndicationPlaceable.measuredHeight, ) lockIconPlaceable.place(x = lockIconBounds.left, y = lockIconBounds.top) } shortcutAreaPlaceable.place( 0, constraints.maxHeight - shortcutAreaPlaceable.measuredHeight, ) settingsMenuPleaceable.placeRelative( x = (constraints.maxWidth - settingsMenuPleaceable.measuredWidth) / 2, y = constraints.maxHeight - settingsMenuPleaceable.measuredHeight, Loading @@ -399,35 +454,38 @@ fun LockscreenSceneLayout( } } /** Draws the bottom area of the layout. */ @Composable private fun BottomArea( startShortcut: @Composable () -> Unit, isAmbientIndicationVisible: Boolean, private fun AmbientIndication( ambientIndication: @Composable () -> Unit, bottomIndication: @Composable () -> Unit, endShortcut: @Composable () -> Unit, unfoldTranslations: UnfoldTranslations, modifier: Modifier = Modifier, ) { Column( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp), modifier = modifier.fillMaxWidth().padding(horizontal = 16.dp), ) { if (isAmbientIndicationVisible) { ambientIndication() } Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) { Box(Modifier.graphicsLayer { translationX = unfoldTranslations.start }) { startShortcut() } /** Draws the shortcut area of the layout. */ @Composable private fun ShortcutArea( startShortcut: @Composable () -> Unit, bottomIndication: @Composable () -> Unit, endShortcut: @Composable () -> Unit, unfoldTranslations: UnfoldTranslations, modifier: Modifier = Modifier, ) { Row( horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically, modifier = modifier.fillMaxWidth().padding(horizontal = 16.dp), ) { Box(Modifier.graphicsLayer { translationX = unfoldTranslations.start }) { startShortcut() } Box(Modifier.weight(1f)) { bottomIndication() } Box(Modifier.graphicsLayer { translationX = unfoldTranslations.end }) { endShortcut() } } } } /** * Draws the content column. Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt +6 −6 Original line number Diff line number Diff line Loading @@ -95,17 +95,17 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa } @Test fun isAmbientIndicationVisible_withUdfps_false() = fun isUdfpsSupported_withoutUdfps_false() = kosmos.runTest { whenever(authController.isUdfpsSupported).thenReturn(true) assertThat(underTest.layout.isAmbientIndicationVisible).isFalse() whenever(authController.isUdfpsSupported).thenReturn(false) assertThat(underTest.layout.isUdfpsSupported).isFalse() } @Test fun isAmbientIndicationVisible_withoutUdfps_true() = fun isUdfpsSupported_withUdfps_true() = kosmos.runTest { whenever(authController.isUdfpsSupported).thenReturn(false) assertThat(underTest.layout.isAmbientIndicationVisible).isTrue() whenever(authController.isUdfpsSupported).thenReturn(true) assertThat(underTest.layout.isUdfpsSupported).isTrue() } @Test Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModel.kt +2 −2 Original line number Diff line number Diff line Loading @@ -146,8 +146,8 @@ constructor( initialValue = activeNotificationsInteractor.areAnyNotificationsPresentValue, ) override val isAmbientIndicationVisible: Boolean get() = !authController.isUdfpsSupported override val isUdfpsSupported: Boolean get() = authController.isUdfpsSupported override val unfoldTranslations: UnfoldTranslations = object : UnfoldTranslations { Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/layout/LockscreenSceneLayout.kt +93 −35 Original line number Diff line number Diff line Loading @@ -72,8 +72,8 @@ interface LockscreenLayoutViewModel { * `false` if only heads-up notifications are showing). */ val isNotificationsVisible: Boolean /** Whether the ambient indication UI should currently be showing. */ val isAmbientIndicationVisible: Boolean /** Whether udfps is supported. */ val isUdfpsSupported: Boolean /** Amount of horizontal translation that should be applied to elements in the scene. */ val unfoldTranslations: UnfoldTranslations } Loading Loading @@ -222,13 +222,25 @@ fun LockscreenSceneLayout( } } /** Convenience function to draw the bottom area without needing to pass a lot of parameters. */ /** * Convenience function to draw the ambient indication without needing to pass a lot of * parameters. */ @Composable fun bottomArea(modifier: Modifier = Modifier) { BottomArea( startShortcut = startShortcut, isAmbientIndicationVisible = viewModel.isAmbientIndicationVisible, fun ambientIndication(modifier: Modifier = Modifier) { AmbientIndication( ambientIndication = ambientIndication, modifier = modifier.navigationBarsPadding(), ) } /** * Convenience function to draw the shortcut area without needing to pass a lot of parameters. */ @Composable fun shortcutArea(modifier: Modifier = Modifier) { ShortcutArea( startShortcut = startShortcut, bottomIndication = bottomIndication, endShortcut = endShortcut, unfoldTranslations = viewModel.unfoldTranslations, Loading @@ -255,19 +267,38 @@ fun LockscreenSceneLayout( Box(Modifier.graphicsLayer { translationX = viewModel.unfoldTranslations.end }) { largeClock() } bottomArea() if (viewModel.isUdfpsSupported) { lockIcon() ambientIndication() } else { ambientIndication() lockIcon() } shortcutArea() settingsMenu() }, modifier = modifier, ) { measurables, constraints -> check(measurables.size == 6) check(measurables.size == 7) val statusBarMeasurable = measurables[0] val contentColumnMeasurable = measurables[1] val largeClockMeasurable = measurables[2] val bottomAreaMeasurable = measurables[3] val lockIconMeasurable = measurables[4] val settingsMenuMeasurable = measurables[5] val ambientIndicationMeasurable = if (viewModel.isUdfpsSupported) { measurables[4] } else { measurables[3] } val lockIconMeasurable = if (viewModel.isUdfpsSupported) { measurables[3] } else { measurables[4] } val shortcutAreaMeasurable = measurables[5] val settingsMenuMeasurable = measurables[6] val statusBarPlaceable = statusBarMeasurable.measure(constraints = Constraints.fixedWidth(constraints.maxWidth)) Loading Loading @@ -349,8 +380,15 @@ fun LockscreenSceneLayout( else -> null } val bottomAreaPlaceable = bottomAreaMeasurable.measure(constraints = Constraints.fixedWidth(constraints.maxWidth)) val ambientIndicationPlaceable = ambientIndicationMeasurable.measure( constraints = Constraints.fixedWidth(constraints.maxWidth) ) val shortcutAreaPlaceable = shortcutAreaMeasurable.measure( constraints = Constraints.fixedWidth(constraints.maxWidth) ) val settingsMenuPleaceable = settingsMenuMeasurable.measure(constraints) Loading Loading @@ -389,8 +427,25 @@ fun LockscreenSceneLayout( }, ) bottomAreaPlaceable.place(0, constraints.maxHeight - bottomAreaPlaceable.measuredHeight) if (viewModel.isUdfpsSupported) { lockIconPlaceable.place(x = lockIconBounds.left, y = lockIconBounds.top) ambientIndicationPlaceable.place( 0, constraints.maxHeight - ambientIndicationPlaceable.measuredHeight, ) } else { ambientIndicationPlaceable.place( 0, constraints.maxHeight - ambientIndicationPlaceable.measuredHeight, ) lockIconPlaceable.place(x = lockIconBounds.left, y = lockIconBounds.top) } shortcutAreaPlaceable.place( 0, constraints.maxHeight - shortcutAreaPlaceable.measuredHeight, ) settingsMenuPleaceable.placeRelative( x = (constraints.maxWidth - settingsMenuPleaceable.measuredWidth) / 2, y = constraints.maxHeight - settingsMenuPleaceable.measuredHeight, Loading @@ -399,35 +454,38 @@ fun LockscreenSceneLayout( } } /** Draws the bottom area of the layout. */ @Composable private fun BottomArea( startShortcut: @Composable () -> Unit, isAmbientIndicationVisible: Boolean, private fun AmbientIndication( ambientIndication: @Composable () -> Unit, bottomIndication: @Composable () -> Unit, endShortcut: @Composable () -> Unit, unfoldTranslations: UnfoldTranslations, modifier: Modifier = Modifier, ) { Column( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp), modifier = modifier.fillMaxWidth().padding(horizontal = 16.dp), ) { if (isAmbientIndicationVisible) { ambientIndication() } Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) { Box(Modifier.graphicsLayer { translationX = unfoldTranslations.start }) { startShortcut() } /** Draws the shortcut area of the layout. */ @Composable private fun ShortcutArea( startShortcut: @Composable () -> Unit, bottomIndication: @Composable () -> Unit, endShortcut: @Composable () -> Unit, unfoldTranslations: UnfoldTranslations, modifier: Modifier = Modifier, ) { Row( horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically, modifier = modifier.fillMaxWidth().padding(horizontal = 16.dp), ) { Box(Modifier.graphicsLayer { translationX = unfoldTranslations.start }) { startShortcut() } Box(Modifier.weight(1f)) { bottomIndication() } Box(Modifier.graphicsLayer { translationX = unfoldTranslations.end }) { endShortcut() } } } } /** * Draws the content column. Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt +6 −6 Original line number Diff line number Diff line Loading @@ -95,17 +95,17 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa } @Test fun isAmbientIndicationVisible_withUdfps_false() = fun isUdfpsSupported_withoutUdfps_false() = kosmos.runTest { whenever(authController.isUdfpsSupported).thenReturn(true) assertThat(underTest.layout.isAmbientIndicationVisible).isFalse() whenever(authController.isUdfpsSupported).thenReturn(false) assertThat(underTest.layout.isUdfpsSupported).isFalse() } @Test fun isAmbientIndicationVisible_withoutUdfps_true() = fun isUdfpsSupported_withUdfps_true() = kosmos.runTest { whenever(authController.isUdfpsSupported).thenReturn(false) assertThat(underTest.layout.isAmbientIndicationVisible).isTrue() whenever(authController.isUdfpsSupported).thenReturn(true) assertThat(underTest.layout.isUdfpsSupported).isTrue() } @Test Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModel.kt +2 −2 Original line number Diff line number Diff line Loading @@ -146,8 +146,8 @@ constructor( initialValue = activeNotificationsInteractor.areAnyNotificationsPresentValue, ) override val isAmbientIndicationVisible: Boolean get() = !authController.isUdfpsSupported override val isUdfpsSupported: Boolean get() = authController.isUdfpsSupported override val unfoldTranslations: UnfoldTranslations = object : UnfoldTranslations { Loading