|
|
@@ -17,6 +17,7 @@ import io.legado.app.R
|
|
|
import io.legado.app.base.VMBaseActivity
|
|
|
import io.legado.app.databinding.ActivityWebViewBinding
|
|
|
import io.legado.app.help.config.AppConfig
|
|
|
+import io.legado.app.help.http.CookieStore
|
|
|
import io.legado.app.lib.dialogs.SelectItem
|
|
|
import io.legado.app.model.Download
|
|
|
import io.legado.app.ui.association.OnLineImportActivity
|
|
|
@@ -41,9 +42,9 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
|
binding.titleBar.title = intent.getStringExtra("title") ?: getString(R.string.loading)
|
|
|
- initWebView()
|
|
|
viewModel.initData(intent) {
|
|
|
val url = viewModel.baseUrl
|
|
|
+ initWebView(url)
|
|
|
val html = viewModel.html
|
|
|
if (html.isNullOrEmpty()) {
|
|
|
binding.webView.loadUrl(url, viewModel.headerMap)
|
|
|
@@ -67,7 +68,7 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
|
|
}
|
|
|
|
|
|
@SuppressLint("JavascriptInterface")
|
|
|
- private fun initWebView() {
|
|
|
+ private fun initWebView(url: String) {
|
|
|
binding.webView.webChromeClient = CustomWebChromeClient()
|
|
|
binding.webView.webViewClient = CustomWebViewClient()
|
|
|
binding.webView.settings.apply {
|
|
|
@@ -76,7 +77,10 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
|
|
allowContentAccess = true
|
|
|
useWideViewPort = true
|
|
|
loadWithOverviewMode = true
|
|
|
+ javaScriptEnabled = true
|
|
|
}
|
|
|
+ val cookieManager = CookieManager.getInstance()
|
|
|
+ cookieManager.setCookie(url, CookieStore.getCookie(url))
|
|
|
binding.webView.addJavascriptInterface(this, "app")
|
|
|
upWebViewTheme()
|
|
|
binding.webView.setOnLongClickListener {
|
|
|
@@ -207,6 +211,10 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
|
|
|
|
|
override fun onPageFinished(view: WebView?, url: String?) {
|
|
|
super.onPageFinished(view, url)
|
|
|
+ val cookieManager = CookieManager.getInstance()
|
|
|
+ url?.let {
|
|
|
+ CookieStore.setCookie(it, cookieManager.getCookie(it))
|
|
|
+ }
|
|
|
view?.title?.let { title ->
|
|
|
if (title != url && title != view.url && title.isNotBlank()) {
|
|
|
binding.titleBar.title = title
|