Added option to require validated connection

This commit is contained in:
M66B
2021-03-17 12:48:44 +01:00
parent c667f48511
commit 8ebfab6093
4 changed files with 42 additions and 8 deletions

View File

@@ -59,6 +59,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private Spinner spDownload;
private SwitchCompat swRoaming;
private SwitchCompat swRlah;
private SwitchCompat swValidated;
private EditText etTimeout;
private SwitchCompat swPreferIp4;
private SwitchCompat swStandaloneVpn;
@@ -71,7 +72,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private TextView tvNetworkInfo;
private final static String[] RESET_OPTIONS = new String[]{
"metered", "download", "roaming", "rlah", "timeout", "prefer_ip4", "standalone_vpn", "tcp_keep_alive", "ssl_harden"
"metered", "download", "roaming", "rlah",
"require_validated", "timeout", "prefer_ip4", "standalone_vpn", "tcp_keep_alive", "ssl_harden"
};
@Override
@@ -88,6 +90,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
spDownload = view.findViewById(R.id.spDownload);
swRoaming = view.findViewById(R.id.swRoaming);
swRlah = view.findViewById(R.id.swRlah);
swValidated = view.findViewById(R.id.swValidated);
etTimeout = view.findViewById(R.id.etTimeout);
swPreferIp4 = view.findViewById(R.id.swPreferIp4);
swStandaloneVpn = view.findViewById(R.id.swStandaloneVpn);
@@ -141,6 +144,14 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
}
});
swValidated.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.M ? View.GONE : View.VISIBLE);
swValidated.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("require_validated", checked).apply();
}
});
etTimeout.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -307,6 +318,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
swRoaming.setChecked(prefs.getBoolean("roaming", true));
swRlah.setChecked(prefs.getBoolean("rlah", true));
swValidated.setChecked(prefs.getBoolean("require_validated", false));
int timeout = prefs.getInt("timeout", 0);
etTimeout.setText(timeout == 0 ? null : Integer.toString(timeout));
etTimeout.setHint(Integer.toString(EmailService.DEFAULT_CONNECT_TIMEOUT));