优化
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package io.legado.app.constant
|
||||
|
||||
import io.legado.app.help.AppConfig
|
||||
|
||||
object AppLog {
|
||||
|
||||
private val mLogs = arrayListOf<Triple<Long, String, Throwable?>>()
|
||||
@@ -20,4 +22,10 @@ object AppLog {
|
||||
mLogs.clear()
|
||||
}
|
||||
|
||||
fun putDebug(message: String?, throwable: Throwable? = null) {
|
||||
if (AppConfig.recordLog) {
|
||||
put(message, throwable)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -271,6 +271,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
val replaceEnableDefault get() = appCtx.getPrefBoolean(PreferKey.replaceEnableDefault, true)
|
||||
|
||||
val recordLog get() = appCtx.getPrefBoolean(PreferKey.recordLog)
|
||||
|
||||
val doublePageHorizontal: Boolean
|
||||
get() = appCtx.getPrefBoolean(PreferKey.doublePageHorizontal, true)
|
||||
|
||||
|
||||
@@ -521,7 +521,7 @@ interface JsExtensions {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Timber.d(msg.toString())
|
||||
}
|
||||
AppLog.put(msg.toString())
|
||||
AppLog.putDebug(msg.toString())
|
||||
return msg
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,10 @@ class HttpReadAloudService : BaseReadAloudService(),
|
||||
|
||||
override fun play() {
|
||||
if (contentList.isEmpty()) {
|
||||
AppLog.putDebug("朗读列表为空")
|
||||
ReadBook.readAloud()
|
||||
} else {
|
||||
super.play()
|
||||
ReadAloud.httpTTS?.let {
|
||||
val fileName =
|
||||
md5SpeakFileName(it.url, AppConfig.ttsSpeechRate.toString(), contentList[nowSpeak])
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.speech.tts.TextToSpeech
|
||||
import android.speech.tts.UtteranceProgressListener
|
||||
import io.legado.app.R
|
||||
import io.legado.app.constant.AppConst
|
||||
import io.legado.app.constant.AppLog
|
||||
import io.legado.app.constant.AppPattern
|
||||
import io.legado.app.constant.EventBus
|
||||
import io.legado.app.help.AppConfig
|
||||
@@ -68,6 +69,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
|
||||
if (!ttsInitFinish) return
|
||||
if (!requestFocus()) return
|
||||
if (contentList.isEmpty()) {
|
||||
AppLog.putDebug("朗读列表为空")
|
||||
ReadBook.readAloud()
|
||||
} else {
|
||||
super.play()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package io.legado.app.utils
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import io.legado.app.help.AppConfig
|
||||
import splitties.init.appCtx
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
@@ -43,7 +44,7 @@ object LogUtils {
|
||||
return (getCurrentDateStr(TIME_PATTERN) + ": " + record.message + "\n")
|
||||
}
|
||||
}
|
||||
level = if (appCtx.getPrefBoolean("recordLog")) {
|
||||
level = if (AppConfig.recordLog) {
|
||||
Level.INFO
|
||||
} else {
|
||||
Level.OFF
|
||||
@@ -52,7 +53,7 @@ object LogUtils {
|
||||
}
|
||||
|
||||
fun upLevel() {
|
||||
fileHandler?.level = if (appCtx.getPrefBoolean("recordLog")) {
|
||||
fileHandler?.level = if (AppConfig.recordLog) {
|
||||
Level.INFO
|
||||
} else {
|
||||
Level.OFF
|
||||
|
||||
Reference in New Issue
Block a user