diff --git a/app/src/main/java/eu/faircode/email/ConnectionHelper.java b/app/src/main/java/eu/faircode/email/ConnectionHelper.java
index e2285d0caf..214c9cd5a9 100644
--- a/app/src/main/java/eu/faircode/email/ConnectionHelper.java
+++ b/app/src/main/java/eu/faircode/email/ConnectionHelper.java
@@ -73,7 +73,7 @@ public class ConnectionHelper {
static final int MAX_REDIRECTS = 5; // https://www.freesoft.org/CIE/RFC/1945/46.htm
static final List PREF_NETWORK = Collections.unmodifiableList(Arrays.asList(
- "metered", "roaming", "rlah", "require_validated", "vpn_only" // update network state
+ "metered", "roaming", "rlah", "require_validated", "require_validated_captive", "vpn_only" // update network state
));
// Roam like at home
@@ -252,6 +252,7 @@ public class ConnectionHelper {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean standalone_vpn = prefs.getBoolean("standalone_vpn", false);
boolean require_validated = prefs.getBoolean("require_validated", false);
+ boolean require_validated_captive = prefs.getBoolean("require_validated_captive", true);
boolean vpn_only = prefs.getBoolean("vpn_only", false);
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
@@ -300,7 +301,7 @@ public class ConnectionHelper {
return null;
}
boolean captive = caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL);
- if ((require_validated || captive) &&
+ if ((require_validated || (require_validated_captive && captive)) &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) {
Log.i("isMetered: not validated captive=" + captive);
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java b/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java
index f3ef62d30f..7f593c6bb0 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsConnection.java
@@ -69,6 +69,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private SwitchCompat swDownloadEml;
private SwitchCompat swDownloadPlain;
private SwitchCompat swValidated;
+ private SwitchCompat swValidatedCaptive;
private SwitchCompat swVpnOnly;
private EditText etTimeout;
private SwitchCompat swPreferIp4;
@@ -92,7 +93,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private final static String[] RESET_OPTIONS = new String[]{
"metered", "download", "roaming", "rlah",
"download_headers", "download_eml", "download_plain",
- "require_validated", "vpn_only",
+ "require_validated", "require_validated_captive", "vpn_only",
"timeout", "prefer_ip4", "bind_socket", "standalone_vpn", "tcp_keep_alive",
"ssl_harden", "ssl_harden_strict", "cert_strict", "open_safe"
};
@@ -116,6 +117,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
swDownloadEml = view.findViewById(R.id.swDownloadEml);
swDownloadPlain = view.findViewById(R.id.swDownloadPlain);
swValidated = view.findViewById(R.id.swValidated);
+ swValidatedCaptive = view.findViewById(R.id.swValidatedCaptive);
swVpnOnly = view.findViewById(R.id.swVpnOnly);
etTimeout = view.findViewById(R.id.etTimeout);
swPreferIp4 = view.findViewById(R.id.swPreferIp4);
@@ -212,6 +214,14 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("require_validated", checked).apply();
+ swValidatedCaptive.setEnabled(!checked);
+ }
+ });
+
+ swValidatedCaptive.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("require_validated_captive", checked).apply();
}
});
@@ -436,6 +446,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
swDownloadPlain.setChecked(prefs.getBoolean("download_plain", false));
swValidated.setChecked(prefs.getBoolean("require_validated", false));
+ swValidatedCaptive.setChecked(prefs.getBoolean("require_validated_captive", true));
+ swValidatedCaptive.setEnabled(!swValidated.isChecked());
swVpnOnly.setChecked(prefs.getBoolean("vpn_only", false));
int timeout = prefs.getInt("timeout", 0);
diff --git a/app/src/main/res/layout/fragment_options_connection.xml b/app/src/main/res/layout/fragment_options_connection.xml
index 7f959e23a9..1b214a3159 100644
--- a/app/src/main/res/layout/fragment_options_connection.xml
+++ b/app/src/main/res/layout/fragment_options_connection.xml
@@ -301,10 +301,23 @@
app:layout_constraintTop_toBottomOf="@id/tvPlainHint"
app:switchPadding="12dp" />
+
+
+ app:layout_constraintTop_toBottomOf="@id/swValidatedCaptive" />
Download raw message files
Download plain text only parts by default (if available)
Require a validated (checked) connection
+ Require a validated captive portal connection
Connect only via a VPN
Connection timeout (seconds)
Prefer IPv4 over IPv6