diff --git a/app/src/main/java/io/legado/app/utils/ChineseUtils.kt b/app/src/main/java/io/legado/app/utils/ChineseUtils.kt index 97fc10ae8..0934af5cf 100644 --- a/app/src/main/java/io/legado/app/utils/ChineseUtils.kt +++ b/app/src/main/java/io/legado/app/utils/ChineseUtils.kt @@ -2,8 +2,6 @@ package io.legado.app.utils import com.github.liuyueyi.quick.transfer.ChineseUtils import com.github.liuyueyi.quick.transfer.constants.TransType -import com.github.liuyueyi.quick.transfer.dictionary.BasicDictionary -import com.github.liuyueyi.quick.transfer.dictionary.DictionaryContainer object ChineseUtils { @@ -15,7 +13,6 @@ object ChineseUtils { fun t2s(content: String): String { if (!fixed) { - fixed = true fixT2sDict() } return ChineseUtils.t2s(content) @@ -30,29 +27,18 @@ object ChineseUtils { } fun fixT2sDict() { - val dict = DictionaryContainer.getInstance().getDictionary(TransType.TRADITIONAL_TO_SIMPLE) - dict.run { - remove( - "劈", "脊", "槃", - "支援", "沈默", "類比", "模擬", "划槳", "列根", "先進", "雪梨", "雪糕", - "零錢", "零钱", "離線", "碟片", "模組", "桌球", "案頭", "機車", "電漿", - "鳳梨", "魔戒", "載入", "菲林", "整合", - "路易斯", "非同步", "出租车", "周杰倫", "马铃薯", "馬鈴薯", "機械人", "電單車", - "電扶梯", "音效卡", "飆車族", "點陣圖", "個入球", "顆進球", - "魔獸紀元", "高空彈跳", "铁达尼号", - "魔鬼終結者", "純文字檔案" - ) - } - } - - fun BasicDictionary.remove(vararg keys: String) { - for (key in keys) { - if (key.length == 1) { - chars.remove(key[0]) - } else { - dict.remove(key) - } - } + fixed = true + val excludeList = listOf( + "槃", + "划槳", "列根", "雪梨", "雪糕", + "零錢", "零钱", "離線", "碟片", "模組", "桌球", "案頭", "機車", "電漿", + "鳳梨", "魔戒", "載入", "菲林", "整合", "變數", + "路易斯", "非同步", "出租车", "周杰倫", "马铃薯", "馬鈴薯", "機械人", "電單車", + "電扶梯", "音效卡", "飆車族", "點陣圖", "個入球", "顆進球", + "魔獸紀元", "高空彈跳", "铁达尼号", + "魔鬼終結者", "純文字檔案" + ) + ChineseUtils.loadExcludeDict(TransType.TRADITIONAL_TO_SIMPLE, excludeList) } } diff --git a/app/src/main/java/io/legado/app/utils/TrieExtensions.kt b/app/src/main/java/io/legado/app/utils/TrieExtensions.kt deleted file mode 100644 index c0e78ef6e..000000000 --- a/app/src/main/java/io/legado/app/utils/TrieExtensions.kt +++ /dev/null @@ -1,41 +0,0 @@ -package io.legado.app.utils - -import com.github.liuyueyi.quick.transfer.Trie -import com.github.liuyueyi.quick.transfer.TrieNode -import java.util.HashMap - -fun Trie.getRoot(): TrieNode { - val rootField = javaClass.getDeclaredField("root") - .apply { isAccessible = true } - @Suppress("UNCHECKED_CAST") - return rootField.get(this) as TrieNode -} - -fun TrieNode.getChildren(): HashMap> { - val childrenField = javaClass.getDeclaredField("children") - .apply { isAccessible = true } - @Suppress("UNCHECKED_CAST") - return childrenField.get(this) as HashMap> -} - -fun Trie.remove(value: String) { - kotlin.runCatching { - var node = getRoot() - val nodes = arrayListOf>() - val chars = value.toCharArray() - for (c in chars) { - nodes.add(node) - node = node.getChildren()[c] ?: break - if (!node.isLeaf) { - continue - } - for ((ch, n) in chars.reversed().zip(nodes.reversed())) { - val children = n.getChildren() - children.remove(ch) - if (children.isNotEmpty()) { - break - } - } - } - } -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7e22e8e23..961c8e95b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -34,7 +34,7 @@ nanoHttpd = "2.3.1" okhttp = "4.12.0" preference = "1.2.1" protobufJavalite = "4.26.1" -quickChineseTransfer = "0.2.15" +quickChineseTransfer = "0.2.16" room = "2.6.1" splitties = "3.0.0" rhino = "1.8.0"