pull/2309/head
kunfei 2 years ago
parent 73afb399ff
commit 515088b67c
  1. 10
      app/src/main/java/io/legado/app/utils/WebSettingsExtensions.kt

@ -13,8 +13,14 @@ import io.legado.app.help.config.AppConfig
@SuppressLint("RequiresFeature") @SuppressLint("RequiresFeature")
fun WebSettings.setDarkeningAllowed(allow: Boolean) { fun WebSettings.setDarkeningAllowed(allow: Boolean) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
WebSettingsCompat.setAlgorithmicDarkeningAllowed(this, allow) kotlin.runCatching {
} else if (AppConfig.isNightTheme) { WebSettingsCompat.setAlgorithmicDarkeningAllowed(this, allow)
return
}.onFailure {
it.printOnDebug()
}
}
if (AppConfig.isNightTheme) {
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) { if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
WebSettingsCompat.setForceDarkStrategy( WebSettingsCompat.setForceDarkStrategy(

Loading…
Cancel
Save