Adjust vertical reading mode tap zones (closes #3551)

Basically L shapes, where top/left goes back, bottom/right goes forward, and middle opens the menu.
This commit is contained in:
arkon 2020-08-03 12:17:28 -04:00
parent af2ef0621a
commit 493c8b0943
2 changed files with 45 additions and 23 deletions

View file

@ -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()
}
}

View file

@ -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()
}
}