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

Commit a528bda1 authored by omarmt's avatar omarmt
Browse files

Cleanup NestedScrollSource.Drag usages

Drag and UserInput are exactly the same

```kotlin
/** Dragging via mouse/touch/etc events. */
@Deprecated(
    "This has been replaced by UserInput.",
    replaceWith =
        ReplaceWith(
            "NestedScrollSource.UserInput",
            "import androidx.compose.ui.input.nestedscroll." +
                "NestedScrollSource.Companion.UserInput"
        )
)
val Drag: NestedScrollSource = UserInput
```

Test: No tests
Bug: 371984715
Flag: com.android.systemui.scene_container
Change-Id: Iac0324f863c52273b9e72392a4168e78a7008685
parent bea86c1d
Loading
Loading
Loading
Loading
+9 −21
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import androidx.compose.foundation.gestures.Orientation
import androidx.compose.material3.Text
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
import androidx.compose.ui.input.nestedscroll.NestedScrollSource.Companion.UserInput
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.LayoutDirection
@@ -294,15 +294,10 @@ class DraggableHandlerTest {
            available: Offset,
            consumedByScroll: Offset = Offset.Zero,
        ) {
            val consumedByPreScroll =
                onPreScroll(available = available, source = NestedScrollSource.Drag)
            val consumedByPreScroll = onPreScroll(available = available, source = UserInput)
            val consumed = consumedByPreScroll + consumedByScroll

            onPostScroll(
                consumed = consumed,
                available = available - consumed,
                source = NestedScrollSource.Drag,
            )
            onPostScroll(consumed = consumed, available = available - consumed, source = UserInput)
        }

        fun NestedScrollConnection.preFling(
@@ -738,7 +733,7 @@ class DraggableHandlerTest {
        val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview)
        nestedScroll.onPreScroll(
            available = downOffset(fractionOfScreen = 0.1f),
            source = NestedScrollSource.Drag,
            source = UserInput,
        )
        assertIdle(currentScene = SceneA)
    }
