From e3aff69916388b77a16550e00e10eb62b3ffe80e Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 11 Sep 2019 21:26:43 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/help/ReadAloud.kt | 6 +++--- .../app/ui/readbook/config/ReadAloudConfigDialog.kt | 13 +++++++++++-- app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_config_aloud.xml | 6 ++++++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadAloud.kt b/app/src/main/java/io/legado/app/help/ReadAloud.kt index 5be1bd764..9dd52c9a4 100644 --- a/app/src/main/java/io/legado/app/help/ReadAloud.kt +++ b/app/src/main/java/io/legado/app/help/ReadAloud.kt @@ -13,10 +13,10 @@ object ReadAloud { var aloudClass: Class<*> = getReadAloudClass() fun getReadAloudClass(): Class<*> { - return if (App.INSTANCE.getPrefBoolean("tts", true)) { - TTSReadAloudService::class.java - } else { + return if (App.INSTANCE.getPrefBoolean("readAloudOnLine")) { HttpReadAloudService::class.java + } else { + TTSReadAloudService::class.java } } diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudConfigDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudConfigDialog.kt index f0358aeed..377ad0242 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudConfigDialog.kt @@ -11,7 +11,9 @@ import androidx.fragment.app.DialogFragment import androidx.preference.PreferenceFragmentCompat import io.legado.app.R import io.legado.app.constant.Bus +import io.legado.app.help.ReadAloud import io.legado.app.lib.theme.ATH +import io.legado.app.service.BaseReadAloudService import io.legado.app.ui.readbook.Help import io.legado.app.utils.postEvent @@ -79,8 +81,15 @@ class ReadAloudConfigDialog : DialogFragment() { key: String? ) { when (key) { - "readAloudByPage" -> postEvent(Bus.READ_ALOUD_BUTTON, false) - + "readAloudByPage" -> { + if (BaseReadAloudService.isRun) { + postEvent(Bus.READ_ALOUD_BUTTON, false) + } + } + "readAloudOnLine" -> { + ReadAloud.stop(requireContext()) + ReadAloud.aloudClass = ReadAloud.getReadAloudClass() + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d0000ebfb..d482ba1f6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -488,6 +488,7 @@ %d分钟 自动亮度%s 按页朗读 + 在线朗读 背景图片 背景颜色 文字颜色 diff --git a/app/src/main/res/xml/pref_config_aloud.xml b/app/src/main/res/xml/pref_config_aloud.xml index 638cb16c5..8fb8ef925 100644 --- a/app/src/main/res/xml/pref_config_aloud.xml +++ b/app/src/main/res/xml/pref_config_aloud.xml @@ -8,5 +8,11 @@ android:key="readAloudByPage" app:iconSpaceReserved="false" /> + + \ No newline at end of file