mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
72f7fa0873
commit
ef8f9df9b3
@ -1,10 +1,12 @@
|
||||
package io.legado.app.help.http
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.net.http.SslError
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.AndroidRuntimeException
|
||||
import android.webkit.CookieManager
|
||||
import android.webkit.SslErrorHandler
|
||||
import android.webkit.WebSettings
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
@ -135,6 +137,15 @@ class BackstageWebView(
|
||||
mHandler.postDelayed(runnable, 1000)
|
||||
}
|
||||
|
||||
@SuppressLint("WebViewClientOnReceivedSslError")
|
||||
override fun onReceivedSslError(
|
||||
view: WebView?,
|
||||
handler: SslErrorHandler?,
|
||||
error: SslError?
|
||||
) {
|
||||
handler?.proceed()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private inner class EvalJsRunnable(
|
||||
@ -197,6 +208,15 @@ class BackstageWebView(
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("WebViewClientOnReceivedSslError")
|
||||
override fun onReceivedSslError(
|
||||
view: WebView?,
|
||||
handler: SslErrorHandler?,
|
||||
error: SslError?
|
||||
) {
|
||||
handler?.proceed()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class LoadJsRunnable(
|
||||
|
@ -3,6 +3,7 @@ package io.legado.app.ui.browser
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.net.Uri
|
||||
import android.net.http.SslError
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
import android.view.Menu
|
||||
@ -247,12 +248,14 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
||||
"http", "https" -> {
|
||||
return false
|
||||
}
|
||||
|
||||
"legado", "yuedu" -> {
|
||||
startActivity<OnLineImportActivity> {
|
||||
data = url
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
else -> {
|
||||
binding.root.longSnackbar("跳转其它应用", "确认") {
|
||||
openUrl(url)
|
||||
@ -262,6 +265,15 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("WebViewClientOnReceivedSslError")
|
||||
override fun onReceivedSslError(
|
||||
view: WebView?,
|
||||
handler: SslErrorHandler?,
|
||||
error: SslError?
|
||||
) {
|
||||
handler?.proceed()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package io.legado.app.ui.login
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Bitmap
|
||||
import android.net.http.SslError
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
@ -85,6 +86,15 @@ class WebViewLoginFragment : BaseFragment(R.layout.fragment_web_view_login) {
|
||||
}
|
||||
super.onPageFinished(view, url)
|
||||
}
|
||||
|
||||
@SuppressLint("WebViewClientOnReceivedSslError")
|
||||
override fun onReceivedSslError(
|
||||
view: WebView?,
|
||||
handler: SslErrorHandler?,
|
||||
error: SslError?
|
||||
) {
|
||||
handler?.proceed()
|
||||
}
|
||||
}
|
||||
binding.webView.webChromeClient = object : WebChromeClient() {
|
||||
|
||||
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.res.Configuration
|
||||
import android.net.Uri
|
||||
import android.net.http.SslError
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.webkit.*
|
||||
@ -66,6 +67,7 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
||||
}
|
||||
|
||||
Configuration.ORIENTATION_PORTRAIT -> {
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
|
||||
@ -95,6 +97,7 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
|
||||
R.id.menu_rss_refresh -> viewModel.refresh {
|
||||
binding.webView.reload()
|
||||
}
|
||||
|
||||
R.id.menu_rss_star -> viewModel.favorite()
|
||||
R.id.menu_share_it -> {
|
||||
binding.webView.url?.let {
|
||||
@ -103,11 +106,13 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
|
||||
share(it.link)
|
||||
} ?: toastOnUi(R.string.null_url)
|
||||
}
|
||||
|
||||
R.id.menu_aloud -> readAloud()
|
||||
R.id.menu_login -> startActivity<SourceLoginActivity> {
|
||||
putExtra("type", "rssSource")
|
||||
putExtra("key", viewModel.rssSource?.loginUrl)
|
||||
}
|
||||
|
||||
R.id.menu_browser_open -> binding.webView.url?.let {
|
||||
openUrl(it)
|
||||
} ?: toastOnUi("url null")
|
||||
@ -397,12 +402,14 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
|
||||
"http", "https", "jsbridge" -> {
|
||||
return false
|
||||
}
|
||||
|
||||
"legado", "yuedu" -> {
|
||||
startActivity<OnLineImportActivity> {
|
||||
data = url
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
else -> {
|
||||
binding.root.longSnackbar(R.string.jump_to_another_app, R.string.confirm) {
|
||||
openUrl(url)
|
||||
@ -412,6 +419,15 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("WebViewClientOnReceivedSslError")
|
||||
override fun onReceivedSslError(
|
||||
view: WebView?,
|
||||
handler: SslErrorHandler?,
|
||||
error: SslError?
|
||||
) {
|
||||
handler?.proceed()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user