diff --git a/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt b/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt
index fd27171cc..a65095ad1 100644
--- a/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt
+++ b/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt
@@ -3,9 +3,6 @@ package io.legado.app.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
-import android.os.Handler
-import android.os.Looper
-import android.os.Message
import android.view.KeyEvent
import io.legado.app.constant.EventBus
import io.legado.app.data.appDb
@@ -19,8 +16,8 @@ import io.legado.app.service.help.ReadBook
import io.legado.app.ui.book.audio.AudioPlayActivity
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.main.MainActivity
+import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.postEvent
-import splitties.init.appCtx
/**
@@ -37,21 +34,6 @@ class MediaButtonReceiver : BroadcastReceiver() {
companion object {
- val handler = object : Handler(Looper.getMainLooper()) {
-
- override fun handleMessage(msg: Message) {
- when (msg.what) {
- KeyEvent.KEYCODE_MEDIA_PREVIOUS -> {
- ReadAloud.prevParagraph(appCtx)
- }
- KeyEvent.KEYCODE_MEDIA_NEXT -> {
- ReadAloud.nextParagraph(appCtx)
- }
- }
- }
-
- }
-
fun handleIntent(context: Context, intent: Intent): Boolean {
val intentAction = intent.action
if (Intent.ACTION_MEDIA_BUTTON == intentAction) {
@@ -62,22 +44,17 @@ class MediaButtonReceiver : BroadcastReceiver() {
if (action == KeyEvent.ACTION_DOWN) {
when (keycode) {
KeyEvent.KEYCODE_MEDIA_PREVIOUS -> {
- if (handler.hasMessages(KeyEvent.KEYCODE_MEDIA_PREVIOUS)) {
- handler.removeMessages(KeyEvent.KEYCODE_MEDIA_PREVIOUS)
+ if (context.getPrefBoolean("mediaButtonPerNext", false)) {
ReadBook.moveToPrevChapter(true)
} else {
- handler.sendEmptyMessageDelayed(
- KeyEvent.KEYCODE_MEDIA_PREVIOUS,
- 500
- )
+ ReadAloud.prevParagraph(context)
}
}
KeyEvent.KEYCODE_MEDIA_NEXT -> {
- if (handler.hasMessages(KeyEvent.KEYCODE_MEDIA_NEXT)) {
- handler.removeMessages(KeyEvent.KEYCODE_MEDIA_NEXT)
+ if (context.getPrefBoolean("mediaButtonPerNext", false)) {
ReadBook.moveToNextChapter(true)
} else {
- handler.sendEmptyMessageDelayed(KeyEvent.KEYCODE_MEDIA_NEXT, 500)
+ ReadAloud.nextParagraph(context)
}
}
else -> readAloud(context)
diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml
index 49c3fec0a..dbe8305ff 100644
--- a/app/src/main/res/values-es-rES/strings.xml
+++ b/app/src/main/res/values-es-rES/strings.xml
@@ -849,4 +849,7 @@
未知错误
end
关闭替换分组/开启添加分组
+ 媒体按钮•上一首|下一首
+ 上一段|下一段/上一章|下一章
+ 及时翻页,翻页时会停顿一下
diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml
index 1ffd710ea..2df18fdb4 100644
--- a/app/src/main/res/values-ja-rJP/strings.xml
+++ b/app/src/main/res/values-ja-rJP/strings.xml
@@ -850,4 +850,7 @@
No export chapter names
end
关闭替换分组/开启添加分组
+ 媒体按钮•上一首|下一首
+ 上一段|下一段/上一章|下一章
+ 及时翻页,翻页时会停顿一下
diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml
index 78aa4c716..8b413ed2a 100644
--- a/app/src/main/res/values-pt-rBR/strings.xml
+++ b/app/src/main/res/values-pt-rBR/strings.xml
@@ -849,4 +849,7 @@
未知错误
end
关闭替换分组/开启添加分组
+ 媒体按钮•上一首|下一首
+ 上一段|下一段/上一章|下一章
+ 及时翻页,翻页时会停顿一下
diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml
index 70c62f14b..94be838df 100644
--- a/app/src/main/res/values-zh-rHK/strings.xml
+++ b/app/src/main/res/values-zh-rHK/strings.xml
@@ -851,5 +851,8 @@
TXT不導出章節名
end
关闭替换分组/开启添加分组
+ 媒体按钮•上一首|下一首
+ 上一段|下一段/上一章|下一章
+ 及时翻页,翻页时会停顿一下
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index bb8b6827a..e73f203ad 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -852,5 +852,8 @@
TXT不匯出章節名
end
关闭替换分组/开启添加分组
+ 媒体按钮•上一首|下一首
+ 上一段|下一段/上一章|下一章
+ 及时翻页,翻页时会停顿一下
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index 78323bbeb..ca37cecdb 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -853,5 +853,8 @@
自动备份失败
结束
关闭替换分组/开启添加分组
+ 媒体按钮•上一首|下一首
+ 上一段|下一段/上一章|下一章
+ 及时翻页,翻页时会停顿一下
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 70aa39e1a..7db201c7b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -855,5 +855,8 @@
Autobackup failed
end
关闭替换分组/开启添加分组
+ 媒体按钮•上一首|下一首
+ 上一段|下一段/上一章|下一章
+ 及时翻页,翻页时会停顿一下
diff --git a/app/src/main/res/xml/pref_config_aloud.xml b/app/src/main/res/xml/pref_config_aloud.xml
index 95d5193d0..ed2eb7c64 100644
--- a/app/src/main/res/xml/pref_config_aloud.xml
+++ b/app/src/main/res/xml/pref_config_aloud.xml
@@ -8,9 +8,17 @@
app:allowDividerBelow="false"
app:iconSpaceReserved="false">
+
+