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

Commit 38a8c65a authored by Aaron Liu's avatar Aaron Liu
Browse files

Remove Notification from clock STL.

Removes the notification from the clock STL. Also remove some redundant
composable invocations by adding additional reusable functions.

Test: look at compose LS landscape and potrait with centering animation.
Flag: ACONFIG com.android.systemui.compose_lockscreen DEVELOPMENT
Bug: 301968149

Change-Id: I19aa4c5344cb3af4371098f94f0383bcd85d86a0
parent 0f65a72e
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -16,10 +16,15 @@

package com.android.systemui.keyguard.ui.composable.blueprint

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.unit.IntRect
@@ -28,6 +33,7 @@ import com.android.systemui.keyguard.ui.composable.LockscreenLongPress
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.LockSection
import com.android.systemui.keyguard.ui.composable.section.NotificationSection
import com.android.systemui.keyguard.ui.composable.section.SettingsMenuSection
import com.android.systemui.keyguard.ui.composable.section.StatusBarSection
import com.android.systemui.keyguard.ui.composable.section.TopAreaSection
@@ -52,6 +58,7 @@ constructor(
    private val bottomAreaSection: BottomAreaSection,
    private val settingsMenuSection: SettingsMenuSection,
    private val topAreaSection: TopAreaSection,
    private val notificationSection: NotificationSection,
) : ComposableLockscreenSceneBlueprint {

    override val id: String = "default"
@@ -59,6 +66,8 @@ constructor(
    @Composable
    override fun SceneScope.Content(modifier: Modifier) {
        val isUdfpsVisible = viewModel.isUdfpsVisible
        val shouldUseSplitNotificationShade by
            viewModel.shouldUseSplitNotificationShade.collectAsState()

        LockscreenLongPress(
            viewModel = viewModel.longPress,
@@ -68,10 +77,27 @@ constructor(
                content = {
                    // Constrained to above the lock icon.
                    Column(
                        modifier = Modifier.fillMaxWidth(),
                        modifier = Modifier.fillMaxSize(),
                    ) {
                        with(statusBarSection) { StatusBar(modifier = Modifier.fillMaxWidth()) }
                        with(topAreaSection) { DefaultClockLayoutWithNotifications() }

                        Box {
                            with(topAreaSection) { DefaultClockLayout() }
                            if (shouldUseSplitNotificationShade) {
                                with(notificationSection) {
                                    Notifications(
                                        Modifier.fillMaxWidth(0.5f)
                                            .fillMaxHeight()
                                            .align(alignment = Alignment.TopEnd)
                                    )
                                }
                            }
                        }
                        if (!shouldUseSplitNotificationShade) {
                            with(notificationSection) {
                                Notifications(Modifier.weight(weight = 1f))
                            }
                        }
                        if (!isUdfpsVisible && ambientIndicationSectionOptional.isPresent) {
                            with(ambientIndicationSectionOptional.get()) {
                                AmbientIndication(modifier = Modifier.fillMaxWidth())
+27 −2
Original line number Diff line number Diff line
@@ -16,10 +16,15 @@

package com.android.systemui.keyguard.ui.composable.blueprint

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.unit.IntRect
@@ -28,6 +33,7 @@ import com.android.systemui.keyguard.ui.composable.LockscreenLongPress
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.LockSection
import com.android.systemui.keyguard.ui.composable.section.NotificationSection
import com.android.systemui.keyguard.ui.composable.section.SettingsMenuSection
import com.android.systemui.keyguard.ui.composable.section.StatusBarSection
import com.android.systemui.keyguard.ui.composable.section.TopAreaSection
@@ -52,6 +58,7 @@ constructor(
    private val bottomAreaSection: BottomAreaSection,
    private val settingsMenuSection: SettingsMenuSection,
    private val topAreaSection: TopAreaSection,
    private val notificationSection: NotificationSection,
) : ComposableLockscreenSceneBlueprint {

    override val id: String = "shortcuts-besides-udfps"
@@ -59,6 +66,8 @@ constructor(
    @Composable
    override fun SceneScope.Content(modifier: Modifier) {
        val isUdfpsVisible = viewModel.isUdfpsVisible
        val shouldUseSplitNotificationShade by
            viewModel.shouldUseSplitNotificationShade.collectAsState()

        LockscreenLongPress(
            viewModel = viewModel.longPress,
@@ -68,11 +77,27 @@ constructor(
                content = {
                    // Constrained to above the lock icon.
                    Column(
                        modifier = Modifier.fillMaxWidth(),
                        modifier = Modifier.fillMaxSize(),
                    ) {
                        with(statusBarSection) { StatusBar(modifier = Modifier.fillMaxWidth()) }
                        with(topAreaSection) { DefaultClockLayoutWithNotifications() }

                        Box {
                            with(topAreaSection) { DefaultClockLayout() }
                            if (shouldUseSplitNotificationShade) {
                                with(notificationSection) {
                                    Notifications(
                                        Modifier.fillMaxWidth(0.5f)
                                            .fillMaxHeight()
                                            .align(alignment = Alignment.TopEnd)
                                    )
                                }
                            }
                        }
                        if (!shouldUseSplitNotificationShade) {
                            with(notificationSection) {
                                Notifications(Modifier.weight(weight = 1f))
                            }
                        }
                        if (!isUdfpsVisible && ambientIndicationSectionOptional.isPresent) {
                            with(ambientIndicationSectionOptional.get()) {
                                AmbientIndication(modifier = Modifier.fillMaxWidth())
+2 −1
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ constructor(
        val burnIn = rememberBurnIn(clockInteractor)
        val resources = LocalContext.current.resources
        val currentClockState = clockViewModel.currentClock.collectAsState()
        val areNotificationsVisible by viewModel.areNotificationsVisible.collectAsState()
        LockscreenLongPress(
            viewModel = viewModel.longPress,
            modifier = modifier,
@@ -145,7 +146,7 @@ constructor(

                        with(mediaCarouselSection) { MediaCarousel() }

                        if (viewModel.areNotificationsVisible) {
                        if (areNotificationsVisible) {
                            with(notificationSection) {
                                Notifications(
                                    modifier = Modifier.fillMaxWidth().weight(weight = 1f)
+33 −1
Original line number Diff line number Diff line
@@ -17,12 +17,25 @@
package com.android.systemui.keyguard.ui.composable.section

import android.view.ViewGroup
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.SceneScope
import com.android.compose.modifiers.thenIf
import com.android.systemui.Flags
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.MigrateClocksToBlueprint
import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
import com.android.systemui.notifications.ui.composable.NotificationStack
import com.android.systemui.res.R
import com.android.systemui.shade.LargeScreenHeaderHelper
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import com.android.systemui.statusbar.notification.stack.ui.viewbinder.SharedNotificationContainerBinder
@@ -39,6 +52,7 @@ constructor(
    sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
    stackScrollLayout: NotificationStackScrollLayout,
    sharedNotificationContainerBinder: SharedNotificationContainerBinder,
    private val lockscreenContentViewModel: LockscreenContentViewModel,
) {

    init {
@@ -65,9 +79,27 @@ constructor(

    @Composable
    fun SceneScope.Notifications(modifier: Modifier = Modifier) {
        val shouldUseSplitNotificationShade by
            lockscreenContentViewModel.shouldUseSplitNotificationShade.collectAsState()
        val areNotificationsVisible by
            lockscreenContentViewModel.areNotificationsVisible.collectAsState()
        val splitShadeTopMargin: Dp =
            if (Flags.centralizedStatusBarHeightFix()) {
                LargeScreenHeaderHelper.getLargeScreenHeaderHeight(LocalContext.current).dp
            } else {
                dimensionResource(id = R.dimen.large_screen_shade_header_height)
            }

        if (!areNotificationsVisible) {
            return
        }

        NotificationStack(
            viewModel = viewModel,
            modifier = modifier,
            modifier =
                modifier.fillMaxWidth().thenIf(shouldUseSplitNotificationShade) {
                    Modifier.padding(top = splitShadeTopMargin)
                },
        )
    }
}
+65 −141
Original line number Diff line number Diff line
@@ -16,30 +16,20 @@

package com.android.systemui.keyguard.ui.composable.section

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.SceneScope
import com.android.compose.animation.scene.SceneTransitionLayout
import com.android.compose.modifiers.thenIf
import com.android.systemui.Flags
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.ui.composable.blueprint.ClockScenes.largeClockScene
import com.android.systemui.keyguard.ui.composable.blueprint.ClockScenes.smallClockScene
@@ -48,8 +38,6 @@ import com.android.systemui.keyguard.ui.composable.blueprint.ClockScenes.splitSh
import com.android.systemui.keyguard.ui.composable.blueprint.ClockTransition
import com.android.systemui.keyguard.ui.composable.blueprint.rememberBurnIn
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.res.R
import com.android.systemui.shade.LargeScreenHeaderHelper
import javax.inject.Inject

class TopAreaSection
@@ -58,19 +46,16 @@ constructor(
    private val clockViewModel: KeyguardClockViewModel,
    private val smartSpaceSection: SmartSpaceSection,
    private val mediaCarouselSection: MediaCarouselSection,
    private val notificationSection: NotificationSection,
    private val clockSection: DefaultClockSection,
    private val clockInteractor: KeyguardClockInteractor,
) {
    @Composable
    fun DefaultClockLayoutWithNotifications(
    fun DefaultClockLayout(
        modifier: Modifier = Modifier,
    ) {
        val isLargeClockVisible by clockViewModel.isLargeClockVisible.collectAsState()
        val currentClockLayout by clockViewModel.currentClockLayout.collectAsState()
        val hasCustomPositionUpdatedAnimation by
            clockViewModel.hasCustomPositionUpdatedAnimation.collectAsState()

        val currentScene =
            when (currentClockLayout) {
                KeyguardClockViewModel.ClockLayout.SPLIT_SHADE_LARGE_CLOCK ->
@@ -81,86 +66,34 @@ constructor(
                KeyguardClockViewModel.ClockLayout.SMALL_CLOCK -> smallClockScene
            }

        val splitShadeTopMargin: Dp =
            if (Flags.centralizedStatusBarHeightFix()) {
                LargeScreenHeaderHelper.getLargeScreenHeaderHeight(LocalContext.current).dp
            } else {
                dimensionResource(id = R.dimen.large_screen_shade_header_height)
            }
        val burnIn = rememberBurnIn(clockInteractor)

        LaunchedEffect(isLargeClockVisible) {
            if (isLargeClockVisible) {
                burnIn.onSmallClockTopChanged(null)
            }
        }

        SceneTransitionLayout(
            modifier = modifier.fillMaxSize(),
            modifier = modifier,
            currentScene = currentScene,
            onChangeScene = {},
            transitions = ClockTransition.defaultClockTransitions,
            enableInterruptions = false,
        ) {
            scene(splitShadeLargeClockScene) {
                Box(modifier = Modifier.fillMaxSize()) {
                    Column(
                        modifier = Modifier.fillMaxSize(),
                        horizontalAlignment = Alignment.CenterHorizontally,
                    ) {
                        with(smartSpaceSection) {
                            SmartSpace(
                                burnInParams = burnIn.parameters,
                                onTopChanged = burnIn.onSmartspaceTopChanged,
                LargeClockWithSmartSpace(
                    shouldOffSetClockToOneHalf = !hasCustomPositionUpdatedAnimation
                )
            }

                        with(clockSection) {
                            LargeClock(
                                modifier =
                                    Modifier.fillMaxSize().thenIf(
                                        !hasCustomPositionUpdatedAnimation
                                    ) {
                                        // If we do not have a custom position animation, we want
                                        // the clock to be on one half of the screen.
                                        Modifier.offset {
                                            IntOffset(
                                                x =
                                                    -clockSection
                                                        .getClockCenteringDistance()
                                                        .toInt(),
                                                y = 0,
                                            )
                                        }
                                    }
                            )
                        }
                    }
            scene(splitShadeSmallClockScene) {
                SmallClockWithSmartSpace(modifier = Modifier.fillMaxWidth(0.5f))
            }

                Row(
                    modifier = Modifier.fillMaxSize(),
                ) {
                    Spacer(modifier = Modifier.weight(weight = 1f))
                    with(notificationSection) {
                        Notifications(
                            modifier =
                                Modifier.fillMaxHeight()
                                    .weight(weight = 1f)
                                    .padding(top = splitShadeTopMargin)
                        )
                    }
            scene(smallClockScene) { SmallClockWithSmartSpace() }

            scene(largeClockScene) { LargeClockWithSmartSpace() }
        }
    }

            scene(splitShadeSmallClockScene) {
                Row(
                    modifier = Modifier.fillMaxSize(),
                ) {
                    Column(
                        modifier = Modifier.fillMaxHeight().weight(weight = 1f),
                        horizontalAlignment = Alignment.CenterHorizontally,
                    ) {
    @Composable
    private fun SceneScope.SmallClockWithSmartSpace(modifier: Modifier = Modifier) {
        val burnIn = rememberBurnIn(clockInteractor)

        Column(modifier = modifier) {
            with(clockSection) {
                SmallClock(
                    burnInParams = burnIn.parameters,
@@ -176,49 +109,40 @@ constructor(
            }
            with(mediaCarouselSection) { MediaCarousel() }
        }
                    with(notificationSection) {
                        Notifications(
                            modifier =
                                Modifier.fillMaxHeight()
                                    .weight(weight = 1f)
                                    .padding(top = splitShadeTopMargin)
                        )
    }

    @Composable
    private fun SceneScope.LargeClockWithSmartSpace(shouldOffSetClockToOneHalf: Boolean = false) {
        val burnIn = rememberBurnIn(clockInteractor)
        val isLargeClockVisible by clockViewModel.isLargeClockVisible.collectAsState()

        LaunchedEffect(isLargeClockVisible) {
            if (isLargeClockVisible) {
                burnIn.onSmallClockTopChanged(null)
            }
        }

            scene(smallClockScene) {
        Column {
                    with(clockSection) {
                        SmallClock(
                            burnInParams = burnIn.parameters,
                            onTopChanged = burnIn.onSmallClockTopChanged,
                            modifier = Modifier.wrapContentSize()
                        )
                    }
            with(smartSpaceSection) {
                SmartSpace(
                    burnInParams = burnIn.parameters,
                    onTopChanged = burnIn.onSmartspaceTopChanged,
                )
            }
                    with(mediaCarouselSection) { MediaCarousel() }
                    with(notificationSection) {
                        Notifications(modifier = Modifier.fillMaxWidth().weight(weight = 1f))
                    }
                }
            }

            scene(largeClockScene) {
                Column {
                    with(smartSpaceSection) {
                        SmartSpace(
                            burnInParams = burnIn.parameters,
                            onTopChanged = burnIn.onSmartspaceTopChanged,
            with(clockSection) {
                LargeClock(
                    modifier =
                        Modifier.fillMaxSize().thenIf(shouldOffSetClockToOneHalf) {
                            // If we do not have a custom position animation, we want
                            // the clock to be on one half of the screen.
                            Modifier.offset {
                                IntOffset(
                                    x = -clockSection.getClockCenteringDistance().toInt(),
                                    y = 0,
                                )
                            }
                    with(clockSection) { LargeClock(modifier = Modifier.fillMaxSize()) }
                        }
                )
            }
        }
    }
Loading