mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-26 00:06:02 +00:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0ac30c6a8 | ||
|
|
83efbe3987 | ||
|
|
10618b0f60 | ||
|
|
801e434345 | ||
|
|
fc8dad5944 | ||
|
|
cf86daa154 | ||
|
|
541e2230df | ||
|
|
2f71916019 | ||
|
|
49201e1afa |
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)
|
||||
|
||||
@@ -83,7 +83,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 -> {
|
||||
anchor(event, -1)
|
||||
return true
|
||||
}
|
||||
State.HELD, State.TAPPED -> return true
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
@@ -137,7 +141,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 -> {
|
||||
anchor(event, event.actionIndex)
|
||||
return true
|
||||
}
|
||||
State.HELD, State.TAPPED -> return true
|
||||
else -> Unit
|
||||
}
|
||||
MotionEvent.ACTION_UP -> {
|
||||
@@ -193,6 +201,13 @@ class TwoFingerGestures(private val slopPx: Float, private val listener: Listene
|
||||
hypot(event.getX(i) - start.first, event.getY(i) - start.second) > slopPx
|
||||
}
|
||||
|
||||
private fun anchor(event: MotionEvent, lifted: Int) {
|
||||
val kept = (0 until event.pointerCount).filter { it != lifted }
|
||||
if (kept.size < 2) return
|
||||
lastX = (event.getX(kept[0]) + event.getX(kept[1])) / 2f
|
||||
lastY = (event.getY(kept[0]) + event.getY(kept[1])) / 2f
|
||||
}
|
||||
|
||||
private fun span(event: MotionEvent) = hypot(event.getX(1) - event.getX(0), event.getY(1) - event.getY(0))
|
||||
private fun midX(event: MotionEvent) = (event.getX(0) + event.getX(1)) / 2f
|
||||
private fun midY(event: MotionEvent) = (event.getY(0) + event.getY(1)) / 2f
|
||||
|
||||
@@ -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,32 @@ 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 230f), 3 to (800f to 580f)))
|
||||
assertEquals(listOf("cancel", "start 450.0,260.0", "scroll 0.0,20.0"), calls)
|
||||
}
|
||||
|
||||
@Test fun aThirdFingerLiftingDuringAScrollKeepsTheRemainingMidpoint() {
|
||||
val c = 3 to (450f to 500f)
|
||||
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_DOWN, 2, 1 to (400f to 260f), 2 to (500f to 260f), c))
|
||||
assertTrue(touch(MotionEvent.ACTION_POINTER_UP, 0, 1 to (400f to 260f), 2 to (500f to 260f), c))
|
||||
assertTrue(touch(MotionEvent.ACTION_MOVE, 0, 2 to (500f to 250f), c))
|
||||
assertEquals(listOf("cancel", "start 450.0,260.0", "scroll 0.0,5.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())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user