@tobyt/expo-pdf-markup 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/ContinuousPdfView.kt +38 -4
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/ExpoPdfMarkupView.kt +1 -0
- package/android/src/main/java/dev/terhoeven/expopdfmarkup/TouchInterceptPolicy.kt +20 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @tobyt/expo-pdf-markup
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3f4fa8c: Android: fix touch-interception lifecycle in the PDF view. The view previously called `requestDisallowInterceptTouchEvent(true)` on every touch event and never released it, and in-progress gestures were never reset when interrupted. This could leave stale touch state on ancestor views shared with sibling screens (e.g. list rows behind the PDF screen becoming unresponsive to taps after navigating back, especially after locking/unlocking the device), and caused unnecessary gesture-handler contention while scrolling.
|
|
8
|
+
|
|
9
|
+
Now the parent intercept hold is requested on `ACTION_DOWN` and released on the final `ACTION_UP`/`ACTION_CANCEL` (held across multi-touch pinch), and all in-progress gestures (ink stroke, highlight/underline drag, annotation move, fling) are cancelled and the hold released when the window loses focus (device lock) or the view detaches. Note: an ink stroke interrupted by a device lock is discarded rather than committed.
|
|
10
|
+
|
|
3
11
|
## 1.1.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -248,6 +248,13 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
|
251
|
+
// Hold off parent interception (e.g. gesture-handler root, scroll
|
|
252
|
+
// containers) for the duration of each gesture only; leaving it set
|
|
253
|
+
// permanently can strand ancestors shared with sibling screens.
|
|
254
|
+
TouchInterceptPolicy.disallowInterceptFor(event.actionMasked)?.let {
|
|
255
|
+
parent?.requestDisallowInterceptTouchEvent(it)
|
|
256
|
+
}
|
|
257
|
+
|
|
251
258
|
// Always let scale detector handle pinch zoom
|
|
252
259
|
scaleDetector.onTouchEvent(event)
|
|
253
260
|
|
|
@@ -306,10 +313,40 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
306
313
|
}
|
|
307
314
|
}
|
|
308
315
|
|
|
309
|
-
parent?.requestDisallowInterceptTouchEvent(true)
|
|
310
316
|
return true
|
|
311
317
|
}
|
|
312
318
|
|
|
319
|
+
/**
|
|
320
|
+
* Cancels any in-progress gesture (ink stroke, drag, move, fling) and
|
|
321
|
+
* releases the parent touch-intercept hold. Needed when the gesture is
|
|
322
|
+
* interrupted without a final ACTION_UP/ACTION_CANCEL — device lock
|
|
323
|
+
* (window focus loss) or view teardown — so that no stale touch state
|
|
324
|
+
* survives on this view or its ancestors. An interrupted ink stroke is
|
|
325
|
+
* discarded rather than committed.
|
|
326
|
+
*/
|
|
327
|
+
fun cancelActiveGestures() {
|
|
328
|
+
isDrawingInk = false
|
|
329
|
+
currentInkPoints.clear()
|
|
330
|
+
inkScreenPath.reset()
|
|
331
|
+
isDragging = false
|
|
332
|
+
dragStartPoint = null
|
|
333
|
+
dragCurrentPoint = null
|
|
334
|
+
clearMovePreview()
|
|
335
|
+
scroller.forceFinished(true)
|
|
336
|
+
parent?.requestDisallowInterceptTouchEvent(false)
|
|
337
|
+
invalidate()
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
override fun onWindowFocusChanged(hasWindowFocus: Boolean) {
|
|
341
|
+
super.onWindowFocusChanged(hasWindowFocus)
|
|
342
|
+
if (!hasWindowFocus) cancelActiveGestures()
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
override fun onDetachedFromWindow() {
|
|
346
|
+
cancelActiveGestures()
|
|
347
|
+
super.onDetachedFromWindow()
|
|
348
|
+
}
|
|
349
|
+
|
|
313
350
|
// --- Ink mode ---
|
|
314
351
|
|
|
315
352
|
private fun handleInkTouch(event: MotionEvent) {
|
|
@@ -321,7 +358,6 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
321
358
|
val pt = AnnotationPoint(event.x, event.y)
|
|
322
359
|
currentInkPoints.add(pt)
|
|
323
360
|
inkScreenPath.moveTo(event.x, event.y)
|
|
324
|
-
parent?.requestDisallowInterceptTouchEvent(true)
|
|
325
361
|
}
|
|
326
362
|
|
|
327
363
|
MotionEvent.ACTION_MOVE -> {
|
|
@@ -385,7 +421,6 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
385
421
|
isDragging = true
|
|
386
422
|
dragStartPoint = AnnotationPoint(event.x, event.y)
|
|
387
423
|
dragCurrentPoint = dragStartPoint
|
|
388
|
-
parent?.requestDisallowInterceptTouchEvent(true)
|
|
389
424
|
}
|
|
390
425
|
|
|
391
426
|
MotionEvent.ACTION_MOVE -> {
|
|
@@ -477,7 +512,6 @@ class ContinuousPdfView(context: Context) : View(context) {
|
|
|
477
512
|
movingAnnotation = hit
|
|
478
513
|
movingPreviewAnnotation = hit
|
|
479
514
|
moveStartPdfPoint = pdfTouch.point
|
|
480
|
-
parent?.requestDisallowInterceptTouchEvent(true)
|
|
481
515
|
invalidate()
|
|
482
516
|
}
|
|
483
517
|
}
|
|
@@ -201,6 +201,7 @@ class ExpoPdfMarkupView(context: Context, appContext: AppContext) : ExpoView(con
|
|
|
201
201
|
|
|
202
202
|
override fun onDetachedFromWindow() {
|
|
203
203
|
super.onDetachedFromWindow()
|
|
204
|
+
pdfView.cancelActiveGestures()
|
|
204
205
|
// Save the successfully-loaded source before close() so we can reload on re-attach.
|
|
205
206
|
// (currentSource is always null after loadPdf() because close() resets it there.)
|
|
206
207
|
sourceToReloadOnAttach = lastLoadedSource
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package dev.terhoeven.expopdfmarkup
|
|
2
|
+
|
|
3
|
+
import android.view.MotionEvent
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Decides whether the parent's touch interception should be disallowed for a
|
|
7
|
+
* given masked motion action, or left unchanged (null).
|
|
8
|
+
*
|
|
9
|
+
* The disallow flag is held for the whole gesture: requested on the initial
|
|
10
|
+
* ACTION_DOWN and released only on the final ACTION_UP or ACTION_CANCEL.
|
|
11
|
+
* ACTION_POINTER_DOWN/ACTION_POINTER_UP (extra fingers during pinch zoom)
|
|
12
|
+
* must not release it mid-gesture.
|
|
13
|
+
*/
|
|
14
|
+
object TouchInterceptPolicy {
|
|
15
|
+
fun disallowInterceptFor(actionMasked: Int): Boolean? = when (actionMasked) {
|
|
16
|
+
MotionEvent.ACTION_DOWN -> true
|
|
17
|
+
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> false
|
|
18
|
+
else -> null
|
|
19
|
+
}
|
|
20
|
+
}
|