diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt
index 312544684..e60f7f508 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceValues.kt
@@ -30,4 +30,11 @@ object PreferenceValues {
COMFORTABLE_GRID,
LIST,
}
+
+ enum class TappingInvertMode {
+ NONE,
+ HORIZONTAL,
+ VERTICAL,
+ BOTH
+ }
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
index df32cb70e..8476c01f2 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
@@ -121,7 +121,7 @@ class PreferencesHelper(val context: Context) {
fun readWithTapping() = flowPrefs.getBoolean(Keys.readWithTapping, true)
- fun readWithTappingInverted() = flowPrefs.getBoolean(Keys.readWithTappingInverted, false)
+ fun readWithTappingInverted() = flowPrefs.getEnum(Keys.readWithTappingInverted, Values.TappingInvertMode.NONE)
fun readWithLongTap() = flowPrefs.getBoolean(Keys.readWithLongTap, true)
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt
index 3410fc46f..78590a1c5 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt
@@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.reader.viewer
import com.tfcporciuncula.flow.Preference
+import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -20,7 +21,7 @@ abstract class ViewerConfig(preferences: PreferencesHelper) {
var tappingEnabled = true
var longTapEnabled = true
- var tappingInverted = false
+ var tappingInverted = TappingInvertMode.NONE
var doubleTapAnimDuration = 500
var volumeKeysEnabled = false
var volumeKeysInverted = false
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 3452cab06..ef5c029d1 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
@@ -7,6 +7,7 @@ import android.view.View
import android.view.ViewGroup.LayoutParams
import androidx.viewpager.widget.ViewPager
import eu.kanade.tachiyomi.R
+import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
@@ -80,10 +81,11 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
}
})
pager.tapListener = { event ->
- val tappingInverted = config.tappingInverted
+ val invertMode = config.tappingInverted
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
@@ -94,6 +96,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
}
} 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
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 5a552ab52..8640859e7 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
@@ -7,6 +7,7 @@ import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.WebtoonLayoutManager
+import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
@@ -14,10 +15,10 @@ import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
-import kotlin.math.max
-import kotlin.math.min
import rx.subscriptions.CompositeSubscription
import timber.log.Timber
+import kotlin.math.max
+import kotlin.math.min
/**
* Implementation of a [BaseViewer] to display pages with a [RecyclerView].
@@ -94,10 +95,12 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
})
recycler.tapListener = { event ->
val positionY = event.rawY
- val tappingInverted = config.tappingInverted
+ val invertMode = config.tappingInverted
val topSideTap = positionY < recycler.height * 0.33f && config.tappingEnabled
val bottomSideTap = positionY > recycler.height * 0.66f && config.tappingEnabled
+ val tappingInverted = invertMode == TappingInvertMode.VERTICAL || invertMode == TappingInvertMode.BOTH
+
when {
topSideTap && !tappingInverted || bottomSideTap && tappingInverted -> scrollUp()
bottomSideTap && !tappingInverted || topSideTap && tappingInverted -> scrollDown()
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt
index f72923e07..dbf27ae7f 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt
@@ -4,9 +4,11 @@ import android.os.Build
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
+import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
import eu.kanade.tachiyomi.util.preference.defaultValue
import eu.kanade.tachiyomi.util.preference.entriesRes
import eu.kanade.tachiyomi.util.preference.intListPreference
+import eu.kanade.tachiyomi.util.preference.listPreference
import eu.kanade.tachiyomi.util.preference.preferenceCategory
import eu.kanade.tachiyomi.util.preference.summaryRes
import eu.kanade.tachiyomi.util.preference.switchPreference
@@ -190,10 +192,23 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_read_with_tapping
defaultValue = true
}
- switchPreference {
+ listPreference {
key = Keys.readWithTappingInverted
titleRes = R.string.pref_read_with_tapping_inverted
- defaultValue = false
+ entriesRes = arrayOf(
+ R.string.tapping_inverted_none,
+ R.string.tapping_inverted_horizontal,
+ R.string.tapping_inverted_vertical,
+ R.string.tapping_inverted_both
+ )
+ entryValues = arrayOf(
+ TappingInvertMode.NONE.name,
+ TappingInvertMode.HORIZONTAL.name,
+ TappingInvertMode.VERTICAL.name,
+ TappingInvertMode.BOTH.name
+ )
+ defaultValue = TappingInvertMode.NONE.name
+ summary = "%s"
}.apply { dependency = Keys.readWithTapping }
switchPreference {
key = Keys.readWithLongTap
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 19173a380..6999c2966 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -665,5 +665,9 @@
Progress
Complete
Invert tapping
+ None
+ Horizontal
+ Vertical
+ Both