diff options
| author | 2023-12-18 17:12:48 -0800 | |
|---|---|---|
| committer | 2023-12-18 17:12:48 -0800 | |
| commit | 1fa628a1cdb88445bf44e7512aba76a20b1cbca5 (patch) | |
| tree | 7902e094a60d5709776b056e2e5dec96d38a3543 | |
| parent | 5dda91132b40972e389f10d39b399e5806023929 (diff) | |
[flexiglass] Shortcuts beside UDFPS blueprint.
Adds the blueprint where the shortcuts are on each side of the lock
icon.
Bug: 316211368
Test: manually, see video at https://drive.google.com/file/d/15nVASX-Q8a3XNc2d_bydoh0p6x1yU6CO/view
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: Ib9871a4e216d83de045f1b261eb27e8526c2e9d8
| -rw-r--r-- | packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ShortcutsBesideUdfpsBlueprint.kt | 140 |
1 files changed, 130 insertions, 10 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ShortcutsBesideUdfpsBlueprint.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ShortcutsBesideUdfpsBlueprint.kt index 6bc0382b180d..fa913f1695fe 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ShortcutsBesideUdfpsBlueprint.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ShortcutsBesideUdfpsBlueprint.kt @@ -16,31 +16,151 @@ package com.android.systemui.keyguard.ui.composable.blueprint -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box -import androidx.compose.material3.Text +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.res.dimensionResource +import androidx.compose.ui.unit.IntOffset import com.android.compose.animation.scene.SceneScope +import com.android.compose.modifiers.height +import com.android.compose.modifiers.width +import com.android.systemui.keyguard.ui.composable.section.AmbientIndicationSection +import com.android.systemui.keyguard.ui.composable.section.BottomAreaSection +import com.android.systemui.keyguard.ui.composable.section.ClockSection +import com.android.systemui.keyguard.ui.composable.section.LockSection +import com.android.systemui.keyguard.ui.composable.section.NotificationSection +import com.android.systemui.keyguard.ui.composable.section.SmartSpaceSection +import com.android.systemui.keyguard.ui.composable.section.StatusBarSection +import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel +import com.android.systemui.res.R import dagger.Binds import dagger.Module import dagger.multibindings.IntoSet import javax.inject.Inject +import kotlin.math.roundToInt -class ShortcutsBesideUdfpsBlueprint @Inject constructor() : LockscreenSceneBlueprint { +/** + * Renders the lockscreen scene when showing with the default layout (e.g. vertical phone form + * factor). + */ +class ShortcutsBesideUdfpsBlueprint +@Inject +constructor( + private val viewModel: LockscreenContentViewModel, + private val statusBarSection: StatusBarSection, + private val clockSection: ClockSection, + private val smartSpaceSection: SmartSpaceSection, + private val notificationSection: NotificationSection, + private val lockSection: LockSection, + private val ambientIndicationSection: AmbientIndicationSection, + private val bottomAreaSection: BottomAreaSection, +) : LockscreenSceneBlueprint { override val id: String = "shortcuts-besides-udfps" @Composable override fun SceneScope.Content(modifier: Modifier) { - Box(modifier.background(Color.Black)) { - Text( - text = "TODO(b/316211368): shortcuts beside UDFPS blueprint", - color = Color.White, - modifier = Modifier.align(Alignment.Center), - ) + val context = LocalContext.current + val lockIconBounds = lockSection.lockIconBounds(context) + val isUdfpsVisible = viewModel.isUdfpsVisible + + Box( + modifier = modifier, + ) { + Column( + modifier = Modifier.fillMaxWidth().height { lockIconBounds.top }, + ) { + with(statusBarSection) { StatusBar(modifier = Modifier.fillMaxWidth()) } + with(clockSection) { SmallClock(modifier = Modifier.fillMaxWidth()) } + with(smartSpaceSection) { SmartSpace(modifier = Modifier.fillMaxWidth()) } + with(clockSection) { LargeClock(modifier = Modifier.fillMaxWidth()) } + with(notificationSection) { + Notifications(modifier = Modifier.fillMaxWidth().weight(1f)) + } + if (!isUdfpsVisible) { + with(ambientIndicationSection) { + AmbientIndication(modifier = Modifier.fillMaxWidth()) + } + } + } + + val shortcutSizePx = + with(LocalDensity.current) { bottomAreaSection.shortcutSizeDp().toSize() } + + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = + Modifier.fillMaxWidth().offset { + val rowTop = + if (shortcutSizePx.height > lockIconBounds.height()) { + (lockIconBounds.top - + (shortcutSizePx.height + lockIconBounds.height()) / 2) + .roundToInt() + } else { + lockIconBounds.top + } + + IntOffset(0, rowTop) + }, + ) { + Spacer(Modifier.weight(1f)) + + with(bottomAreaSection) { Shortcut(isStart = true) } + + Spacer(Modifier.weight(1f)) + + with(lockSection) { + LockIcon( + modifier = + Modifier.width { lockIconBounds.width() } + .height { lockIconBounds.height() } + ) + } + + Spacer(Modifier.weight(1f)) + + with(bottomAreaSection) { Shortcut(isStart = false) } + + Spacer(Modifier.weight(1f)) + } + + Column(modifier = Modifier.fillMaxWidth().align(Alignment.BottomCenter)) { + if (isUdfpsVisible) { + with(ambientIndicationSection) { + AmbientIndication(modifier = Modifier.fillMaxWidth()) + } + } + + with(bottomAreaSection) { + IndicationArea( + modifier = + Modifier.fillMaxWidth() + .padding( + horizontal = + dimensionResource( + R.dimen.keyguard_affordance_horizontal_offset + ) + ) + .padding( + bottom = + dimensionResource( + R.dimen.keyguard_affordance_vertical_offset + ) + ) + .heightIn(min = shortcutSizeDp().height), + ) + } + } } } } |