1.替换繁简转换jar包

2.优化包体积。
master 1.0.0
Z 4 years ago
parent 2dd625aea1
commit 0d4eb3cb38
  1. 3
      app/build.gradle
  2. BIN
      app/libs/ZHConverter.jar
  3. 9
      app/proguard-rules.pro
  4. 15
      app/src/main/java/com/novel/read/App.kt
  5. 1
      app/src/main/java/com/novel/read/constant/PreferKey.kt
  6. 5
      app/src/main/java/com/novel/read/help/AppConfig.kt
  7. 10
      app/src/main/java/com/novel/read/help/BookHelp.kt
  8. 4
      app/src/main/java/com/novel/read/network/repository/SearchRepository.kt
  9. 8
      app/src/main/java/com/novel/read/service/help/ReadBook.kt
  10. 3
      app/src/main/java/com/novel/read/ui/main/mail/MailViewModel.kt
  11. 1
      app/src/main/java/com/novel/read/ui/setting/OtherConfigFragment.kt
  12. 13
      app/src/main/java/com/novel/read/ui/welcome/WelcomeActivity.kt
  13. 7
      app/src/main/java/com/novel/read/utils/StringUtils.kt

@ -138,8 +138,7 @@ dependencies {
implementation 'io.noties.markwon:core:4.6.0' implementation 'io.noties.markwon:core:4.6.0'
implementation 'io.noties.markwon:image-glide: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 //brvah
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.6' implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.6'

Binary file not shown.

@ -215,10 +215,6 @@
public static ** valueOf(java.lang.String); public static ** valueOf(java.lang.String);
} }
-keep class com.burst.k17reader_sdk.** { *; }
-keep class com.chineseall.reader.utils.** { *; }
-keep class org.litepal.** { *;} -keep class org.litepal.** { *;}
-keep class * extends org.litepal.crud.DataSupport { *;} -keep class * extends org.litepal.crud.DataSupport { *;}
-keep class * extends org.litepal.crud.LitePalSupport { *;} -keep class * extends org.litepal.crud.LitePalSupport { *;}
@ -230,7 +226,4 @@
public static ** valueOf(java.lang.String); public static ** valueOf(java.lang.String);
} }
-dontwarn com.youth.banner.** -keep class com.spreada.utils.chinese.**
-keep class com.youth.banner.**{*;}
-keep class com.android.vending.billing.**

@ -9,6 +9,7 @@ import android.provider.Settings
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.multidex.MultiDexApplication import androidx.multidex.MultiDexApplication
import com.bumptech.glide.Glide
import com.jeremyliao.liveeventbus.LiveEventBus import com.jeremyliao.liveeventbus.LiveEventBus
import com.novel.read.constant.AppConst.channelIdDownload import com.novel.read.constant.AppConst.channelIdDownload
import com.novel.read.constant.AppConst.channelIdReadAloud 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)
}
} }

