pull/90/head^2
kunfei 5 years ago
parent fd814edf08
commit 30be4ba3e0
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 6
      app/src/main/java/io/legado/app/help/AppConfig.kt
  3. 4
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt
  4. 4
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt
  5. 4
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt
  6. 9
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt

@ -10,6 +10,7 @@ object PreferKey {
const val precisionSearch = "precisionSearch"
const val readAloudOnLine = "readAloudOnLine"
const val readAloudByPage = "readAloudByPage"
const val ttsSpeechRate = "ttsSpeechRate"
const val ttsSpeechPer = "ttsSpeechPer"
const val prevKey = "prevKeyCode"
const val nextKey = "nextKeyCode"

@ -50,6 +50,12 @@ object AppConfig {
}
}
var ttsSpeechRate: Int
get() = App.INSTANCE.getPrefInt(PreferKey.ttsSpeechRate, 5)
set(value) {
App.INSTANCE.putPrefInt(PreferKey.ttsSpeechRate, value)
}
val isEInkMode: Boolean
get() = App.INSTANCE.getPrefBoolean("isEInkMode")

@ -4,12 +4,12 @@ import android.app.PendingIntent
import android.media.MediaPlayer
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.help.AppConfig
import io.legado.app.help.IntentHelp
import io.legado.app.help.http.HttpHelper
import io.legado.app.help.http.api.HttpPostApi
import io.legado.app.service.help.ReadBook
import io.legado.app.utils.FileUtils
import io.legado.app.utils.getPrefInt
import io.legado.app.utils.getPrefString
import io.legado.app.utils.postEvent
import kotlinx.coroutines.Dispatchers.IO
@ -112,7 +112,7 @@ class HttpReadAloudService : BaseReadAloudService(),
private fun getAudioBody(content: String): Map<String, String> {
return mapOf(
Pair("tex", encodeTwo(content)),
Pair("spd", ((getPrefInt("ttsSpeechRate", 25) + 5) / 5).toString()),
Pair("spd", ((AppConfig.ttsSpeechRate + 5) / 5).toString()),
Pair("per", getPrefString(PreferKey.ttsSpeechPer) ?: "0"),
Pair("cuid", "baidu_speech_demo"),
Pair("idx", "1"),

@ -7,11 +7,11 @@ import android.speech.tts.UtteranceProgressListener
import io.legado.app.R
import io.legado.app.constant.AppConst
import io.legado.app.constant.EventBus
import io.legado.app.help.AppConfig
import io.legado.app.help.IntentHelp
import io.legado.app.help.MediaHelp
import io.legado.app.service.help.ReadBook
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.getPrefInt
import io.legado.app.utils.postEvent
import kotlinx.coroutines.launch
import org.jetbrains.anko.toast
@ -96,7 +96,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
textToSpeech = TextToSpeech(this, this)
}
} else {
textToSpeech?.setSpeechRate((this.getPrefInt("ttsSpeechRate", 5) + 5) / 10f)
textToSpeech?.setSpeechRate((AppConfig.ttsSpeechRate + 5) / 10f)
}
}

@ -96,7 +96,9 @@ class ReadAloudConfigDialog : DialogFragment() {
ReadAloud.stop(requireContext())
ReadAloud.aloudClass = ReadAloud.getReadAloudClass()
}
PreferKey.ttsSpeechPer -> ReadAloud.upTtsSpeechRate(requireContext())
PreferKey.ttsSpeechPer -> {
ReadAloud.upTtsSpeechRate(requireContext())
}
}
}

@ -10,11 +10,14 @@ import android.widget.SeekBar
import androidx.fragment.app.DialogFragment
import io.legado.app.R
import io.legado.app.constant.EventBus
import io.legado.app.help.AppConfig
import io.legado.app.service.BaseReadAloudService
import io.legado.app.service.help.ReadAloud
import io.legado.app.service.help.ReadBook
import io.legado.app.ui.book.read.Help
import io.legado.app.utils.*
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.observeEvent
import io.legado.app.utils.putPrefBoolean
import kotlinx.android.synthetic.main.dialog_read_aloud.*
import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.sdk27.listeners.onLongClick
@ -65,7 +68,7 @@ class ReadAloudDialog : DialogFragment() {
requireContext().getString(R.string.timer_m, BaseReadAloudService.timeMinute)
cb_tts_follow_sys.isChecked = requireContext().getPrefBoolean("ttsFollowSys", true)
seek_tts_SpeechRate.isEnabled = !cb_tts_follow_sys.isChecked
seek_tts_SpeechRate.progress = requireContext().getPrefInt("ttsSpeechRate", 5)
seek_tts_SpeechRate.progress = AppConfig.ttsSpeechRate
}
private fun initOnChange() {
@ -83,7 +86,7 @@ class ReadAloudDialog : DialogFragment() {
override fun onStartTrackingTouch(seekBar: SeekBar?) = Unit
override fun onStopTrackingTouch(seekBar: SeekBar?) {
requireContext().putPrefInt("ttsSpeechRate", seek_tts_SpeechRate.progress)
AppConfig.ttsSpeechRate = seek_tts_SpeechRate.progress
upTtsSpeechRate()
}
})

Loading…
Cancel
Save