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

Commit e7a4f39a authored by 0's avatar 0 Committed by Shawn Lee
Browse files

[flexiglass] Expose NestedScrollSource in PriorityNestedScrollConnection API

This allows us to define a different check for when we are scrolling from a fling; an example is an overscroll boundary past which the fling-driven motion should end and onStop should be called, whereas if the motion is drag-driven the overscroll should ignore the boundary and continue until the finger is lifted.

Bug: 332569054
Test: verified manually that canContinueScroll implementations can access NestedScrollSource
Flag: com.android.systemui.scene_container
Change-Id: I9ab4950ad8a6f7908253f10e90d55c8d1473cd42
parent 34df8bb9
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ class PriorityNestedScrollConnection(
    private val canStartPreScroll: (offsetAvailable: Offset, offsetBeforeStart: Offset) -> Boolean,
    private val canStartPostScroll: (offsetAvailable: Offset, offsetBeforeStart: Offset) -> Boolean,
    private val canStartPostFling: (velocityAvailable: Velocity) -> Boolean,
    private val canContinueScroll: () -> Boolean,
    private val canContinueScroll: (source: NestedScrollSource) -> Boolean,
    private val canScrollOnFling: Boolean,
    private val onStart: (offsetAvailable: Offset) -> Unit,
    private val onScroll: (offsetAvailable: Offset) -> Offset,
@@ -61,7 +61,7 @@ class PriorityNestedScrollConnection(

        if (
            isPriorityMode ||
                (source == NestedScrollSource.Fling && !canScrollOnFling) ||
                (source == NestedScrollSource.SideEffect && !canScrollOnFling) ||
                !canStartPostScroll(available, offsetBeforeStart)
        ) {
            // The priority mode cannot start so we won't consume the available offset.
@@ -73,7 +73,7 @@ class PriorityNestedScrollConnection(

    override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
        if (!isPriorityMode) {
            if (source != NestedScrollSource.Fling || canScrollOnFling) {
            if (source == NestedScrollSource.UserInput || canScrollOnFling) {
                if (canStartPreScroll(available, offsetScrolledBeforePriorityMode)) {
                    return onPriorityStart(available)
                }
@@ -84,7 +84,7 @@ class PriorityNestedScrollConnection(
            return Offset.Zero
        }

        if (!canContinueScroll()) {
        if (!canContinueScroll(source)) {
            // Step 3a: We have lost priority and we no longer need to intercept scroll events.
            onPriorityStop(velocity = Velocity.Zero)

@@ -170,7 +170,7 @@ fun PriorityNestedScrollConnection(
    canStartPreScroll: (offsetAvailable: Float, offsetBeforeStart: Float) -> Boolean,
    canStartPostScroll: (offsetAvailable: Float, offsetBeforeStart: Float) -> Boolean,
    canStartPostFling: (velocityAvailable: Float) -> Boolean,
    canContinueScroll: () -> Boolean,
    canContinueScroll: (source: NestedScrollSource) -> Boolean,
    canScrollOnFling: Boolean,
    onStart: (offsetAvailable: Float) -> Unit,
    onScroll: (offsetAvailable: Float) -> Float,
+1 −1

File changed.

Contains only whitespace changes.