mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 04:37:25 +01:00
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:
parent
af2ef0621a
commit
493c8b0943
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user