@ -14,7 +14,6 @@ object PreferKey {
const val ttsSpeechRate = "ttsSpeechRate" const val ttsSpeechRate = "ttsSpeechRate"
const val prevKeys = "prevKeyCodes" const val prevKeys = "prevKeyCodes"
const val nextKeys = "nextKeyCodes" const val nextKeys = "nextKeyCodes"
const val showRss = "showRss"
const val bookshelfLayout = "bookshelfLayout" const val bookshelfLayout = "bookshelfLayout"
const val bookshelfSort = "bookshelfSort" const val bookshelfSort = "bookshelfSort"
const val recordLog = "recordLog" const val recordLog = "recordLog"

@ -55,9 +55,6 @@ object AppConfig {
} }
} }
val autoRefreshBook: Boolean
get() = App.INSTANCE.getPrefBoolean(R.string.pk_auto_refresh)
var threadCount: Int var threadCount: Int
get() = App.INSTANCE.getPrefInt(PreferKey.threadCount, 16) get() = App.INSTANCE.getPrefInt(PreferKey.threadCount, 16)
set(value) { set(value) {
@ -83,7 +80,7 @@ object AppConfig {
val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false) val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false)
var chineseConverterType: Int var chineseConverterType: Int
get() = App.INSTANCE.getPrefInt(PreferKey.chineseConverterType,2) get() = App.INSTANCE.getPrefInt(PreferKey.chineseConverterType,1)
set(value) { set(value) {
App.INSTANCE.putPrefInt(PreferKey.chineseConverterType, value) App.INSTANCE.putPrefInt(PreferKey.chineseConverterType, value)
} }

@ -1,7 +1,6 @@
package com.novel.read.help package com.novel.read.help
import android.util.Log import android.util.Log
import com.hankcs.hanlp.HanLP
import com.novel.read.App import com.novel.read.App
import com.novel.read.constant.AppPattern import com.novel.read.constant.AppPattern
import com.novel.read.constant.EventBus 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.help.coroutine.Coroutine
import com.novel.read.network.repository.ImageRepository import com.novel.read.network.repository.ImageRepository
import com.novel.read.utils.NetworkUtils import com.novel.read.utils.NetworkUtils
import com.spreada.utils.chinese.ZHConverter
import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@ -367,12 +367,12 @@ object BookHelp {
try { try {
when (AppConfig.chineseConverterType) { when (AppConfig.chineseConverterType) {
1 -> { 1 -> {
title1 = HanLP.convertToSimplifiedChinese(title1) title1=ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(title1)
content1 = HanLP.convertToSimplifiedChinese(content1) content1=ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(content1)
} }
2 -> { 2 -> {
title1 = HanLP.convertToTraditionalChinese(title1) title1=ZHConverter.getInstance(ZHConverter.TRADITIONAL).convert(title1)
content1 = HanLP.convertToTraditionalChinese(content1) content1=ZHConverter.getInstance(ZHConverter.TRADITIONAL).convert(content1)
} }
} }
} catch (e: Exception) { } catch (e: Exception) {

@ -1,8 +1,8 @@
package com.novel.read.network.repository package com.novel.read.network.repository
import com.hankcs.hanlp.HanLP
import com.novel.read.network.ServiceCreator import com.novel.read.network.ServiceCreator
import com.novel.read.utils.ext.GSON import com.novel.read.utils.ext.GSON
import com.spreada.utils.chinese.ZHConverter
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import okhttp3.MediaType import okhttp3.MediaType
@ -14,7 +14,7 @@ class SearchRepository {
suspend fun searchBook(page: Int, pageSize: Int, key: String) = withContext(Dispatchers.IO) { suspend fun searchBook(page: Int, pageSize: Int, key: String) = withContext(Dispatchers.IO) {
val map = HashMap<String, String>() val map = HashMap<String, String>()
val key1 = HanLP.convertToSimplifiedChinese(key) val key1 = ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(key)
map["pageNum"] = page.toString() map["pageNum"] = page.toString()
map["pageSize"] = pageSize.toString() map["pageSize"] = pageSize.toString()
map["searchTerms"] = key1 map["searchTerms"] = key1

@ -1,9 +1,7 @@
package com.novel.read.service.help package com.novel.read.service.help
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import com.hankcs.hanlp.HanLP
import com.novel.read.App import com.novel.read.App
import com.novel.read.constant.AppConst
import com.novel.read.constant.BookType import com.novel.read.constant.BookType
import com.novel.read.data.db.entity.Book import com.novel.read.data.db.entity.Book
import com.novel.read.data.db.entity.BookChapter 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.help.ReadBookConfig
import com.novel.read.service.BaseReadAloudService import com.novel.read.service.BaseReadAloudService
import com.novel.read.help.coroutine.Coroutine 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.ChapterProvider
import io.legado.app.ui.book.read.page.provider.ImageProvider import io.legado.app.ui.book.read.page.provider.ImageProvider
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -25,7 +24,6 @@ import kotlinx.coroutines.launch
import org.jetbrains.anko.getStackTraceString import org.jetbrains.anko.getStackTraceString
import org.jetbrains.anko.toast import org.jetbrains.anko.toast
object ReadBook { object ReadBook {
var titleDate = MutableLiveData<String>() var titleDate = MutableLiveData<String>()
var book: Book? = null var book: Book? = null
@ -354,8 +352,8 @@ object ReadBook {
Coroutine.async { Coroutine.async {
if (chapter.chapterIndex in durChapterIndex - 1..durChapterIndex + 1) { if (chapter.chapterIndex in durChapterIndex - 1..durChapterIndex + 1) {
chapter.chapterName = when (AppConfig.chineseConverterType) { chapter.chapterName = when (AppConfig.chineseConverterType) {
1 -> HanLP.convertToSimplifiedChinese(chapter.chapterName) 1 -> ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(chapter.chapterName)
2 -> HanLP.convertToTraditionalChinese(chapter.chapterName) 2 -> ZHConverter.getInstance(ZHConverter.TRADITIONAL).convert(chapter.chapterName)
else -> chapter.chapterName else -> chapter.chapterName
} }
val contents = BookHelp.disposeContent( val contents = BookHelp.disposeContent(

@ -9,8 +9,10 @@ import com.novel.read.network.repository.HomeRepository
class MailViewModel(application: Application) : BaseViewModel(application) { class MailViewModel(application: Application) : BaseViewModel(application) {
private val homeRepository by lazy { HomeRepository() } private val homeRepository by lazy { HomeRepository() }
var homeResp = MutableLiveData<HomeResp>() var homeResp = MutableLiveData<HomeResp>()
val refreshStatus = MutableLiveData<Int>() val refreshStatus = MutableLiveData<Int>()
fun getAll() { fun getAll() {
refreshStatus.value = AppConst.loading refreshStatus.value = AppConst.loading
launch(block = { launch(block = {
@ -20,4 +22,5 @@ class MailViewModel(application: Application) : BaseViewModel(application) {
refreshStatus.value = AppConst.error refreshStatus.value = AppConst.error
}, showErrorToast = false) }, showErrorToast = false)
} }
} }

@ -65,7 +65,6 @@ class OtherConfigFragment : BasePreferenceFragment(), CoroutineScope by MainScop
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
when (key) { when (key) {
PreferKey.showRss -> postEvent(EventBus.SHOW_RSS, "")
PreferKey.language -> { PreferKey.language -> {
val lg = sharedPreferences?.all?.get("language") val lg = sharedPreferences?.all?.get("language")
if (lg == "zh") { if (lg == "zh") {

@ -3,16 +3,13 @@ package com.novel.read.ui.welcome
import android.Manifest import android.Manifest
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import com.hankcs.hanlp.HanLP
import com.permissionx.guolindev.PermissionX import com.permissionx.guolindev.PermissionX
import com.novel.read.R import com.novel.read.R
import com.novel.read.base.BaseActivity import com.novel.read.base.BaseActivity
import com.novel.read.databinding.ActivityWelcomeBinding import com.novel.read.databinding.ActivityWelcomeBinding
import com.novel.read.help.AppConfig
import com.novel.read.ui.MainActivity import com.novel.read.ui.MainActivity
import com.novel.read.ui.read.ReadBookActivity import com.novel.read.ui.read.ReadBookActivity
import com.novel.read.utils.ext.getPrefBoolean import com.novel.read.utils.ext.getPrefBoolean
import com.novel.read.help.coroutine.Coroutine
import org.jetbrains.anko.startActivity import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast import org.jetbrains.anko.toast
@ -33,15 +30,6 @@ class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() {
} }
private fun init() { private fun init() {
Coroutine.async {
//初始化简繁转换引擎
when (AppConfig.chineseConverterType) {
1 -> HanLP.convertToSimplifiedChinese("初始化")
2 -> HanLP.convertToTraditionalChinese("初始化")
else -> null
}
}
PermissionX.init(this) PermissionX.init(this)
.permissions( .permissions(
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE,
@ -52,7 +40,6 @@ class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() {
binding.rootView.postDelayed({ startMainActivity() }, 2500) binding.rootView.postDelayed({ startMainActivity() }, 2500)
} else { } else {
toast("权限被拒绝,将导致部分功能异常,请到设置中开启相关权限") toast("权限被拒绝,将导致部分功能异常,请到设置中开启相关权限")
// finish()
} }
} }

@ -2,12 +2,13 @@ package com.novel.read.utils
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.text.TextUtils.isEmpty import android.text.TextUtils.isEmpty
import com.hankcs.hanlp.HanLP import android.util.Log
import com.novel.read.App import com.novel.read.App
import com.novel.read.constant.PreferKey import com.novel.read.constant.PreferKey
import com.novel.read.help.AppConfig import com.novel.read.help.AppConfig
import com.novel.read.utils.ext.getPrefInt import com.novel.read.utils.ext.getPrefInt
import com.novel.read.utils.ext.getPrefLong import com.novel.read.utils.ext.getPrefLong
import com.spreada.utils.chinese.ZHConverter
import java.text.DecimalFormat import java.text.DecimalFormat
import java.text.ParseException import java.text.ParseException
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
@ -340,10 +341,10 @@ object StringUtils {
fun convertCC(input: String?): String { fun convertCC(input: String?): String {
return when (AppConfig.chineseConverterType) { return when (AppConfig.chineseConverterType) {
1 -> { 1 -> {
HanLP.convertToSimplifiedChinese(input) ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(input)
} }
2 -> { 2 -> {
HanLP.convertToTraditionalChinese(input) ZHConverter.getInstance(ZHConverter.TRADITIONAL).convert(input)
} }
else -> { else -> {
input!! input!!

Loading…
Cancel
Save