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 bea325281..a4f5a3e95 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 @@ -80,29 +80,38 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer { isIdle = state == ViewPager.SCROLL_STATE_IDLE } }) - pager.tapListener = { event -> + pager.tapListener = f@{ event -> + if (!config.tappingEnabled) { + activity.toggleMenu() + return@f + } + + val positionX = event.x + val positionY = event.y + val topSideTap = positionY < pager.height * 0.25f + val bottomSideTap = positionY > pager.height * 0.75f + val leftSideTap = positionX < pager.width * 0.33f + val rightSideTap = positionX > pager.width * 0.66f + val invertMode = config.tappingInverted + val invertVertical = invertMode == TappingInvertMode.VERTICAL || invertMode == TappingInvertMode.BOTH + val invertHorizontal = invertMode == TappingInvertMode.HORIZONTAL || invertMode == TappingInvertMode.BOTH if (this is VerticalPagerViewer) { - val positionY = event.y - val tappingInverted = invertMode == TappingInvertMode.VERTICAL || invertMode == TappingInvertMode.BOTH - val topSideTap = positionY < pager.height * 0.33f && config.tappingEnabled - val bottomSideTap = positionY > pager.height * 0.66f && config.tappingEnabled - when { - topSideTap && !tappingInverted || bottomSideTap && tappingInverted -> moveLeft() - bottomSideTap && !tappingInverted || topSideTap && tappingInverted -> moveRight() + topSideTap && !invertVertical || bottomSideTap && invertVertical -> moveLeft() + bottomSideTap && !invertVertical || topSideTap && invertVertical -> moveRight() + + leftSideTap && !invertHorizontal || rightSideTap && invertHorizontal -> moveLeft() + rightSideTap && !invertHorizontal || leftSideTap && invertHorizontal -> moveRight() + else -> activity.toggleMenu() } } else { - val positionX = event.x - val tappingInverted = invertMode == TappingInvertMode.HORIZONTAL || invertMode == TappingInvertMode.BOTH - 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() + leftSideTap && !invertHorizontal || rightSideTap && invertHorizontal -> moveLeft() + rightSideTap && !invertHorizontal || leftSideTap && invertHorizontal -> moveRight() + else -> activity.toggleMenu() } } 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 deed31237..bb927f923 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 @@ -93,17 +93,30 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr } } }) - recycler.tapListener = { event -> - val positionY = event.rawY - val invertMode = config.tappingInverted - val topSideTap = positionY < recycler.height * 0.33f && config.tappingEnabled - val bottomSideTap = positionY > recycler.height * 0.66f && config.tappingEnabled + recycler.tapListener = f@{ event -> + if (!config.tappingEnabled) { + activity.toggleMenu() + return@f + } - val tappingInverted = invertMode == TappingInvertMode.VERTICAL || invertMode == TappingInvertMode.BOTH + val positionX = event.rawX + val positionY = event.rawY + val topSideTap = positionY < recycler.height * 0.25f + val bottomSideTap = positionY > recycler.height * 0.75f + val leftSideTap = positionX < recycler.width * 0.33f + val rightSideTap = positionX > recycler.width * 0.66f + + val invertMode = config.tappingInverted + val invertVertical = invertMode == TappingInvertMode.VERTICAL || invertMode == TappingInvertMode.BOTH + val invertHorizontal = invertMode == TappingInvertMode.HORIZONTAL || invertMode == TappingInvertMode.BOTH when { - topSideTap && !tappingInverted || bottomSideTap && tappingInverted -> scrollUp() - bottomSideTap && !tappingInverted || topSideTap && tappingInverted -> scrollDown() + topSideTap && !invertVertical || bottomSideTap && invertVertical -> scrollUp() + bottomSideTap && !invertVertical || topSideTap && invertVertical -> scrollDown() + + leftSideTap && !invertHorizontal || rightSideTap && invertHorizontal -> scrollUp() + rightSideTap && !invertHorizontal || leftSideTap && invertHorizontal -> scrollDown() + else -> activity.toggleMenu() } }