Add option to invert volume keys. Closes #834

This commit is contained in:
len 2017-06-11 11:36:12 +02:00
parent 0210ee8747
commit 1794782323
7 changed files with 15 additions and 7 deletions

View File

@ -92,10 +92,6 @@ android {
checkReleaseBuilds false checkReleaseBuilds false
} }
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
} }
dependencies { dependencies {

View File

@ -41,6 +41,8 @@ object PreferenceKeys {
const val readWithVolumeKeys = "reader_volume_keys" const val readWithVolumeKeys = "reader_volume_keys"
const val readWithVolumeKeysInverted = "reader_volume_keys_inverted"
const val portraitColumns = "pref_library_columns_portrait_key" const val portraitColumns = "pref_library_columns_portrait_key"
const val landscapeColumns = "pref_library_columns_landscape_key" const val landscapeColumns = "pref_library_columns_landscape_key"

View File

@ -69,6 +69,8 @@ class PreferencesHelper(val context: Context) {
fun readWithVolumeKeys() = rxPrefs.getBoolean(Keys.readWithVolumeKeys, false) fun readWithVolumeKeys() = rxPrefs.getBoolean(Keys.readWithVolumeKeys, false)
fun readWithVolumeKeysInverted() = rxPrefs.getBoolean(Keys.readWithVolumeKeysInverted, false)
fun portraitColumns() = rxPrefs.getInteger(Keys.portraitColumns, 0) fun portraitColumns() = rxPrefs.getInteger(Keys.portraitColumns, 0)
fun landscapeColumns() = rxPrefs.getInteger(Keys.landscapeColumns, 0) fun landscapeColumns() = rxPrefs.getInteger(Keys.landscapeColumns, 0)

View File

@ -84,6 +84,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
private val volumeKeysEnabled by lazy { preferences.readWithVolumeKeys().getOrDefault() } private val volumeKeysEnabled by lazy { preferences.readWithVolumeKeys().getOrDefault() }
private val volumeKeysInverted by lazy { preferences.readWithVolumeKeysInverted().getOrDefault() }
val preferences by injectLazy<PreferencesHelper>() val preferences by injectLazy<PreferencesHelper>()
private var systemUi: SystemUiHelper? = null private var systemUi: SystemUiHelper? = null
@ -194,7 +196,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
KeyEvent.KEYCODE_VOLUME_DOWN -> { KeyEvent.KEYCODE_VOLUME_DOWN -> {
if (volumeKeysEnabled) { if (volumeKeysEnabled) {
if (event.action == KeyEvent.ACTION_UP) { if (event.action == KeyEvent.ACTION_UP) {
viewer?.moveDown() if (!volumeKeysInverted) viewer?.moveDown() else viewer?.moveUp()
} }
return true return true
} }
@ -202,7 +204,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
KeyEvent.KEYCODE_VOLUME_UP -> { KeyEvent.KEYCODE_VOLUME_UP -> {
if (volumeKeysEnabled) { if (volumeKeysEnabled) {
if (event.action == KeyEvent.ACTION_UP) { if (event.action == KeyEvent.ACTION_UP) {
viewer?.moveUp() if (!volumeKeysInverted) viewer?.moveUp() else viewer?.moveDown()
} }
return true return true
} }

View File

@ -100,6 +100,11 @@ class SettingsReaderController : SettingsController() {
titleRes = R.string.pref_read_with_volume_keys titleRes = R.string.pref_read_with_volume_keys
defaultValue = false defaultValue = false
} }
switchPreference {
key = Keys.readWithVolumeKeysInverted
titleRes = R.string.pref_read_with_volume_keys_inverted
defaultValue = false
}.apply { dependency = Keys.readWithVolumeKeys }
} }
} }

View File

@ -150,6 +150,7 @@
<string name="pref_keep_screen_on">Keep screen on</string> <string name="pref_keep_screen_on">Keep screen on</string>
<string name="pref_reader_navigation">Navigation</string> <string name="pref_reader_navigation">Navigation</string>
<string name="pref_read_with_volume_keys">Volume keys</string> <string name="pref_read_with_volume_keys">Volume keys</string>
<string name="pref_read_with_volume_keys_inverted">Invert volume keys</string>
<string name="pref_read_with_tapping">Tapping</string> <string name="pref_read_with_tapping">Tapping</string>
<string name="pref_reader_theme">Background color</string> <string name="pref_reader_theme">Background color</string>
<string name="white_background">White</string> <string name="white_background">White</string>

View File

@ -6,7 +6,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { 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' classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files