mirror of
https://github.com/mihonapp/mihon.git
synced 2025-07-01 05:27:50 +02:00
add support for S Pen actions (#4029)
This commit is contained in:
committed by
GitHub
parent
122b2b1a8e
commit
c9b1a425a7
@ -261,6 +261,17 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_N) {
|
||||
presenter.loadNextChapter()
|
||||
return true
|
||||
} else if (keyCode == KeyEvent.KEYCODE_P) {
|
||||
presenter.loadPreviousChapter()
|
||||
return true
|
||||
}
|
||||
return super.onKeyUp(keyCode, event)
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches a key event. If the viewer doesn't handle it, call the default implementation.
|
||||
*/
|
||||
|
@ -324,6 +324,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
*/
|
||||
override fun handleKeyEvent(event: KeyEvent): Boolean {
|
||||
val isUp = event.action == KeyEvent.ACTION_UP
|
||||
val ctrlPressed = event.metaState.and(KeyEvent.META_CTRL_ON) > 0
|
||||
|
||||
when (event.keyCode) {
|
||||
KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
||||
@ -340,8 +341,16 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
if (!config.volumeKeysInverted) moveUp() else moveDown()
|
||||
}
|
||||
}
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT -> if (isUp) moveRight()
|
||||
KeyEvent.KEYCODE_DPAD_LEFT -> if (isUp) moveLeft()
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT -> {
|
||||
if (isUp) {
|
||||
if (ctrlPressed) moveToNext() else moveRight()
|
||||
}
|
||||
}
|
||||
KeyEvent.KEYCODE_DPAD_LEFT -> {
|
||||
if (isUp) {
|
||||
if (ctrlPressed) moveToPrevious() else moveLeft()
|
||||
}
|
||||
}
|
||||
KeyEvent.KEYCODE_DPAD_DOWN -> if (isUp) moveDown()
|
||||
KeyEvent.KEYCODE_DPAD_UP -> if (isUp) moveUp()
|
||||
KeyEvent.KEYCODE_PAGE_DOWN -> if (isUp) moveDown()
|
||||
|
Reference in New Issue
Block a user