|
|
@@ -11,8 +11,6 @@ import android.view.View
|
|
|
import android.webkit.*
|
|
|
import androidx.activity.viewModels
|
|
|
import androidx.core.view.size
|
|
|
-import androidx.webkit.WebSettingsCompat
|
|
|
-import androidx.webkit.WebViewFeature
|
|
|
import io.legado.app.R
|
|
|
import io.legado.app.base.VMBaseActivity
|
|
|
import io.legado.app.constant.AppConst
|
|
|
@@ -87,6 +85,7 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
|
|
binding.webView.webChromeClient = CustomWebChromeClient()
|
|
|
binding.webView.webViewClient = CustomWebViewClient()
|
|
|
binding.webView.settings.apply {
|
|
|
+ setDarkeningAllowed(AppConfig.isNightTheme)
|
|
|
mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
|
|
|
domStorageEnabled = true
|
|
|
allowContentAccess = true
|
|
|
@@ -100,7 +99,6 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
|
|
val cookieManager = CookieManager.getInstance()
|
|
|
cookieManager.setCookie(url, CookieStore.getCookie(url))
|
|
|
binding.webView.addJavascriptInterface(this, "app")
|
|
|
- upWebViewTheme()
|
|
|
binding.webView.setOnLongClickListener {
|
|
|
val hitTestResult = binding.webView.hitTestResult
|
|
|
if (hitTestResult.type == WebView.HitTestResult.IMAGE_TYPE ||
|
|
|
@@ -122,25 +120,6 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private fun upWebViewTheme() {
|
|
|
- if (AppConfig.isNightTheme) {
|
|
|
- if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) {
|
|
|
- @Suppress("DEPRECATION")
|
|
|
- WebSettingsCompat.setForceDarkStrategy(
|
|
|
- binding.webView.settings,
|
|
|
- WebSettingsCompat.DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING
|
|
|
- )
|
|
|
- }
|
|
|
- if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
|
|
|
- @Suppress("DEPRECATION")
|
|
|
- WebSettingsCompat.setForceDark(
|
|
|
- binding.webView.settings,
|
|
|
- WebSettingsCompat.FORCE_DARK_ON
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private fun saveImage(webPic: String) {
|
|
|
this.webPic = webPic
|
|
|
val path = ACache.get().getAsString(imagePathKey)
|
|
|
@@ -227,8 +206,7 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
- @Deprecated("Deprecated in Java")
|
|
|
- @Suppress("DEPRECATION")
|
|
|
+ @Suppress("DEPRECATION", "OVERRIDE_DEPRECATION", "KotlinRedundantDiagnosticSuppress")
|
|
|
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
|
|
|
url?.let {
|
|
|
return shouldOverrideUrlLoading(Uri.parse(it))
|