Keep a scroll steady when a finger lands again, keep the clipboard echo for repeat callbacks, and never follow a linked pacman sync folder

This commit is contained in:
maxjivi05 committed 2026-10-30 14:04:06 -04:00
1 parent 801e434345
commit 10618b0f60
5 files changed
+41 -9

No files matched your search

@@ -57,10 +57,7 @@ class SessionClipboard(context: Context, private val hasFocus: () -> Boolean) {
val clip = clipboard.primaryClip
if (clip != null && clip.itemCount == 0) return
val text = clip?.getItemAt(0)?.text?.toString()
if (echo != null && text == echo) {
echo = null
return
}
if (echo != null && text == echo) return
echo = null
if (!changed && published && text == shared) return
publish(text)
@@ -26,6 +26,7 @@ class TwoFingerGestures(private val slopPx: Float, private val listener: Listene
private var startSpan = 0f
private var lastX = 0f
private var lastY = 0f
private var anchored = false
private val starts = HashMap<Int, Pair<Float, Float>>()
private val held = ArrayList<MotionEvent>()
private val hold = Runnable {
@@ -83,7 +84,11 @@ class TwoFingerGestures(private val slopPx: Float, private val listener: Listene
pass(State.PASSING)
return true
}
State.SCROLLING, State.HELD, State.TAPPED -> return true
State.SCROLLING -> {
anchored = false
return true
}
State.HELD, State.TAPPED -> return true
else -> Unit
}
}
@@ -106,6 +111,7 @@ class TwoFingerGestures(private val slopPx: Float, private val listener: Listene
listener.cancelTouch()
lastX = midX(event)
lastY = midY(event)
anchored = true
listener.scrollStart(lastX, lastY)
return true
}
@@ -116,7 +122,8 @@ class TwoFingerGestures(private val slopPx: Float, private val listener: Listene
if (event.pointerCount >= 2) {
val mx = midX(event)
val my = midY(event)
listener.scroll(lastX - mx, lastY - my)
if (anchored) listener.scroll(lastX - mx, lastY - my)
anchored = true
lastX = mx
lastY = my
}
@@ -137,7 +144,11 @@ class TwoFingerGestures(private val slopPx: Float, private val listener: Listene
pass(State.PASSING)
return true
}
State.SCROLLING, State.HELD, State.TAPPED -> return true
State.SCROLLING -> {
anchored = false
return true
}
State.HELD, State.TAPPED -> return true
else -> Unit
}
MotionEvent.ACTION_UP -> {
@@ -97,8 +97,10 @@ internal object DesktopFileRemoval {
}
if (!dir.delete()) throw IOException("Cannot remove $dir")
}
for (name in listOf("sync/droiddeck.db", "droiddeck-desktop")) {
val file = File(lib, name)
val sync = File(lib, "sync")
val files = listOf(File(lib, "droiddeck-desktop")) +
listOfNotNull(File(sync, "droiddeck.db").takeUnless { Files.isSymbolicLink(sync.toPath()) })
for (file in files) {
if (Files.isSymbolicLink(file.toPath()) || file.isFile) Files.delete(file.toPath())
}
}
@@ -62,6 +62,20 @@ class TwoFingerGesturesTest {
assertEquals(listOf("cancel", "start 450.0,260.0", "scroll 0.0,60.0", "end"), calls)
}
@Test fun aFingerLandingAgainDuringAScrollDoesNotJump() {
touch(MotionEvent.ACTION_DOWN, 0, a)
time += 20
touch(MotionEvent.ACTION_POINTER_DOWN, 1, a, b)
time += 20
touch(MotionEvent.ACTION_MOVE, 0, 1 to (400f to 260f), 2 to (500f to 260f))
assertTrue(touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (400f to 260f), 2 to (500f to 260f)))
assertTrue(touch(MotionEvent.ACTION_MOVE, 0, 1 to (400f to 250f)))
assertTrue(touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (400f to 250f), 3 to (800f to 600f)))
assertTrue(touch(MotionEvent.ACTION_MOVE, 0, 1 to (400f to 250f), 3 to (800f to 600f)))
assertTrue(touch(MotionEvent.ACTION_MOVE, 0, 1 to (400f to 230f), 3 to (800f to 580f)))
assertEquals(listOf("cancel", "start 450.0,260.0", "scroll 0.0,20.0"), calls)
}
@Test fun pinchPassesThroughForZoom() {
touch(MotionEvent.ACTION_DOWN, 0, a)
time += 20
@@ -94,4 +94,12 @@ class DesktopFileRemovalTest {
assertFalse(File(root, "var/lib/pacman/sync/droiddeck.db").exists())
assertFalse(File(root, "var/lib/pacman/droiddeck-desktop").exists())
}
@Test fun aSymlinkedSyncDirectoryIsNotFollowed() {
val outside = File(dir, "outside/droiddeck.db").apply { parentFile.mkdirs(); writeText("keep") }
File(root, "var/lib/pacman/local").mkdirs()
Files.createSymbolicLink(File(root, "var/lib/pacman/sync").toPath(), outside.parentFile.toPath())
DesktopFileRemoval.removeRecords(root, emptySet())
assertEquals("keep", outside.readText())
}
}