Merge "New naming for NestedScrollBehavior" into main
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt
index 2986504..ded6cc1 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/NestedScrollToScene.kt
@@ -44,22 +44,22 @@
* 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
* can no longer be consumed). If the gesture is partially consumed by the scrollable component,
- * there will be NO overscroll effect between scenes.
+ * there will be NO preview of the next scene.
*
* In addition, during scene transitions, scroll events are consumed by the
* [SceneTransitionLayout] instead of the scrollable component.
*/
- EdgeNoOverscroll(canStartOnPostFling = false),
+ EdgeNoPreview(canStartOnPostFling = false),
/**
* 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. If the gesture is partially consumed
- * by the scrollable component, there will be an overscroll effect between scenes.
+ * by the scrollable component, there will be a preview of the next scene.
*
* In addition, during scene transitions, scroll events are consumed by the
* [SceneTransitionLayout] instead of the scrollable component.
*/
- EdgeWithOverscroll(canStartOnPostFling = true),
+ EdgeWithPreview(canStartOnPostFling = true),
/**
* Any overscroll will be used by the [SceneTransitionLayout] to move to the next scene.
@@ -67,7 +67,7 @@
* In addition, during scene transitions, scroll events are consumed by the
* [SceneTransitionLayout] instead of the scrollable component.
*/
- Always(canStartOnPostFling = true),
+ EdgeAlways(canStartOnPostFling = true),
}
internal fun Modifier.nestedScrollToScene(
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
index 661ac9a..212c9eb6 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
@@ -577,15 +577,15 @@
canChangeScene = false // unused: added for consistency
false
}
- NestedScrollBehavior.EdgeNoOverscroll -> {
+ NestedScrollBehavior.EdgeNoPreview -> {
canChangeScene = isZeroOffset
isZeroOffset && hasNextScene(offsetAvailable)
}
- NestedScrollBehavior.EdgeWithOverscroll -> {
+ NestedScrollBehavior.EdgeWithPreview -> {
canChangeScene = isZeroOffset
hasNextScene(offsetAvailable)
}
- NestedScrollBehavior.Always -> {
+ NestedScrollBehavior.EdgeAlways -> {
canChangeScene = true
hasNextScene(offsetAvailable)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
index 07add77..afa184b 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
@@ -132,8 +132,8 @@
*/
fun Modifier.nestedScrollToScene(
orientation: Orientation,
- startBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoOverscroll,
- endBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoOverscroll,
+ startBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview,
+ endBehavior: NestedScrollBehavior = NestedScrollBehavior.EdgeNoPreview,
): Modifier
/**
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneGestureHandlerTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneGestureHandlerTest.kt
index b407165..aa942e0 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneGestureHandlerTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneGestureHandlerTest.kt
@@ -29,10 +29,10 @@
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.Velocity
import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.android.compose.animation.scene.NestedScrollBehavior.Always
import com.android.compose.animation.scene.NestedScrollBehavior.DuringTransitionBetweenScenes
-import com.android.compose.animation.scene.NestedScrollBehavior.EdgeNoOverscroll
-import com.android.compose.animation.scene.NestedScrollBehavior.EdgeWithOverscroll
+import com.android.compose.animation.scene.NestedScrollBehavior.EdgeAlways
+import com.android.compose.animation.scene.NestedScrollBehavior.EdgeNoPreview
+import com.android.compose.animation.scene.NestedScrollBehavior.EdgeWithPreview
import com.android.compose.animation.scene.TestScenes.SceneA
import com.android.compose.animation.scene.TestScenes.SceneB
import com.android.compose.animation.scene.TestScenes.SceneC
@@ -439,14 +439,14 @@
@Test
fun onInitialPreScroll_EdgeWithOverscroll_doNotChangeState() = runGestureTest {
- val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithOverscroll)
+ val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview)
nestedScroll.onPreScroll(available = offsetY10, source = NestedScrollSource.Drag)
assertIdle(currentScene = SceneA)
}
@Test
fun onPostScrollWithNothingAvailable_EdgeWithOverscroll_doNotChangeState() = runGestureTest {
- val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithOverscroll)
+ val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview)
val consumed =
nestedScroll.onPostScroll(
consumed = Offset.Zero,
@@ -460,7 +460,7 @@
@Test
fun onPostScrollWithSomethingAvailable_startSceneTransition() = runGestureTest {
- val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithOverscroll)
+ val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview)
val consumed =
nestedScroll.onPostScroll(
consumed = Offset.Zero,
@@ -489,7 +489,7 @@
@Test
fun afterSceneTransitionIsStarted_interceptPreScrollEvents() = runGestureTest {
- val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithOverscroll)
+ val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview)
nestedScroll.scroll(available = offsetY10)
assertTransition(currentScene = SceneA)
@@ -517,7 +517,7 @@
firstScroll: Float,
secondScroll: Float
) {
- val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithOverscroll)
+ val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview)
// start scene transition
nestedScroll.scroll(available = Offset(0f, SCREEN_SIZE * firstScroll))
@@ -570,7 +570,7 @@
@Test
fun onPreFling_velocityLowerThanThreshold_remainSameScene() = runGestureTest {
- val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithOverscroll)
+ val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview)
nestedScroll.scroll(available = offsetY10)
assertTransition(currentScene = SceneA)
@@ -602,7 +602,7 @@
@Test
fun flingAfterScroll_EdgeNoOverscroll_goToNextScene() = runGestureTest {
- flingAfterScroll(use = EdgeNoOverscroll, idleAfterScroll = false)
+ flingAfterScroll(use = EdgeNoPreview, idleAfterScroll = false)
assertTransition(currentScene = SceneC)
@@ -613,7 +613,7 @@
@Test
fun flingAfterScroll_EdgeWithOverscroll_goToNextScene() = runGestureTest {
- flingAfterScroll(use = EdgeWithOverscroll, idleAfterScroll = false)
+ flingAfterScroll(use = EdgeWithPreview, idleAfterScroll = false)
assertTransition(currentScene = SceneC)
@@ -624,7 +624,7 @@
@Test
fun flingAfterScroll_Always_goToNextScene() = runGestureTest {
- flingAfterScroll(use = Always, idleAfterScroll = false)
+ flingAfterScroll(use = EdgeAlways, idleAfterScroll = false)
assertTransition(currentScene = SceneC)
@@ -658,14 +658,14 @@
@Test
fun flingAfterScrollStartedInScene_EdgeNoOverscroll_doNothing() = runGestureTest {
- flingAfterScrollStartedInScene(use = EdgeNoOverscroll, idleAfterScroll = true)
+ flingAfterScrollStartedInScene(use = EdgeNoPreview, idleAfterScroll = true)
assertIdle(currentScene = SceneA)
}
@Test
fun flingAfterScrollStartedInScene_EdgeWithOverscroll_doOverscrollAnimation() = runGestureTest {
- flingAfterScrollStartedInScene(use = EdgeWithOverscroll, idleAfterScroll = false)
+ flingAfterScrollStartedInScene(use = EdgeWithPreview, idleAfterScroll = false)
assertTransition(currentScene = SceneA)
@@ -676,7 +676,7 @@
@Test
fun flingAfterScrollStartedInScene_Always_goToNextScene() = runGestureTest {
- flingAfterScrollStartedInScene(use = Always, idleAfterScroll = false)
+ flingAfterScrollStartedInScene(use = EdgeAlways, idleAfterScroll = false)
assertTransition(currentScene = SceneC)
@@ -699,14 +699,14 @@
@Test
fun beforeNestedScrollStart_stop_shouldBeIgnored() = runGestureTest {
- val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithOverscroll)
+ val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview)
nestedScroll.onPreFling(Velocity(0f, velocityThreshold))
assertIdle(currentScene = SceneA)
}
@Test
fun startNestedScrollWhileDragging() = runGestureTest {
- val nestedScroll = nestedScrollConnection(nestedScrollBehavior = Always)
+ val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeAlways)
draggable.onDragStarted()
assertTransition(currentScene = SceneA)