diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt index fc646784d..165b25ac3 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt @@ -143,6 +143,9 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) { val isReaderControlAlwaysLTR: Boolean get() = prefs.getBoolean(KEY_READER_CONTROL_LTR, false) + val isReaderNavigationInverted: Boolean + get() = prefs.getBoolean(KEY_READER_NAVIGATION_INVERTED, false) + val isReaderFullscreenEnabled: Boolean get() = prefs.getBoolean(KEY_READER_FULLSCREEN, true) @@ -631,6 +634,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) { const val KEY_READER_DOUBLE_PAGES = "reader_double_pages" const val KEY_READER_ZOOM_BUTTONS = "reader_zoom_buttons" const val KEY_READER_CONTROL_LTR = "reader_taps_ltr" + const val KEY_READER_NAVIGATION_INVERTED = "reader_navigation_inverted" const val KEY_READER_FULLSCREEN = "reader_fullscreen" const val KEY_READER_VOLUME_BUTTONS = "reader_volume_buttons" const val KEY_READER_ORIENTATION = "reader_orientation" diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderControlDelegate.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderControlDelegate.kt index e1e6d20ae..657b82e54 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderControlDelegate.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderControlDelegate.kt @@ -60,28 +60,28 @@ class ReaderControlDelegate( KeyEvent.KEYCODE_L -> switchBy(-1, null, false) KeyEvent.KEYCODE_VOLUME_UP -> if (settings.isReaderVolumeButtonsEnabled) { - switchBy(-1, event, false) + switchBy(if (settings.isReaderNavigationInverted) 1 else -1, event, false) } else { return false } KeyEvent.KEYCODE_VOLUME_DOWN -> if (settings.isReaderVolumeButtonsEnabled) { - switchBy(1, event, false) + switchBy(if (settings.isReaderNavigationInverted) -1 else 1, event, false) } else { return false } - KeyEvent.KEYCODE_DPAD_RIGHT -> switchByRelative(1, event) + KeyEvent.KEYCODE_DPAD_RIGHT -> switchByRelative(if (settings.isReaderNavigationInverted) -1 else 1, event) - KeyEvent.KEYCODE_DPAD_LEFT -> switchByRelative(-1, event) + KeyEvent.KEYCODE_DPAD_LEFT -> switchByRelative(if (settings.isReaderNavigationInverted) 1 else -1, event) KeyEvent.KEYCODE_DPAD_CENTER -> listener.toggleUiVisibility() KeyEvent.KEYCODE_SYSTEM_NAVIGATION_UP, - KeyEvent.KEYCODE_DPAD_UP -> switchBy(-1, event, true) + KeyEvent.KEYCODE_DPAD_UP -> switchBy(if (settings.isReaderNavigationInverted) 1 else -1, event, true) KeyEvent.KEYCODE_SYSTEM_NAVIGATION_DOWN, - KeyEvent.KEYCODE_DPAD_DOWN -> switchBy(1, event, true) + KeyEvent.KEYCODE_DPAD_DOWN -> switchBy(if (settings.isReaderNavigationInverted) -1 else 1, event, true) else -> return false } @@ -95,10 +95,10 @@ class ReaderControlDelegate( private fun processAction(action: TapAction) { when (action) { - TapAction.PAGE_NEXT -> listener.switchPageBy(1) - TapAction.PAGE_PREV -> listener.switchPageBy(-1) - TapAction.CHAPTER_NEXT -> listener.switchChapterBy(1) - TapAction.CHAPTER_PREV -> listener.switchChapterBy(-1) + TapAction.PAGE_NEXT -> listener.switchPageBy(if (settings.isReaderNavigationInverted) -1 else 1) + TapAction.PAGE_PREV -> listener.switchPageBy(if (settings.isReaderNavigationInverted) 1 else -1) + TapAction.CHAPTER_NEXT -> listener.switchChapterBy(if (settings.isReaderNavigationInverted) -1 else 1) + TapAction.CHAPTER_PREV -> listener.switchChapterBy(if (settings.isReaderNavigationInverted) 1 else -1) TapAction.TOGGLE_UI -> listener.toggleUiVisibility() TapAction.SHOW_MENU -> listener.openMenu() } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e40d729f4..47e1ea0d0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -565,6 +565,8 @@ Configure actions for tappable screen areas Enable volume buttons Use volume buttons for switching pages + Invert navigation controls + Swap the direction of volume button and screen tap navigation (left becomes right, right becomes left) Tap action Long tap action None diff --git a/app/src/main/res/xml/pref_reader.xml b/app/src/main/res/xml/pref_reader.xml index 894bed8f3..3045b3d0a 100644 --- a/app/src/main/res/xml/pref_reader.xml +++ b/app/src/main/res/xml/pref_reader.xml @@ -75,6 +75,12 @@ android:summary="@string/switch_pages_volume_buttons_summary" android:title="@string/switch_pages_volume_buttons" /> + +