diff options
author | 2024-10-03 19:47:16 +0000 | |
---|---|---|
committer | 2024-10-03 19:47:16 +0000 | |
commit | d843f5768a570be84387463a301c20f58bb66137 (patch) | |
tree | ae14838544de61b3c87f3763bae3a7dc82f8b1c9 | |
parent | eb08e8210faa67cd05f787feb006d5183bf785bc (diff) | |
parent | 686efe65c7f7e1117ce324671f2e87c4c033b892 (diff) |
Merge "[flexiglass] Transitions for communal" into main
6 files changed, 95 insertions, 27 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt index 9d5252e05bbd..340ac326bdeb 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneContainerTransitions.kt @@ -13,6 +13,8 @@ import com.android.systemui.scene.shared.model.TransitionKeys.SlightlyFasterShad import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade import com.android.systemui.scene.ui.composable.transitions.bouncerToGoneTransition import com.android.systemui.scene.ui.composable.transitions.bouncerToLockscreenPreview +import com.android.systemui.scene.ui.composable.transitions.communalToBouncerTransition +import com.android.systemui.scene.ui.composable.transitions.communalToShadeTransition import com.android.systemui.scene.ui.composable.transitions.goneToQuickSettingsTransition import com.android.systemui.scene.ui.composable.transitions.goneToShadeTransition import com.android.systemui.scene.ui.composable.transitions.goneToSplitShadeTransition @@ -89,6 +91,8 @@ val SceneContainerTransitions = transitions { sharedElement(Notifications.Elements.NotificationStackPlaceholder, enabled = false) sharedElement(Notifications.Elements.HeadsUpNotificationPlaceholder, enabled = false) } + from(Scenes.Communal, to = Scenes.Shade) { communalToShadeTransition() } + from(Scenes.Communal, to = Scenes.Bouncer) { communalToBouncerTransition() } // Overlay transitions diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromCommunalToBouncerTransition.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromCommunalToBouncerTransition.kt new file mode 100644 index 000000000000..d7173fd3cffb --- /dev/null +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromCommunalToBouncerTransition.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.scene.ui.composable.transitions + +import com.android.compose.animation.scene.TransitionBuilder + +fun TransitionBuilder.communalToBouncerTransition() { + toBouncerTransition() +} diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromCommunalToShadeTransition.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromCommunalToShadeTransition.kt new file mode 100644 index 000000000000..ba920acec0a5 --- /dev/null +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromCommunalToShadeTransition.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.scene.ui.composable.transitions + +import com.android.compose.animation.scene.TransitionBuilder + +fun TransitionBuilder.communalToShadeTransition() { + toShadeTransition() +} diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToBouncerTransition.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToBouncerTransition.kt index 4c0efd2047ff..dd37b533ae4c 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToBouncerTransition.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/FromLockscreenToBouncerTransition.kt @@ -1,29 +1,11 @@ package com.android.systemui.scene.ui.composable.transitions import androidx.compose.animation.core.CubicBezierEasing -import androidx.compose.animation.core.tween -import androidx.compose.ui.unit.dp import com.android.compose.animation.scene.TransitionBuilder -import com.android.compose.animation.scene.UserActionDistance import com.android.systemui.bouncer.ui.composable.Bouncer -const val FROM_LOCK_SCREEN_TO_BOUNCER_FADE_FRACTION = 0.5f -const val FROM_LOCK_SCREEN_TO_BOUNCER_SWIPE_DISTANCE_FRACTION = 0.5f - fun TransitionBuilder.lockscreenToBouncerTransition() { - spec = tween(durationMillis = 500) - - distance = UserActionDistance { fromSceneSize, _ -> - fromSceneSize.height * FROM_LOCK_SCREEN_TO_BOUNCER_SWIPE_DISTANCE_FRACTION - } - - translate(Bouncer.Elements.Content, y = 300.dp) - fractionRange(end = FROM_LOCK_SCREEN_TO_BOUNCER_FADE_FRACTION) { - fade(Bouncer.Elements.Background) - } - fractionRange(start = FROM_LOCK_SCREEN_TO_BOUNCER_FADE_FRACTION) { - fade(Bouncer.Elements.Content) - } + toBouncerTransition() } fun TransitionBuilder.bouncerToLockscreenPreview() { diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/ToBouncerTransition.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/ToBouncerTransition.kt new file mode 100644 index 000000000000..de76f708c1c7 --- /dev/null +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/transitions/ToBouncerTransition.kt @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.scene.ui.composable.transitions + +import androidx.compose.animation.core.tween +import androidx.compose.ui.unit.dp +import com.android.compose.animation.scene.TransitionBuilder +import com.android.compose.animation.scene.UserActionDistance +import com.android.systemui.bouncer.ui.composable.Bouncer + +const val TO_BOUNCER_FADE_FRACTION = 0.5f +private const val TO_BOUNCER_SWIPE_DISTANCE_FRACTION = 0.5f + +fun TransitionBuilder.toBouncerTransition() { + spec = tween(durationMillis = 500) + + distance = UserActionDistance { fromSceneSize, _ -> + fromSceneSize.height * TO_BOUNCER_SWIPE_DISTANCE_FRACTION + } + + translate(Bouncer.Elements.Content, y = 300.dp) + fractionRange(end = TO_BOUNCER_FADE_FRACTION) { fade(Bouncer.Elements.Background) } + fractionRange(start = TO_BOUNCER_FADE_FRACTION) { fade(Bouncer.Elements.Content) } +} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToPrimaryBouncerTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToPrimaryBouncerTransitionViewModel.kt index c0b9efaaec01..914730e1ea4a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToPrimaryBouncerTransitionViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenToPrimaryBouncerTransitionViewModel.kt @@ -25,7 +25,7 @@ import com.android.systemui.keyguard.ui.KeyguardTransitionAnimationFlow import com.android.systemui.keyguard.ui.transitions.DeviceEntryIconTransition import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.scene.shared.model.Scenes -import com.android.systemui.scene.ui.composable.transitions.FROM_LOCK_SCREEN_TO_BOUNCER_FADE_FRACTION +import com.android.systemui.scene.ui.composable.transitions.TO_BOUNCER_FADE_FRACTION import javax.inject.Inject import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -49,14 +49,12 @@ constructor( duration = FromLockscreenTransitionInteractor.TO_PRIMARY_BOUNCER_DURATION, edge = Edge.create(from = LOCKSCREEN, to = Scenes.Bouncer), ) - .setupWithoutSceneContainer( - edge = Edge.create(from = LOCKSCREEN, to = PRIMARY_BOUNCER), - ) + .setupWithoutSceneContainer(edge = Edge.create(from = LOCKSCREEN, to = PRIMARY_BOUNCER)) private val alphaForAnimationStep: (Float) -> Float = when { SceneContainerFlag.isEnabled -> { step -> - 1f - Math.min((step / FROM_LOCK_SCREEN_TO_BOUNCER_FADE_FRACTION), 1f) + 1f - Math.min((step / TO_BOUNCER_FADE_FRACTION), 1f) } else -> { step -> 1f - step } } @@ -64,7 +62,7 @@ constructor( val shortcutsAlpha: Flow<Float> = transitionAnimation.sharedFlow( duration = FromLockscreenTransitionInteractor.TO_PRIMARY_BOUNCER_DURATION, - onStep = alphaForAnimationStep + onStep = alphaForAnimationStep, ) val lockscreenAlpha: Flow<Float> = shortcutsAlpha @@ -76,8 +74,8 @@ constructor( duration = 250.milliseconds, onStep = { 1f - it }, onCancel = { 0f }, - onFinish = { 0f } + onFinish = { 0f }, ), - flowWhenShadeIsExpanded = transitionAnimation.immediatelyTransitionTo(0f) + flowWhenShadeIsExpanded = transitionAnimation.immediatelyTransitionTo(0f), ) } |