优化
This commit is contained in:
@@ -116,6 +116,7 @@ object PreferKey {
|
|||||||
const val parallelExportBook = "parallelExportBook"
|
const val parallelExportBook = "parallelExportBook"
|
||||||
const val progressBarBehavior = "progressBarBehavior"
|
const val progressBarBehavior = "progressBarBehavior"
|
||||||
const val sourceEditMaxLine = "sourceEditMaxLine"
|
const val sourceEditMaxLine = "sourceEditMaxLine"
|
||||||
|
const val ttsTimer = "ttsTimer"
|
||||||
|
|
||||||
const val cPrimary = "colorPrimary"
|
const val cPrimary = "colorPrimary"
|
||||||
const val cAccent = "colorAccent"
|
const val cAccent = "colorAccent"
|
||||||
|
|||||||
@@ -355,10 +355,12 @@ interface JsExtensions {
|
|||||||
fun hexDecodeToByteArray(hex: String): ByteArray? {
|
fun hexDecodeToByteArray(hex: String): ByteArray? {
|
||||||
return HexUtil.decodeHex(hex)
|
return HexUtil.decodeHex(hex)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* hexString 解码为utf8String*/
|
/* hexString 解码为utf8String*/
|
||||||
fun hexDecodeToString(hex: String): String? {
|
fun hexDecodeToString(hex: String): String? {
|
||||||
return HexUtil.decodeHexStr(hex)
|
return HexUtil.decodeHexStr(hex)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* utf8 编码为hexString */
|
/* utf8 编码为hexString */
|
||||||
fun hexEncodeToString(utf8: String): String? {
|
fun hexEncodeToString(utf8: String): String? {
|
||||||
return HexUtil.encodeHexStr(utf8)
|
return HexUtil.encodeHexStr(utf8)
|
||||||
@@ -675,7 +677,7 @@ interface JsExtensions {
|
|||||||
* java.createSymmetricCrypto(transformation, key, iv).encrypt(data)
|
* java.createSymmetricCrypto(transformation, key, iv).encrypt(data)
|
||||||
* java.createSymmetricCrypto(transformation, key, iv).encryptBase64(data)
|
* java.createSymmetricCrypto(transformation, key, iv).encryptBase64(data)
|
||||||
* java.createSymmetricCrypto(transformation, key, iv).encryptHex(data)
|
* java.createSymmetricCrypto(transformation, key, iv).encryptHex(data)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* 调用SymmetricCrypto key为null时使用随机密钥*/
|
/* 调用SymmetricCrypto key为null时使用随机密钥*/
|
||||||
fun createSymmetricCrypto(
|
fun createSymmetricCrypto(
|
||||||
|
|||||||
@@ -190,6 +190,12 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
|||||||
appCtx.putPrefInt(PreferKey.ttsSpeechRate, value)
|
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
|
val speechRatePlay: Int get() = if (ttsFlowSys) defaultSpeechRate else ttsSpeechRate
|
||||||
|
|
||||||
var chineseConverterType: Int
|
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.ReadBookActivity
|
||||||
import io.legado.app.ui.book.read.page.entities.TextChapter
|
import io.legado.app.ui.book.read.page.entities.TextChapter
|
||||||
import io.legado.app.utils.*
|
import io.legado.app.utils.*
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.isActive
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import splitties.systemservices.audioManager
|
import splitties.systemservices.audioManager
|
||||||
import splitties.systemservices.powerManager
|
import splitties.systemservices.powerManager
|
||||||
|
|
||||||
@@ -92,7 +89,7 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
initBroadcastReceiver()
|
initBroadcastReceiver()
|
||||||
upNotification()
|
upNotification()
|
||||||
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING)
|
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING)
|
||||||
doDs()
|
setTimer(AppConfig.ttsTimer)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
|||||||
@@ -156,7 +156,13 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
val oldBook = book.copy()
|
val oldBook = book.copy()
|
||||||
val preUpdateJs = it.ruleToc?.preUpdateJs
|
val preUpdateJs = it.ruleToc?.preUpdateJs
|
||||||
if (!preUpdateJs.isNullOrBlank()) {
|
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)
|
WebBook.getChapterList(viewModelScope, it, book)
|
||||||
.onSuccess(IO) { cList ->
|
.onSuccess(IO) { cList ->
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ class ReadAloudDialog : BaseDialogFragment(R.layout.dialog_read_aloud) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||||
|
AppConfig.ttsTimer = seekTimer.progress
|
||||||
ReadAloud.setTimer(requireContext(), seekTimer.progress)
|
ReadAloud.setTimer(requireContext(), seekTimer.progress)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user