mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 06:17:57 +01:00 
			
		
		
		
	Add option to invert volume keys. Closes #834
This commit is contained in:
		| @@ -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 } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user