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 f66ba439d..388769252 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