diff options
author | cyBerta <cyberta@riseup.net> | 2021-11-28 23:30:33 +0100 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2021-11-28 23:30:33 +0100 |
commit | 14a2c58d8b666b9707df534306a15784e253f415 (patch) | |
tree | 390feb35b8dd736d127718deaeeb7f25be4ac9a7 /app/src | |
parent | e4335df262cf9604195c62301ab3b48a2eeddca6 (diff) |
disable bridges UI switch if UDP preference is enabled
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java | 15 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 1 |
2 files changed, 11 insertions, 5 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java index 5ea70085..a20d0b73 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java @@ -32,7 +32,7 @@ import static android.content.Context.MODE_PRIVATE; import static android.view.View.GONE; import static android.view.View.VISIBLE; import static se.leap.bitmaskclient.R.string.advanced_settings; -import static se.leap.bitmaskclient.base.MainActivity.ACTION_SHOW_VPN_FRAGMENT; +import static se.leap.bitmaskclient.base.models.Constants.PREFER_UDP; import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES; import static se.leap.bitmaskclient.base.models.Constants.USE_BRIDGES; import static se.leap.bitmaskclient.base.models.Constants.USE_IPv6_FIREWALL; @@ -53,6 +53,7 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh private IconTextEntry tethering; private IconSwitchEntry firewall; + IconSwitchEntry useUdpEntry; @Override public void onCreate(@Nullable Bundle savedInstanceState) { @@ -98,8 +99,12 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh Toast.makeText(getContext(), R.string.reconnecting, Toast.LENGTH_LONG).show(); } }); - - + //We check the UI state of the useUdpEntry here as well, in order to avoid a situation + //where both entries are disabled, because both preferences are enabled. + //bridges can be enabled not only from here but also from error handling + boolean useUDP = getPreferUDP(getContext()) && useUdpEntry.isEnabled(); + useBridges.setEnabled(!useUDP); + useBridges.setSubtitle(getString(useUDP ? R.string.disabled_while_udp_on : R.string.nav_drawer_subtitle_obfuscated_connection)); } else { useBridges.setVisibility(GONE); } @@ -134,7 +139,7 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh } private void initPreferUDPEntry(View rootView) { - IconSwitchEntry useUdpEntry = rootView.findViewById(R.id.prefer_udp); + useUdpEntry = rootView.findViewById(R.id.prefer_udp); useUdpEntry.setVisibility(VISIBLE); useUdpEntry.setChecked(getPreferUDP(getContext())); useUdpEntry.setOnCheckedChangeListener((buttonView, isChecked) -> { @@ -235,7 +240,7 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh if (rootView == null) { return; } - if (key.equals(USE_BRIDGES)) { + if (key.equals(USE_BRIDGES) || key.equals(PREFER_UDP)) { initUseBridgesEntry(rootView); initPreferUDPEntry(rootView); } else if (key.equals(USE_IPv6_FIREWALL)) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f927cae0..741633bd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -196,4 +196,5 @@ <string name="connection_not_connected" >You may be leaking information to your internet provider or local network.</string> <string name="eip_state_no_network">You have no working Internet connection. Once you get it back, you will be automatically connected to</string> <string name="eip_state_blocking">%1$s is blocking all internet traffic.</string> + <string name="disabled_while_udp_on">Disabled while UDP is on.</string> </resources> |