@@ -750,7 +745,7 @@ class DraggableHandlerTest {
            nestedScroll.onPostScroll(
                consumed = Offset.Zero,
                available = Offset.Zero,
                source = NestedScrollSource.Drag,
                source = UserInput,
            )

        assertIdle(currentScene = SceneA)
@@ -764,7 +759,7 @@ class DraggableHandlerTest {
            nestedScroll.onPostScroll(
                consumed = Offset.Zero,
                available = downOffset(fractionOfScreen = 0.1f),
                source = NestedScrollSource.Drag,
                source = UserInput,
            )

        assertTransition(currentScene = SceneA)
@@ -784,16 +779,12 @@ class DraggableHandlerTest {
        val consumed =
            nestedScroll.onPreScroll(
                available = downOffset(fractionOfScreen = 0.1f),
                source = NestedScrollSource.Drag,
                source = UserInput,
            )
        assertThat(progress).isEqualTo(0.2f)

        // do nothing on postScroll
        nestedScroll.onPostScroll(
            consumed = consumed,
            available = Offset.Zero,
            source = NestedScrollSource.Drag,
        )
        nestedScroll.onPostScroll(consumed = consumed, available = Offset.Zero, source = UserInput)
        assertThat(progress).isEqualTo(0.2f)

        nestedScroll.scroll(available = downOffset(fractionOfScreen = 0.1f))
@@ -813,10 +804,7 @@ class DraggableHandlerTest {
        nestedScroll.preFling(available = Velocity.Zero)

        // a pre scroll event, that could be intercepted by DraggableHandlerImpl
        nestedScroll.onPreScroll(
            available = Offset(0f, secondScroll),
            source = NestedScrollSource.Drag,
        )
        nestedScroll.onPreScroll(available = Offset(0f, secondScroll), source = UserInput)
    }

    @Test
+15 −42
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package com.android.systemui.statusbar.notification

import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
import androidx.compose.ui.input.nestedscroll.NestedScrollSource.Companion.UserInput
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
@@ -58,10 +58,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
        contentHeight = COLLAPSED_CONTENT_HEIGHT

        val offsetConsumed =
            scrollConnection.onPreScroll(
                available = Offset(x = 0f, y = -1f),
                source = NestedScrollSource.Drag,
            )
            scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput)

        assertThat(offsetConsumed).isEqualTo(Offset.Zero)
        assertThat(isStarted).isEqualTo(false)
@@ -73,10 +70,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
        scrimOffset = MIN_SCRIM_OFFSET

        val offsetConsumed =
            scrollConnection.onPreScroll(
                available = Offset(x = 0f, y = -1f),
                source = NestedScrollSource.Drag,
            )
            scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput)

        assertThat(offsetConsumed).isEqualTo(Offset.Zero)
        assertThat(isStarted).isEqualTo(false)
@@ -88,10 +82,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {

        val availableOffset = Offset(x = 0f, y = -1f)
        val offsetConsumed =
            scrollConnection.onPreScroll(
                available = availableOffset,
                source = NestedScrollSource.Drag,
            )
            scrollConnection.onPreScroll(available = availableOffset, source = UserInput)

        assertThat(offsetConsumed).isEqualTo(availableOffset)
        assertThat(isStarted).isEqualTo(true)
@@ -105,10 +96,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
        val availableOffset = Offset(x = 0f, y = -2f)
        val consumableOffset = Offset(x = 0f, y = -1f)
        val offsetConsumed =
            scrollConnection.onPreScroll(
                available = availableOffset,
                source = NestedScrollSource.Drag,
            )
            scrollConnection.onPreScroll(available = availableOffset, source = UserInput)

        assertThat(offsetConsumed).isEqualTo(consumableOffset)
        assertThat(isStarted).isEqualTo(true)
@@ -120,7 +108,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
            scrollConnection.onPostScroll(
                consumed = Offset.Zero,
                available = Offset(x = 0f, y = -1f),
                source = NestedScrollSource.Drag,
                source = UserInput,
            )

        assertThat(offsetConsumed).isEqualTo(Offset.Zero)
@@ -130,10 +118,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
    @Test
    fun onScrollDown_canStartPreScroll_ignoreScroll() = runTest {
        val offsetConsumed =
            scrollConnection.onPreScroll(
                available = Offset(x = 0f, y = 1f),
                source = NestedScrollSource.Drag,
            )
            scrollConnection.onPreScroll(available = Offset(x = 0f, y = 1f), source = UserInput)

        assertThat(offsetConsumed).isEqualTo(Offset.Zero)
        assertThat(isStarted).isEqualTo(false)
@@ -148,7 +133,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
            scrollConnection.onPostScroll(
                consumed = Offset.Zero,
                available = availableOffset,
                source = NestedScrollSource.Drag
                source = UserInput,
            )

        assertThat(offsetConsumed).isEqualTo(availableOffset)
@@ -165,7 +150,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
            scrollConnection.onPostScroll(
                consumed = Offset.Zero,
                available = availableOffset,
                source = NestedScrollSource.Drag
                source = UserInput,
            )

        assertThat(offsetConsumed).isEqualTo(consumableOffset)
@@ -180,7 +165,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
            scrollConnection.onPostScroll(
                consumed = Offset.Zero,
                available = Offset(x = 0f, y = 1f),
                source = NestedScrollSource.Drag
                source = UserInput,
            )

        assertThat(offsetConsumed).isEqualTo(Offset.Zero)
@@ -197,7 +182,7 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
            scrollConnection.onPostScroll(
                consumed = Offset.Zero,
                available = Offset(x = 0f, y = 1f),
                source = NestedScrollSource.Drag
                source = UserInput,
            )

        assertThat(offsetConsumed).isEqualTo(Offset.Zero)
@@ -210,17 +195,11 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
    fun canContinueScroll_inBetweenMinMaxOffset_true() = runTest {
        scrimOffset = (MIN_SCRIM_OFFSET + MAX_SCRIM_OFFSET) / 2f
        contentHeight = EXPANDED_CONTENT_HEIGHT
        scrollConnection.onPreScroll(
            available = Offset(x = 0f, y = -1f),
            source = NestedScrollSource.Drag
        )
        scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput)

        assertThat(isStarted).isEqualTo(true)

        scrollConnection.onPreScroll(
            available = Offset(x = 0f, y = 1f),
            source = NestedScrollSource.Drag
        )
        scrollConnection.onPreScroll(available = Offset(x = 0f, y = 1f), source = UserInput)

        assertThat(isStarted).isEqualTo(true)
    }
@@ -229,17 +208,11 @@ class NotificationScrimNestedScrollConnectionTest : SysuiTestCase() {
    fun canContinueScroll_atMaxOffset_false() = runTest {
        scrimOffset = MAX_SCRIM_OFFSET
        contentHeight = EXPANDED_CONTENT_HEIGHT
        scrollConnection.onPreScroll(
            available = Offset(x = 0f, y = -1f),
            source = NestedScrollSource.Drag
        )
        scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = UserInput)

        assertThat(isStarted).isEqualTo(true)

        scrollConnection.onPreScroll(
            available = Offset(x = 0f, y = 1f),
            source = NestedScrollSource.Drag
        )
        scrollConnection.onPreScroll(available = Offset(x = 0f, y = 1f), source = UserInput)

        assertThat(isStarted).isEqualTo(false)
    }