pull/2441/head
Horis 2 years ago
parent 214ff956cf
commit f6599802a3
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 4
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  3. 6
      app/src/main/java/io/legado/app/help/config/AppConfig.kt
  4. 7
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  5. 8
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  6. 1
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt

@ -116,6 +116,7 @@ object PreferKey {
const val parallelExportBook = "parallelExportBook"
const val progressBarBehavior = "progressBarBehavior"
const val sourceEditMaxLine = "sourceEditMaxLine"
const val ttsTimer = "ttsTimer"
const val cPrimary = "colorPrimary"
const val cAccent = "colorAccent"

@ -355,10 +355,12 @@ interface JsExtensions {
fun hexDecodeToByteArray(hex: String): ByteArray? {
return HexUtil.decodeHex(hex)
}
/* hexString 解码为utf8String*/
fun hexDecodeToString(hex: String): String? {
return HexUtil.decodeHexStr(hex)
}
/* utf8 编码为hexString */
fun hexEncodeToString(utf8: String): String? {
return HexUtil.encodeHexStr(utf8)
@ -675,7 +677,7 @@ interface JsExtensions {
* java.createSymmetricCrypto(transformation, key, iv).encrypt(data)
* java.createSymmetricCrypto(transformation, key, iv).encryptBase64(data)
* java.createSymmetricCrypto(transformation, key, iv).encryptHex(data)
*/
*/
/* 调用SymmetricCrypto key为null时使用随机密钥*/
fun createSymmetricCrypto(

@ -190,6 +190,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
appCtx.putPrefInt(PreferKey.ttsSpeechRate, value)
}
var ttsTimer: Int
get() = appCtx.getPrefInt(PreferKey.ttsTimer, 0)
set(value) {
appCtx.putPrefInt(PreferKey.ttsTimer, value)
}
val speechRatePlay: Int get() = if (ttsFlowSys) defaultSpeechRate else ttsSpeechRate
var chineseConverterType: Int

@ -26,10 +26,7 @@ import io.legado.app.receiver.MediaButtonReceiver
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.read.page.entities.TextChapter
import io.legado.app.utils.*
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.*
import splitties.systemservices.audioManager
import splitties.systemservices.powerManager
@ -92,7 +89,7 @@ abstract class BaseReadAloudService : BaseService(),
initBroadcastReceiver()
upNotification()
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING)
doDs()
setTimer(AppConfig.ttsTimer)
}
override fun onDestroy() {

@ -156,7 +156,13 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
val oldBook = book.copy()
val preUpdateJs = it.ruleToc?.preUpdateJs
if (!preUpdateJs.isNullOrBlank()) {
AnalyzeRule(book, it).evalJS(preUpdateJs)
val source = it
kotlin.runCatching {
AnalyzeRule(book, it).evalJS(preUpdateJs)
}.onFailure {
ReadBook.upMsg("执行preUpdateJs规则失败")
AppLog.put("执行preUpdateJs规则失败 书源:${source.bookSourceName}", it)
}
}
WebBook.getChapterList(viewModelScope, it, book)
.onSuccess(IO) { cList ->

@ -137,6 +137,7 @@ class ReadAloudDialog : BaseDialogFragment(R.layout.dialog_read_aloud) {
}
override fun onStopTrackingTouch(seekBar: SeekBar) {
AppConfig.ttsTimer = seekTimer.progress
ReadAloud.setTimer(requireContext(), seekTimer.progress)
}
})

Loading…
Cancel
Save