@devries-cameron20 / t3code-1 / commits / ff7aa5ace3
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(mobile): Android PDF preview double-tap zoom and easier link taps (#33570)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 9, 2026 at 13:41 UTC ff7aa5ace311c70587631dcedb43f1d92068c342
3 files changed +76 -2
patches/react-native-pdf-jsi@6.1.0.patch new
+71
@@ -0,0 +1,71 @@
1 +diff --git a/android/src/main/java/org/wonday/pdf/viewer/PdfViewerView.kt b/android/src/main/java/org/wonday/pdf/viewer/PdfViewerView.kt
2 +index c51515507544fb7a56f029fff8ea2b1ee35cbe9d..2de8b3ecfa0b75d55f0868c700a0a56b83c17053 100644
3 +--- a/android/src/main/java/org/wonday/pdf/viewer/PdfViewerView.kt
4 ++++ b/android/src/main/java/org/wonday/pdf/viewer/PdfViewerView.kt
5 +@@ -21,6 +21,7 @@ import org.json.JSONArray
6 + import org.json.JSONObject
7 + import kotlin.math.abs
8 + import kotlin.math.ceil
9 ++import kotlin.math.hypot
10 + import kotlin.math.max
11 + import kotlin.math.min
12 + import kotlin.math.roundToInt
13 +@@ -40,6 +41,10 @@ data class PdfHighlightRect(val page: Int, val x: Float, val y: Float, val width
14 + * Page and scale events are sent only once scrolling and zooming have settled.
15 + */
16 + class PdfViewerView(context: Context) : View(context) {
17 ++ private companion object {
18 ++ const val LINK_TAP_SLOP_DP = 10f
19 ++ }
20 ++
21 + var onEvent: ((JSONObject) -> Unit)? = null
22 +
23 + private val main = Handler(Looper.getMainLooper())
24 +@@ -109,10 +114,9 @@ class PdfViewerView(context: Context) : View(context) {
25 + private val scratch = RectF()
26 +
27 + private val gestures = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
28 +- override fun onDown(e: MotionEvent): Boolean {
29 +- stopMotion()
30 +- return true
31 +- }
32 ++ // Motion stops in onTouchEvent: GestureDetector calls onDown after onDoubleTap for the
33 ++ // same event, so stopping here would cancel the zoom the double tap just started.
34 ++ override fun onDown(e: MotionEvent): Boolean = true
35 +
36 + override fun onScroll(e1: MotionEvent?, e2: MotionEvent, dx: Float, dy: Float): Boolean {
37 + if (!scrollEnabled || scaling) return false
38 +@@ -694,6 +698,7 @@ class PdfViewerView(context: Context) : View(context) {
39 + when (event.actionMasked) {
40 + MotionEvent.ACTION_DOWN -> {
41 + touching = true
42 ++ stopMotion()
43 + if (scrollEnabled) parent?.requestDisallowInterceptTouchEvent(true)
44 + }
45 + MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> touching = false
46 +@@ -804,7 +809,11 @@ class PdfViewerView(context: Context) : View(context) {
47 + val pointX = (x - rect.left) / scale
48 + val pointY = (y - rect.top) / scale
49 + val docPage = pageBase + index
50 +- val hit = linksFor(docPage).firstOrNull { it.contains(pointX, pointY) }
51 ++ // Links such as citations are only a few glyphs wide, so a tap near one still counts.
52 ++ val slop = LINK_TAP_SLOP_DP * density / scale
53 ++ val hit = linksFor(docPage)
54 ++ .filter { it.distanceTo(pointX, pointY) <= slop }
55 ++ .minByOrNull { it.distanceTo(pointX, pointY) }
56 + when {
57 + hit?.uri != null -> emit(JSONObject().put("type", "link").put("url", hit.uri))
58 + hit != null && hit.page >= 0 -> goToPage(hit.page, true)
59 +@@ -818,7 +827,11 @@ class PdfViewerView(context: Context) : View(context) {
60 + }
61 +
62 + private class PageLinkHit(val x: Float, val y: Float, val width: Float, val height: Float, val page: Int, val uri: String?) {
63 +- fun contains(px: Float, py: Float) = px >= x && px <= x + width && py >= y && py <= y + height
64 ++ fun distanceTo(px: Float, py: Float): Float {
65 ++ val dx = max(0f, max(x - px, px - (x + width)))
66 ++ val dy = max(0f, max(y - py, py - (y + height)))
67 ++ return hypot(dx, dy)
68 ++ }
69 + }
70 +
71 + private fun linksFor(docPage: Int): List<PageLinkHit> = links.getOrPut(docPage) {
pnpm-lock.yaml
+3 -2
@@ -383,6 +383,7 @@ patchedDependencies:
383 react-native-gesture-handler@3.5.0: 171379dd378f8f11e9187876dec2116e5cbf5f21cef6576cdde6956518324f98
384 react-native-image-viewing@0.2.2: 4aa038d541c7ddcc8f1437eb3e7b4f769f61de78e7f91b53f9805dfca608474d
385 react-native-keyboard-controller@1.23.0: 1c7c80317ef050e08d4aabe034a0813d03b497dff2dc8b37fb5f4a6e3b20fddb
386 + react-native-pdf-jsi@6.1.0: d29e6b69813548de641a09db705dd94823d3f96832821ae9c3f6a196dd15cb68
387 react-native-reanimated@4.7.1: 95ee26e5fcab5f50bc4b4c47b3f7e6278a0b20850205efb9f6ee7e70a22d2b59
388 react-native-svg@15.16.1: 110f9243ffad03654ce40dd1cdb09f01af16b8fa2ccb2b2cd3d62e682c180399
389 react-native-webview@14.0.1: 71009983c76818bd5e73d4ca597f76efd04101600c84cd4b4c5d920781c048ae
@@ -743,7 +744,7 @@ importers:
744 version: 0.37.2(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
745 react-native-pdf-jsi:
746 specifier: 6.1.0
746 - version: 6.1.0(expo@58.0.23)(react-native-nitro-modules@0.37.2(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
747 + version: 6.1.0(patch_hash=d29e6b69813548de641a09db705dd94823d3f96832821ae9c3f6a196dd15cb68)(expo@58.0.23)(react-native-nitro-modules@0.37.2(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
748 react-native-reanimated:
749 specifier: 4.7.1
750 version: 4.7.1(patch_hash=95ee26e5fcab5f50bc4b4c47b3f7e6278a0b20850205efb9f6ee7e70a22d2b59)(react-native-worklets@0.13.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)(supports-color@8.1.1))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
@@ -21021,7 +21022,7 @@ snapshots:
21022 react: 19.3.0
21023 react-native: 0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)
21024
21024 - react-native-pdf-jsi@6.1.0(expo@58.0.23)(react-native-nitro-modules@0.37.2(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0):
21025 + react-native-pdf-jsi@6.1.0(patch_hash=d29e6b69813548de641a09db705dd94823d3f96832821ae9c3f6a196dd15cb68)(expo@58.0.23)(react-native-nitro-modules@0.37.2(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0))(react-native@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0):
21026 dependencies:
21027 react: 19.3.0
21028 react-native: 0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.1(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)
pnpm-workspace.yaml
+2
@@ -261,6 +261,8 @@ patchedDependencies:
261 react-native-svg@15.16.1: patches/react-native-svg@15.16.1.patch
262 # iOS: a feed following its end keeps the end through a size-only reflow in one pass.
263 "@legendapp/list@3.7.2": patches/@legendapp__list@3.7.2.patch
264 + # Android: double-tap zoom no longer cancels itself, and taps near a link open it.
265 + react-native-pdf-jsi@6.1.0: patches/react-native-pdf-jsi@6.1.0.patch
266
267 # Unmet peers fail resolution, so a pin outside a dependency's peer range is
268 # caught when the lockfile changes instead of scrolling past as a warning.