updated algorithmicDarkeningAllowed

This commit is contained in:
Lorenzo Pichilli 2022-10-07 01:50:51 +02:00
parent 22ae9deac6
commit 1fd8a062f3
5 changed files with 25 additions and 7 deletions

View File

@ -385,8 +385,8 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
WebSettingsCompat.setWillSuppressErrorPage(settings, customSettings.willSuppressErrorPage);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
settings.setAlgorithmicDarkeningAllowed(customSettings.algorithmicDarkeningAllowed);
if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
WebSettingsCompat.setAlgorithmicDarkeningAllowed(settings, customSettings.algorithmicDarkeningAllowed);
}
contentBlockerHandler.getRuleList().clear();
@ -1032,8 +1032,8 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
if (newSettingsMap.get("algorithmicDarkeningAllowed") != null &&
!Util.objEquals(customSettings.algorithmicDarkeningAllowed, newCustomSettings.algorithmicDarkeningAllowed) &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
settings.setAlgorithmicDarkeningAllowed(newCustomSettings.algorithmicDarkeningAllowed);
WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
WebSettingsCompat.setAlgorithmicDarkeningAllowed(settings, newCustomSettings.algorithmicDarkeningAllowed);
}
customSettings = newCustomSettings;

View File

@ -561,8 +561,8 @@ public class InAppWebViewSettings implements ISettings<InAppWebViewInterface> {
if (WebViewFeature.isFeatureSupported(WebViewFeature.SUPPRESS_ERROR_PAGE)) {
realSettings.put("willSuppressErrorPage", WebSettingsCompat.willSuppressErrorPage(settings));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
realSettings.put("algorithmicDarkeningAllowed", settings.isAlgorithmicDarkeningAllowed());
if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
realSettings.put("algorithmicDarkeningAllowed", WebSettingsCompat.isAlgorithmicDarkeningAllowed(settings));
}
}
return realSettings;

View File

@ -196,6 +196,10 @@ class WebViewFeature_ {
static const SUPPRESS_ERROR_PAGE =
const WebViewFeature_._internal("SUPPRESS_ERROR_PAGE");
///This feature covers [InAppWebViewSettings.algorithmicDarkeningAllowed].
static const ALGORITHMIC_DARKENING =
const WebViewFeature_._internal("ALGORITHMIC_DARKENING");
///Return whether a feature is supported at run-time. On devices running Android version `Build.VERSION_CODES.LOLLIPOP` and higher,
///this will check whether a feature is supported, depending on the combination of the desired feature, the Android version of device,
///and the WebView APK on the device. If running on a device with a lower API level, this will always return `false`.
@ -403,6 +407,10 @@ class AndroidWebViewFeature_ {
static const SUPPRESS_ERROR_PAGE =
const AndroidWebViewFeature_._internal("SUPPRESS_ERROR_PAGE");
///This feature covers [InAppWebViewSettings.algorithmicDarkeningAllowed].
static const ALGORITHMIC_DARKENING =
const AndroidWebViewFeature_._internal("ALGORITHMIC_DARKENING");
///Return whether a feature is supported at run-time. On devices running Android version `Build.VERSION_CODES.LOLLIPOP` and higher,
///this will check whether a feature is supported, depending on the combination of the desired feature, the Android version of device,
///and the WebView APK on the device. If running on a device with a lower API level, this will always return `false`.

View File

@ -197,6 +197,10 @@ class WebViewFeature {
static const SUPPRESS_ERROR_PAGE =
WebViewFeature._internal('SUPPRESS_ERROR_PAGE', 'SUPPRESS_ERROR_PAGE');
///This feature covers [InAppWebViewSettings.algorithmicDarkeningAllowed].
static const ALGORITHMIC_DARKENING = WebViewFeature._internal(
'ALGORITHMIC_DARKENING', 'ALGORITHMIC_DARKENING');
///Set of all values of [WebViewFeature].
static final Set<WebViewFeature> values = [
WebViewFeature.CREATE_WEB_MESSAGE_CHANNEL,
@ -242,6 +246,7 @@ class WebViewFeature {
WebViewFeature.WEB_VIEW_RENDERER_TERMINATE,
WebViewFeature.DOCUMENT_START_SCRIPT,
WebViewFeature.SUPPRESS_ERROR_PAGE,
WebViewFeature.ALGORITHMIC_DARKENING,
].toSet();
///Gets a possible [WebViewFeature] instance from [String] value.
@ -497,6 +502,10 @@ class AndroidWebViewFeature {
static const SUPPRESS_ERROR_PAGE = AndroidWebViewFeature._internal(
'SUPPRESS_ERROR_PAGE', 'SUPPRESS_ERROR_PAGE');
///This feature covers [InAppWebViewSettings.algorithmicDarkeningAllowed].
static const ALGORITHMIC_DARKENING = AndroidWebViewFeature._internal(
'ALGORITHMIC_DARKENING', 'ALGORITHMIC_DARKENING');
///Set of all values of [AndroidWebViewFeature].
static final Set<AndroidWebViewFeature> values = [
AndroidWebViewFeature.CREATE_WEB_MESSAGE_CHANNEL,
@ -542,6 +551,7 @@ class AndroidWebViewFeature {
AndroidWebViewFeature.WEB_VIEW_RENDERER_TERMINATE,
AndroidWebViewFeature.DOCUMENT_START_SCRIPT,
AndroidWebViewFeature.SUPPRESS_ERROR_PAGE,
AndroidWebViewFeature.ALGORITHMIC_DARKENING,
].toSet();
///Gets a possible [AndroidWebViewFeature] instance from [String] value.

View File

@ -672,7 +672,7 @@ class InAppWebViewSettings {
///
///If Android is applying Force Dark to WebView then WebView will ignore the value of this setting and behave as if it were set to true.
///
///**NOTE**: available on Android 33+
///**NOTE**: available on Android 29+.
bool algorithmicDarkeningAllowed;
///Set to `true` to disable the bouncing of the WebView when the scrolling has reached an edge of the content. The default value is `false`.