Added option to connect via VPN only

This commit is contained in:
M66B
2021-09-11 10:07:08 +02:00
parent 5b5a4b62d8
commit 7fb81ccf7a
4 changed files with 35 additions and 4 deletions

View File

@@ -63,6 +63,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private SwitchCompat swDownloadHeaders;
private SwitchCompat swDownloadEml;
private SwitchCompat swValidated;
private SwitchCompat swVpnOnly;
private EditText etTimeout;
private SwitchCompat swPreferIp4;
private SwitchCompat swBindSocket;
@@ -81,7 +82,8 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
private final static String[] RESET_OPTIONS = new String[]{
"metered", "download", "roaming", "rlah",
"download_headers", "download_eml",
"require_validated", "timeout", "prefer_ip4", "bind_socket", "standalone_vpn", "tcp_keep_alive", "ssl_harden"
"require_validated", "vpn_only",
"timeout", "prefer_ip4", "bind_socket", "standalone_vpn", "tcp_keep_alive", "ssl_harden"
};
@Override
@@ -101,6 +103,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
swDownloadHeaders = view.findViewById(R.id.swDownloadHeaders);
swDownloadEml = view.findViewById(R.id.swDownloadEml);
swValidated = view.findViewById(R.id.swValidated);
swVpnOnly = view.findViewById(R.id.swVpnOnly);
etTimeout = view.findViewById(R.id.etTimeout);
swPreferIp4 = view.findViewById(R.id.swPreferIp4);
swBindSocket = view.findViewById(R.id.swBindSocket);
@@ -181,6 +184,13 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
}
});
swVpnOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("vpn_only", checked).apply();
}
});
etTimeout.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -353,6 +363,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
swDownloadEml.setChecked(prefs.getBoolean("download_eml", false));
swValidated.setChecked(prefs.getBoolean("require_validated", false));
swVpnOnly.setChecked(prefs.getBoolean("vpn_only", false));
int timeout = prefs.getInt("timeout", 0);
etTimeout.setText(timeout == 0 ? null : Integer.toString(timeout));