From 26db3cd2398e0ae80fcc53e7933f2de747c074b4 Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Tue, 23 Jan 2018 15:55:00 +0100 Subject: add custom provider option --- app/build.gradle | 2 +- .../bitmaskclient/BaseConfigurationWizard.java | 31 ++---- .../java/se/leap/bitmaskclient/DefaultedURL.java | 5 +- .../main/java/se/leap/bitmaskclient/Provider.java | 10 ++ .../se/leap/bitmaskclient/ProviderListAdapter.java | 112 +-------------------- .../se/leap/bitmaskclient/ProviderManager.java | 50 ++++----- .../se/leap/bitmaskclient/ProviderRenderer.java | 8 +- .../res/menu/configuration_wizard_activity.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values/strings.xml | 3 +- .../se/leap/bitmaskclient/ConfigurationWizard.java | 2 - 11 files changed, 61 insertions(+), 166 deletions(-) (limited to 'app') diff --git a/app/build.gradle b/app/build.gradle index b28d9f35..bf3f53a7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 26 - buildToolsVersion '26.0.0' + buildToolsVersion '26.0.2' defaultConfig { applicationId "se.leap.bitmaskclient" diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java index 0726a785..cb52eb48 100644 --- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java +++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java @@ -27,7 +27,6 @@ import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentTransaction; import android.util.Log; import android.view.Menu; -import android.view.MenuItem; import android.widget.ListView; import com.pedrogomez.renderers.Renderer; @@ -116,8 +115,6 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity @Override protected void onSaveInstanceState(@NotNull Bundle outState) { - //if (progressbarDescription != null) - // outState.putString(PROGRESSBAR_TEXT, progressbarDescription.getText().toString()); outState.putString(ACTIVITY_STATE, mConfigState.getAction()); outState.putParcelable(Provider.KEY, provider); @@ -170,7 +167,6 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity isActivityShowing = true; if (SETTING_UP_PROVIDER.equals(mConfigState.getAction())) { showProgressBar(); - adapter.hideAllBut(adapter.indexOf(provider)); checkProviderSetUp(); } else if (PENDING_SHOW_FAILED_DIALOG.equals(mConfigState.getAction())) { showDownloadFailedDialog(); @@ -276,10 +272,15 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity } //TODO Code 2 pane view - mConfigState.setAction(SETTING_UP_PROVIDER); provider = adapter.getItem(position); - showProgressBar(); - onItemSelectedLogic(); + if (provider != null && !provider.isDefault()) { + //TODO Code 2 pane view + mConfigState.setAction(SETTING_UP_PROVIDER); + showProgressBar(); + onItemSelectedLogic(); + } else { + addAndSelectNewProvider(); + } } @Override @@ -304,7 +305,6 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity public void cancelSettingUpProvider() { hideProgressBar(); mConfigState.setAction(PROVIDER_NOT_SET); - adapter.showAllProviders(); preferences.edit().remove(Provider.KEY).remove(PROVIDER_ALLOW_ANONYMOUS).remove(PROVIDER_KEY).apply(); } @@ -412,24 +412,9 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity return true; } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.about_leap: - startActivityForResult(new Intent(this, AboutFragment.class), 0); - return true; - case R.id.new_provider: - addAndSelectNewProvider(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - public void cancelAndShowAllProviders() { mConfigState.setAction(PROVIDER_NOT_SET); provider = null; - adapter.showAllProviders(); } public class ProviderAPIBroadcastReceiver extends BroadcastReceiver { diff --git a/app/src/main/java/se/leap/bitmaskclient/DefaultedURL.java b/app/src/main/java/se/leap/bitmaskclient/DefaultedURL.java index 52c797a4..57ff1fd8 100644 --- a/app/src/main/java/se/leap/bitmaskclient/DefaultedURL.java +++ b/app/src/main/java/se/leap/bitmaskclient/DefaultedURL.java @@ -1,6 +1,7 @@ package se.leap.bitmaskclient; -import java.net.*; +import java.net.MalformedURLException; +import java.net.URL; public class DefaultedURL { private URL DEFAULT_URL; @@ -8,7 +9,7 @@ public class DefaultedURL { private URL url; - public DefaultedURL() { + DefaultedURL() { try { DEFAULT_URL = new URL(default_url); url = DEFAULT_URL; diff --git a/app/src/main/java/se/leap/bitmaskclient/Provider.java b/app/src/main/java/se/leap/bitmaskclient/Provider.java index 30504080..4d8c741d 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Provider.java +++ b/app/src/main/java/se/leap/bitmaskclient/Provider.java @@ -306,4 +306,14 @@ public final class Provider implements Parcelable { putString(Provider.MAIN_URL, getMainUrl().toString()). putString(Provider.KEY, getDefinition().toString()).apply(); } + + public boolean isDefault() { + return getMainUrl().isDefault() && + getApiUrl().isDefault() && + certificatePin.isEmpty() && + certificatePinEncoding.isEmpty() && + caCert.isEmpty(); + + } + } diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderListAdapter.java b/app/src/main/java/se/leap/bitmaskclient/ProviderListAdapter.java index 4a34caa0..6672c575 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderListAdapter.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderListAdapter.java @@ -1,119 +1,15 @@ package se.leap.bitmaskclient; -import android.view.*; +import android.view.LayoutInflater; -import com.pedrogomez.renderers.*; - -import java.util.*; +import com.pedrogomez.renderers.AdapteeCollection; +import com.pedrogomez.renderers.RendererAdapter; +import com.pedrogomez.renderers.RendererBuilder; public class ProviderListAdapter extends RendererAdapter { - private static boolean[] hidden = null; - - public void hide(int position) { - hidden[getRealPosition(position)] = true; - notifyDataSetChanged(); - notifyDataSetInvalidated(); - } - - public void unHide(int position) { - hidden[getRealPosition(position)] = false; - notifyDataSetChanged(); - notifyDataSetInvalidated(); - } - - public void showAllProviders() { - for (int i = 0; i < hidden.length; i++) - hidden[i] = false; - notifyDataSetChanged(); - notifyDataSetInvalidated(); - } - - public void hideAllBut(int position) { - for (int i = 0; i < hidden.length; i++) { - if (i != position) - hidden[i] = true; - else - hidden[i] = false; - } - notifyDataSetChanged(); - notifyDataSetInvalidated(); - } - - private int getRealPosition(int position) { - int hElements = getHiddenCountUpTo(position); - int diff = 0; - for (int i = 0; i < hElements; i++) { - diff++; - if (hidden[position + diff]) - i--; - } - return (position + diff); - } - - private int getHiddenCount() { - int count = 0; - for (int i = 0; i < hidden.length; i++) - if (hidden[i]) - count++; - return count; - } - - private int getHiddenCountUpTo(int location) { - int count = 0; - for (int i = 0; i <= location; i++) { - if (hidden[i]) - count++; - } - return count; - } - - @Override - public int getCount() { - return (hidden.length - getHiddenCount()); - } - public ProviderListAdapter(LayoutInflater layoutInflater, RendererBuilder rendererBuilder, AdapteeCollection collection) { super(layoutInflater, rendererBuilder, collection); - hidden = new boolean[collection.size()]; - for (int i = 0; i < collection.size(); i++) - hidden[i] = false; - } - - @Override - public void add(Provider item) { - super.add(item); - if (getCollection().size() > hidden.length) { - boolean[] new_hidden = new boolean[hidden.length + 1]; - System.arraycopy(hidden, 0, new_hidden, 0, hidden.length); - new_hidden[hidden.length] = false; - hidden = new_hidden; - } - } - - @Override - public void remove(Provider item) { - super.remove(item); - boolean[] new_hidden = new boolean[hidden.length - 1]; - System.arraycopy(hidden, 0, new_hidden, 0, hidden.length - 1); - hidden = new_hidden; - } - - protected int indexOf(Provider item) { - int index = 0; - ProviderManager provider_manager = (ProviderManager) getCollection(); - Set providers = provider_manager.providers(); - for (Provider provider : providers) { - if (provider.equals(item)) { - break; - } else index++; - } - return index; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - return super.getView(getRealPosition(position), convertView, parent); } public void saveProviders() { diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java b/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java index 62c04c1a..ed41be67 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderManager.java @@ -15,9 +15,11 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; /** @@ -25,15 +27,14 @@ import java.util.Set; */ public class ProviderManager implements AdapteeCollection { - private static final String TAG = ProviderManager.class.getName(); - private AssetManager assets_manager; + private AssetManager assetsManager; private File externalFilesDir; private Set defaultProviders; private Set customProviders; private static ProviderManager instance; - final protected static String URLS = "urls"; + final private static String URLS = "urls"; public static ProviderManager getInstance(AssetManager assetsManager, File externalFilesDir) { if (instance == null) @@ -42,8 +43,8 @@ public class ProviderManager implements AdapteeCollection { return instance; } - public ProviderManager(AssetManager assetManager, File externalFilesDir) { - this.assets_manager = assetManager; + private ProviderManager(AssetManager assetManager, File externalFilesDir) { + this.assetsManager = assetManager; addDefaultProviders(assetManager); addCustomProviders(externalFilesDir); } @@ -57,7 +58,7 @@ public class ProviderManager implements AdapteeCollection { } private Set providersFromAssets(String directory, String[] relativeFilePaths) { - Set providers = new HashSet(); + Set providers = new HashSet<>(); for (String file : relativeFilePaths) { String mainUrl = null; @@ -65,10 +66,10 @@ public class ProviderManager implements AdapteeCollection { String providerDefinition = null; try { String provider = file.substring(0, file.length() - ".url".length()); - InputStream provider_file = assets_manager.open(directory + "/" + file); + InputStream provider_file = assetsManager.open(directory + "/" + file); mainUrl = extractMainUrlFromInputStream(provider_file); - certificate = ConfigHelper.loadInputStreamAsString(assets_manager.open(provider + ".pem")); - providerDefinition = ConfigHelper.loadInputStreamAsString(assets_manager.open(provider + ".json")); + certificate = ConfigHelper.loadInputStreamAsString(assetsManager.open(provider + ".pem")); + providerDefinition = ConfigHelper.loadInputStreamAsString(assetsManager.open(provider + ".json")); } catch (IOException e) { e.printStackTrace(); } @@ -91,11 +92,11 @@ public class ProviderManager implements AdapteeCollection { } private Set providersFromFiles(String[] files) { - Set providers = new HashSet(); + Set providers = new HashSet<>(); try { for (String file : files) { - String main_url = extractMainUrlFromInputStream(new FileInputStream(externalFilesDir.getAbsolutePath() + "/" + file)); - providers.add(new Provider(new URL(main_url))); + String mainUrl = extractMainUrlFromInputStream(new FileInputStream(externalFilesDir.getAbsolutePath() + "/" + file)); + providers.add(new Provider(new URL(mainUrl))); } } catch (MalformedURLException | FileNotFoundException e) { e.printStackTrace(); @@ -104,12 +105,12 @@ public class ProviderManager implements AdapteeCollection { return providers; } - private String extractMainUrlFromInputStream(InputStream input_stream) { + private String extractMainUrlFromInputStream(InputStream inputStream) { String mainUrl = ""; - JSONObject file_contents = inputStreamToJson(input_stream); - if (file_contents != null) - mainUrl = file_contents.optString(Provider.MAIN_URL); + JSONObject fileContents = inputStreamToJson(inputStream); + if (fileContents != null) + mainUrl = fileContents.optString(Provider.MAIN_URL); return mainUrl; } @@ -126,12 +127,13 @@ public class ProviderManager implements AdapteeCollection { return json; } - public Set providers() { - Set all_providers = new HashSet(); - all_providers.addAll(defaultProviders); + public List providers() { + List allProviders = new ArrayList<>(); + allProviders.addAll(defaultProviders); if(customProviders != null) - all_providers.addAll(customProviders); - return all_providers; + allProviders.addAll(customProviders); + allProviders.add(new Provider()); + return allProviders; } @Override @@ -151,9 +153,7 @@ public class ProviderManager implements AdapteeCollection { @Override public boolean add(Provider element) { - if (!defaultProviders.contains(element)) - return customProviders.add(element); - else return true; + return !defaultProviders.contains(element) || customProviders.add(element); } @Override @@ -179,7 +179,7 @@ public class ProviderManager implements AdapteeCollection { customProviders.clear(); } - protected void saveCustomProvidersToFile() { + void saveCustomProvidersToFile() { try { for (Provider provider : customProviders) { File providerFile = new File(externalFilesDir, provider.getName() + ".json"); diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderRenderer.java b/app/src/main/java/se/leap/bitmaskclient/ProviderRenderer.java index 4a5d0db1..5b3e5728 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderRenderer.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderRenderer.java @@ -45,7 +45,11 @@ public class ProviderRenderer extends Renderer { @Override public void render() { Provider provider = getContent(); - name.setText(provider.getName()); - domain.setText(provider.getDomain()); + if (!provider.isDefault()) { + name.setText(provider.getName()); + domain.setText(provider.getDomain()); + } else { + domain.setText(R.string.add_provider); + } } } diff --git a/app/src/main/res/menu/configuration_wizard_activity.xml b/app/src/main/res/menu/configuration_wizard_activity.xml index 9936b6dc..21591547 100644 --- a/app/src/main/res/menu/configuration_wizard_activity.xml +++ b/app/src/main/res/menu/configuration_wizard_activity.xml @@ -8,7 +8,7 @@ diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 6355ce62..cd55531c 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -19,7 +19,7 @@ Estado no definido. Acceso a Internet Encriptado con VPN Elige un proveedor - Nuevo proveedor + Nuevo proveedor AƱadir un nuevo proveedor Guardar Dominio diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 01715c32..c681f861 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -17,7 +17,7 @@ Status unknown. Encrypted VPN Internet Access Select a service provider - Add new Provider + Add new Provider Add a new service provider Save Domain name @@ -102,4 +102,5 @@ Stored provider details are corrupted. You can either update Bitmask (recommended) or update the provider details using a commercial CA certificate. Stored provider certificate is invalid. You can either update Bitmask (recommended) or update the provider certificate using a commercial CA certificate. Stored provider certificate is expired. You can either update Bitmask (recommended) or update the provider certificate using a commercial CA certificate. + diff --git a/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java index f7102508..4e16647a 100644 --- a/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/app/src/production/java/se/leap/bitmaskclient/ConfigurationWizard.java @@ -86,8 +86,6 @@ public class ConfigurationWizard extends BaseConfigurationWizard { addAndSelectNewProvider(ProviderAPI.lastProviderMainUrl()); } else { showProgressBar(); - adapter.hideAllBut(adapter.indexOf(provider)); - Intent providerApiCommand = new Intent(this, ProviderAPI.class); providerApiCommand.setAction(ProviderAPI.SET_UP_PROVIDER); -- cgit v1.2.3 From ca1390e5f4af3100d962dec252afdfb11e148ea1 Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Thu, 25 Jan 2018 13:29:29 +0100 Subject: add custom provider option --- .../se/leap/bitmaskclient/BaseConfigurationWizard.java | 14 ++++++-------- .../java/se/leap/bitmaskclient/DownloadFailedDialog.java | 12 ++++++------ .../java/se/leap/bitmaskclient/ProviderApiManagerBase.java | 12 ++++++++---- 3 files changed, 20 insertions(+), 18 deletions(-) (limited to 'app') diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java index b5040cdc..9db9c3f4 100644 --- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java +++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java @@ -208,7 +208,6 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity private void setUpProviderAPIResultReceiver() { providerAPIResultReceiver = new ProviderAPIResultReceiver(new Handler(), this); providerAPIBroadcastReceiver = new ProviderAPIBroadcastReceiver(); - IntentFilter updateIntentFilter = new IntentFilter(PROVIDER_API_EVENT); updateIntentFilter.addCategory(Intent.CATEGORY_DEFAULT); registerReceiver(providerAPIBroadcastReceiver, updateIntentFilter); @@ -434,20 +433,14 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity Bundle resultData = intent.getParcelableExtra(RESULT_KEY); String handledProvider = resultData.getString(Provider.KEY); - - String providerName = getProviderName(handledProvider); String providerDomain = getProviderDomain(handledProvider); - if (providerName != null && providerName.equalsIgnoreCase(provider.getName()) && - providerDomain != null && + if (providerDomain != null && providerDomain.equalsIgnoreCase(provider.getDomain())) { switch (resultCode) { case PROVIDER_OK: handleProviderSetUp(); break; - case PROVIDER_NOK: - handleProviderSetupFailed(resultData); - break; case CORRECTLY_DOWNLOADED_CERTIFICATE: handleCorrectlyDownloadedCertificate(); break; @@ -456,6 +449,11 @@ public abstract class BaseConfigurationWizard extends ConfigWizardBaseActivity break; } } + + // providerDomain can be null + if (resultCode == PROVIDER_NOK) { + handleProviderSetupFailed(resultData); + } } } } diff --git a/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java b/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java index 527ce1a7..dde71642 100644 --- a/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java @@ -16,12 +16,12 @@ */ package se.leap.bitmaskclient; -import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; -import android.support.v4.app.DialogFragment; +import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import org.json.JSONObject; @@ -134,12 +134,12 @@ public class DownloadFailedDialog extends DialogFragment { DownloadFailedDialogInterface interface_with_ConfigurationWizard; @Override - public void onAttach(Activity activity) { - super.onAttach(activity); + public void onAttach(Context context) { + super.onAttach(context); try { - interface_with_ConfigurationWizard = (DownloadFailedDialogInterface) activity; + interface_with_ConfigurationWizard = (DownloadFailedDialogInterface) context; } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() + throw new ClassCastException(context.toString() + " must implement NoticeDialogListener"); } } diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java index cfc6e49d..8117fb99 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java @@ -163,12 +163,16 @@ public abstract class ProviderApiManagerBase { if (action.equals(UPDATE_PROVIDER_DETAILS)) { resetProviderDetails(); Bundle task = new Bundle(); - task.putString(MAIN_URL, lastProviderMainUrl); + String mainUrl = parameters.getString(Provider.MAIN_URL); + if (mainUrl == null) { + mainUrl = lastProviderMainUrl; + } + task.putString(MAIN_URL, mainUrl); Bundle result = setUpProvider(task); if (result.getBoolean(RESULT_KEY)) { - receiver.send(PROVIDER_OK, result); + sendToReceiverOrBroadcast(receiver, PROVIDER_OK, result); } else { - receiver.send(PROVIDER_NOK, result); + sendToReceiverOrBroadcast(receiver, PROVIDER_NOK, result); } } else if (action.equalsIgnoreCase(SET_UP_PROVIDER)) { Bundle result = setUpProvider(parameters); @@ -222,7 +226,7 @@ public abstract class ProviderApiManagerBase { } else if (action.equalsIgnoreCase(PROVIDER_SET_UP)) { if(EIP_SERVICE_JSON_DOWNLOADED && CA_CERT_DOWNLOADED && PROVIDER_JSON_DOWNLOADED ) { if(receiver!= null) { - receiver.send(PROVIDER_OK, Bundle.EMPTY); + sendToReceiverOrBroadcast(receiver, PROVIDER_OK, Bundle.EMPTY); } } } -- cgit v1.2.3 From 1a25b1dea9ab2d7e76cd79e8928d27f855ca9f2a Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Thu, 25 Jan 2018 14:08:08 +0100 Subject: custom provider for insecure --- app/build.gradle | 2 +- app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/build.gradle b/app/build.gradle index bf3f53a7..b28d9f35 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 26 - buildToolsVersion '26.0.2' + buildToolsVersion '26.0.0' defaultConfig { applicationId "se.leap.bitmaskclient" diff --git a/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java index 3e176fc1..6481c9f5 100644 --- a/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/app/src/insecure/java/se/leap/bitmaskclient/ConfigurationWizard.java @@ -75,7 +75,7 @@ public class ConfigurationWizard extends BaseConfigurationWizard { private void autoSelectProvider(Provider provider, boolean danger_on) { preferences.edit().putBoolean(ProviderItem.DANGER_ON, danger_on).apply(); - provider = provider; + this.provider = provider; onItemSelectedLogic(); showProgressBar(); } @@ -117,7 +117,6 @@ public class ConfigurationWizard extends BaseConfigurationWizard { addAndSelectNewProvider(ProviderAPI.lastProviderMainUrl(), ProviderAPI.lastDangerOn()); } else { showProgressBar(); - adapter.hideAllBut(adapter.indexOf(provider)); Intent providerAPICommand = new Intent(this, ProviderAPI.class); -- cgit v1.2.3 From 6be60844db062575055752b554dbf14941e8e185 Mon Sep 17 00:00:00 2001 From: Fup Duck Date: Tue, 30 Jan 2018 14:35:25 +0100 Subject: 8828 - fix EipFragment leak --- app/src/main/java/se/leap/bitmaskclient/EipFragment.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index 414b1f2a..4027bc14 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -130,13 +130,13 @@ public class EipFragment extends Fragment implements Observer { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); eipStatus = EipStatus.getInstance(); - eipStatus.addObserver(this); eipReceiver = new EIPReceiver(new Handler()); preferences = getActivity().getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + eipStatus.addObserver(this); View view = inflater.inflate(R.layout.eip_service_fragment, container, false); ButterKnife.inject(this, view); @@ -162,6 +162,12 @@ public class EipFragment extends Fragment implements Observer { getActivity().unbindService(openVpnConnection); } + @Override + public void onDestroyView() { + super.onDestroyView(); + eipStatus.deleteObserver(this); + } + @Override public void onSaveInstanceState(Bundle outState) { outState.putBoolean(IS_CONNECTED, eipStatus.isConnected()); -- cgit v1.2.3