From 0ea0eba4f0562f0008214a28a88e3413d1faff33 Mon Sep 17 00:00:00 2001 From: Andreas E Date: Tue, 23 Jun 2020 10:58:56 +0200 Subject: [PATCH] Invert tapping for Webtoon and Vertical --- .../eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt | 2 +- .../tachiyomi/ui/reader/viewer/pager/PagerViewer.kt | 9 +++++++-- .../tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt | 8 ++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt index 4221cf6d58..3410fc46f2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt @@ -32,7 +32,7 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { .register({ tappingEnabled = it }) preferences.readWithTappingInverted() - .register({ tappingInverted = it }) + .register({ tappingInverted = it }) preferences.readWithLongTap() .register({ longTapEnabled = it }) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt index 04ebc1a453..3452cab061 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt @@ -81,17 +81,22 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer { }) pager.tapListener = { event -> val tappingInverted = config.tappingInverted + if (this is VerticalPagerViewer) { val positionY = event.y + val topSideTap = positionY < pager.height * 0.33f && config.tappingEnabled + val bottomSideTap = positionY > pager.height * 0.66f && config.tappingEnabled + when { - positionY < pager.height * 0.33f && config.tappingEnabled -> moveLeft() - positionY > pager.height * 0.66f && config.tappingEnabled -> moveRight() + topSideTap && !tappingInverted || bottomSideTap && tappingInverted -> moveLeft() + bottomSideTap && !tappingInverted || topSideTap && tappingInverted -> moveRight() else -> activity.toggleMenu() } } else { val positionX = event.x val leftSideTap = positionX < pager.width * 0.33f && config.tappingEnabled val rightSideTap = positionX > pager.width * 0.66f && config.tappingEnabled + when { leftSideTap && !tappingInverted || rightSideTap && tappingInverted -> moveLeft() rightSideTap && !tappingInverted || leftSideTap && tappingInverted -> moveRight() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt index 802f969e0f..5a552ab526 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt @@ -94,9 +94,13 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr }) recycler.tapListener = { event -> val positionY = event.rawY + val tappingInverted = config.tappingInverted + val topSideTap = positionY < recycler.height * 0.33f && config.tappingEnabled + val bottomSideTap = positionY > recycler.height * 0.66f && config.tappingEnabled + when { - positionY < recycler.height * 0.33f && config.tappingEnabled -> scrollUp() - positionY > recycler.height * 0.66f && config.tappingEnabled -> scrollDown() + topSideTap && !tappingInverted || bottomSideTap && tappingInverted -> scrollUp() + bottomSideTap && !tappingInverted || topSideTap && tappingInverted -> scrollDown() else -> activity.toggleMenu() } }