summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorNorbel AMBANUMBEN <aanorbel@gmail.com>2024-11-07 07:44:34 +0100
committercyBerta <cyberta@riseup.net>2024-11-28 22:53:30 +0100
commit56717309981f3458e7b2cf202e56308ebc7522c4 (patch)
treeb839f75530a85e9a96ced6d96af15c6726f627a0 /app/src/main/java
parent7e72d95516f375ab55e24659dd7f21948fe87070 (diff)
updated settings
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/fragments/CensorshipCircumventionFragment.java15
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/fragments/SettingsFragment.java26
2 files changed, 36 insertions, 5 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/CensorshipCircumventionFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/CensorshipCircumventionFragment.java
index ca27f8e9..74a9ba4a 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/CensorshipCircumventionFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/CensorshipCircumventionFragment.java
@@ -16,14 +16,17 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
+import de.blinkt.openvpn.core.VpnStatus;
import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.base.models.ProviderObservable;
import se.leap.bitmaskclient.databinding.FCensorshipCircumventionBinding;
+import se.leap.bitmaskclient.eip.EipCommand;
public class CensorshipCircumventionFragment extends Fragment {
public static int DISCOVERY_NONE = 100200000;
@@ -94,9 +97,18 @@ public class CensorshipCircumventionFragment extends Fragment {
} else if (checkedId == DISCOVERY_INVITE_PROXY) {
useSnowflake(false);
}
+
+ tryReconnectVpn();
});
}
+ private void tryReconnectVpn() {
+ if (VpnStatus.isVPNActive()) {
+ EipCommand.startVPN(getContext(), false);
+ Toast.makeText(getContext(), R.string.reconnecting, Toast.LENGTH_LONG).show();
+ }
+ }
+
private void initTunneling() {
RadioButton noneRadioButton = new RadioButton(binding.getRoot().getContext());
@@ -132,7 +144,7 @@ public class CensorshipCircumventionFragment extends Fragment {
setUseObfs4Kcp(true);
setUseObfs4(false);
}
-
+ tryReconnectVpn();
});
}
@@ -145,6 +157,7 @@ public class CensorshipCircumventionFragment extends Fragment {
return;
}
setUsePortHopping(isChecked);
+ tryReconnectVpn();
});
}
} \ No newline at end of file
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 1a9fd809..1167e8a7 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
@@ -42,6 +42,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
@@ -128,14 +129,15 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh
}
private void initManualCircumventionEntry(View rootView) {
- IconSwitchEntry manualConfiguration = rootView.findViewById(R.id.bridge_manual_switch);
+ IconTextEntry manualConfiguration = rootView.findViewById(R.id.bridge_manual_switch);
manualConfiguration.setVisibility(ProviderObservable.getInstance().getCurrentProvider().supportsPluggableTransports() ? VISIBLE : GONE);
- manualConfiguration.setChecked(usesManualBridges());
- manualConfiguration.setOnCheckedChangeListener((buttonView, isChecked) -> {
+ SwitchCompat manualConfigurationSwitch = rootView.findViewById(R.id.bridge_manual_switch_control);
+ manualConfigurationSwitch.setChecked(usesManualBridges());
+ manualConfigurationSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (!buttonView.isPressed()) {
return;
}
- openManualConfigurationFragment();
+ resetManualConfig();
});
manualConfiguration.setOnClickListener((buttonView) -> openManualConfigurationFragment());
@@ -147,6 +149,22 @@ public class SettingsFragment extends Fragment implements SharedPreferences.OnSh
manualConfiguration.setSubtitle(getString(useUDP? R.string.disabled_while_udp_on:R.string.manual_bridge_description));
}
+ private void resetManualConfig() {
+ useSnowflake(false);
+ setUseObfs4Kcp(false);
+ setUseObfs4(false);
+ setUsePortHopping(false);
+ if (VpnStatus.isVPNActive()) {
+ EipCommand.startVPN(getContext(), false);
+ Toast.makeText(getContext(), R.string.reconnecting, Toast.LENGTH_LONG).show();
+ }
+ View rootView = getView();
+ if (rootView == null) {
+ return;
+ }
+ initAutomaticCircumventionEntry(rootView);
+ }
+
private void openManualConfigurationFragment() {
FragmentManagerEnhanced fragmentManager = new FragmentManagerEnhanced(getActivity().getSupportFragmentManager());
Fragment fragment = CensorshipCircumventionFragment.newInstance();