Loading packages/SystemUI/compose/core/src/com/android/compose/gesture/NestedDraggable.kt +3 −2 Original line number Diff line number Diff line Loading @@ -549,9 +549,10 @@ private class NestedDraggableNode( nestedScrollController == null && // TODO(b/388231324): Remove this. !lastEventWasScrollWheel && draggable.shouldConsumeNestedScroll(sign) draggable.shouldConsumeNestedScroll(sign) && lastFirstDown != null ) { val startedPosition = checkNotNull(lastFirstDown) { "lastFirstDown is not set" } val startedPosition = checkNotNull(lastFirstDown) // TODO(b/382665591): Ensure that there is at least one pointer down. val pointersDownCount = pointersDown.size.coerceAtLeast(1) Loading packages/SystemUI/compose/core/tests/src/com/android/compose/gesture/NestedDraggableTest.kt +23 −0 Original line number Diff line number Diff line Loading @@ -773,6 +773,29 @@ class NestedDraggableTest(override val orientation: Orientation) : OrientationAw rule.onNodeWithTag(buttonTag).assertTextEquals("Count: 3") } @Test fun nestedDragNotStartedWhenEnabledAfterDragStarted() { val draggable = TestDraggable() var enabled by mutableStateOf(false) val touchSlop = rule.setContentWithTouchSlop { Box( Modifier.fillMaxSize() .nestedDraggable(draggable, orientation, enabled = enabled) .scrollable(rememberScrollableState { 0f }, orientation) ) } rule.onRoot().performTouchInput { down(center) } enabled = true rule.waitForIdle() rule.onRoot().performTouchInput { moveBy((touchSlop + 1f).toOffset()) } assertThat(draggable.onDragStartedCalled).isFalse() } private fun ComposeContentTestRule.setContentWithTouchSlop( content: @Composable () -> Unit ): Float { Loading Loading
packages/SystemUI/compose/core/src/com/android/compose/gesture/NestedDraggable.kt +3 −2 Original line number Diff line number Diff line Loading @@ -549,9 +549,10 @@ private class NestedDraggableNode( nestedScrollController == null && // TODO(b/388231324): Remove this. !lastEventWasScrollWheel && draggable.shouldConsumeNestedScroll(sign) draggable.shouldConsumeNestedScroll(sign) && lastFirstDown != null ) { val startedPosition = checkNotNull(lastFirstDown) { "lastFirstDown is not set" } val startedPosition = checkNotNull(lastFirstDown) // TODO(b/382665591): Ensure that there is at least one pointer down. val pointersDownCount = pointersDown.size.coerceAtLeast(1) Loading
packages/SystemUI/compose/core/tests/src/com/android/compose/gesture/NestedDraggableTest.kt +23 −0 Original line number Diff line number Diff line Loading @@ -773,6 +773,29 @@ class NestedDraggableTest(override val orientation: Orientation) : OrientationAw rule.onNodeWithTag(buttonTag).assertTextEquals("Count: 3") } @Test fun nestedDragNotStartedWhenEnabledAfterDragStarted() { val draggable = TestDraggable() var enabled by mutableStateOf(false) val touchSlop = rule.setContentWithTouchSlop { Box( Modifier.fillMaxSize() .nestedDraggable(draggable, orientation, enabled = enabled) .scrollable(rememberScrollableState { 0f }, orientation) ) } rule.onRoot().performTouchInput { down(center) } enabled = true rule.waitForIdle() rule.onRoot().performTouchInput { moveBy((touchSlop + 1f).toOffset()) } assertThat(draggable.onDragStartedCalled).isFalse() } private fun ComposeContentTestRule.setContentWithTouchSlop( content: @Composable () -> Unit ): Float { Loading