mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
Keep a still direct touch held unless Long press is on (#1578)
This commit is contained in:
1 parent
8cf2ffe2ad
commit
71fee6b3cc
4 files changed
+30
-4
No files matched your search
@@ -22,7 +22,7 @@ class DirectTouchHoldTest {
|
||||
}
|
||||
override fun onWheel(steps: Int) {}
|
||||
override fun onLongPress() {}
|
||||
}) { events += "cancel touch" }
|
||||
}) { events += "cancel touch" }.also { it.configure(TouchGestureConfig(longPressEnabled = true, longPressDelay = 500)) }
|
||||
|
||||
@Test fun holdReleasesRawTouchBeforeClickAndConsumesTheLift() {
|
||||
assertFalse(touch(MotionEvent.ACTION_DOWN))
|
||||
@@ -35,6 +35,25 @@ class DirectTouchHoldTest {
|
||||
hold.cancel()
|
||||
}
|
||||
|
||||
@Test fun stillHoldKeepsTheTouchWhenLongPressIsOff() {
|
||||
hold.configure(TouchGestureConfig())
|
||||
assertFalse(touch(MotionEvent.ACTION_DOWN))
|
||||
advance(2000)
|
||||
assertFalse(touch(MotionEvent.ACTION_MOVE))
|
||||
assertFalse(touch(MotionEvent.ACTION_UP))
|
||||
assertTrue(events.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun longPressFollowsTheConfiguredDelay() {
|
||||
hold.configure(TouchGestureConfig(longPressEnabled = true, longPressDelay = 800))
|
||||
touch(MotionEvent.ACTION_DOWN)
|
||||
advance(700)
|
||||
assertTrue(events.isEmpty())
|
||||
advance(100)
|
||||
assertEquals(listOf("cancel touch", "true at 40.0,30.0"), events)
|
||||
hold.cancel()
|
||||
}
|
||||
|
||||
@Test fun tapDragSecondFingerAndCancellationDoNotRightClick() {
|
||||
for (action in listOf(MotionEvent.ACTION_UP, MotionEvent.ACTION_MOVE,
|
||||
MotionEvent.ACTION_POINTER_DOWN, MotionEvent.ACTION_CANCEL)) {
|
||||
|
||||
@@ -172,7 +172,7 @@ class SessionGestureRoutingTest {
|
||||
val event = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN, 400f, 300f, 0)
|
||||
try { assertTrue(activity.onTouchEvent(event)) } finally { event.recycle() }
|
||||
val gestureMode = mode == SessionPrefs.TOUCH_GESTURES
|
||||
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(if (gestureMode) 350 else 500))
|
||||
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(if (gestureMode) 350 else 320))
|
||||
assertEquals(if (gestureMode) listOf(18 to true) else emptyList(), keys)
|
||||
assertEquals(if (gestureMode) emptyList() else listOf(PointerGestures.BTN_RIGHT to true), directButtons)
|
||||
ReflectionHelpers.callInstanceMethod<Unit>(activity, "onPause")
|
||||
@@ -220,7 +220,7 @@ class SessionGestureRoutingTest {
|
||||
override fun onButton(button: Int, pressed: Boolean, x: Float, y: Float) { directButtons += button to pressed }
|
||||
override fun onWheel(steps: Int) {}
|
||||
override fun onLongPress() {}
|
||||
}) {}
|
||||
}) {}.also { it.configure(config) }
|
||||
setField("directTouchHold", directHold)
|
||||
launcherScroll = ScrollTouchGestures(8f, 50f, object : ScrollTouchGestures.Listener {
|
||||
override fun onMove(x: Float, y: Float) { scrollPositions += x to y }
|
||||
|
||||
Reference in new issue
Block a user