diff --git a/app/src/main/java/io/legado/app/help/DirectLinkUpload.kt b/app/src/main/java/io/legado/app/help/DirectLinkUpload.kt
index 511c9029b..fd8b2021b 100644
--- a/app/src/main/java/io/legado/app/help/DirectLinkUpload.kt
+++ b/app/src/main/java/io/legado/app/help/DirectLinkUpload.kt
@@ -21,8 +21,12 @@ object DirectLinkUpload {
const val ruleFileName = "directLinkUploadRule.json"
@Throws(NoStackTraceException::class)
- suspend fun upLoad(fileName: String, file: Any, contentType: String): String {
- val rule = getRule()
+ suspend fun upLoad(
+ fileName: String,
+ file: Any,
+ contentType: String,
+ rule: Rule = getRule()
+ ): String {
val url = rule.uploadUrl
if (url.isBlank()) {
throw NoStackTraceException("上传url未配置")
diff --git a/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt b/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt
index ef7cb48f2..71e2fd3f8 100644
--- a/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt
+++ b/app/src/main/java/io/legado/app/help/http/OkHttpUtils.kt
@@ -18,7 +18,9 @@ import okhttp3.Response
import okhttp3.ResponseBody
import java.io.File
import java.io.IOException
+import java.io.InputStream
import java.nio.charset.Charset
+import java.util.zip.ZipInputStream
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
@@ -92,6 +94,19 @@ fun ResponseBody.text(encode: String? = null): String {
return String(responseBytes, Charset.forName(charsetName))
}
+fun ResponseBody.unCompress(success: (inputStream: InputStream) -> Unit) {
+ if (contentType() == "application/zip".toMediaType()) {
+ byteStream().use { byteStream ->
+ ZipInputStream(byteStream).use {
+ it.nextEntry
+ success.invoke(it)
+ }
+ }
+ } else {
+ byteStream().use(success)
+ }
+}
+
fun Request.Builder.addHeaders(headers: Map) {
headers.forEach {
addHeader(it.key, it.value)
diff --git a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
index 69bed152c..e3f7a2710 100644
--- a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
+++ b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
@@ -17,7 +17,15 @@ import io.legado.app.help.config.AppConfig
import io.legado.app.help.http.newCallResponseBody
import io.legado.app.help.http.okHttpClient
import io.legado.app.help.source.SourceHelp
-import io.legado.app.utils.*
+import io.legado.app.utils.GSON
+import io.legado.app.utils.fromJsonArray
+import io.legado.app.utils.fromJsonObject
+import io.legado.app.utils.inputStream
+import io.legado.app.utils.isAbsUrl
+import io.legado.app.utils.isJsonArray
+import io.legado.app.utils.isJsonObject
+import io.legado.app.utils.isUri
+import io.legado.app.utils.splitNotBlank
class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
@@ -179,13 +187,13 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
} else {
url(url)
}
- }.byteStream().use { body ->
- GSON.fromJsonArray(body).getOrThrow().let {
- val source = it.firstOrNull() ?: return@let
+ }.byteStream().use {
+ GSON.fromJsonArray(it).getOrThrow().let { list ->
+ val source = list.firstOrNull() ?: return@let
if (source.bookSourceUrl.isEmpty()) {
throw NoStackTraceException("不是书源")
}
- allSources.addAll(it)
+ allSources.addAll(list)
}
}
}
diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt
index 1c905b9ed..58904be97 100644
--- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt
+++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt
@@ -15,7 +15,14 @@ import io.legado.app.help.config.AppConfig
import io.legado.app.help.http.newCallResponseBody
import io.legado.app.help.http.okHttpClient
import io.legado.app.help.source.SourceHelp
-import io.legado.app.utils.*
+import io.legado.app.utils.GSON
+import io.legado.app.utils.fromJsonArray
+import io.legado.app.utils.fromJsonObject
+import io.legado.app.utils.isAbsUrl
+import io.legado.app.utils.isJsonArray
+import io.legado.app.utils.isJsonObject
+import io.legado.app.utils.jsonPath
+import io.legado.app.utils.splitNotBlank
class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
var isAddGroup = false
@@ -141,7 +148,7 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
} else {
url(url)
}
- }.byteStream().let { body ->
+ }.byteStream().use { body ->
val items: List
是否压缩
反序
+ 测试
diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml
index 5d47afb79..b3637d081 100644
--- a/app/src/main/res/values-ja-rJP/strings.xml
+++ b/app/src/main/res/values-ja-rJP/strings.xml
@@ -1117,4 +1117,5 @@
减小数据库文件的大小
是否压缩
反序
+ 测试
diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml
index 670fe4b3d..6801cc400 100644
--- a/app/src/main/res/values-pt-rBR/strings.xml
+++ b/app/src/main/res/values-pt-rBR/strings.xml
@@ -1117,4 +1117,5 @@
减小数据库文件的大小
是否压缩
反序
+ 测试
diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml
index 31f918106..440615bbc 100644
--- a/app/src/main/res/values-zh-rHK/strings.xml
+++ b/app/src/main/res/values-zh-rHK/strings.xml
@@ -1114,4 +1114,5 @@
减小数据库文件的大小
是否压缩
反序
+ 测试
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 343e27c14..d5ad893b3 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -1116,4 +1116,5 @@
减小数据库文件的大小
是否压缩
反序
+ 测试
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index 117dd31dc..a5e34ff38 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -1116,4 +1116,5 @@
减小数据库文件的大小
是否压缩
反序
+ 测试
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d33591618..3c0a93250 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1117,4 +1117,5 @@
减小数据库文件的大小
是否压缩
反序
+ 测试