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

Commit 0e19a294 authored by Lucas Silva's avatar Lucas Silva
Browse files

Allow swipe from lockscreen->hub when postured/charging

This change allows swiping from the lockscreen to the hub if the hub
condition is met (postured/charging/docked). It also re-adds a proper
swipe transition to translate the elements of the hub correctly.

Bug: 393365531
Test: mp droid and verified gestures
Test: atest GlanceableHubContainerControllerTest
Flag: com.android.systemui.glanceable_hub_v2
Change-Id: Ibfd9f479b7201e299d1031d4acf42e22ca1c3c5b
parent 38a9eca9
Loading
Loading
Loading
Loading
+34 −4
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.compose.animation.scene.MutableSceneTransitionLayoutState
import com.android.compose.animation.scene.SceneKey
import com.android.compose.animation.scene.SceneKey
import com.android.compose.animation.scene.SceneTransitionLayout
import com.android.compose.animation.scene.SceneTransitionLayout
import com.android.compose.animation.scene.Swipe
import com.android.compose.animation.scene.Swipe
import com.android.compose.animation.scene.UserActionResult
import com.android.compose.animation.scene.observableTransitionState
import com.android.compose.animation.scene.observableTransitionState
import com.android.compose.animation.scene.rememberMutableSceneTransitionLayoutState
import com.android.compose.animation.scene.rememberMutableSceneTransitionLayoutState
import com.android.compose.animation.scene.transitions
import com.android.compose.animation.scene.transitions
@@ -87,10 +88,26 @@ val sceneTransitionsV2 = transitions {
        spec = tween(durationMillis = TransitionDuration.TO_GLANCEABLE_HUB_DURATION_MS)
        spec = tween(durationMillis = TransitionDuration.TO_GLANCEABLE_HUB_DURATION_MS)
        fade(AllElements)
        fade(AllElements)
    }
    }
    to(CommunalScenes.Communal, key = CommunalTransitionKeys.Swipe) {
        spec = tween(durationMillis = TransitionDuration.TO_GLANCEABLE_HUB_DURATION_MS)
        translate(Communal.Elements.Grid, Edge.End)
        timestampRange(startMillis = 167, endMillis = 334) { fade(AllElements) }
    }
    to(CommunalScenes.Blank) {
    to(CommunalScenes.Blank) {
        spec = tween(durationMillis = TO_GONE_DURATION.toInt(DurationUnit.MILLISECONDS))
        spec = tween(durationMillis = TO_GONE_DURATION.toInt(DurationUnit.MILLISECONDS))
        fade(AllElements)
        fade(AllElements)
    }
    }
    to(CommunalScenes.Blank, key = CommunalTransitionKeys.Swipe) {
        spec = tween(durationMillis = TransitionDuration.TO_GLANCEABLE_HUB_DURATION_MS)
        translate(Communal.Elements.Grid, Edge.End)
        timestampRange(endMillis = 167) {
            fade(Communal.Elements.Grid)
            fade(Communal.Elements.IndicationArea)
            fade(Communal.Elements.LockIcon)
            fade(Communal.Elements.StatusBar)
        }
        timestampRange(startMillis = 167, endMillis = 334) { fade(Communal.Elements.Scrim) }
    }
}
}


