Fix missing inversion in tap zones help overlay. (#9812)
This commit is contained in:
parent
627f07408e
commit
26b3eb696c
7 changed files with 14 additions and 10 deletions
|
@ -61,7 +61,7 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet)
|
||||||
override fun onDraw(canvas: Canvas) {
|
override fun onDraw(canvas: Canvas) {
|
||||||
if (navigation == null) return
|
if (navigation == null) return
|
||||||
|
|
||||||
navigation?.regions?.forEach { region ->
|
navigation?.getRegions()?.forEach { region ->
|
||||||
val rect = region.rectF
|
val rect = region.rectF
|
||||||
|
|
||||||
// Scale rect from 1f,1f to screen width and height
|
// Scale rect from 1f,1f to screen width and height
|
||||||
|
|
|
@ -32,15 +32,19 @@ abstract class ViewerNavigation {
|
||||||
|
|
||||||
private var constantMenuRegion: RectF = RectF(0f, 0f, 1f, 0.05f)
|
private var constantMenuRegion: RectF = RectF(0f, 0f, 1f, 0.05f)
|
||||||
|
|
||||||
abstract var regions: List<Region>
|
|
||||||
|
|
||||||
var invertMode: ReaderPreferences.TappingInvertMode = ReaderPreferences.TappingInvertMode.NONE
|
var invertMode: ReaderPreferences.TappingInvertMode = ReaderPreferences.TappingInvertMode.NONE
|
||||||
|
|
||||||
|
protected abstract var regionList: List<Region>
|
||||||
|
|
||||||
|
/** Returns regions with applied inversion. */
|
||||||
|
fun getRegions(): List<Region> {
|
||||||
|
return regionList.map { it.invert(invertMode) }
|
||||||
|
}
|
||||||
|
|
||||||
fun getAction(pos: PointF): NavigationRegion {
|
fun getAction(pos: PointF): NavigationRegion {
|
||||||
val x = pos.x
|
val x = pos.x
|
||||||
val y = pos.y
|
val y = pos.y
|
||||||
val region = regions.map { it.invert(invertMode) }
|
val region = getRegions().find { it.rectF.contains(x, y) }
|
||||||
.find { it.rectF.contains(x, y) }
|
|
||||||
return when {
|
return when {
|
||||||
region != null -> region.type
|
region != null -> region.type
|
||||||
constantMenuRegion.contains(x, y) -> NavigationRegion.MENU
|
constantMenuRegion.contains(x, y) -> NavigationRegion.MENU
|
||||||
|
|
|
@ -14,5 +14,5 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||||
*/
|
*/
|
||||||
class DisabledNavigation : ViewerNavigation() {
|
class DisabledNavigation : ViewerNavigation() {
|
||||||
|
|
||||||
override var regions: List<Region> = emptyList()
|
override var regionList: List<Region> = emptyList()
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||||
*/
|
*/
|
||||||
class EdgeNavigation : ViewerNavigation() {
|
class EdgeNavigation : ViewerNavigation() {
|
||||||
|
|
||||||
override var regions: List<Region> = listOf(
|
override var regionList: List<Region> = listOf(
|
||||||
Region(
|
Region(
|
||||||
rectF = RectF(0f, 0f, 0.33f, 1f),
|
rectF = RectF(0f, 0f, 0.33f, 1f),
|
||||||
type = NavigationRegion.NEXT,
|
type = NavigationRegion.NEXT,
|
||||||
|
|
|
@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||||
*/
|
*/
|
||||||
class KindlishNavigation : ViewerNavigation() {
|
class KindlishNavigation : ViewerNavigation() {
|
||||||
|
|
||||||
override var regions: List<Region> = listOf(
|
override var regionList: List<Region> = listOf(
|
||||||
Region(
|
Region(
|
||||||
rectF = RectF(0.33f, 0.33f, 1f, 1f),
|
rectF = RectF(0.33f, 0.33f, 1f, 1f),
|
||||||
type = NavigationRegion.NEXT,
|
type = NavigationRegion.NEXT,
|
||||||
|
|
|
@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||||
*/
|
*/
|
||||||
open class LNavigation : ViewerNavigation() {
|
open class LNavigation : ViewerNavigation() {
|
||||||
|
|
||||||
override var regions: List<Region> = listOf(
|
override var regionList: List<Region> = listOf(
|
||||||
Region(
|
Region(
|
||||||
rectF = RectF(0f, 0.33f, 0.33f, 0.66f),
|
rectF = RectF(0f, 0.33f, 0.33f, 0.66f),
|
||||||
type = NavigationRegion.PREV,
|
type = NavigationRegion.PREV,
|
||||||
|
|
|
@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||||
*/
|
*/
|
||||||
class RightAndLeftNavigation : ViewerNavigation() {
|
class RightAndLeftNavigation : ViewerNavigation() {
|
||||||
|
|
||||||
override var regions: List<Region> = listOf(
|
override var regionList: List<Region> = listOf(
|
||||||
Region(
|
Region(
|
||||||
rectF = RectF(0f, 0f, 0.33f, 1f),
|
rectF = RectF(0f, 0f, 0.33f, 1f),
|
||||||
type = NavigationRegion.LEFT,
|
type = NavigationRegion.LEFT,
|
||||||
|
|
Reference in a new issue