Merge pull request #95 from hingbong/master

添加内容简繁转换功能(开关在其他设置中)
pull/97/head
kunfei 5 years ago committed by GitHub
commit f79cfba183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/build.gradle
  2. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  3. 3
      app/src/main/java/io/legado/app/help/AppConfig.kt
  4. 10
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  5. 11
      app/src/main/res/values/arrays.xml
  6. 2
      app/src/main/res/values/strings.xml
  7. 8
      app/src/main/res/xml/pref_config_other.xml

@ -175,6 +175,8 @@ dependencies {
//MarkDown //MarkDown
implementation 'ru.noties.markwon:core:3.0.2' implementation 'ru.noties.markwon:core:3.0.2'
//
implementation 'com.github.houbb:opencc4j:1.4.0'
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'

@ -31,4 +31,5 @@ object PreferKey {
const val webDavAccount = "web_dav_account" const val webDavAccount = "web_dav_account"
const val webDavPassword = "web_dav_password" const val webDavPassword = "web_dav_password"
const val changeSourceLoadToc = "changeSourceLoadToc" const val changeSourceLoadToc = "changeSourceLoadToc"
const val isChineseConverterEnable = "isChineseConverterEnable"
} }

@ -77,4 +77,7 @@ object AppConfig {
get() = App.INSTANCE.getPrefBoolean("isEInkMode") get() = App.INSTANCE.getPrefBoolean("isEInkMode")
val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false) val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false)
val isChineseConverterEnable: String?
get() = App.INSTANCE.getPrefString(PreferKey.isChineseConverterEnable)
} }

@ -9,9 +9,11 @@ import android.view.Gravity
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.ImageView import android.widget.ImageView
import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.AppCompatImageView
import com.github.houbb.opencc4j.util.ZhConverterUtil
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.AppConst.TIME_FORMAT import io.legado.app.constant.AppConst.TIME_FORMAT
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.android.synthetic.main.view_book_page.view.* import kotlinx.android.synthetic.main.view_book_page.view.*
@ -111,7 +113,13 @@ class ContentView : FrameLayout {
fun setContent(textPage: TextPage?) { fun setContent(textPage: TextPage?) {
if (textPage != null) { if (textPage != null) {
content_text_view.gravity = Gravity.START 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 tv_bottom_left.text = textPage.title
pageSize = textPage.pageSize pageSize = textPage.pageSize
setPageIndex(textPage.index) setPageIndex(textPage.index)

@ -142,4 +142,15 @@
<item>@string/icon_book</item> <item>@string/icon_book</item>
</string-array> </string-array>
<string-array name="chinese_mode">
<item>关闭</item>
<item>简体转繁体</item>
<item>繁体转简体</item>
</string-array>
<string-array name="chinese_mode_v">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
</resources> </resources>

@ -605,5 +605,5 @@
<string name="add_to_text_context_menu_s">长按文字在操作菜单中显示阅读·搜索</string> <string name="add_to_text_context_menu_s">长按文字在操作菜单中显示阅读·搜索</string>
<string name="add_to_text_context_menu_t">文字操作显示搜索</string> <string name="add_to_text_context_menu_t">文字操作显示搜索</string>
<string name="record_log">记录日志</string> <string name="record_log">记录日志</string>
<string name="is_chinese_converter_enable">中文简繁体转换</string>
</resources> </resources>

@ -50,4 +50,12 @@
android:title="@string/record_log" android:title="@string/record_log"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<io.legado.app.lib.theme.prefs.ATEListPreference
android:defaultValue="0"
android:key="isChineseConverterEnable"
android:entries="@array/chinese_mode"
android:entryValues="@array/chinese_mode_v"
android:title="@string/is_chinese_converter_enable"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>
Loading…
Cancel
Save