val sceneTransitions = transitions {
val sceneTransitions = transitions {
@@ -165,6 +182,7 @@ fun CommunalContainer(
        viewModel.communalBackground.collectAsStateWithLifecycle(
        viewModel.communalBackground.collectAsStateWithLifecycle(
            initialValue = CommunalBackgroundType.ANIMATED
            initialValue = CommunalBackgroundType.ANIMATED
        )
        )
    val swipeToHubEnabled by viewModel.swipeToHubEnabled.collectAsStateWithLifecycle()
    val state: MutableSceneTransitionLayoutState =
    val state: MutableSceneTransitionLayoutState =
        rememberMutableSceneTransitionLayoutState(
        rememberMutableSceneTransitionLayoutState(
            initialScene = currentSceneKey,
            initialScene = currentSceneKey,
@@ -200,15 +218,27 @@ fun CommunalContainer(
        scene(
        scene(
            CommunalScenes.Blank,
            CommunalScenes.Blank,
            userActions =
            userActions =
                if (viewModel.swipeToHubEnabled())
                if (swipeToHubEnabled) {
                    mapOf(Swipe.Start(fromSource = Edge.End) to CommunalScenes.Communal)
                    mapOf(
                else emptyMap(),
                        Swipe.Start(fromSource = Edge.End) to
                            UserActionResult(CommunalScenes.Communal, CommunalTransitionKeys.Swipe)
                    )
                } else {
                    emptyMap()
                },
        ) {
        ) {
            // This scene shows nothing only allowing for transitions to the communal scene.
            // This scene shows nothing only allowing for transitions to the communal scene.
            Box(modifier = Modifier.fillMaxSize())
            Box(modifier = Modifier.fillMaxSize())
        }
        }


        scene(CommunalScenes.Communal, userActions = mapOf(Swipe.End to CommunalScenes.Blank)) {
        scene(
            CommunalScenes.Communal,
            userActions =
                mapOf(
                    Swipe.End to
                        UserActionResult(CommunalScenes.Blank, CommunalTransitionKeys.Swipe)
                ),
        ) {
            CommunalScene(
            CommunalScene(
                backgroundType = backgroundType,
                backgroundType = backgroundType,
                colors = colors,
                colors = colors,
+2 −0
Original line number Original line Diff line number Diff line
@@ -31,4 +31,6 @@ object CommunalTransitionKeys {
    val ToEditMode = TransitionKey("ToEditMode")
    val ToEditMode = TransitionKey("ToEditMode")
    /** Transition to the glanceable hub after exiting edit mode */
    /** Transition to the glanceable hub after exiting edit mode */
    val FromEditMode = TransitionKey("FromEditMode")
    val FromEditMode = TransitionKey("FromEditMode")
    /** Swipes the glanceable hub in/out of view */
    val Swipe = TransitionKey("Swipe")
}
}
+7 −1
Original line number Original line Diff line number Diff line
@@ -359,7 +359,13 @@ constructor(
    /** See [CommunalSettingsInteractor.isV2FlagEnabled] */
    /** See [CommunalSettingsInteractor.isV2FlagEnabled] */
    fun v2FlagEnabled(): Boolean = communalSettingsInteractor.isV2FlagEnabled()
    fun v2FlagEnabled(): Boolean = communalSettingsInteractor.isV2FlagEnabled()


    fun swipeToHubEnabled(): Boolean = swipeToHub
    val swipeToHubEnabled: StateFlow<Boolean> by lazy {
        if (v2FlagEnabled()) {
            communalInteractor.shouldShowCommunal
        } else {
            MutableStateFlow(swipeToHub)
        }
    }


    companion object {
    companion object {
        const val POPUP_AUTO_HIDE_TIMEOUT_MS = 12000L
        const val POPUP_AUTO_HIDE_TIMEOUT_MS = 12000L
+5 −4
Original line number Original line Diff line number Diff line
@@ -231,6 +231,9 @@ constructor(
     */
     */
    private var isDreaming = false
    private var isDreaming = false


    /** True if we should allow swiping open the glanceable hub. */
    private var swipeToHubEnabled = false

    /** Observes and logs state when the lifecycle that controls the [touchMonitor] updates. */
    /** Observes and logs state when the lifecycle that controls the [touchMonitor] updates. */
    private val touchLifecycleLogger: LifecycleObserver = LifecycleEventObserver { _, event ->
    private val touchLifecycleLogger: LifecycleObserver = LifecycleEventObserver { _, event ->
        logger.d({
        logger.d({
@@ -438,6 +441,7 @@ constructor(
            },
            },
        )
        )
        collectFlow(containerView, keyguardInteractor.isDreaming, { isDreaming = it })
        collectFlow(containerView, keyguardInteractor.isDreaming, { isDreaming = it })
        collectFlow(containerView, communalViewModel.swipeToHubEnabled, { swipeToHubEnabled = it })


        communalContainerWrapper = CommunalWrapper(containerView.context)
        communalContainerWrapper = CommunalWrapper(containerView.context)
        communalContainerWrapper?.addView(communalContainerView)
        communalContainerWrapper?.addView(communalContainerView)
@@ -520,10 +524,7 @@ constructor(
        val glanceableHubV2 = communalSettingsInteractor.isV2FlagEnabled()
        val glanceableHubV2 = communalSettingsInteractor.isV2FlagEnabled()
        if (
        if (
            !hubShowing &&
            !hubShowing &&
                (touchOnNotifications ||
                (touchOnNotifications || touchOnUmo || touchOnSmartspace || !swipeToHubEnabled)
                    touchOnUmo ||
                    touchOnSmartspace ||
                    !communalViewModel.swipeToHubEnabled())
        ) {
        ) {
            logger.d({
            logger.d({
                "Lockscreen touch ignored: touchOnNotifications: $bool1, touchOnUmo: $bool2, " +
                "Lockscreen touch ignored: touchOnNotifications: $bool1, touchOnUmo: $bool2, " +
+375 −470

File changed.

Preview size limit exceeded, changes collapsed.