From 3b62ce358f4cbc3a8e7042018023e46e08dc2cfe Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 26 Aug 2019 10:11:00 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/help/storage/OldRule.kt | 6 ++++++ app/src/main/java/io/legado/app/help/storage/Restore.kt | 1 + 2 files changed, 7 insertions(+) diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index 27738806c..361fd1402 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -45,4 +45,10 @@ object OldRule { } return url } + + fun uaToHeader(ua: String?): String? { + if (ua.isNullOrEmpty()) return null + val map = mapOf(Pair("user_agent", ua)) + return GSON.toJson(map) + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index 0e9b73dbf..82d256d88 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -109,6 +109,7 @@ object Restore { source.loginUrl = jsonItem.readString("loginUrl") source.bookUrlPattern = jsonItem.readString("ruleBookUrlPattern") source.customOrder = jsonItem.readInt("serialNumber") ?: 0 + source.header = OldRule.uaToHeader(jsonItem.readString("httpUserAgent")) val searchRule = SearchRule( searchUrl = OldRule.toNewUrl(jsonItem.readString("ruleSearchUrl")), bookList = jsonItem.readString("ruleSearchList"),