Use relative touch positions for reader tap events

Fixes #10004
This commit is contained in:
arkon 2023-10-12 22:15:30 -04:00
parent 97b4d1f13d
commit 90d3dd2242
3 changed files with 5 additions and 5 deletions

View file

@ -41,13 +41,13 @@ open class GestureDetectorWithLongTap(
// This is the key difference with the built-in detector. We have to ignore the // This is the key difference with the built-in detector. We have to ignore the
// event if the last up and current down are too close in time (double tap). // event if the last up and current down are too close in time (double tap).
if (ev.downTime - lastUp > doubleTapTime) { if (ev.downTime - lastUp > doubleTapTime) {
downX = ev.rawX downX = ev.x
downY = ev.rawY downY = ev.y
handler.postDelayed(longTapFn, longTapTime) handler.postDelayed(longTapFn, longTapTime)
} }
} }
MotionEvent.ACTION_MOVE -> { MotionEvent.ACTION_MOVE -> {
if (abs(ev.rawX - downX) > slop || abs(ev.rawY - downY) > slop) { if (abs(ev.x - downX) > slop || abs(ev.y - downY) > slop) {
handler.removeCallbacks(longTapFn) handler.removeCallbacks(longTapFn)
} }
} }

View file

@ -102,7 +102,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : Viewer {
}, },
) )
pager.tapListener = { event -> pager.tapListener = { event ->
val pos = PointF(event.rawX / pager.width, event.rawY / pager.height) val pos = PointF(event.x / pager.width, event.y / pager.height)
when (config.navigator.getAction(pos)) { when (config.navigator.getAction(pos)) {
NavigationRegion.MENU -> activity.toggleMenu() NavigationRegion.MENU -> activity.toggleMenu()
NavigationRegion.NEXT -> moveToNext() NavigationRegion.NEXT -> moveToNext()

View file

@ -111,7 +111,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
}, },
) )
recycler.tapListener = { event -> recycler.tapListener = { event ->
val pos = PointF(event.rawX / recycler.width, event.rawY / recycler.height) val pos = PointF(event.x / recycler.width, event.y / recycler.height)
when (config.navigator.getAction(pos)) { when (config.navigator.getAction(pos)) {
NavigationRegion.MENU -> activity.toggleMenu() NavigationRegion.MENU -> activity.toggleMenu()
NavigationRegion.NEXT, NavigationRegion.RIGHT -> scrollDown() NavigationRegion.NEXT, NavigationRegion.RIGHT -> scrollDown()