From c54b8e62d72bf6e8e7508d9f43373749b99142e0 Mon Sep 17 00:00:00 2001 From: Andreas E Date: Sun, 21 Jun 2020 16:47:18 +0200 Subject: [PATCH] Add option to reverse tapping --- .../kanade/tachiyomi/data/preference/PreferenceKeys.kt | 2 ++ .../tachiyomi/data/preference/PreferencesHelper.kt | 2 ++ .../eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt | 4 ++++ .../tachiyomi/ui/reader/viewer/pager/PagerViewer.kt | 9 +++++++-- .../tachiyomi/ui/setting/SettingsReaderController.kt | 5 +++++ app/src/main/res/values/strings.xml | 1 + 6 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 851e17029..d93fd0c8e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -55,6 +55,8 @@ object PreferenceKeys { const val readWithTapping = "reader_tap" + const val readWithTappingInverted = "reader_volume_keys_inverted" + const val readWithLongTap = "reader_long_tap" const val readWithVolumeKeys = "reader_volume_keys" 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 8cb193959..df32cb70e 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,6 +121,8 @@ class PreferencesHelper(val context: Context) { fun readWithTapping() = flowPrefs.getBoolean(Keys.readWithTapping, true) + fun readWithTappingInverted() = flowPrefs.getBoolean(Keys.readWithTappingInverted, false) + fun readWithLongTap() = flowPrefs.getBoolean(Keys.readWithLongTap, true) fun readWithVolumeKeys() = flowPrefs.getBoolean(Keys.readWithVolumeKeys, false) 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 752045821..4221cf6d5 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 @@ -20,6 +20,7 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { var tappingEnabled = true var longTapEnabled = true + var tappingInverted = false var doubleTapAnimDuration = 500 var volumeKeysEnabled = false var volumeKeysInverted = false @@ -30,6 +31,9 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { preferences.readWithTapping() .register({ tappingEnabled = it }) + preferences.readWithTappingInverted() + .register({ tappingInverted = it }) + preferences.readWithLongTap() .register({ longTapEnabled = it }) 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 81ea15a41..29132c079 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 @@ -81,9 +81,14 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer { }) pager.tapListener = { event -> val positionX = event.x + val tappingInverted = config.tappingInverted + + val leftSideTap = positionX < pager.width * 0.33f && config.tappingEnabled + val rightSideTap = positionX > pager.width * 0.66f && config.tappingEnabled + when { - positionX < pager.width * 0.33f && config.tappingEnabled -> moveLeft() - positionX > pager.width * 0.66f && config.tappingEnabled -> moveRight() + leftSideTap && !tappingInverted || rightSideTap && tappingInverted -> moveLeft() + rightSideTap && !tappingInverted || leftSideTap && tappingInverted -> moveRight() else -> activity.toggleMenu() } } 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 12fe7f5ca..f72923e07 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 @@ -190,6 +190,11 @@ class SettingsReaderController : SettingsController() { titleRes = R.string.pref_read_with_tapping defaultValue = true } + switchPreference { + key = Keys.readWithTappingInverted + titleRes = R.string.pref_read_with_tapping_inverted + defaultValue = false + }.apply { dependency = Keys.readWithTapping } switchPreference { key = Keys.readWithLongTap titleRes = R.string.pref_read_with_long_tap diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 13cac05c9..15339ad10 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -665,5 +665,6 @@ Backup and restore Progress Complete + Invert tapping