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

Commit c7f817b5 authored by omarmt's avatar omarmt
Browse files

STL remove PriorityNestedScrollConnection.canStartPostFling

This will be converted to an OverscrollEffect in a later CL.

For more information, see b/378470603

Test: Removed canStartPostFling tests.
Test: Manually tested on Flexiglass.
Bug: 378470603
Flag: com.android.systemui.scene_container
Change-Id: Ib99a12e28a3b5441a55a823ac3c7bee04139a1a8
parent 1be1da96
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ fun NotificationScrimNestedScrollConnection(
        canStartPostScroll = { offsetAvailable, _, _ ->
            offsetAvailable > 0 && (scrimOffset() < maxScrimOffset || isCurrentGestureOverscroll())
        },
        canStartPostFling = { false },
        onStart = { firstScroll ->
            onStart(firstScroll)
            object : ScrollController {
+25 −4
Original line number Diff line number Diff line
@@ -25,11 +25,13 @@ import androidx.compose.foundation.layout.offset
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.Velocity
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastCoerceAtLeast
import com.android.compose.nestedscroll.OnStopScope
@@ -80,9 +82,29 @@ fun Modifier.stackVerticalOverscroll(
        }

    return this.then(
        Modifier.nestedScroll(stackNestedScrollConnection).offset {
            IntOffset(x = 0, y = overscrollOffset.value.roundToInt())
        Modifier.nestedScroll(
                remember {
                    object : NestedScrollConnection {
                        override suspend fun onPostFling(
                            consumed: Velocity,
                            available: Velocity,
                        ): Velocity {
                            return if (available.y < 0f && !canScrollForward()) {
                                overscrollOffset.animateTo(
                                    targetValue = 0f,
                                    initialVelocity = available.y,
                                    animationSpec = tween(),
                                )
                                available
                            } else {
                                Velocity.Zero
                            }
                        }
                    }
                }
            )
            .nestedScroll(stackNestedScrollConnection)
            .offset { IntOffset(x = 0, y = overscrollOffset.value.roundToInt()) }
    )
}

@@ -100,7 +122,6 @@ fun NotificationStackNestedScrollConnection(
        canStartPostScroll = { offsetAvailable, offsetBeforeStart, _ ->
            offsetAvailable < 0f && offsetBeforeStart < 0f && !canScrollForward()
        },
        canStartPostFling = { velocityAvailable -> velocityAvailable < 0f && !canScrollForward() },
        onStart = { firstScroll ->
            onStart(firstScroll)
            object : ScrollController {
+0 −25
Original line number Diff line number Diff line
@@ -536,31 +536,6 @@ internal class NestedScrollHandlerImpl(
                    }
                }
            },
            canStartPostFling = { velocityAvailable ->
                val behavior: NestedScrollBehavior =
                    when {
                        velocityAvailable > 0f -> topOrLeftBehavior
                        velocityAvailable < 0f -> bottomOrRightBehavior
                        else -> return@PriorityNestedScrollConnection false
                    }

                // We could start an overscroll animation
                canChangeScene = false

                val pointersDown: PointersInfo.PointersDown? =
                    when (val info = pointersInfoOwner.pointersInfo()) {
                        PointersInfo.MouseWheel -> {
                            // Do not support mouse wheel interactions
                            return@PriorityNestedScrollConnection false
                        }

                        is PointersInfo.PointersDown -> info
                        null -> null
                    }
                lastPointersDown = pointersDown

                behavior.canStartOnPostFling && shouldEnableSwipes()
            },
            onStart = { firstScroll ->
                scrollController(
                    dragController =
+4 −4
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import androidx.compose.ui.platform.InspectorInfo
 * not consumed by the [SceneTransitionLayout] unless specifically requested via
 * [nestedScrollToScene].
 */
enum class NestedScrollBehavior(val canStartOnPostFling: Boolean) {
enum class NestedScrollBehavior {
    /**
     * Overscroll will only be used by the [SceneTransitionLayout] to move to the next scene if the
     * gesture begins at the edge of the scrollable component (so that a scroll in that direction
@@ -42,7 +42,7 @@ enum class NestedScrollBehavior(val canStartOnPostFling: Boolean) {
     * In addition, during scene transitions, scroll events are consumed by the
     * [SceneTransitionLayout] instead of the scrollable component.
     */
    EdgeNoPreview(canStartOnPostFling = false),
    EdgeNoPreview,

    /**
     * Overscroll will only be used by the [SceneTransitionLayout] to move to the next scene if the
@@ -52,7 +52,7 @@ enum class NestedScrollBehavior(val canStartOnPostFling: Boolean) {
     * In addition, during scene transitions, scroll events are consumed by the
     * [SceneTransitionLayout] instead of the scrollable component.
     */
    EdgeWithPreview(canStartOnPostFling = true),
    @Deprecated("This will be removed, see b/378470603") EdgeWithPreview,

    /**
     * Any overscroll will be used by the [SceneTransitionLayout] to move to the next scene.
@@ -60,7 +60,7 @@ enum class NestedScrollBehavior(val canStartOnPostFling: Boolean) {
     * In addition, during scene transitions, scroll events are consumed by the
     * [SceneTransitionLayout] instead of the scrollable component.
     */
    EdgeAlways(canStartOnPostFling = true);
    EdgeAlways;

    companion object {
        val Default = EdgeNoPreview
+0 −1
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ fun LargeTopAppBarNestedScrollConnection(
        canStartPostScroll = { offsetAvailable, _, _ ->
            offsetAvailable > 0 && height() < maxHeight()
        },
        canStartPostFling = { false },
        onStart = {
            LargeTopAppBarScrollController(
                height = height,
Loading