pull/1251/head
gedoor 3 years ago
parent 7ac00c1e74
commit c10e32c0c3
  1. 33
      app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt
  2. 3
      app/src/main/res/values-es-rES/strings.xml
  3. 3
      app/src/main/res/values-ja-rJP/strings.xml
  4. 3
      app/src/main/res/values-pt-rBR/strings.xml
  5. 3
      app/src/main/res/values-zh-rHK/strings.xml
  6. 3
      app/src/main/res/values-zh-rTW/strings.xml
  7. 3
      app/src/main/res/values-zh/strings.xml
  8. 3
      app/src/main/res/values/strings.xml
  9. 8
      app/src/main/res/xml/pref_config_aloud.xml

@ -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)

@ -849,4 +849,7 @@
<string name="unknown_error">未知错误</string>
<string name="end">end</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string>
<string name="pref_media_button_per_next">媒体按钮•上一首|下一首</string>
<string name="pref_media_button_per_next_summary">上一段|下一段/上一章|下一章</string>
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
</resources>

@ -850,4 +850,7 @@
<string name="export_no_chapter_name">No export chapter names</string>
<string name="end">end</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string>
<string name="pref_media_button_per_next">媒体按钮•上一首|下一首</string>
<string name="pref_media_button_per_next_summary">上一段|下一段/上一章|下一章</string>
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
</resources>

@ -849,4 +849,7 @@
<string name="unknown_error">未知错误</string>
<string name="end">end</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string>
<string name="pref_media_button_per_next">媒体按钮•上一首|下一首</string>
<string name="pref_media_button_per_next_summary">上一段|下一段/上一章|下一章</string>
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
</resources>

@ -851,5 +851,8 @@
<string name="export_no_chapter_name">TXT不導出章節名</string>
<string name="end">end</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string>
<string name="pref_media_button_per_next">媒体按钮•上一首|下一首</string>
<string name="pref_media_button_per_next_summary">上一段|下一段/上一章|下一章</string>
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
</resources>

@ -852,5 +852,8 @@
<string name="export_no_chapter_name">TXT不匯出章節名</string>
<string name="end">end</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string>
<string name="pref_media_button_per_next">媒体按钮•上一首|下一首</string>
<string name="pref_media_button_per_next_summary">上一段|下一段/上一章|下一章</string>
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
</resources>

@ -853,5 +853,8 @@
<string name="autobackup_fail">自动备份失败</string>
<string name="end">结束</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string>
<string name="pref_media_button_per_next">媒体按钮•上一首|下一首</string>
<string name="pref_media_button_per_next_summary">上一段|下一段/上一章|下一章</string>
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
</resources>

@ -855,5 +855,8 @@
<string name="autobackup_fail">Autobackup failed</string>
<string name="end">end</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string>
<string name="pref_media_button_per_next">媒体按钮•上一首|下一首</string>
<string name="pref_media_button_per_next_summary">上一段|下一段/上一章|下一章</string>
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
</resources>

@ -8,9 +8,17 @@
app:allowDividerBelow="false"
app:iconSpaceReserved="false">
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/pref_media_button_per_next"
android:summary="@string/pref_media_button_per_next_summary"
android:key="mediaButtonPerNext"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/read_aloud_by_page"
android:summary="@string/read_aloud_by_page_summary"
android:key="readAloudByPage"
app:iconSpaceReserved="false" />

Loading…
Cancel
Save