From 17fd77a53ec6f4662010014f7a6f3b9db3f2a4dd Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 13 May 2022 14:24:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=BA=90=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B8=85=E9=99=A4cookie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/http/CookieStore.kt | 2 +- .../app/ui/book/source/edit/BookSourceEditActivity.kt | 2 +- .../legado/app/ui/rss/source/edit/RssSourceEditActivity.kt | 1 + .../app/ui/rss/source/edit/RssSourceEditViewModel.kt | 7 +++++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/http/CookieStore.kt b/app/src/main/java/io/legado/app/help/http/CookieStore.kt index b19c1feca..be94137fa 100644 --- a/app/src/main/java/io/legado/app/help/http/CookieStore.kt +++ b/app/src/main/java/io/legado/app/help/http/CookieStore.kt @@ -56,8 +56,8 @@ object CookieStore : CookieManager { override fun removeCookie(url: String) { val domain = NetworkUtils.getSubDomain(url) - CacheManager.deleteMemory("${domain}_cookie") appDb.cookieDao.delete(domain) + CacheManager.deleteMemory("${domain}_cookie") } override fun cookieToMap(cookie: String): MutableMap { diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index 0a405400d..9a4ce4b86 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -109,7 +109,7 @@ class BookSourceEditActivity : } } } - R.id.menu_clear_cookie -> getSource().let { viewModel.clearCookie(it.bookSourceUrl) } + R.id.menu_clear_cookie -> viewModel.clearCookie(getSource().bookSourceUrl) R.id.menu_auto_complete -> viewModel.autoComplete = !viewModel.autoComplete R.id.menu_copy_source -> sendToClip(GSON.toJson(getSource())) R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index 9d9fe765b..aac1bda3b 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -130,6 +130,7 @@ class RssSourceEditActivity : } } } + R.id.menu_clear_cookie -> viewModel.clearCookie(getRssSource().sourceUrl) R.id.menu_auto_complete -> viewModel.autoComplete = !viewModel.autoComplete R.id.menu_copy_source -> sendToClip(GSON.toJson(getRssSource())) R.id.menu_qr_code_camera -> qrCodeResult.launch() diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt index 25002eb3a..da911a5f4 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.kt @@ -6,6 +6,7 @@ import io.legado.app.base.BaseViewModel import io.legado.app.data.appDb import io.legado.app.data.entities.RssSource import io.legado.app.help.RuleComplete +import io.legado.app.help.http.CookieStore import io.legado.app.utils.getClipText import io.legado.app.utils.msg import io.legado.app.utils.printOnDebug @@ -77,6 +78,12 @@ class RssSourceEditViewModel(application: Application) : BaseViewModel(applicati } } + fun clearCookie(url: String) { + execute { + CookieStore.removeCookie(url) + } + } + fun ruleComplete(rule: String?, preRule: String? = null, type: Int = 1): String? { if (autoComplete) { return RuleComplete.autoComplete(rule, preRule, type)