diff options
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/CircumventionSetupFragment.java')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/CircumventionSetupFragment.java | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/CircumventionSetupFragment.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/CircumventionSetupFragment.java index 11fa582b..34a93319 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/CircumventionSetupFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/CircumventionSetupFragment.java @@ -1,5 +1,8 @@ package se.leap.bitmaskclient.providersetup.fragments; +import static se.leap.bitmaskclient.base.utils.ConfigHelper.isDefaultBitmask; + +import android.content.Context; import android.graphics.Typeface; import android.os.Bundle; import android.view.LayoutInflater; @@ -9,10 +12,14 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.base.utils.PreferenceHelper; import se.leap.bitmaskclient.databinding.FCircumventionSetupBinding; +import se.leap.bitmaskclient.providersetup.ProviderManager; +import se.leap.bitmaskclient.providersetup.activities.CancelCallback; +import se.leap.bitmaskclient.providersetup.activities.SetupActivityCallback; -public class CircumventionSetupFragment extends BaseSetupFragment { +public class CircumventionSetupFragment extends BaseSetupFragment implements CancelCallback { public static CircumventionSetupFragment newInstance(int position) { CircumventionSetupFragment fragment = new CircumventionSetupFragment(); @@ -24,7 +31,8 @@ public class CircumventionSetupFragment extends BaseSetupFragment { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { FCircumventionSetupBinding binding = FCircumventionSetupBinding.inflate(inflater, container, false); - + binding.rbPlainVpn.setText(getString(R.string.use_standard_vpn, getString(R.string.app_name))); + binding.tvCircumventionDetailDescription.setText(getString(R.string.circumvention_setup_hint, getString(R.string.app_name))); binding.circumventionRadioGroup.setOnCheckedChangeListener((group, checkedId) -> { if (binding.rbCircumvention.getId() == checkedId) { PreferenceHelper.useBridges(true); @@ -50,9 +58,38 @@ public class CircumventionSetupFragment extends BaseSetupFragment { } @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + setupActivityCallback.registerCancelCallback(this); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + setupActivityCallback.removeCancelCallback(this); + } + + @Override public void onFragmentSelected() { super.onFragmentSelected(); - setupActivityCallback.setCancelButtonHidden(false); + setupActivityCallback.setCancelButtonHidden(!isDefaultBitmask()); setupActivityCallback.setNavigationButtonHidden(false); + if (!isDefaultBitmask()) { + loadProviderFromAssets(); + } + } + + private void loadProviderFromAssets() { + ProviderManager providerManager = ProviderManager.getInstance(getContext().getApplicationContext().getAssets(), + getContext().getExternalFilesDir(null)); + providerManager.setAddDummyEntry(false); + setupActivityCallback.onProviderSelected(providerManager.providers().get(0)); + } + + @Override + public void onCanceled() { + if (!isDefaultBitmask()) { + loadProviderFromAssets(); + } } }
\ No newline at end of file |