diff --git a/app/build.gradle b/app/build.gradle index 1041b9d6c..6bd69f624 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -191,7 +191,7 @@ dependencies { implementation 'ru.noties.markwon:core:3.1.0' //转换繁体 - implementation 'com.github.houbb:opencc4j:1.4.0' + implementation 'com.hankcs:hanlp:portable-1.7.7' } diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 956b3f46b..514c5327c 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -1,6 +1,6 @@ package io.legado.app.help -import com.github.houbb.opencc4j.core.impl.ZhConvertBootstrap +import com.hankcs.hanlp.HanLP import io.legado.app.App import io.legado.app.constant.EventBus import io.legado.app.data.entities.Book @@ -233,8 +233,8 @@ object BookHelp { } try { when (AppConfig.chineseConverterType) { - 1 -> c = ZhConvertBootstrap.newInstance().toSimple(c) - 2 -> c = ZhConvertBootstrap.newInstance().toTraditional(c) + 1 -> c = HanLP.convertToSimplifiedChinese(c) + 2 -> c = HanLP.convertToTraditionalChinese(c) } } catch (e: Exception) { withContext(Main) { 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 d87311f09..d38a924b4 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 @@ -5,7 +5,7 @@ import android.content.Context import android.graphics.drawable.Drawable import android.view.MotionEvent import android.widget.FrameLayout -import com.github.houbb.opencc4j.core.impl.ZhConvertBootstrap +import com.hankcs.hanlp.HanLP import io.legado.app.R import io.legado.app.constant.AppConst.timeFormat import io.legado.app.help.AppConfig @@ -119,8 +119,8 @@ class ContentView(context: Context) : FrameLayout(context) { @SuppressLint("SetTextI18n") fun setProgress(textPage: TextPage) = textPage.apply { val title = when (AppConfig.chineseConverterType) { - 1 -> ZhConvertBootstrap.newInstance().toSimple(textPage.title) - 2 -> ZhConvertBootstrap.newInstance().toTraditional(textPage.title) + 1 -> HanLP.convertToSimplifiedChinese(textPage.title) + 2 -> HanLP.convertToTraditionalChinese(textPage.title) else -> textPage.title } if (ReadBookConfig.hideStatusBar) { diff --git a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt index fdf77bc85..63455fc9a 100644 --- a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt +++ b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt @@ -2,7 +2,7 @@ package io.legado.app.ui.welcome import android.content.Intent import android.os.Bundle -import com.github.houbb.opencc4j.util.ZhConverterUtil +import com.hankcs.hanlp.HanLP import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseActivity @@ -37,8 +37,8 @@ open class WelcomeActivity : BaseActivity(R.layout.activity_welcome) { .clearExpired(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1)) //初始化简繁转换引擎 when (AppConfig.chineseConverterType) { - 1 -> ZhConverterUtil.toSimple("初始化") - 2 -> ZhConverterUtil.toTraditional("初始化") + 1 -> HanLP.convertToSimplifiedChinese("初始化") + 2 -> HanLP.convertToTraditionalChinese("初始化") else -> null } }