diff --git a/app/build.gradle b/app/build.gradle index 550d06afc..346d88e3e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -174,7 +174,6 @@ dependencies { //网络 implementation 'com.ljx.rxhttp:rxhttp:2.4.4-beta3' implementation 'com.squareup.okhttp3:okhttp:4.9.0' - implementation 'com.github.franmontiel:PersistentCookieJar:v1.0.1' kapt 'com.ljx.rxhttp:rxhttp-compiler:2.4.4-beta3' //Glide 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 8c4aa34ec..9aa344dbb 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 @@ -3,14 +3,12 @@ package io.legado.app.help.http import android.text.TextUtils -import com.franmontiel.persistentcookiejar.persistence.CookiePersistor -import com.franmontiel.persistentcookiejar.persistence.SerializableCookie import io.legado.app.App import io.legado.app.data.entities.Cookie import io.legado.app.help.http.api.CookieManager import io.legado.app.utils.NetworkUtils -object CookieStore : CookiePersistor, CookieManager { +object CookieStore : CookieManager { override fun setCookie(url: String, cookie: String?) { val cookieBean = Cookie(NetworkUtils.getSubDomain(url), cookie ?: "") @@ -78,36 +76,8 @@ object CookieStore : CookiePersistor, CookieManager { return builder.deleteCharAt(builder.lastIndexOf(";")).toString() } - override fun loadAll(): MutableList { - val cookies = arrayListOf() - App.db.cookieDao.getOkHttpCookies().forEach { - val serializedCookie = it.cookie - SerializableCookie().decode(serializedCookie)?.let { ck -> - cookies.add(ck) - } - } - return cookies - } - - override fun saveAll(cookies: MutableCollection?) { - val mCookies = arrayListOf() - cookies?.forEach { - mCookies.add(Cookie(createCookieKey(it), SerializableCookie().encode(it))) - } - App.db.cookieDao.insert(*mCookies.toTypedArray()) - } - - override fun removeAll(cookies: MutableCollection?) { - cookies?.forEach { - App.db.cookieDao.delete(createCookieKey(it)) - } - } - - override fun clear() { + fun clear() { App.db.cookieDao.deleteOkHttp() } - private fun createCookieKey(cookie: okhttp3.Cookie): String { - return (if (cookie.secure) "https" else "http") + "://" + cookie.domain + cookie.path + "|" + cookie.name - } } \ No newline at end of file