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

Commit 59bb8822 authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Automerger Merge Worker
Browse files

Merge "[flexiglass] Scalable scene transition definitions in Flexiglass." into...

Merge "[flexiglass] Scalable scene transition definitions in Flexiglass." into udc-qpr-dev am: c1adfb30

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24405059



Change-Id: I44faca58dd94dd030b5ce9dc5abf0678c822b3e4
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c7b7bb27 c1adfb30
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -37,7 +37,14 @@ sealed class Key(val name: String, val identity: Any) {
}
}


/** Key for a scene. */
/** Key for a scene. */
class SceneKey(name: String, identity: Any = Object()) : Key(name, identity) {
class SceneKey(
    name: String,
    identity: Any = Object(),
) : Key(name, identity) {

    /** The unique [ElementKey] identifying this scene's root element. */
    val rootElementKey = ElementKey(name, identity)

    override fun toString(): String {
    override fun toString(): String {
        return "SceneKey(name=$name)"
        return "SceneKey(name=$name)"
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -35,7 +35,7 @@ import com.android.compose.ui.util.fastMap


/** The transitions configuration of a [SceneTransitionLayout]. */
/** The transitions configuration of a [SceneTransitionLayout]. */
class SceneTransitions(
class SceneTransitions(
    val transitionSpecs: List<TransitionSpec>,
    private val transitionSpecs: List<TransitionSpec>,
) {
) {
    private val cache = mutableMapOf<SceneKey, MutableMap<SceneKey, TransitionSpec>>()
    private val cache = mutableMapOf<SceneKey, MutableMap<SceneKey, TransitionSpec>>()


+1 −1
Original line number Original line Diff line number Diff line
@@ -75,7 +75,7 @@ private class SceneTransitionsBuilderImpl : SceneTransitionsBuilder {
    }
    }
}
}


private class TransitionBuilderImpl : TransitionBuilder {
internal class TransitionBuilderImpl : TransitionBuilder {
    val transformations = mutableListOf<Transformation>()
    val transformations = mutableListOf<Transformation>()
    override var spec: AnimationSpec<Float> = spring(stiffness = Spring.StiffnessLow)
    override var spec: AnimationSpec<Float> = spring(stiffness = Spring.StiffnessLow)


+86 −72
Original line number Original line Diff line number Diff line
@@ -24,7 +24,7 @@ import android.content.DialogInterface
import androidx.compose.animation.Crossfade
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.snap
import androidx.compose.animation.core.snap
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Column
@@ -46,6 +46,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.SceneScope
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.R
import com.android.systemui.R
import com.android.systemui.bouncer.ui.viewmodel.AuthMethodBouncerViewModel
import com.android.systemui.bouncer.ui.viewmodel.AuthMethodBouncerViewModel
@@ -63,6 +64,13 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.asStateFlow


object Bouncer {
    object Elements {
        val Background = ElementKey("BouncerBackground")
        val Content = ElementKey("BouncerContent")
    }
}

/** The bouncer scene displays authentication challenges like PIN, password, or pattern. */
/** The bouncer scene displays authentication challenges like PIN, password, or pattern. */
@SysUISingleton
@SysUISingleton
class BouncerScene
class BouncerScene
@@ -88,7 +96,7 @@ constructor(
}
}


@Composable
@Composable
private fun BouncerScene(
private fun SceneScope.BouncerScene(
    viewModel: BouncerViewModel,
    viewModel: BouncerViewModel,
    dialogFactory: BouncerSceneDialogFactory,
    dialogFactory: BouncerSceneDialogFactory,
    modifier: Modifier = Modifier,
    modifier: Modifier = Modifier,
@@ -97,14 +105,19 @@ private fun BouncerScene(
    val authMethodViewModel: AuthMethodBouncerViewModel? by viewModel.authMethod.collectAsState()
    val authMethodViewModel: AuthMethodBouncerViewModel? by viewModel.authMethod.collectAsState()
    val dialogMessage: String? by viewModel.throttlingDialogMessage.collectAsState()
    val dialogMessage: String? by viewModel.throttlingDialogMessage.collectAsState()
    var dialog: Dialog? by remember { mutableStateOf(null) }
    var dialog: Dialog? by remember { mutableStateOf(null) }
    val backgroundColor = MaterialTheme.colorScheme.surface

    Box(modifier) {
        Canvas(Modifier.element(Bouncer.Elements.Background).fillMaxSize()) {
            drawRect(color = backgroundColor)
        }


        Column(
        Column(
            horizontalAlignment = Alignment.CenterHorizontally,
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.spacedBy(60.dp),
            verticalArrangement = Arrangement.spacedBy(60.dp),
            modifier =
            modifier =
            modifier
                Modifier.element(Bouncer.Elements.Content)
                    .fillMaxSize()
                    .fillMaxSize()
                .background(MaterialTheme.colorScheme.surface)
                    .padding(start = 32.dp, top = 92.dp, end = 32.dp, bottom = 32.dp)
                    .padding(start = 32.dp, top = 92.dp, end = 32.dp, bottom = 32.dp)
        ) {
        ) {
            Crossfade(
            Crossfade(
@@ -178,6 +191,7 @@ private fun BouncerScene(
            }
            }
        }
        }
    }
    }
}


interface BouncerSceneDialogFactory {
interface BouncerSceneDialogFactory {
    operator fun invoke(): AlertDialog
    operator fun invoke(): AlertDialog
+9 −1
Original line number Original line Diff line number Diff line
@@ -31,9 +31,17 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.dp
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.SceneScope

object Notifications {
    object Elements {
        val Notifications = ElementKey("Notifications")
    }
}


@Composable
@Composable
fun Notifications(
fun SceneScope.Notifications(
    modifier: Modifier = Modifier,
    modifier: Modifier = Modifier,
) {
) {
    // TODO(b/272779828): implement.
    // TODO(b/272779828): implement.
Loading