summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFup Duck <fupduck@sacknagel.com>2018-01-25 13:29:29 +0100
committerFup Duck <fupduck@sacknagel.com>2018-01-25 13:29:29 +0100
commitca1390e5f4af3100d962dec252afdfb11e148ea1 (patch)
treeaaf748e3ecd620b01fb59dbc0fca09464e3fed73 /app
parentf18f51aa68bf3443d38163f1bd1d25a45ed14102 (diff)
add custom provider option
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java14
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java12
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java12
3 files changed, 20 insertions, 18 deletions
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);
}
}
}