This commit is contained in:
Horis
2024-09-26 21:39:12 +08:00
parent 45252a24dc
commit bd671f4bb5
12 changed files with 31 additions and 9 deletions

View File

@@ -148,6 +148,7 @@ object PreferKey {
const val updateToVariant = "updateToVariant"
const val streamReadAloudAudio = "streamReadAloudAudio"
const val pauseReadAloudWhilePhoneCalls = "pauseReadAloudWhilePhoneCalls"
const val readAloudByMediaButton = "readAloudByMediaButton"
const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent"

View File

@@ -453,6 +453,9 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
val mediaButtonOnExit get() = appCtx.getPrefBoolean("mediaButtonOnExit", true)
val readAloudByMediaButton
get() = appCtx.getPrefBoolean(PreferKey.readAloudByMediaButton, false)
val replaceEnableDefault get() = appCtx.getPrefBoolean(PreferKey.replaceEnableDefault, true)
val webDavDir get() = appCtx.getPrefString(PreferKey.webDavDir, "legado")

View File

@@ -63,10 +63,6 @@ class MediaButtonReceiver : BroadcastReceiver() {
}
}
KeyEvent.KEYCODE_MEDIA_PAUSE -> {
pauseReadAloud(context)
}
else -> readAloud(context)
}
}
@@ -74,11 +70,6 @@ class MediaButtonReceiver : BroadcastReceiver() {
return true
}
private fun pauseReadAloud(context: Context) {
ReadAloud.pause(context)
AudioPlay.pause(context)
}
fun readAloud(context: Context, isMediaKey: Boolean = true) {
when {
BaseReadAloudService.isRun -> {
@@ -99,6 +90,10 @@ class MediaButtonReceiver : BroadcastReceiver() {
}
}
isMediaKey && !AppConfig.readAloudByMediaButton -> {
// break
}
LifecycleHelp.isExistActivity(ReadBookActivity::class.java) ->
postEvent(EventBus.MEDIA_BUTTON, true)

View File

@@ -1164,4 +1164,6 @@
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</string>
<string name="read_aloud_read_phone_state_permission_rationale">阅读需要读取手机状态实现来电期间暂停朗读功能</string>
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
</resources>

View File

@@ -1167,4 +1167,6 @@
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</string>
<string name="read_aloud_read_phone_state_permission_rationale">阅读需要读取手机状态实现来电期间暂停朗读功能</string>
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
</resources>

View File

@@ -1167,4 +1167,6 @@
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</string>
<string name="read_aloud_read_phone_state_permission_rationale">阅读需要读取手机状态实现来电期间暂停朗读功能</string>
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
</resources>

View File

@@ -1163,4 +1163,6 @@ Còn </string>
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</string>
<string name="read_aloud_read_phone_state_permission_rationale">阅读需要读取手机状态实现来电期间暂停朗读功能</string>
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
</resources>

View File

@@ -1164,4 +1164,6 @@
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</string>
<string name="read_aloud_read_phone_state_permission_rationale">阅读需要读取手机状态实现来电期间暂停朗读功能</string>
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
</resources>

View File

@@ -1166,4 +1166,6 @@
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</string>
<string name="read_aloud_read_phone_state_permission_rationale">阅读需要读取手机状态实现来电期间暂停朗读功能</string>
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
</resources>

View File

@@ -1166,4 +1166,6 @@
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</string>
<string name="read_aloud_read_phone_state_permission_rationale">阅读需要读取手机状态实现来电期间暂停朗读功能</string>
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
</resources>

View File

@@ -1167,4 +1167,6 @@
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</string>
<string name="read_aloud_read_phone_state_permission_rationale">阅读需要读取手机状态实现来电期间暂停朗读功能</string>
<string name="read_aloud_by_media_button_title">耳机按键启动朗读</string>
<string name="read_aloud_by_media_button_summary">通过耳机按键来启动朗读</string>
</resources>

View File

@@ -128,6 +128,13 @@
android:title="@string/media_button_on_exit_title"
app:iconSpaceReserved="false" />
<io.legado.app.lib.prefs.SwitchPreference
android:defaultValue="false"
android:key="readAloudByMediaButton"
android:summary="@string/read_aloud_by_media_button_summary"
android:title="@string/read_aloud_by_media_button_title"
app:iconSpaceReserved="false" />
<io.legado.app.lib.prefs.SwitchPreference
android:defaultValue="false"
android:key="ignoreAudioFocus"