From d1e6cf22b1c4ac7a337a1f529d50535f0e11a1b2 Mon Sep 17 00:00:00 2001 From: hingbong Date: Tue, 11 Feb 2020 16:34:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=86=85=E5=AE=B9=E7=AE=80?= =?UTF-8?q?=E7=B9=81=E8=BD=AC=E6=8D=A2=E5=8A=9F=E8=83=BD(=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E5=9C=A8=E5=85=B6=E4=BB=96=E8=AE=BE=E7=BD=AE=E4=B8=AD?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 ++ app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + app/src/main/java/io/legado/app/help/AppConfig.kt | 3 +++ .../io/legado/app/ui/book/read/page/ContentView.kt | 10 +++++++++- app/src/main/res/values/arrays.xml | 11 +++++++++++ app/src/main/res/values/strings.xml | 2 +- app/src/main/res/xml/pref_config_other.xml | 8 ++++++++ 7 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 835fcda25..eafaac8a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -175,6 +175,8 @@ dependencies { //MarkDown implementation 'ru.noties.markwon:core:3.0.2' + // 转换繁体 + implementation 'com.github.houbb:opencc4j:1.4.0' } apply plugin: 'com.google.gms.google-services' \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index 0c49b66b3..ff6198af2 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -31,4 +31,5 @@ object PreferKey { const val webDavAccount = "web_dav_account" const val webDavPassword = "web_dav_password" const val changeSourceLoadToc = "changeSourceLoadToc" + const val isChineseConverterEnable = "isChineseConverterEnable" } \ 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 4189d9787..c1d779be3 100644 --- a/app/src/main/java/io/legado/app/help/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/AppConfig.kt @@ -77,4 +77,7 @@ object AppConfig { get() = App.INSTANCE.getPrefBoolean("isEInkMode") val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false) + + val isChineseConverterEnable: String? + get() = App.INSTANCE.getPrefString(PreferKey.isChineseConverterEnable) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index cc9e9e666..f53b1550d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -9,9 +9,11 @@ import android.view.Gravity import android.widget.FrameLayout import android.widget.ImageView import androidx.appcompat.widget.AppCompatImageView +import com.github.houbb.opencc4j.util.ZhConverterUtil import io.legado.app.R import io.legado.app.constant.AppConst.TIME_FORMAT import io.legado.app.constant.PreferKey +import io.legado.app.help.AppConfig import io.legado.app.help.ReadBookConfig import io.legado.app.utils.* import kotlinx.android.synthetic.main.view_book_page.view.* @@ -111,7 +113,13 @@ class ContentView : FrameLayout { fun setContent(textPage: TextPage?) { if (textPage != null) { content_text_view.gravity = Gravity.START - content_text_view.text = textPage.text + content_text_view.text = if ("0" != AppConfig.isChineseConverterEnable) { + if ("1" == AppConfig.isChineseConverterEnable) + ZhConverterUtil.toTraditional(textPage.text.toString()) + else ZhConverterUtil.toSimple(textPage.text.toString()) + } else { + textPage.text + } tv_bottom_left.text = textPage.title pageSize = textPage.pageSize setPageIndex(textPage.index) diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 64a83e78a..37f196921 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -142,4 +142,15 @@ @string/icon_book + + 关闭 + 简体转繁体 + 繁体转简体 + + + + 0 + 1 + 2 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c1e9aa069..7a8b44380 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -605,5 +605,5 @@ 长按文字在操作菜单中显示阅读·搜索 文字操作显示搜索 记录日志 - + 中文简繁体转换 diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index 3eb6ede41..da9a870b0 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -50,4 +50,12 @@ android:title="@string/record_log" app:iconSpaceReserved="false" /> + + \ No newline at end of file