From b0f82513fb9172aa8fc7beaf0b97c0de2569b0ab Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 11 Feb 2022 20:29:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/ReadBook.kt | 1 - .../main/java/io/legado/app/receiver/MediaButtonReceiver.kt | 1 + .../main/java/io/legado/app/ui/book/read/ReadBookActivity.kt | 5 ++++- .../io/legado/app/ui/book/read/config/SpeakEngineDialog.kt | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/ReadBook.kt b/app/src/main/java/io/legado/app/model/ReadBook.kt index 30e2b86a0..a0518651b 100644 --- a/app/src/main/java/io/legado/app/model/ReadBook.kt +++ b/app/src/main/java/io/legado/app/model/ReadBook.kt @@ -215,7 +215,6 @@ object ReadBook : CoroutineScope by MainScope() { */ fun readAloud(play: Boolean = true) { book?.let { - ReadAloud.upReadAloudClass() ReadAloud.play(appCtx, play) } } 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 0c66e9181..5e1fabc5f 100644 --- a/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt +++ b/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt @@ -86,6 +86,7 @@ class MediaButtonReceiver : BroadcastReceiver() { LifecycleHelp.isExistActivity(AudioPlayActivity::class.java) -> postEvent(EventBus.MEDIA_BUTTON, true) else -> if (AppConfig.mediaButtonOnExit || LifecycleHelp.activitySize() > 0 || !isMediaKey) { + ReadAloud.upReadAloudClass() if (ReadBook.book != null) { ReadBook.readAloud() } else { diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index ab35358a1..da828bc2e 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -863,7 +863,10 @@ class ReadBookActivity : BaseReadBookActivity(), override fun onClickReadAloud() { autoPageStop() when { - !BaseReadAloudService.isRun -> ReadBook.readAloud() + !BaseReadAloudService.isRun -> { + ReadAloud.upReadAloudClass() + ReadBook.readAloud() + } BaseReadAloudService.pause -> ReadAloud.resume(this) else -> ReadAloud.pause(this) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt index 05dbf478e..e164d515a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt @@ -105,6 +105,7 @@ class SpeakEngineDialog(val callBack: CallBack) : BaseDialogFragment(R.layout.di tvFooterLeft.setOnClickListener { ReadBook.book?.setTtsEngine(ttsEngine) callBack.upSpeakEngineSummary() + ReadAloud.upReadAloudClass() dismissAllowingStateLoss() } tvOk.setText(R.string.general) @@ -112,6 +113,7 @@ class SpeakEngineDialog(val callBack: CallBack) : BaseDialogFragment(R.layout.di tvOk.setOnClickListener { ReadBook.book?.setTtsEngine(null) AppConfig.ttsEngine = ttsEngine + ReadAloud.upReadAloudClass() dismissAllowingStateLoss() } tvCancel.visible()