Przeglądaj źródła

fix:三星Spen失效的问题,并添加上一章和下一章的操作选项 (#1583)

fansan 4 miesięcy temu
rodzic
commit
4f25e6d73b

+ 45 - 0
app/src/main/AndroidManifest.xml

@@ -44,7 +44,12 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <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.main.Launcher0"
@@ -54,7 +59,12 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <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>
         <!-- 图标1 -->
         <activity
@@ -65,7 +75,12 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <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>
         <!-- 图标2 -->
         <activity
@@ -76,7 +91,12 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <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>
         <!-- 图标3 -->
         <activity
@@ -87,7 +107,12 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <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>
         <!-- 图标4 -->
         <activity
@@ -98,7 +123,12 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <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>
         <!-- 图标5 -->
         <activity
@@ -109,7 +139,12 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <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>
         <!-- 图标6 -->
         <activity
@@ -120,7 +155,12 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <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
@@ -132,7 +172,12 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <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.welcome.WelcomeActivity"

+ 14 - 0
app/src/main/java/io/legado/app/ui/book/read/ReadBookController.kt

@@ -975,6 +975,20 @@ class ReadBookController(
                 handleKeyPage(PageDirection.NEXT, longPress)
                 return true
             }
+
+            KeyEvent.KEYCODE_MEDIA_NEXT -> {
+                if (ReadBook.book != null) {
+                    ReadBook.moveToNextChapter(true)
+                }
+                return true
+            }
+
+            KeyEvent.KEYCODE_MEDIA_PREVIOUS -> {
+                if (ReadBook.book != null) {
+                    ReadBook.moveToPrevChapter(upContent = true, toLast = false)
+                }
+                return true
+            }
         }
         return false
     }

+ 19 - 0
app/src/main/res/xml/spen_remote_actions.xml

@@ -11,6 +11,7 @@
         trigger_key="PAGE_DOWN">
         <preference name="gesture" value="click" />
     </action>
+
     <action
         id="prev_page"
         label="@string/prev_page"
@@ -20,4 +21,22 @@
         trigger_key="PAGE_UP">
         <preference name="gesture" value="double_click" />
     </action>
+
+    <action
+        id="prev_chapter"
+        label="@string/previous_chapter"
+        priority="3"
+        repeatable="false"
+        trigger_key="MEDIA_PREVIOUS">
+        <preference name="gesture" value="move_left" />
+    </action>
+
+    <action
+        id="next_chapter"
+        label="@string/next_chapter"
+        priority="4"
+        repeatable="false"
+        trigger_key="MEDIA_NEXT">
+        <preference name="gesture" value="move_right" />
+    </action>
 </remote-actions>