优化
This commit is contained in:
@@ -148,6 +148,7 @@ object PreferKey {
|
|||||||
const val updateToVariant = "updateToVariant"
|
const val updateToVariant = "updateToVariant"
|
||||||
const val streamReadAloudAudio = "streamReadAloudAudio"
|
const val streamReadAloudAudio = "streamReadAloudAudio"
|
||||||
const val pauseReadAloudWhilePhoneCalls = "pauseReadAloudWhilePhoneCalls"
|
const val pauseReadAloudWhilePhoneCalls = "pauseReadAloudWhilePhoneCalls"
|
||||||
|
const val readAloudByMediaButton = "readAloudByMediaButton"
|
||||||
|
|
||||||
const val cPrimary = "colorPrimary"
|
const val cPrimary = "colorPrimary"
|
||||||
const val cAccent = "colorAccent"
|
const val cAccent = "colorAccent"
|
||||||
|
|||||||
@@ -453,6 +453,9 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
|
|
||||||
val mediaButtonOnExit get() = appCtx.getPrefBoolean("mediaButtonOnExit", true)
|
val mediaButtonOnExit get() = appCtx.getPrefBoolean("mediaButtonOnExit", true)
|
||||||
|
|
||||||
|
val readAloudByMediaButton
|
||||||
|
get() = appCtx.getPrefBoolean(PreferKey.readAloudByMediaButton, false)
|
||||||
|
|
||||||
val replaceEnableDefault get() = appCtx.getPrefBoolean(PreferKey.replaceEnableDefault, true)
|
val replaceEnableDefault get() = appCtx.getPrefBoolean(PreferKey.replaceEnableDefault, true)
|
||||||
|
|
||||||
val webDavDir get() = appCtx.getPrefString(PreferKey.webDavDir, "legado")
|
val webDavDir get() = appCtx.getPrefString(PreferKey.webDavDir, "legado")
|
||||||
|
|||||||
@@ -63,10 +63,6 @@ class MediaButtonReceiver : BroadcastReceiver() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_MEDIA_PAUSE -> {
|
|
||||||
pauseReadAloud(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> readAloud(context)
|
else -> readAloud(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,11 +70,6 @@ class MediaButtonReceiver : BroadcastReceiver() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pauseReadAloud(context: Context) {
|
|
||||||
ReadAloud.pause(context)
|
|
||||||
AudioPlay.pause(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun readAloud(context: Context, isMediaKey: Boolean = true) {
|
fun readAloud(context: Context, isMediaKey: Boolean = true) {
|
||||||
when {
|
when {
|
||||||
BaseReadAloudService.isRun -> {
|
BaseReadAloudService.isRun -> {
|
||||||
@@ -99,6 +90,10 @@ class MediaButtonReceiver : BroadcastReceiver() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isMediaKey && !AppConfig.readAloudByMediaButton -> {
|
||||||
|
// break
|
||||||
|
}
|
||||||
|
|
||||||
LifecycleHelp.isExistActivity(ReadBookActivity::class.java) ->
|
LifecycleHelp.isExistActivity(ReadBookActivity::class.java) ->
|
||||||
postEvent(EventBus.MEDIA_BUTTON, true)
|
postEvent(EventBus.MEDIA_BUTTON, true)
|
||||||
|
|
||||||
|
|||||||
@@ -1164,4 +1164,6 @@
|
|||||||
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
||||||
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</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_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>
|
</resources>
|
||||||
|
|||||||
@@ -1167,4 +1167,6 @@
|
|||||||
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
||||||
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</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_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>
|
</resources>
|
||||||
|
|||||||
@@ -1167,4 +1167,6 @@
|
|||||||
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
||||||
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</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_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>
|
</resources>
|
||||||
|
|||||||
@@ -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_title">来电期间暂停朗读</string>
|
||||||
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</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_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>
|
</resources>
|
||||||
|
|||||||
@@ -1164,4 +1164,6 @@
|
|||||||
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
||||||
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</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_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>
|
</resources>
|
||||||
|
|||||||
@@ -1166,4 +1166,6 @@
|
|||||||
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
||||||
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</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_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>
|
</resources>
|
||||||
|
|||||||
@@ -1166,4 +1166,6 @@
|
|||||||
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
||||||
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</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_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>
|
</resources>
|
||||||
|
|||||||
@@ -1167,4 +1167,6 @@
|
|||||||
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
<string name="pause_read_aloud_while_phone_calls_title">来电期间暂停朗读</string>
|
||||||
<string name="pause_read_aloud_while_phone_calls_summary">在通话期间暂停朗读,需要读取手机状态权限</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_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>
|
</resources>
|
||||||
|
|||||||
@@ -128,6 +128,13 @@
|
|||||||
android:title="@string/media_button_on_exit_title"
|
android:title="@string/media_button_on_exit_title"
|
||||||
app:iconSpaceReserved="false" />
|
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
|
<io.legado.app.lib.prefs.SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="ignoreAudioFocus"
|
android:key="ignoreAudioFocus"
|
||||||
|
|||||||
Reference in New Issue
Block a user