add support for S Pen remote actions

pull/801/head
Dacer 4 years ago
parent ce2f544017
commit dd5df93022
  1. 10
      app/src/main/AndroidManifest.xml
  2. 8
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 23
      app/src/main/res/xml/spen_remote_actions.xml

@ -150,7 +150,15 @@
<activity
android:name=".ui.book.read.ReadBookActivity"
android:configChanges="locale|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"
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/spen_remote_actions" />
</activity>
<!-- 书籍详情页 -->
<activity
android:name=".ui.book.info.BookInfoActivity"

@ -302,6 +302,14 @@ class ReadBookActivity : ReadBookBaseActivity(),
return true
}
}
keyCode == KeyEvent.KEYCODE_PAGE_UP -> {
binding.readView.pageDelegate?.keyTurnPage(PageDirection.PREV)
return true
}
keyCode == KeyEvent.KEYCODE_PAGE_DOWN -> {
binding.readView.pageDelegate?.keyTurnPage(PageDirection.NEXT)
return true
}
keyCode == KeyEvent.KEYCODE_SPACE -> {
binding.readView.pageDelegate?.keyTurnPage(PageDirection.NEXT)
return true

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<remote-actions
actionset_label="@string/app_name"
version="1.2">
<action
id="next_page"
label="@string/next_page"
priority="1"
repeatable="true"
repeatable_interval="short"
trigger_key="PAGE_DOWN">
<preference name="gesture" value="click" />
</action>
<action
id="prev_page"
label="@string/prev_page"
priority="2"
repeatable="true"
repeatable_interval="short"
trigger_key="PAGE_UP">
<preference name="gesture" value="double_click" />
</action>
</remote-actions>
Loading…
Cancel
Save