From e19f8448e8b9185dabaf4139304e3305606feabe Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 23 Jan 2021 15:11:10 +0100 Subject: [PATCH] Safe browsing compat --- .../main/java/eu/faircode/email/FragmentOptionsPrivacy.java | 3 ++- app/src/main/java/eu/faircode/email/WebViewEx.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java index 3c8a135ef4..5557ba0894 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsPrivacy.java @@ -53,6 +53,7 @@ import androidx.appcompat.widget.SwitchCompat; import androidx.constraintlayout.widget.Group; import androidx.lifecycle.Lifecycle; import androidx.preference.PreferenceManager; +import androidx.webkit.WebViewFeature; import java.io.IOException; import java.text.DateFormat; @@ -267,7 +268,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer } }); - grpSafeBrowsing.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O); + grpSafeBrowsing.setEnabled(WebViewFeature.isFeatureSupported(WebViewFeature.SAFE_BROWSING_ENABLE)); ibDisconnectBlacklist.setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/java/eu/faircode/email/WebViewEx.java b/app/src/main/java/eu/faircode/email/WebViewEx.java index 66a9b6fba3..b13e655d87 100644 --- a/app/src/main/java/eu/faircode/email/WebViewEx.java +++ b/app/src/main/java/eu/faircode/email/WebViewEx.java @@ -70,8 +70,8 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) - settings.setSafeBrowsingEnabled(safe_browsing); + if (WebViewFeature.isFeatureSupported(WebViewFeature.SAFE_BROWSING_ENABLE)) + WebSettingsCompat.setSafeBrowsingEnabled(settings, safe_browsing); if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) WebSettingsCompat.setForceDark(settings,