mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 12:47:26 +01:00
Add option to invert volume keys. Closes #834
This commit is contained in:
parent
0210ee8747
commit
1794782323
@ -92,10 +92,6 @@ android {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
@ -84,6 +84,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
|
||||
private val volumeKeysEnabled by lazy { preferences.readWithVolumeKeys().getOrDefault() }
|
||||
|
||||
private val volumeKeysInverted by lazy { preferences.readWithVolumeKeysInverted().getOrDefault() }
|
||||
|
||||
val preferences by injectLazy<PreferencesHelper>()
|
||||
|
||||
private var systemUi: SystemUiHelper? = null
|
||||
@ -194,7 +196,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
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<ReaderPresenter>() {
|
||||
KeyEvent.KEYCODE_VOLUME_UP -> {
|
||||
if (volumeKeysEnabled) {
|
||||
if (event.action == KeyEvent.ACTION_UP) {
|
||||
viewer?.moveUp()
|
||||
if (!volumeKeysInverted) viewer?.moveUp() else viewer?.moveDown()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,6 +150,7 @@
|
||||
<string name="pref_keep_screen_on">Keep screen on</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_inverted">Invert volume keys</string>
|
||||
<string name="pref_read_with_tapping">Tapping</string>
|
||||
<string name="pref_reader_theme">Background color</string>
|
||||
<string name="white_background">White</string>
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user