Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1fa628a1 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[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
parent 5dda9113
Loading
Loading
Loading
Loading
+130 −10
Original line number Diff line number Diff line
@@ -16,32 +16,152 @@

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),
                    )
                }
            }
        }
    }
}