Added setting to disable safe browsing

Closes #175
pull/176/head
M66B 5 years ago
parent ae1c03cb87
commit 26eee7fd76

@ -55,7 +55,7 @@
android:value="true" /> android:value="true" />
<meta-data <meta-data
android:name="android.webkit.WebView.EnableSafeBrowsing" android:name="android.webkit.WebView.EnableSafeBrowsing"
android:value="false" /> android:value="true" />
<meta-data <meta-data
android:name="android.allow_multiple_resumed_activities" android:name="android.allow_multiple_resumed_activities"
android:value="true" /> android:value="true" />

@ -24,6 +24,7 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.TextUtils; import android.text.TextUtils;
@ -61,11 +62,12 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
private Button btnBiometrics; private Button btnBiometrics;
private Button btnPin; private Button btnPin;
private Spinner spBiometricsTimeout; private Spinner spBiometricsTimeout;
private SwitchCompat swSafeBrowsing;
private final static String[] RESET_OPTIONS = new String[]{ private final static String[] RESET_OPTIONS = new String[]{
"confirm_links", "confirm_images", "confirm_html", "confirm_links", "confirm_images", "confirm_html",
"disable_tracking", "display_hidden", "secure", "disable_tracking", "display_hidden", "secure",
"biometrics", "pin", "biometrics_timeout" "biometrics", "pin", "biometrics_timeout", "safe_browsing"
}; };
@Override @Override
@ -88,6 +90,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
btnBiometrics = view.findViewById(R.id.btnBiometrics); btnBiometrics = view.findViewById(R.id.btnBiometrics);
btnPin = view.findViewById(R.id.btnPin); btnPin = view.findViewById(R.id.btnPin);
spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout); spBiometricsTimeout = view.findViewById(R.id.spBiometricsTimeout);
swSafeBrowsing = view.findViewById(R.id.swSafeBrowsing);
setOptions(); 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); PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view; return view;
@ -255,6 +266,8 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
spBiometricsTimeout.setSelection(pos); spBiometricsTimeout.setSelection(pos);
break; break;
} }
swSafeBrowsing.setChecked(prefs.getBoolean("safe_browsing", true));
} }
public static class FragmentDialogPin extends FragmentDialogBase { public static class FragmentDialogPin extends FragmentDialogBase {

@ -20,6 +20,7 @@ package eu.faircode.email;
*/ */
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.util.Pair; import android.util.Pair;
@ -29,6 +30,8 @@ import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import androidx.preference.PreferenceManager;
public class WebViewEx extends WebView implements DownloadListener, View.OnLongClickListener { public class WebViewEx extends WebView implements DownloadListener, View.OnLongClickListener {
private int height; private int height;
private IWebView intf; private IWebView intf;
@ -53,6 +56,12 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
settings.setAllowFileAccess(false); settings.setAllowFileAccess(false);
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); 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( void init(

@ -231,5 +231,17 @@
android:entries="@array/biometricsTimeoutNames" android:entries="@array/biometricsTimeoutNames"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" /> app:layout_constraintTop_toBottomOf="@id/tvBiometricsTimeout" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSafeBrowsing"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_safe_browsing"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spBiometricsTimeout"
app:switchPadding="12dp" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>

@ -406,16 +406,18 @@
<string name="title_advanced_confirm_html">Show reformatted messages by default</string> <string name="title_advanced_confirm_html">Show reformatted messages by default</string>
<string name="title_advanced_tracking">Automatically recognize and disable tracking images</string> <string name="title_advanced_tracking">Automatically recognize and disable tracking images</string>
<string name="title_advanced_display_hidden">Display hidden message texts</string> <string name="title_advanced_display_hidden">Display hidden message texts</string>
<string name="title_advanced_secure">Hide from recent apps screen and prevent taking screenshots</string>
<string name="title_advanced_pin">PIN</string>
<string name="title_advanced_biometrics_timeout">Biometric authentication timeout</string>
<string name="title_advanced_safe_browsing" translatable="false">Safe browsing</string>
<string name="title_advanced_encrypt_method">Default encryption method</string> <string name="title_advanced_encrypt_method">Default encryption method</string>
<string name="title_advanced_openpgp">OpenPGP provider</string>
<string name="title_advanced_autocrypt">Use Autocrypt</string>
<string name="title_advanced_autocrypt_mutual">Autocrypt mutual mode</string>
<string name="title_advanced_sign_default">Sign by default</string> <string name="title_advanced_sign_default">Sign by default</string>
<string name="title_advanced_encrypt_default">Encrypt by default</string> <string name="title_advanced_encrypt_default">Encrypt by default</string>
<string name="title_advanced_auto_decrypt">Automatically decrypt messages</string> <string name="title_advanced_auto_decrypt">Automatically decrypt messages</string>
<string name="title_advanced_secure">Hide from recent apps screen and prevent taking screenshots</string> <string name="title_advanced_openpgp">OpenPGP provider</string>
<string name="title_advanced_pin">PIN</string> <string name="title_advanced_autocrypt">Use Autocrypt</string>
<string name="title_advanced_biometrics_timeout">Biometric authentication timeout</string> <string name="title_advanced_autocrypt_mutual">Autocrypt mutual mode</string>
<string name="title_advanced_manage_certificates">Manage public keys</string> <string name="title_advanced_manage_certificates">Manage public keys</string>
<string name="title_advanced_import_key">Import private key</string> <string name="title_advanced_import_key">Import private key</string>
<string name="title_advanced_manage_keys">Manage private keys</string> <string name="title_advanced_manage_keys">Manage private keys</string>

Loading…
Cancel
Save