Added setting to disable safe browsing

Closes #175
This commit is contained in:
M66B
2020-03-12 08:24:10 +01:00
parent ae1c03cb87
commit 26eee7fd76
5 changed files with 45 additions and 9 deletions

View File

@@ -24,6 +24,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
@@ -61,11 +62,12 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private Button btnBiometrics;
private Button btnPin;
private Spinner spBiometricsTimeout;
private SwitchCompat swSafeBrowsing;
private final static String[] RESET_OPTIONS = new String[]{
"confirm_links", "confirm_images", "confirm_html",
"disable_tracking", "display_hidden", "secure",
"biometrics", "pin", "biometrics_timeout"
"biometrics", "pin", "biometrics_timeout", "safe_browsing"
};
@Override
@@ -88,6 +90,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
btnBiometrics = view.findViewById(R.id.btnBiometrics);
btnPin = view.findViewById(R.id.btnPin);
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
swSafeBrowsing = view.findViewById(R.id.swSafeBrowsing);
setOptions();
@@ -189,6 +192,14 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
}
});
swSafeBrowsing.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? View.GONE : View.VISIBLE);
swSafeBrowsing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("safe_browsing", checked).apply();
}
});
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view;
@@ -255,6 +266,8 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
spBiometricsTimeout.setSelection(pos);
break;
}
swSafeBrowsing.setChecked(prefs.getBoolean("safe_browsing", true));
}
public static class FragmentDialogPin extends FragmentDialogBase {

View File

@@ -20,6 +20,7 @@ package eu.faircode.email;
*/
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.util.Pair;
@@ -29,6 +30,8 @@ import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.preference.PreferenceManager;
public class WebViewEx extends WebView implements DownloadListener, View.OnLongClickListener {
private int height;
private IWebView intf;
@@ -53,6 +56,12 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
settings.setAllowFileAccess(false);
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean safe_browsing = prefs.getBoolean("safe_browsing", true);
settings.setSafeBrowsingEnabled(safe_browsing);
}
}
void init(