Android 13: fixed force dark / webview

This commit is contained in:
M66B
2022-06-10 08:07:40 +02:00
parent b97fc1ae23
commit d5d7be98ee
3 changed files with 21 additions and 8 deletions

View File

@@ -117,10 +117,15 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
WebSettings settings = getSettings();
boolean dark = Helper.isDarkTheme(context);
boolean canForce = WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK);
if (canForce)
WebSettingsCompat.setForceDark(settings, dark && !force_light ? FORCE_DARK_ON : FORCE_DARK_OFF);
setBackgroundColor(canForce && force_light ? Color.WHITE : Color.TRANSPARENT);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
boolean canForce = WebViewEx.isFeatureSupported(WebViewFeature.FORCE_DARK);
if (canForce)
WebSettingsCompat.setForceDark(settings, dark && !force_light ? FORCE_DARK_ON : FORCE_DARK_OFF);
setBackgroundColor(canForce && force_light ? Color.WHITE : Color.TRANSPARENT);
} else {
settings.setAlgorithmicDarkeningAllowed(dark && !force_light);
setBackgroundColor(force_light ? Color.WHITE : Color.TRANSPARENT);
}
float fontSize = 16f /* Default */ *
(browser_zoom ? 1f : message_zoom / 100f);