From c4dfb573418bb2ac7d2e3161332541f054a584ac Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 3 Feb 2022 20:59:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/constant/AppLog.kt | 8 +++++ .../main/java/io/legado/app/help/AppConfig.kt | 2 ++ .../java/io/legado/app/help/JsExtensions.kt | 2 +- .../app/service/HttpReadAloudService.kt | 2 ++ .../legado/app/service/TTSReadAloudService.kt | 2 ++ .../main/java/io/legado/app/utils/LogUtils.kt | 5 +-- app/src/main/res/values-es-rES/strings.xml | 2 ++ app/src/main/res/values-ja-rJP/strings.xml | 4 ++- app/src/main/res/values-pt-rBR/strings.xml | 4 ++- app/src/main/res/values-zh-rHK/strings.xml | 2 ++ app/src/main/res/values-zh-rTW/strings.xml | 2 ++ app/src/main/res/values-zh/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 3 +- app/src/main/res/xml/pref_config_other.xml | 31 ++++++++++--------- 14 files changed, 50 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/AppLog.kt b/app/src/main/java/io/legado/app/constant/AppLog.kt index 396f0108f..472976d47 100644 --- a/app/src/main/java/io/legado/app/constant/AppLog.kt +++ b/app/src/main/java/io/legado/app/constant/AppLog.kt @@ -1,5 +1,7 @@ package io.legado.app.constant +import io.legado.app.help.AppConfig + object AppLog { private val mLogs = arrayListOf>() @@ -20,4 +22,10 @@ object AppLog { mLogs.clear() } + fun putDebug(message: String?, throwable: Throwable? = null) { + if (AppConfig.recordLog) { + put(message, throwable) + } + } + } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/AppConfig.kt b/app/src/main/java/io/legado/app/help/AppConfig.kt index ea4f9a846..0f8fa940e 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -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) diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index ba66b900e..072a07c4d 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -521,7 +521,7 @@ interface JsExtensions { if (BuildConfig.DEBUG) { Timber.d(msg.toString()) } - AppLog.put(msg.toString()) + AppLog.putDebug(msg.toString()) return msg } diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index 260a482e1..db06ea216 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -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]) diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 9eef5c2b1..09f122f18 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -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() diff --git a/app/src/main/java/io/legado/app/utils/LogUtils.kt b/app/src/main/java/io/legado/app/utils/LogUtils.kt index c525a90de..1bd11173c 100644 --- a/app/src/main/java/io/legado/app/utils/LogUtils.kt +++ b/app/src/main/java/io/legado/app/utils/LogUtils.kt @@ -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 diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index da15cf11a..52599d81a 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -873,6 +873,7 @@ 路径 直链上传规则 用于导出书源书单时生成直链url + 直链上传配置 拷贝播放Url 设置源变量 设置书籍变量 @@ -925,5 +926,6 @@ 小于 校验超时: %1$s秒\n校验项目:%2$s + 记录调试日志 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index ae42ead4a..7ee8d230b 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -640,7 +640,7 @@ Android 10+ unable to read and write file due to permission restrictions Long tap to display Legado·Search in the operation menu Text operation display Search - Log + Record log Log Simplified conversion The icon is a vector icon, which was not supported before Android 8.0 @@ -876,6 +876,7 @@ 路径 直链上传规则 用于导出书源书单时生成直链url + 直链上传配置 拷贝播放Url 设置源变量 设置书籍变量 @@ -928,5 +929,6 @@ 小于 校验超时: %1$s秒\n校验项目:%2$s + 记录调试日志 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 94363d657..e4056e388 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -640,7 +640,7 @@ Android 10+ não é capaz de ler e salvar arquivos devido a restrições de permissão Clique longo para exibir o Legado·Pesquisa no menu de operação Visualização da operação de texto na Pesquisa - Log + Record log Log Conversão simplificada O ícone é um ícone vetorial, que não era suportado antes de Android 8.0 @@ -876,6 +876,7 @@ 路径 直链上传规则 用于导出书源书单时生成直链url + 直链上传配置 拷贝播放Url 设置源变量 设置书籍变量 @@ -928,5 +929,6 @@ 小于 校验超时: %1$s秒\n校验项目:%2$s + 记录调试日志 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 4bd59ebd3..891ea6dcb 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -873,6 +873,7 @@ 路徑 直鏈上傳規則 用於導出書源書單時生成直鏈url + 直链上传配置 複製播放Url 設置源變量 設置書籍變量 @@ -925,5 +926,6 @@ 小于 校验超时: %1$s秒\n校验项目:%2$s + 记录调试日志 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index d69c3868a..c1dd02fc1 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -875,6 +875,7 @@ 路徑 直鏈上傳規則 用於匯出書源書單時生成直鏈url + 直链上传配置 複製播放Url 設定源變數 設定書籍變數 @@ -927,5 +928,6 @@ 小于 校验超时: %1$s秒\n校验项目:%2$s + 记录调试日志 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 284c5d686..87e293862 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -877,6 +877,7 @@ 路径 直链上传规则 用于导出书源书单时生成直链url + 直链上传配置 拷贝播放Url 设置源变量 设置书籍变量 @@ -927,5 +928,6 @@ 小于 校验超时: %1$s秒\n校验项目:%2$s + 记录调试日志 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d489fbcae..a8314a49f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -640,7 +640,7 @@ Android 10+ unable to read and write file due to permission restrictions Long tap to display Legado·Search in the operation menu Text operation display Search - Log + Record log Log Simplified conversion The icon is a vector icon, which was not supported before Android 8.0 @@ -929,5 +929,6 @@ 小于 校验超时: %1$s秒\n校验项目:%2$s + 记录调试日志 diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index 65571633f..9388b4878 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -3,9 +3,9 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> @@ -58,8 +58,8 @@ + android:summary="@string/book_tree_uri_s" + android:title="@string/book_tree_uri_t" /> + android:summary="@string/direct_link_upload_rule_summary" + android:title="@string/direct_link_upload_rule" /> + android:key="Cronet" + android:summary="@string/pref_cronet_summary" + android:title="Cronet" /> + android:summary="@string/pre_download_s" + android:title="@string/pre_download" /> + android:summary="@string/auto_clear_expired_summary" + android:title="@string/auto_clear_expired" />