add support for S Pen actions (#4029)
This commit is contained in:
parent
122b2b1a8e
commit
c9b1a425a7
6 changed files with 96 additions and 3 deletions
|
@ -60,7 +60,14 @@
|
|||
</activity>
|
||||
<activity
|
||||
android:name=".ui.reader.ReaderActivity"
|
||||
android:launchMode="singleTask" />
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter>
|
||||
<action android:name="com.samsung.android.support.REMOTE_ACTION" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data android:name="com.samsung.android.support.REMOTE_ACTION"
|
||||
android:resource="@xml/s_pen_actions"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.security.BiometricUnlockActivity"
|
||||
android:theme="@style/Theme.Splash" />
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -401,4 +401,6 @@
|
|||
<string name="label_more">Více</string>
|
||||
<string name="action_menu">Menu</string>
|
||||
<string name="label_sources">Zdroje</string>
|
||||
<string name="spen_previous_page">Předchozí stránka</string>
|
||||
<string name="spen_next_page">Následující stránka</string>
|
||||
</resources>
|
|
@ -719,4 +719,8 @@
|
|||
<string name="tapping_inverted_vertical">Vertical</string>
|
||||
<string name="tapping_inverted_both">Both</string>
|
||||
|
||||
<!-- S Pen actions -->
|
||||
<string name="spen_previous_page">Previous page</string>
|
||||
<string name="spen_next_page">Next page</string>
|
||||
|
||||
</resources>
|
||||
|
|
60
app/src/main/res/xml/s_pen_actions.xml
Normal file
60
app/src/main/res/xml/s_pen_actions.xml
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<remote-actions
|
||||
actionset_label="@string/app_name"
|
||||
version="1.2">
|
||||
<action
|
||||
id="tachiyomi_next_page"
|
||||
label="@string/spen_next_page"
|
||||
priority="1"
|
||||
repeatable="true"
|
||||
repeatable_interval="short"
|
||||
trigger_key="CTRL_LEFT+DPAD_RIGHT">
|
||||
<preference
|
||||
name="gesture"
|
||||
value="click" />
|
||||
</action>
|
||||
<action
|
||||
id="tachiyomi_previous_page"
|
||||
label="@string/spen_previous_page"
|
||||
priority="2"
|
||||
repeatable="true"
|
||||
repeatable_interval="short"
|
||||
trigger_key="CTRL_LEFT+DPAD_LEFT">
|
||||
<preference
|
||||
name="gesture"
|
||||
value="double_click" />
|
||||
</action>
|
||||
<action
|
||||
id="tachiyomi_back"
|
||||
label="@string/action_webview_back"
|
||||
priority="3"
|
||||
repeatable="true"
|
||||
repeatable_interval="short"
|
||||
trigger_key="BACK">
|
||||
<preference
|
||||
name="gesture"
|
||||
value="circle_ccw" />
|
||||
</action>
|
||||
<action
|
||||
id="tachiyomi_next_chapter"
|
||||
label="@string/action_next_chapter"
|
||||
priority="4"
|
||||
repeatable="true"
|
||||
repeatable_interval="short"
|
||||
trigger_key="N">
|
||||
<preference
|
||||
name="gesture"
|
||||
value="swipe_right" />
|
||||
</action>
|
||||
<action
|
||||
id="tachiyomi_previous_chapter"
|
||||
label="@string/action_previous_chapter"
|
||||
priority="5"
|
||||
repeatable="true"
|
||||
repeatable_interval="short"
|
||||
trigger_key="P">
|
||||
<preference
|
||||
name="gesture"
|
||||
value="swipe_left" />
|
||||
</action>
|
||||
</remote-actions>
|
Reference in a new issue