编辑源菜单添加清除cookie

pull/1881/head
kunfei 3 years ago
parent fe994b2332
commit 17fd77a53e
  1. 2
      app/src/main/java/io/legado/app/help/http/CookieStore.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  3. 1
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt
  4. 7
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditViewModel.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<String, String> {

@ -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) }

@ -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()

@ -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)

Loading…
Cancel
Save