1
0
mirror of https://github.com/fumiama/copymanga.git synced 2026-06-09 09:43:11 +08:00
修复
1. 一些闪退
This commit is contained in:
源文雨
2025-06-05 21:53:30 +09:00
parent 4460dc9f0b
commit bf1f0c9395
6 changed files with 31 additions and 10 deletions

View File

@@ -12,8 +12,8 @@ android {
minSdkVersion 23
//noinspection OldTargetApi
targetSdkVersion 34
versionCode 74
versionName '2.5.3'
versionCode 75
versionName '2.5.4'
resourceConfigurations += ['zh', 'zh-rCN']
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View File

@@ -79,6 +79,8 @@ object Config {
val manga_dl_max_batch = PreferenceInt("settings_cat_md_sb_max_batch", 16)
val manga_dl_show_0m_manga = PreferenceBoolean("settings_cat_md_sw_show_0m_manga", false)
val net_use_gzip = PreferenceBoolean("settings_cat_net_sw_use_gzip", false)
val net_use_json = PreferenceBoolean("settings_cat_net_sw_use_json", false)
val net_use_comandy = PreferenceBoolean("settings_cat_net_sw_use_comandy", false)
val net_use_foreign = PreferenceBoolean("settings_cat_net_sw_use_foreign", false)
private val net_use_img_proxy = PreferenceBoolean("settings_cat_net_sw_use_img_proxy", false)

View File

@@ -70,12 +70,12 @@ class Api {
throw NoSuchElementException("API列表为空")
}
var r: ReturnBase? = null
apis.forEach { api ->
apis.forEachIndexed { i, api ->
val u = "https://$api$path"
val ret = (apiProxy?.comancry(u) {
DownloadTools.getApiContent(it)
}?: DownloadTools.getApiContent(u)).decodeToString()
try {
val ret = (apiProxy?.comancry(u) {
DownloadTools.getApiContent(it)
}?: DownloadTools.getApiContent(u)).decodeToString()
r = Gson().fromJson(ret, ReturnBase::class.java)
if (r!!.code != 200) {
mu.write { mHostApiUrls.remove(api) }
@@ -84,6 +84,9 @@ class Api {
}
} catch (e: Exception) {
mu.write { mHostApiUrls.remove(api) }
if (i >= apis.size-1) { // throw lase exception
throw e
}
}
}
throw IllegalStateException("错误码${r?.code?:-1}, 信息: ${r?.message?:"空"}")

View File

@@ -35,13 +35,13 @@ object DownloadTools {
// deviceinfo
setRequestProperty("webp", "1")
setRequestProperty("dt", SimpleDateFormat("yyyy.MM.dd", Locale.getDefault()).format(Calendar.getInstance().time))
setRequestProperty("accept-encoding", "gzip")
if (Config.net_use_gzip.value) setRequestProperty("accept-encoding", "gzip")
setRequestProperty("authorization", "Token${Config.token.value?.let { tk ->
if (tk.isNotEmpty()) " $tk" else ""
}}")
setRequestProperty("platform", Config.platform.value)
setRequestProperty("referer", Config.referer)
setRequestProperty("accept", "application/json")
if (Config.net_use_json.value) setRequestProperty("accept", "application/json")
setRequestProperty("version", Config.app_ver.value)
setRequestProperty("region", if(!Config.net_use_foreign.value) "1" else "0")
// device
@@ -64,13 +64,13 @@ object DownloadTools {
// deviceinfo
capsule.headers["webp"] = "1"
capsule.headers["dt"] = SimpleDateFormat("yyyy.MM.dd", Locale.getDefault()).format(Calendar.getInstance().time)
capsule.headers["accept-encoding"] = "gzip"
if (Config.net_use_gzip.value) capsule.headers["accept-encoding"] = "gzip"
capsule.headers["authorization"] = "Token${Config.token.value?.let { tk ->
if (tk.isNotEmpty()) " $tk" else ""
}}"
capsule.headers["platform"] = Config.platform.value
capsule.headers["referer"] = Config.referer
capsule.headers["accept"] = "application/json"
if (Config.net_use_json.value) capsule.headers["accept"] = "application/json"
capsule.headers["version"] = Config.app_ver.value
capsule.headers["region"] = if(!Config.net_use_foreign.value) "1" else "0"
// device

View File

@@ -173,6 +173,10 @@
<string name="settings_cat_net_sm_use_foreign">不管使用什么线路, API访问均是海外, 只有图片CDN可能会变化也可能不变, 请酌情选择使用</string>
<string name="settings_cat_net_sw_use_comandy">增强型数据访问</string>
<string name="settings_cat_net_sm_use_comandy">使用经过优化的请求方法访问服务器</string>
<string name="settings_cat_net_sw_use_gzip">请求GZip</string>
<string name="settings_cat_net_sm_use_gzip">告知服务器优先返回GZip格式数据</string>
<string name="settings_cat_net_sw_use_json">请求JSON</string>
<string name="settings_cat_net_sm_use_json">显式告知服务器返回JSON格式数据</string>
<string name="settings_cat_net_et_title_api_url">请求API网址</string>
<string name="settings_cat_net_et_summary_api_url">一般无需更改,除非拷贝漫画官方更改网址,默认:&hosturl;</string>
<string name="settings_cat_net_et_title_reverse_proxy">反向代理</string>

View File

@@ -77,6 +77,18 @@
app:selectable="true"
app:summary="@string/settings_cat_net_sm_use_comandy"
app:title="@string/settings_cat_net_sw_use_comandy" />
<SwitchPreferenceCompat
app:iconSpaceReserved="false"
app:key="settings_cat_net_sw_use_gzip"
app:selectable="true"
app:summary="@string/settings_cat_net_sm_use_gzip"
app:title="@string/settings_cat_net_sw_use_gzip" />
<SwitchPreferenceCompat
app:iconSpaceReserved="false"
app:key="settings_cat_net_sw_use_json"
app:selectable="true"
app:summary="@string/settings_cat_net_sm_use_json"
app:title="@string/settings_cat_net_sw_use_json" />
<ListPreference
android:max="1500"
app:iconSpaceReserved="false"