Skip to content

Commit 036fdac

Browse files
committed
v2.5.8
优化 1. 主页加载速度 2. 默认UA判定 3. TCP Client
1 parent e53db67 commit 036fdac

File tree

24 files changed

+259
-391
lines changed

24 files changed

+259
-391
lines changed

.idea/dictionaries/fumiama.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
minSdkVersion 23
1313
//noinspection OldTargetApi
1414
targetSdkVersion 34
15-
versionCode 80
16-
versionName '2.5.7'
15+
versionCode 81
16+
versionName '2.5.8'
1717
resourceConfigurations += ['zh', 'zh-rCN']
1818

1919
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -124,4 +124,5 @@ dependencies {
124124
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
125125
implementation 'com.airbnb.android:lottie:6.6.6'
126126
implementation 'net.java.dev.jna:jna:5.17.0@aar'
127+
implementation 'top.fumiama:sdict:0.1.0'
127128
}

app/src/main/java/top/fumiama/copymanga/MainActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import top.fumiama.copymanga.api.update.Update
6363
import top.fumiama.copymanga.api.user.Member
6464
import top.fumiama.copymanga.lib.Comancry
6565
import top.fumiama.copymanga.lib.Comandy
66-
import top.fumiama.copymanga.storage.DataLoader
66+
import top.fumiama.copymanga.storage.ConfigLoader
6767
import top.fumiama.copymanga.strings.Base16384
6868
import top.fumiama.dmzj.copymanga.BuildConfig
6969
import top.fumiama.dmzj.copymanga.R
@@ -225,15 +225,15 @@ class MainActivity : AppCompatActivity() {
225225
toolsBox.buildInfo("备份管理", "可选择导出或导入base16384格式配置项",
226226
"导出", "导入", "取消", { // ok
227227
MaterialDialog(this).show {
228-
input(prefill = Base16384.encode(DataLoader().toByteArray()))
228+
input(prefill = Base16384.encode(ConfigLoader().toByteArray()))
229229
positiveButton(android.R.string.ok)
230230
title(null, "请复制配置文本并保存")
231231
}
232232
}, { // neutral
233233
MaterialDialog(this).show {
234234
input { _, c ->
235235
try {
236-
DataLoader(Base16384.decode(c.toString())).settings.export()
236+
ConfigLoader(Base16384.decode(c.toString())).settings.export()
237237
navController?.apply {
238238
currentDestination?.id?.let {
239239
popBackStack()

app/src/main/java/top/fumiama/copymanga/api/Config.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ object Config {
5858

5959
val proxyUrl = MainActivity.mainWeakReference?.get()?.getString(R.string.proxyUrl)!!
6060
val pc_ua get() = MainActivity.mainWeakReference?.get()?.getString(R.string.pc_ua)?.format(app_ver.value)?:""
61+
val default_ua get() = MainActivity.mainWeakReference?.get()?.getString(R.string.default_ua)?:""
6162
val referer get() = MainActivity.mainWeakReference?.get()?.getString(R.string.referer)?.format(app_ver.value)?:""
6263

6364
val navTextInfo = UserPreferenceString("navTextInfo", R.string.navTextInfo)
@@ -95,7 +96,7 @@ object Config {
9596
val net_img_resolution = PreferenceString(R.string.imgResolutionKeyID)
9697
val net_umstring = PreferenceString("settings_cat_net_et_umstring")
9798
val net_source = PreferenceString("settings_cat_net_et_source", R.string.source)
98-
val net_ua = PreferenceString("settings_cat_net_et_ua", "__default_ua__")
99+
val net_ua = PreferenceString("settings_cat_net_et_ua", R.string.default_ua)
99100

100101
val view_manga_inverse_chapters = PreferenceBoolean("settings_cat_vm_sw_inverse_chapters", false)
101102
val view_manga_always_dark_bg = PreferenceBoolean("settings_cat_vm_sw_always_dark_bg", false)

app/src/main/java/top/fumiama/copymanga/api/update/ByteArrayQueue.kt

Lines changed: 0 additions & 27 deletions
This file was deleted.

app/src/main/java/top/fumiama/copymanga/api/update/SimpleKanban.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package top.fumiama.copymanga.api.update
22

33
import android.util.Log
4-
import top.fumiama.copymanga.net.Client
4+
import top.fumiama.sdict.io.Client
55

66
class SimpleKanban(private val client: Client, private val pwd: String) { //must run in thread
77
private val raw: ByteArray?
@@ -51,13 +51,13 @@ class SimpleKanban(private val client: Client, private val pwd: String) { //mu
5151
client.sendMessage("${pwd}get${version}quit")
5252
client.receiveRawMessage(36) //Welcome to simple kanban server. get
5353
val r = try {
54-
val firstRecv = client.receiveRawMessage(4)
55-
if(firstRecv.decodeToString() == "null") "null"
54+
val firstReceive = client.receiveRawMessage(4)
55+
if(firstReceive.decodeToString() == "null") "null"
5656
else {
57-
val length = convert2Int(firstRecv)
57+
val length = convert2Int(firstReceive)
5858
Log.d("MySK", "Msg len: $length")
5959
var re = byteArrayOf()
60-
if(firstRecv.size > 4) re += firstRecv.copyOfRange(4, firstRecv.size)
60+
if(firstReceive.size > 4) re += firstReceive.copyOfRange(4, firstReceive.size)
6161
re += client.receiveRawMessage(length - re.size)
6262
if(re.isNotEmpty()) re.decodeToString() else "null"
6363
}

app/src/main/java/top/fumiama/copymanga/api/update/Update.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import kotlinx.android.synthetic.main.dialog_progress.view.*
1616
import kotlinx.coroutines.Dispatchers
1717
import kotlinx.coroutines.launch
1818
import kotlinx.coroutines.withContext
19-
import top.fumiama.copymanga.net.Client
19+
import top.fumiama.sdict.io.Client
2020
import top.fumiama.copymanga.view.interaction.UITools
2121
import top.fumiama.dmzj.copymanga.BuildConfig
2222
import top.fumiama.dmzj.copymanga.R
23+
import top.fumiama.sdict.utils.Utils.toHexStr
2324
import java.io.File
2425
import java.security.MessageDigest
2526

@@ -63,7 +64,7 @@ object Update {
6364
fetch(client, kanban, this@apply) {
6465
lifecycleScope.launch {
6566
val md5 = msg.substringAfterLast("md5:")
66-
if (md5 == UITools.toHexStr(
67+
if (md5 == toHexStr(
6768
MessageDigest.getInstance("MD5").digest(it)
6869
)
6970
) {

app/src/main/java/top/fumiama/copymanga/lib/template/LazyLibrary.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import kotlinx.coroutines.Dispatchers
1010
import kotlinx.coroutines.withContext
1111
import top.fumiama.copymanga.MainActivity
1212
import top.fumiama.copymanga.json.ComandyVersion
13-
import top.fumiama.copymanga.net.Client
13+
import top.fumiama.sdict.io.Client
1414
import top.fumiama.copymanga.net.DownloadTools
1515
import top.fumiama.copymanga.storage.PreferenceBoolean
1616
import top.fumiama.copymanga.storage.UserPreferenceInt

app/src/main/java/top/fumiama/copymanga/net/Client.kt

Lines changed: 0 additions & 124 deletions
This file was deleted.

app/src/main/java/top/fumiama/copymanga/net/DownloadTools.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import kotlinx.coroutines.Dispatchers
77
import kotlinx.coroutines.runBlocking
88
import kotlinx.coroutines.withContext
99
import org.json.JSONObject
10+
import top.fumiama.sdict.io.Client
1011
import top.fumiama.copymanga.api.Config
1112
import top.fumiama.copymanga.api.Config.proxyUrl
1213
import top.fumiama.copymanga.json.ComandyCapsule
@@ -34,7 +35,7 @@ object DownloadTools {
3435
connection.apply {
3536
Config.net_ua.value.let {
3637
if (it.isEmpty()) return@let
37-
setRequestProperty("user-agent", if (it == "__default_ua__") Config.pc_ua else it)
38+
setRequestProperty("user-agent", if (it == Config.default_ua) Config.pc_ua else it)
3839
}
3940
Config.net_source.value.let { if(it.isNotEmpty()) setRequestProperty("source", it) }
4041
// deviceinfo
@@ -43,7 +44,7 @@ object DownloadTools {
4344
if (Config.net_use_gzip.value) setRequestProperty("accept-encoding", "gzip")
4445
setRequestProperty("authorization", "Token${Config.token.value?.let { tk ->
4546
if (tk.isNotEmpty()) " $tk" else ""
46-
}}")
47+
}?:""}")
4748
if (Config.net_platform.value) setRequestProperty("platform", Config.platform.value)
4849
if (Config.net_referer.value) setRequestProperty("referer", Config.referer)
4950
if (Config.net_use_json.value) setRequestProperty("accept", "application/json")
@@ -66,7 +67,7 @@ object DownloadTools {
6667
capsule.headers = hashMapOf()
6768
Config.net_ua.value.let {
6869
if (it.isEmpty()) return@let
69-
capsule.headers["user-agent"] = if (it == "__default_ua__") Config.pc_ua else it
70+
capsule.headers["user-agent"] = if (it == Config.default_ua) Config.pc_ua else it
7071
}
7172
Config.net_source.value.let { if(it.isNotEmpty()) capsule.headers["source"] = it }
7273
// deviceinfo
@@ -75,7 +76,7 @@ object DownloadTools {
7576
if (Config.net_use_gzip.value) capsule.headers["accept-encoding"] = "gzip"
7677
capsule.headers["authorization"] = "Token${Config.token.value?.let { tk ->
7778
if (tk.isNotEmpty()) " $tk" else ""
78-
}}"
79+
}?:""}"
7980
if (Config.net_platform.value) capsule.headers["platform"] = Config.platform.value
8081
if (Config.net_referer.value) capsule.headers["referer"] = Config.referer
8182
if (Config.net_use_json.value) capsule.headers["accept"] = "application/json"

0 commit comments

Comments
 (0)