From 17947823235c366b03d32e0ffcd7390fde21f4c3 Mon Sep 17 00:00:00 2001 From: len Date: Sun, 11 Jun 2017 11:36:12 +0200 Subject: [PATCH] Add option to invert volume keys. Closes #834 --- app/build.gradle | 4 ---- .../eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt | 2 ++ .../kanade/tachiyomi/data/preference/PreferencesHelper.kt | 2 ++ .../java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt | 6 ++++-- .../kanade/tachiyomi/ui/setting/SettingsReaderController.kt | 5 +++++ app/src/main/res/values/strings.xml | 1 + build.gradle | 2 +- 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 055a572773..cce2cb6368 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -92,10 +92,6 @@ android { checkReleaseBuilds false } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - } dependencies { 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 fb4f6f45b0..15a092b391 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 @@ -41,6 +41,8 @@ object PreferenceKeys { const val readWithVolumeKeys = "reader_volume_keys" + const val readWithVolumeKeysInverted = "reader_volume_keys_inverted" + const val portraitColumns = "pref_library_columns_portrait_key" const val landscapeColumns = "pref_library_columns_landscape_key" 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 4559c6ab95..13057e2952 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 @@ -69,6 +69,8 @@ class PreferencesHelper(val context: Context) { fun readWithVolumeKeys() = rxPrefs.getBoolean(Keys.readWithVolumeKeys, false) + fun readWithVolumeKeysInverted() = rxPrefs.getBoolean(Keys.readWithVolumeKeysInverted, false) + fun portraitColumns() = rxPrefs.getInteger(Keys.portraitColumns, 0) fun landscapeColumns() = rxPrefs.getInteger(Keys.landscapeColumns, 0) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 07964dfd62..70ee645200 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -84,6 +84,8 @@ class ReaderActivity : BaseRxActivity() { private val volumeKeysEnabled by lazy { preferences.readWithVolumeKeys().getOrDefault() } + private val volumeKeysInverted by lazy { preferences.readWithVolumeKeysInverted().getOrDefault() } + val preferences by injectLazy() private var systemUi: SystemUiHelper? = null @@ -194,7 +196,7 @@ class ReaderActivity : BaseRxActivity() { KeyEvent.KEYCODE_VOLUME_DOWN -> { if (volumeKeysEnabled) { if (event.action == KeyEvent.ACTION_UP) { - viewer?.moveDown() + if (!volumeKeysInverted) viewer?.moveDown() else viewer?.moveUp() } return true } @@ -202,7 +204,7 @@ class ReaderActivity : BaseRxActivity() { KeyEvent.KEYCODE_VOLUME_UP -> { if (volumeKeysEnabled) { if (event.action == KeyEvent.ACTION_UP) { - viewer?.moveUp() + if (!volumeKeysInverted) viewer?.moveUp() else viewer?.moveDown() } return true } 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 229a709a62..03ec76a745 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 @@ -100,6 +100,11 @@ class SettingsReaderController : SettingsController() { titleRes = R.string.pref_read_with_volume_keys defaultValue = false } + switchPreference { + key = Keys.readWithVolumeKeysInverted + titleRes = R.string.pref_read_with_volume_keys_inverted + defaultValue = false + }.apply { dependency = Keys.readWithVolumeKeys } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 718d9a3452..8fed988aa8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -150,6 +150,7 @@ Keep screen on Navigation Volume keys + Invert volume keys Tapping Background color White diff --git a/build.gradle b/build.gradle index 66b50e6c4c..495a1cf782 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.1' + classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files