diff options
| author | 2024-10-16 12:32:48 +0000 | |
|---|---|---|
| committer | 2024-10-18 15:34:24 +0000 | |
| commit | a528bda1b1a2543a42d63a172e88eaa43da08be2 (patch) | |
| tree | 363e82f44b07cda0921590d29163828cb37f4d2c | |
| parent | bea86c1dbcd7640f675a125733628584a4fb95d3 (diff) | |
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
2 files changed, 24 insertions, 63 deletions
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt index a0fed9064181..339445e3483a 100644 --- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt +++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt @@ -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 diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt index 97fa6eb17b5b..75479ad35725 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/NotificationScrimNestedScrollConnectionTest.kt @@ -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) } |