From 26b3eb696c95b6363176e77effdd38089af5c19e Mon Sep 17 00:00:00 2001 From: Mekanik Date: Sat, 5 Aug 2023 15:36:19 -0700 Subject: [PATCH] Fix missing inversion in tap zones help overlay. (#9812) --- .../ui/reader/ReaderNavigationOverlayView.kt | 2 +- .../tachiyomi/ui/reader/viewer/ViewerNavigation.kt | 12 ++++++++---- .../reader/viewer/navigation/DisabledNavigation.kt | 2 +- .../ui/reader/viewer/navigation/EdgeNavigation.kt | 2 +- .../reader/viewer/navigation/KindlishNavigation.kt | 2 +- .../ui/reader/viewer/navigation/LNavigation.kt | 2 +- .../viewer/navigation/RightAndLeftNavigation.kt | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderNavigationOverlayView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderNavigationOverlayView.kt index 9a0258ba45..f96242b69f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderNavigationOverlayView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderNavigationOverlayView.kt @@ -61,7 +61,7 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet) override fun onDraw(canvas: Canvas) { if (navigation == null) return - navigation?.regions?.forEach { region -> + navigation?.getRegions()?.forEach { region -> val rect = region.rectF // Scale rect from 1f,1f to screen width and height diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerNavigation.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerNavigation.kt index 67e923d3f0..be27506c42 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerNavigation.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerNavigation.kt @@ -32,15 +32,19 @@ abstract class ViewerNavigation { private var constantMenuRegion: RectF = RectF(0f, 0f, 1f, 0.05f) - abstract var regions: List - var invertMode: ReaderPreferences.TappingInvertMode = ReaderPreferences.TappingInvertMode.NONE + protected abstract var regionList: List + + /** Returns regions with applied inversion. */ + fun getRegions(): List { + return regionList.map { it.invert(invertMode) } + } + fun getAction(pos: PointF): NavigationRegion { val x = pos.x val y = pos.y - val region = regions.map { it.invert(invertMode) } - .find { it.rectF.contains(x, y) } + val region = getRegions().find { it.rectF.contains(x, y) } return when { region != null -> region.type constantMenuRegion.contains(x, y) -> NavigationRegion.MENU diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/DisabledNavigation.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/DisabledNavigation.kt index 11a715faf8..e6fac74d07 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/DisabledNavigation.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/DisabledNavigation.kt @@ -14,5 +14,5 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation */ class DisabledNavigation : ViewerNavigation() { - override var regions: List = emptyList() + override var regionList: List = emptyList() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/EdgeNavigation.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/EdgeNavigation.kt index 7440b1e353..ebd69ee3bb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/EdgeNavigation.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/EdgeNavigation.kt @@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation */ class EdgeNavigation : ViewerNavigation() { - override var regions: List = listOf( + override var regionList: List = listOf( Region( rectF = RectF(0f, 0f, 0.33f, 1f), type = NavigationRegion.NEXT, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/KindlishNavigation.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/KindlishNavigation.kt index 21bf053ebb..9b6fa362a1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/KindlishNavigation.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/KindlishNavigation.kt @@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation */ class KindlishNavigation : ViewerNavigation() { - override var regions: List = listOf( + override var regionList: List = listOf( Region( rectF = RectF(0.33f, 0.33f, 1f, 1f), type = NavigationRegion.NEXT, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/LNavigation.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/LNavigation.kt index 8f94a61006..c2a751fb32 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/LNavigation.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/LNavigation.kt @@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation */ open class LNavigation : ViewerNavigation() { - override var regions: List = listOf( + override var regionList: List = listOf( Region( rectF = RectF(0f, 0.33f, 0.33f, 0.66f), type = NavigationRegion.PREV, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/RightAndLeftNavigation.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/RightAndLeftNavigation.kt index b660000f2d..4c9bc6a77b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/RightAndLeftNavigation.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/navigation/RightAndLeftNavigation.kt @@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation */ class RightAndLeftNavigation : ViewerNavigation() { - override var regions: List = listOf( + override var regionList: List = listOf( Region( rectF = RectF(0f, 0f, 0.33f, 1f), type = NavigationRegion.LEFT,