Merge pull request #2077 from 821938089/fix-login-webview-alert-bug

修复登录webView不弹出alert的bug
pull/2078/head
kunfei 2 years ago committed by GitHub
commit 24dc483e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      app/src/main/java/io/legado/app/ui/login/WebViewLoginFragment.kt

@ -6,10 +6,7 @@ import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.webkit.CookieManager import android.webkit.*
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.fragment.app.activityViewModels import androidx.fragment.app.activityViewModels
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseFragment import io.legado.app.base.BaseFragment
@ -88,6 +85,16 @@ class WebViewLoginFragment : BaseFragment(R.layout.fragment_web_view_login) {
super.onPageFinished(view, url) super.onPageFinished(view, url)
} }
} }
binding.webView.webChromeClient = object : WebChromeClient() {
override fun onJsAlert(
view: WebView?,
url: String?,
message: String?,
result: JsResult?
): Boolean {
return super.onJsAlert(view, url, message, result)
}
}
source.loginUrl?.let { source.loginUrl?.let {
binding.webView.loadUrl(it, source.getHeaderMap(true)) binding.webView.loadUrl(it, source.getHeaderMap(true))
} }

Loading…
Cancel
Save