diff options
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/providersetup')
10 files changed, 211 insertions, 27 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java index 07ea4691..ed30c454 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderAPI.java @@ -52,15 +52,18 @@ public class ProviderAPI extends JobIntentService implements ProviderApiManagerB */ static final int JOB_ID = 161375; + @Deprecated + final public static String + UPDATE_PROVIDER_DETAILS = "updateProviderDetails", + SIGN_UP = "srpRegister", + LOG_IN = "srpAuth", + LOG_OUT = "logOut"; + final public static String TAG = ProviderAPI.class.getSimpleName(), SET_UP_PROVIDER = "setUpProvider", - UPDATE_PROVIDER_DETAILS = "updateProviderDetails", DOWNLOAD_GEOIP_JSON = "downloadGeoIpJson", DOWNLOAD_MOTD = "downloadMotd", - SIGN_UP = "srpRegister", - LOG_IN = "srpAuth", - LOG_OUT = "logOut", // all vpn certificate download commands are used in different scenarios with different error handling // command key used for the initial vpn certificate download during the provider setup DOWNLOAD_VPN_CERTIFICATE = "downloadUserAuthedVPNCertificate", diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java index 9468f76e..93648bb0 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java @@ -96,6 +96,8 @@ import static se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog.DOWN import static se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog.DOWNLOAD_ERRORS.ERROR_CORRUPTED_PROVIDER_JSON; import static se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog.DOWNLOAD_ERRORS.ERROR_INVALID_CERTIFICATE; import static se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog.DOWNLOAD_ERRORS.ERROR_TOR_TIMEOUT; +import static se.leap.bitmaskclient.providersetup.ProviderSetupObservable.DOWNLOADED_GEOIP_JSON; +import static se.leap.bitmaskclient.providersetup.ProviderSetupObservable.DOWNLOADED_VPN_CERTIFICATE; import static se.leap.bitmaskclient.tor.TorStatusObservable.TorStatus.OFF; import static se.leap.bitmaskclient.tor.TorStatusObservable.TorStatus.ON; import static se.leap.bitmaskclient.tor.TorStatusObservable.getProxyPort; @@ -256,6 +258,9 @@ public abstract class ProviderApiManagerBase { result = setUpProvider(provider, parameters); if (result.getBoolean(BROADCAST_RESULT_KEY)) { getGeoIPJson(provider); + if (provider.hasGeoIpJson()) { + ProviderSetupObservable.updateProgress(DOWNLOADED_GEOIP_JSON); + } sendToReceiverOrBroadcast(receiver, PROVIDER_OK, result, provider); } else { sendToReceiverOrBroadcast(receiver, PROVIDER_NOK, result, provider); @@ -289,6 +294,7 @@ public abstract class ProviderApiManagerBase { ProviderObservable.getInstance().setProviderForDns(provider); result = updateVpnCertificate(provider); if (result.getBoolean(BROADCAST_RESULT_KEY)) { + ProviderSetupObservable.updateProgress(DOWNLOADED_VPN_CERTIFICATE); sendToReceiverOrBroadcast(receiver, CORRECTLY_DOWNLOADED_VPN_CERTIFICATE, result, provider); } else { sendToReceiverOrBroadcast(receiver, INCORRECTLY_DOWNLOADED_VPN_CERTIFICATE, result, provider); diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderManager.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderManager.java index 0f6c5090..b46072ff 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderManager.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderManager.java @@ -73,9 +73,9 @@ public class ProviderManager implements AdapteeCollection<Provider> { addCustomProviders(externalFilesDir); } - private void addDefaultProviders(AssetManager assets_manager) { + private void addDefaultProviders(AssetManager assetManager) { try { - defaultProviders = providersFromAssets(URLS, assets_manager.list(URLS)); + defaultProviders = providersFromAssets(URLS, assetManager.list(URLS)); defaultProviderURLs = getProviderUrlSetFromProviderSet(defaultProviders); } catch (IOException e) { e.printStackTrace(); diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupObservable.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupObservable.java new file mode 100644 index 00000000..90a32fea --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupObservable.java @@ -0,0 +1,103 @@ +package se.leap.bitmaskclient.providersetup; +/** + * Copyright (c) 2023 LEAP Encryption Access Project and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +import android.os.Handler; +import android.os.Looper; + +import java.util.Observable; + +import se.leap.bitmaskclient.tor.TorStatusObservable; + +public class ProviderSetupObservable extends Observable { + + private static final String TAG = ProviderSetupObservable.class.getSimpleName(); + + private int progress = 0; + private boolean canceled = false; + public static final int DOWNLOADED_PROVIDER_JSON = 20; + public static final int DOWNLOADED_CA_CERT = 40; + public static final int DOWNLOADED_EIP_SERVICE_JSON = 60; + public static final int DOWNLOADED_GEOIP_JSON = 80; + public static final int DOWNLOADED_VPN_CERTIFICATE = 100; + + private static ProviderSetupObservable instance; + private final Handler handler = new Handler(Looper.getMainLooper()); + private long lastUpdate = 0; + + public static ProviderSetupObservable getInstance() { + if (instance == null) { + instance = new ProviderSetupObservable(); + } + return instance; + } + + public static void updateProgress(int progress) { + if (getInstance().canceled) { + return; + } + long now = System.currentTimeMillis(); + getInstance().handler.postDelayed(() -> { + if (TorStatusObservable.isRunning()) { + getInstance().progress = (TorStatusObservable.getBootstrapProgress() + progress) / 2; + } else { + getInstance().progress = progress; + } + + getInstance().setChanged(); + getInstance().notifyObservers(); + }, now - getInstance().lastUpdate < 500L ? 500L : 0L); + getInstance().lastUpdate = System.currentTimeMillis() + 500; + } + + public static void updateTorSetupProgress() { + if (!TorStatusObservable.isRunning() || getInstance().canceled) { + return; + } + long now = System.currentTimeMillis(); + getInstance().handler.postDelayed(() -> { + getInstance().progress = (TorStatusObservable.getBootstrapProgress()) / 2; + + getInstance().setChanged(); + getInstance().notifyObservers(); + }, now - getInstance().lastUpdate < 500L ? 500L : 0); + getInstance().lastUpdate = System.currentTimeMillis() + 500; + } + + public static int getProgress() { + return getInstance().progress; + } + + public static void reset() { + getInstance().progress = 0; + getInstance().setChanged(); + getInstance().notifyObservers(); + } + + public static void cancel() { + getInstance().canceled = true; + reset(); + } + + public static boolean isCanceled() { + return getInstance().canceled; + } + + public static void startSetup() { + getInstance().canceled = false; + } +} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/SetupViewPagerAdapter.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/SetupViewPagerAdapter.java index a4a8fabd..00630f39 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/SetupViewPagerAdapter.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/SetupViewPagerAdapter.java @@ -1,5 +1,6 @@ package se.leap.bitmaskclient.providersetup; +import static se.leap.bitmaskclient.base.utils.ConfigHelper.isDefaultBitmask; import static se.leap.bitmaskclient.providersetup.fragments.SetupFragmentFactory.CIRCUMVENTION_SETUP_FRAGMENT; import static se.leap.bitmaskclient.providersetup.fragments.SetupFragmentFactory.CONFIGURE_PROVIDER_FRAGMENT; import static se.leap.bitmaskclient.providersetup.fragments.SetupFragmentFactory.NOTIFICATION_PERMISSON_EDUCATIONAL_FRAGMENT; @@ -33,7 +34,9 @@ public class SetupViewPagerAdapter extends FragmentStateAdapter { this(fragmentManager, lifecycle); ArrayList<Integer> fragments = new ArrayList<>(); if (providerSetup) { - fragments.add(PROVIDER_SELECTION_FRAGMENT); + if (isDefaultBitmask()) { + fragments.add(PROVIDER_SELECTION_FRAGMENT); + } fragments.add(CIRCUMVENTION_SETUP_FRAGMENT); fragments.add(CONFIGURE_PROVIDER_FRAGMENT); } diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/CustomProviderSetupActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/CustomProviderSetupActivity.java index 9cd46049..520395f8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/CustomProviderSetupActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/CustomProviderSetupActivity.java @@ -145,6 +145,7 @@ public class CustomProviderSetupActivity extends ProviderSetupBaseActivity { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_CONFIGURE_LEAP) { setResult(resultCode, data); finish(); diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SetupActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SetupActivity.java index a6e50769..b258a100 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SetupActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SetupActivity.java @@ -3,6 +3,7 @@ package se.leap.bitmaskclient.providersetup.activities; import static android.view.View.GONE; import static android.view.View.VISIBLE; import static androidx.appcompat.app.ActionBar.DISPLAY_SHOW_CUSTOM; +import static se.leap.bitmaskclient.base.utils.ConfigHelper.isDefaultBitmask; import static se.leap.bitmaskclient.base.utils.PreferenceHelper.deleteProviderDetailsFromPreferences; import static se.leap.bitmaskclient.providersetup.fragments.SetupFragmentFactory.CONFIGURE_PROVIDER_FRAGMENT; import static se.leap.bitmaskclient.tor.TorStatusObservable.TorStatus.OFF; @@ -47,6 +48,7 @@ import se.leap.bitmaskclient.base.utils.ViewHelper; import se.leap.bitmaskclient.base.views.ActionBarTitle; import se.leap.bitmaskclient.databinding.ActivitySetupBinding; import se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog; +import se.leap.bitmaskclient.providersetup.ProviderSetupObservable; import se.leap.bitmaskclient.providersetup.SetupViewPagerAdapter; import se.leap.bitmaskclient.tor.TorServiceCommand; import se.leap.bitmaskclient.tor.TorStatusObservable; @@ -84,14 +86,19 @@ public class SetupActivity extends AppCompatActivity implements SetupActivityCal fragmentManager = new FragmentManagerEnhanced(getSupportFragmentManager()); ArrayList<View> indicatorViews = new ArrayList<>(); - // indicator views for provider selection and config setup + if (isDefaultBitmask()) { + // indicator view for provider selection + addIndicatorView(indicatorViews); + } + + // indicator views for config setup boolean basicProviderSetup = !ProviderObservable.getInstance().getCurrentProvider().isConfigured() || switchProvider; if (basicProviderSetup) { - for (int i = 0; i < 3; i++) { - addIndicatorView(indicatorViews); - } + addIndicatorView(indicatorViews); + addIndicatorView(indicatorViews); } + // indicator views for VPN permission Intent requestVpnPermission = VpnService.prepare(this); if (requestVpnPermission != null) { @@ -160,6 +167,7 @@ public class SetupActivity extends AppCompatActivity implements SetupActivityCal private void cancel() { binding.viewPager.setCurrentItem(0, false); + ProviderSetupObservable.cancel(); if (TorStatusObservable.getStatus() != OFF) { Log.d(TAG, "SHUTDOWN - cancelSettingUpProvider"); TorServiceCommand.stopTorServiceAsync(this); @@ -281,6 +289,7 @@ public class SetupActivity extends AppCompatActivity implements SetupActivityCal @Override public void onSetupFinished() { + ProviderSetupObservable.reset(); Intent intent = getIntent(); if (provider == null && ProviderObservable.getInstance().getCurrentProvider().isConfigured()) { // only permissions were requested, no new provider configured, so reuse previously configured one 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 diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ConfigureProviderFragment.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ConfigureProviderFragment.java index 3c36065e..ec646cac 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ConfigureProviderFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ConfigureProviderFragment.java @@ -9,6 +9,7 @@ import static se.leap.bitmaskclient.R.string.description_configure_provider_circ import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_CODE; import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_KEY; import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY; +import static se.leap.bitmaskclient.base.utils.ConfigHelper.isDefaultBitmask; import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getUseSnowflake; import static se.leap.bitmaskclient.base.utils.ViewHelper.animateContainerVisibility; import static se.leap.bitmaskclient.providersetup.ProviderAPI.CORRECTLY_DOWNLOADED_VPN_CERTIFICATE; @@ -21,20 +22,23 @@ import static se.leap.bitmaskclient.providersetup.ProviderAPI.PROVIDER_OK; import static se.leap.bitmaskclient.providersetup.ProviderAPI.SET_UP_PROVIDER; import static se.leap.bitmaskclient.providersetup.ProviderAPI.TOR_EXCEPTION; import static se.leap.bitmaskclient.providersetup.ProviderAPI.TOR_TIMEOUT; -import static se.leap.bitmaskclient.tor.TorStatusObservable.getBootstrapProgress; import static se.leap.bitmaskclient.tor.TorStatusObservable.getLastLogs; import static se.leap.bitmaskclient.tor.TorStatusObservable.getLastSnowflakeLog; import static se.leap.bitmaskclient.tor.TorStatusObservable.getLastTorLog; import android.app.Activity; import android.content.Intent; +import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.res.ResourcesCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -42,11 +46,13 @@ import java.util.List; import java.util.Observable; import java.util.Observer; +import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.base.models.Provider; import se.leap.bitmaskclient.databinding.FConfigureProviderBinding; import se.leap.bitmaskclient.eip.EipSetupListener; import se.leap.bitmaskclient.eip.EipSetupObserver; import se.leap.bitmaskclient.providersetup.ProviderAPICommand; +import se.leap.bitmaskclient.providersetup.ProviderSetupObservable; import se.leap.bitmaskclient.providersetup.TorLogAdapter; import se.leap.bitmaskclient.providersetup.activities.CancelCallback; import se.leap.bitmaskclient.tor.TorStatusObservable; @@ -60,6 +66,8 @@ public class ConfigureProviderFragment extends BaseSetupFragment implements Obse private boolean ignoreProviderAPIUpdates = false; private TorLogAdapter torLogAdapter; + private Handler handler = new Handler(Looper.getMainLooper()); + public static ConfigureProviderFragment newInstance(int position) { ConfigureProviderFragment fragment = new ConfigureProviderFragment(); @@ -97,14 +105,14 @@ public class ConfigureProviderFragment extends BaseSetupFragment implements Obse public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setupActivityCallback.registerCancelCallback(this); - TorStatusObservable.getInstance().addObserver(this); + ProviderSetupObservable.getInstance().addObserver(this); EipSetupObserver.addListener(this); } @Override public void onDestroyView() { setupActivityCallback.removeCancelCallback(this); - TorStatusObservable.getInstance().deleteObserver(this); + ProviderSetupObservable.getInstance().deleteObserver(this); EipSetupObserver.removeListener(this); binding = null; super.onDestroyView(); @@ -116,8 +124,14 @@ public class ConfigureProviderFragment extends BaseSetupFragment implements Obse ignoreProviderAPIUpdates = false; binding.detailContainer.setVisibility(getUseSnowflake() ? VISIBLE : GONE); binding.tvCircumventionDescription.setText(getUseSnowflake() ? description_configure_provider_circumvention : description_configure_provider); + if (!isDefaultBitmask()) { + Drawable drawable = ResourcesCompat.getDrawable(getResources(), R.drawable.setup_progress_spinner, null); + binding.progressSpinner.setAnimatedSpinnerDrawable(drawable); + } + binding.progressSpinner.update(ProviderSetupObservable.getProgress()); setupActivityCallback.setNavigationButtonHidden(true); setupActivityCallback.setCancelButtonHidden(false); + ProviderSetupObservable.startSetup(); ProviderAPICommand.execute(getContext(), SET_UP_PROVIDER, setupActivityCallback.getSelectedProvider()); } @@ -145,7 +159,7 @@ public class ConfigureProviderFragment extends BaseSetupFragment implements Obse @Override public void update(Observable o, Object arg) { - if (o instanceof TorStatusObservable) { + if (o instanceof ProviderSetupObservable) { Activity activity = getActivity(); if (activity == null || binding == null) { return; @@ -162,7 +176,7 @@ public class ConfigureProviderFragment extends BaseSetupFragment implements Obse } } binding.tvProgressStatus.setText(TorStatusObservable.getStringForCurrentStatus(activity)); - binding.progressSpinner.update(getBootstrapProgress()); + binding.progressSpinner.update(ProviderSetupObservable.getProgress()); }); } } @@ -191,7 +205,8 @@ public class ConfigureProviderFragment extends BaseSetupFragment implements Obse Provider provider = resultData.getParcelable(PROVIDER_KEY); if (ignoreProviderAPIUpdates || provider == null || - !setupActivityCallback.getSelectedProvider().getDomain().equals(provider.getDomain())) { + (setupActivityCallback.getSelectedProvider() != null && + !setupActivityCallback.getSelectedProvider().getDomain().equals(provider.getDomain()))) { return; } @@ -205,7 +220,11 @@ public class ConfigureProviderFragment extends BaseSetupFragment implements Obse break; case CORRECTLY_DOWNLOADED_VPN_CERTIFICATE: setupActivityCallback.onProviderSelected(provider); - setupActivityCallback.onConfigurationSuccess(); + handler.postDelayed(() -> { + if (!ProviderSetupObservable.isCanceled()) { + setupActivityCallback.onConfigurationSuccess(); + } + }, 750); break; case PROVIDER_NOK: case INCORRECTLY_DOWNLOADED_VPN_CERTIFICATE: diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/EmptyPermissionSetupFragment.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/EmptyPermissionSetupFragment.java index 4226d804..849ac681 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/EmptyPermissionSetupFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/EmptyPermissionSetupFragment.java @@ -14,6 +14,7 @@ import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.databinding.FEmptyPermissionSetupBinding; public class EmptyPermissionSetupFragment extends BaseSetupFragment { @@ -31,9 +32,10 @@ public class EmptyPermissionSetupFragment extends BaseSetupFragment { setupActivityCallback.onConfigurationSuccess(); } } else { - Toast.makeText(getContext(), "Permission request failed :(", Toast.LENGTH_LONG).show(); - setupActivityCallback.setNavigationButtonHidden(false); - // TODO: implement sth. useful + Toast.makeText(getContext(), getText(R.string.permission_rejected), Toast.LENGTH_LONG).show(); + if (setupActivityCallback != null) { + setupActivityCallback.onConfigurationSuccess(); + } } }); @@ -46,9 +48,10 @@ public class EmptyPermissionSetupFragment extends BaseSetupFragment { setupActivityCallback.onConfigurationSuccess(); } } else { - Toast.makeText(getContext(), "Permission request failed :(", Toast.LENGTH_LONG).show(); - setupActivityCallback.setNavigationButtonHidden(false); - // TODO: implement sth. useful + Toast.makeText(getContext(), getText(R.string.permission_rejected), Toast.LENGTH_LONG).show(); + if (setupActivityCallback != null) { + setupActivityCallback.onConfigurationSuccess(); + } } } ); |