diff --git a/app/build.gradle b/app/build.gradle index 394c28a..d04f72d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -138,8 +138,7 @@ dependencies { implementation 'io.noties.markwon:core:4.6.0' implementation 'io.noties.markwon:image-glide:4.6.0' //转换繁体 - implementation 'com.hankcs:hanlp:portable-1.7.8' - + implementation files('libs/ZHConverter.jar') //brvah implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.6' diff --git a/app/libs/ZHConverter.jar b/app/libs/ZHConverter.jar new file mode 100644 index 0000000..fb4a6b3 Binary files /dev/null and b/app/libs/ZHConverter.jar differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 58b42f3..61aa03f 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -215,10 +215,6 @@ public static ** valueOf(java.lang.String); } - --keep class com.burst.k17reader_sdk.** { *; } --keep class com.chineseall.reader.utils.** { *; } - -keep class org.litepal.** { *;} -keep class * extends org.litepal.crud.DataSupport { *;} -keep class * extends org.litepal.crud.LitePalSupport { *;} @@ -230,7 +226,4 @@ public static ** valueOf(java.lang.String); } --dontwarn com.youth.banner.** --keep class com.youth.banner.**{*;} - --keep class com.android.vending.billing.** +-keep class com.spreada.utils.chinese.** diff --git a/app/src/main/java/com/novel/read/App.kt b/app/src/main/java/com/novel/read/App.kt index 4a8262a..7bd5b34 100644 --- a/app/src/main/java/com/novel/read/App.kt +++ b/app/src/main/java/com/novel/read/App.kt @@ -9,6 +9,7 @@ import android.provider.Settings import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatDelegate import androidx.multidex.MultiDexApplication +import com.bumptech.glide.Glide import com.jeremyliao.liveeventbus.LiveEventBus import com.novel.read.constant.AppConst.channelIdDownload import com.novel.read.constant.AppConst.channelIdReadAloud @@ -120,4 +121,18 @@ class App : MultiDexApplication() { } } + + override fun onLowMemory() { + super.onLowMemory() + Glide.get(this).clearMemory() + } + + override fun onTrimMemory(level: Int) { + super.onTrimMemory(level) + if (level == TRIM_MEMORY_UI_HIDDEN) { + Glide.get(this).clearMemory() + } + Glide.get(this).trimMemory(level) + } + } \ No newline at end of file diff --git a/app/src/main/java/com/novel/read/constant/PreferKey.kt b/app/src/main/java/com/novel/read/constant/PreferKey.kt index 54319ae..a18402f 100644 --- a/app/src/main/java/com/novel/read/constant/PreferKey.kt +++ b/app/src/main/java/com/novel/read/constant/PreferKey.kt @@ -14,7 +14,6 @@ object PreferKey { const val ttsSpeechRate = "ttsSpeechRate" const val prevKeys = "prevKeyCodes" const val nextKeys = "nextKeyCodes" - const val showRss = "showRss" const val bookshelfLayout = "bookshelfLayout" const val bookshelfSort = "bookshelfSort" const val recordLog = "recordLog" diff --git a/app/src/main/java/com/novel/read/help/AppConfig.kt b/app/src/main/java/com/novel/read/help/AppConfig.kt index 24dc0b1..019ec74 100644 --- a/app/src/main/java/com/novel/read/help/AppConfig.kt +++ b/app/src/main/java/com/novel/read/help/AppConfig.kt @@ -55,9 +55,6 @@ object AppConfig { } } - val autoRefreshBook: Boolean - get() = App.INSTANCE.getPrefBoolean(R.string.pk_auto_refresh) - var threadCount: Int get() = App.INSTANCE.getPrefInt(PreferKey.threadCount, 16) set(value) { @@ -83,7 +80,7 @@ object AppConfig { val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false) var chineseConverterType: Int - get() = App.INSTANCE.getPrefInt(PreferKey.chineseConverterType,2) + get() = App.INSTANCE.getPrefInt(PreferKey.chineseConverterType,1) set(value) { App.INSTANCE.putPrefInt(PreferKey.chineseConverterType, value) } diff --git a/app/src/main/java/com/novel/read/help/BookHelp.kt b/app/src/main/java/com/novel/read/help/BookHelp.kt index a1e693b..10e3b66 100644 --- a/app/src/main/java/com/novel/read/help/BookHelp.kt +++ b/app/src/main/java/com/novel/read/help/BookHelp.kt @@ -1,7 +1,6 @@ package com.novel.read.help import android.util.Log -import com.hankcs.hanlp.HanLP import com.novel.read.App import com.novel.read.constant.AppPattern import com.novel.read.constant.EventBus @@ -14,6 +13,7 @@ import com.novel.read.utils.ext.* import com.novel.read.help.coroutine.Coroutine import com.novel.read.network.repository.ImageRepository import com.novel.read.utils.NetworkUtils +import com.spreada.utils.chinese.ZHConverter import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.delay import kotlinx.coroutines.withContext @@ -367,12 +367,12 @@ object BookHelp { try { when (AppConfig.chineseConverterType) { 1 -> { - title1 = HanLP.convertToSimplifiedChinese(title1) - content1 = HanLP.convertToSimplifiedChinese(content1) + title1=ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(title1) + content1=ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(content1) } 2 -> { - title1 = HanLP.convertToTraditionalChinese(title1) - content1 = HanLP.convertToTraditionalChinese(content1) + title1=ZHConverter.getInstance(ZHConverter.TRADITIONAL).convert(title1) + content1=ZHConverter.getInstance(ZHConverter.TRADITIONAL).convert(content1) } } } catch (e: Exception) { diff --git a/app/src/main/java/com/novel/read/network/repository/SearchRepository.kt b/app/src/main/java/com/novel/read/network/repository/SearchRepository.kt index 498b9a6..989eadb 100644 --- a/app/src/main/java/com/novel/read/network/repository/SearchRepository.kt +++ b/app/src/main/java/com/novel/read/network/repository/SearchRepository.kt @@ -1,8 +1,8 @@ package com.novel.read.network.repository -import com.hankcs.hanlp.HanLP import com.novel.read.network.ServiceCreator import com.novel.read.utils.ext.GSON +import com.spreada.utils.chinese.ZHConverter import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import okhttp3.MediaType @@ -14,7 +14,7 @@ class SearchRepository { suspend fun searchBook(page: Int, pageSize: Int, key: String) = withContext(Dispatchers.IO) { val map = HashMap() - val key1 = HanLP.convertToSimplifiedChinese(key) + val key1 = ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(key) map["pageNum"] = page.toString() map["pageSize"] = pageSize.toString() map["searchTerms"] = key1 diff --git a/app/src/main/java/com/novel/read/service/help/ReadBook.kt b/app/src/main/java/com/novel/read/service/help/ReadBook.kt index 31b08a9..7563c2e 100644 --- a/app/src/main/java/com/novel/read/service/help/ReadBook.kt +++ b/app/src/main/java/com/novel/read/service/help/ReadBook.kt @@ -1,9 +1,7 @@ package com.novel.read.service.help import androidx.lifecycle.MutableLiveData -import com.hankcs.hanlp.HanLP import com.novel.read.App -import com.novel.read.constant.AppConst import com.novel.read.constant.BookType import com.novel.read.data.db.entity.Book import com.novel.read.data.db.entity.BookChapter @@ -16,6 +14,7 @@ import com.novel.read.help.IntentDataHelp import com.novel.read.help.ReadBookConfig import com.novel.read.service.BaseReadAloudService import com.novel.read.help.coroutine.Coroutine +import com.spreada.utils.chinese.ZHConverter import io.legado.app.ui.book.read.page.provider.ChapterProvider import io.legado.app.ui.book.read.page.provider.ImageProvider import kotlinx.coroutines.Dispatchers @@ -25,7 +24,6 @@ import kotlinx.coroutines.launch import org.jetbrains.anko.getStackTraceString import org.jetbrains.anko.toast - object ReadBook { var titleDate = MutableLiveData() var book: Book? = null @@ -354,8 +352,8 @@ object ReadBook { Coroutine.async { if (chapter.chapterIndex in durChapterIndex - 1..durChapterIndex + 1) { chapter.chapterName = when (AppConfig.chineseConverterType) { - 1 -> HanLP.convertToSimplifiedChinese(chapter.chapterName) - 2 -> HanLP.convertToTraditionalChinese(chapter.chapterName) + 1 -> ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(chapter.chapterName) + 2 -> ZHConverter.getInstance(ZHConverter.TRADITIONAL).convert(chapter.chapterName) else -> chapter.chapterName } val contents = BookHelp.disposeContent( diff --git a/app/src/main/java/com/novel/read/ui/main/mail/MailViewModel.kt b/app/src/main/java/com/novel/read/ui/main/mail/MailViewModel.kt index 4faeb60..f3f5716 100644 --- a/app/src/main/java/com/novel/read/ui/main/mail/MailViewModel.kt +++ b/app/src/main/java/com/novel/read/ui/main/mail/MailViewModel.kt @@ -9,8 +9,10 @@ import com.novel.read.network.repository.HomeRepository class MailViewModel(application: Application) : BaseViewModel(application) { private val homeRepository by lazy { HomeRepository() } + var homeResp = MutableLiveData() val refreshStatus = MutableLiveData() + fun getAll() { refreshStatus.value = AppConst.loading launch(block = { @@ -18,6 +20,7 @@ class MailViewModel(application: Application) : BaseViewModel(application) { refreshStatus.value = AppConst.complete }, error = { refreshStatus.value = AppConst.error - },showErrorToast = false) + }, showErrorToast = false) } + } \ No newline at end of file diff --git a/app/src/main/java/com/novel/read/ui/setting/OtherConfigFragment.kt b/app/src/main/java/com/novel/read/ui/setting/OtherConfigFragment.kt index d293e6e..0be5ccd 100644 --- a/app/src/main/java/com/novel/read/ui/setting/OtherConfigFragment.kt +++ b/app/src/main/java/com/novel/read/ui/setting/OtherConfigFragment.kt @@ -65,7 +65,6 @@ class OtherConfigFragment : BasePreferenceFragment(), CoroutineScope by MainScop override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { when (key) { - PreferKey.showRss -> postEvent(EventBus.SHOW_RSS, "") PreferKey.language -> { val lg = sharedPreferences?.all?.get("language") if (lg == "zh") { diff --git a/app/src/main/java/com/novel/read/ui/welcome/WelcomeActivity.kt b/app/src/main/java/com/novel/read/ui/welcome/WelcomeActivity.kt index 5d3da7c..52a4093 100644 --- a/app/src/main/java/com/novel/read/ui/welcome/WelcomeActivity.kt +++ b/app/src/main/java/com/novel/read/ui/welcome/WelcomeActivity.kt @@ -3,16 +3,13 @@ package com.novel.read.ui.welcome import android.Manifest import android.content.Intent import android.os.Bundle -import com.hankcs.hanlp.HanLP import com.permissionx.guolindev.PermissionX import com.novel.read.R import com.novel.read.base.BaseActivity import com.novel.read.databinding.ActivityWelcomeBinding -import com.novel.read.help.AppConfig import com.novel.read.ui.MainActivity import com.novel.read.ui.read.ReadBookActivity import com.novel.read.utils.ext.getPrefBoolean -import com.novel.read.help.coroutine.Coroutine import org.jetbrains.anko.startActivity import org.jetbrains.anko.toast @@ -33,15 +30,6 @@ class WelcomeActivity : BaseActivity() { } private fun init() { - Coroutine.async { - //初始化简繁转换引擎 - when (AppConfig.chineseConverterType) { - 1 -> HanLP.convertToSimplifiedChinese("初始化") - 2 -> HanLP.convertToTraditionalChinese("初始化") - else -> null - } - } - PermissionX.init(this) .permissions( Manifest.permission.WRITE_EXTERNAL_STORAGE, @@ -52,7 +40,6 @@ class WelcomeActivity : BaseActivity() { binding.rootView.postDelayed({ startMainActivity() }, 2500) } else { toast("权限被拒绝,将导致部分功能异常,请到设置中开启相关权限") -// finish() } } diff --git a/app/src/main/java/com/novel/read/utils/StringUtils.kt b/app/src/main/java/com/novel/read/utils/StringUtils.kt index 6ef2916..38cda36 100644 --- a/app/src/main/java/com/novel/read/utils/StringUtils.kt +++ b/app/src/main/java/com/novel/read/utils/StringUtils.kt @@ -2,12 +2,13 @@ package com.novel.read.utils import android.annotation.SuppressLint import android.text.TextUtils.isEmpty -import com.hankcs.hanlp.HanLP +import android.util.Log import com.novel.read.App import com.novel.read.constant.PreferKey import com.novel.read.help.AppConfig import com.novel.read.utils.ext.getPrefInt import com.novel.read.utils.ext.getPrefLong +import com.spreada.utils.chinese.ZHConverter import java.text.DecimalFormat import java.text.ParseException import java.text.SimpleDateFormat @@ -340,10 +341,10 @@ object StringUtils { fun convertCC(input: String?): String { return when (AppConfig.chineseConverterType) { 1 -> { - HanLP.convertToSimplifiedChinese(input) + ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(input) } 2 -> { - HanLP.convertToTraditionalChinese(input) + ZHConverter.getInstance(ZHConverter.TRADITIONAL).convert(input) } else -> { input!!