pull/84/head
kunfei 5 years ago
parent 2a66d84946
commit c1cb5fb0d7
  1. 3
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 7
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  3. 3
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt
  4. 3
      app/src/main/java/io/legado/app/service/help/ReadAloud.kt
  5. 9
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt

@ -8,6 +8,9 @@ object PreferKey {
const val clickAllNext = "clickAllNext"
const val hideNavigationBar = "hideNavigationBar"
const val precisionSearch = "precisionSearch"
const val readAloudOnLine = "readAloudOnLine"
const val readAloudByPage = "readAloudByPage"
const val ttsSpeechPer = "ttsSpeechPer"
const val prevKey = "prevKeyCode"
const val nextKey = "nextKeyCode"
const val showRss = "showRss"

@ -16,10 +16,7 @@ import androidx.core.app.NotificationCompat
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseService
import io.legado.app.constant.Action
import io.legado.app.constant.AppConst
import io.legado.app.constant.Bus
import io.legado.app.constant.Status
import io.legado.app.constant.*
import io.legado.app.help.IntentDataHelp
import io.legado.app.help.IntentHelp
import io.legado.app.help.MediaHelp
@ -111,7 +108,7 @@ abstract class BaseReadAloudService : BaseService(),
nowSpeak = 0
readAloudNumber = textChapter.getReadLength(pageIndex)
contentList.clear()
if (getPrefBoolean("readAloudByPage")) {
if (getPrefBoolean(PreferKey.readAloudByPage)) {
for (index in pageIndex..textChapter.lastIndex()) {
textChapter.page(index)?.text?.split("\n")?.let {
contentList.addAll(it)

@ -3,6 +3,7 @@ package io.legado.app.service
import android.app.PendingIntent
import android.media.MediaPlayer
import io.legado.app.constant.Bus
import io.legado.app.constant.PreferKey
import io.legado.app.help.IntentHelp
import io.legado.app.help.http.HttpHelper
import io.legado.app.help.http.api.HttpPostApi
@ -107,7 +108,7 @@ class HttpReadAloudService : BaseReadAloudService(),
return mapOf(
Pair("tex", encodeTwo(content)),
Pair("spd", ((getPrefInt("ttsSpeechRate", 25) + 5) / 5).toString()),
Pair("per", getPrefString("ttsSpeechPer") ?: "0"),
Pair("per", getPrefString(PreferKey.ttsSpeechPer) ?: "0"),
Pair("cuid", "baidu_speech_demo"),
Pair("idx", "1"),
Pair("cod", "2"),

@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent
import io.legado.app.App
import io.legado.app.constant.Action
import io.legado.app.constant.PreferKey
import io.legado.app.service.BaseReadAloudService
import io.legado.app.service.HttpReadAloudService
import io.legado.app.service.TTSReadAloudService
@ -13,7 +14,7 @@ object ReadAloud {
var aloudClass: Class<*> = getReadAloudClass()
fun getReadAloudClass(): Class<*> {
return if (App.INSTANCE.getPrefBoolean("readAloudOnLine")) {
return if (App.INSTANCE.getPrefBoolean(PreferKey.readAloudOnLine)) {
HttpReadAloudService::class.java
} else {
TTSReadAloudService::class.java

@ -13,6 +13,7 @@ import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.R
import io.legado.app.constant.Bus
import io.legado.app.constant.PreferKey
import io.legado.app.lib.theme.ATH
import io.legado.app.service.BaseReadAloudService
import io.legado.app.service.help.ReadAloud
@ -68,7 +69,7 @@ class ReadAloudConfigDialog : DialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
ATH.applyEdgeEffectColor(listView)
bindPreferenceSummaryToValue(findPreference("ttsSpeechPer"))
bindPreferenceSummaryToValue(findPreference(PreferKey.ttsSpeechPer))
}
override fun onResume() {
@ -86,18 +87,18 @@ class ReadAloudConfigDialog : DialogFragment() {
key: String?
) {
when (key) {
"readAloudByPage" -> {
PreferKey.readAloudByPage -> {
if (BaseReadAloudService.isRun) {
postEvent(Bus.MEDIA_BUTTON, false)
}
}
"readAloudOnLine" -> {
PreferKey.readAloudOnLine -> {
if (BaseReadAloudService.isRun) {
ReadAloud.stop(requireContext())
ReadAloud.aloudClass = ReadAloud.getReadAloudClass()
}
}
"ttsSpeechPer" -> ReadAloud.upTtsSpeechRate(requireContext())
PreferKey.ttsSpeechPer -> ReadAloud.upTtsSpeechRate(requireContext())
}
}

Loading…
Cancel
Save