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

Commit 11611d23 authored by Danny Burakov's avatar Danny Burakov Committed by Android (Google) Code Review
Browse files

Merge "[Dual Shade] Define the user action distance for the notification shade." into main

parents 016826ea ebbc30cf
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -17,8 +17,11 @@
package com.android.systemui.scene.ui.composable.transitions

import androidx.compose.animation.core.tween
import com.android.compose.animation.scene.ContentKey
import com.android.compose.animation.scene.Edge
import com.android.compose.animation.scene.TransitionBuilder
import com.android.compose.animation.scene.UserActionDistance
import com.android.compose.animation.scene.UserActionDistanceScope
import com.android.systemui.keyguard.ui.composable.blueprint.ClockElementKeys
import com.android.systemui.notifications.ui.composable.Notifications
import com.android.systemui.notifications.ui.composable.NotificationsShade
@@ -28,6 +31,10 @@ import kotlin.time.Duration.Companion.milliseconds

fun TransitionBuilder.toNotificationsShadeTransition(durationScale: Double = 1.0) {
    spec = tween(durationMillis = (DefaultDuration * durationScale).inWholeMilliseconds.toInt())
    distance = UserActionDistance { _, shadeContentKey, _ ->
        calculateShadePanelTargetPositionY(shadeContentKey)
    }

    // Ensure the clock isn't clipped by the shade outline during the transition from lockscreen.
    sharedElement(
        ClockElementKeys.smallClockElementKey,
@@ -43,4 +50,12 @@ fun TransitionBuilder.toNotificationsShadeTransition(durationScale: Double = 1.0
    fractionRange(start = .5f) { fade(Notifications.Elements.NotificationScrim) }
}

/** Returns the Y position of the bottom of the shade container panel within [shadeOverlayKey]. */
fun UserActionDistanceScope.calculateShadePanelTargetPositionY(shadeOverlayKey: ContentKey): Float {
    val marginTop = OverlayShade.Elements.Panel.targetOffset(shadeOverlayKey)?.y ?: 0f
    val panelHeight =
        OverlayShade.Elements.Panel.targetSize(shadeOverlayKey)?.height?.toFloat() ?: 0f
    return marginTop + panelHeight
}

private val DefaultDuration = 300.milliseconds
+2 −3
Original line number Diff line number Diff line
@@ -25,9 +25,8 @@ import kotlin.time.Duration.Companion.milliseconds

fun TransitionBuilder.toQuickSettingsShadeTransition(durationScale: Double = 1.0) {
    spec = tween(durationMillis = (DefaultDuration * durationScale).inWholeMilliseconds.toInt())
    distance = UserActionDistance { fromContent, _, _ ->
        val fromContentSize = checkNotNull(fromContent.targetSize())
        fromContentSize.height.toFloat() * 2 / 3f
    distance = UserActionDistance { _, shadeContentKey, _ ->
        calculateShadePanelTargetPositionY(shadeContentKey)
    }

    translate(OverlayShade.Elements.Panel, Edge.Top)