pull/34/head
kunfei 5 years ago
parent 9e488031ea
commit e3aff69916
  1. 6
      app/src/main/java/io/legado/app/help/ReadAloud.kt
  2. 13
      app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudConfigDialog.kt
  3. 1
      app/src/main/res/values/strings.xml
  4. 6
      app/src/main/res/xml/pref_config_aloud.xml

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

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

@ -488,6 +488,7 @@
<string name="timer_m">%d分钟</string>
<string name="brightness_auto">自动亮度%s</string>
<string name="read_aloud_by_page">按页朗读</string>
<string name="read_aloud_on_line">在线朗读</string>
<string name="bg_image">背景图片</string>
<string name="bg_color">背景颜色</string>
<string name="text_color">文字颜色</string>

@ -8,5 +8,11 @@
android:key="readAloudByPage"
app:iconSpaceReserved="false" />
<io.legado.app.lib.theme.prefs.ATESwitchPreference
android:defaultValue="false"
android:title="@string/read_aloud_on_line"
android:key="readAloudOnLine"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceScreen>
Loading…
Cancel
Save