summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/se/leap/bitmaskclient/ConfigurationWizard.java36
-rw-r--r--src/se/leap/bitmaskclient/DownloadFailedDialog.java3
-rw-r--r--src/se/leap/bitmaskclient/NewProviderDialog.java10
-rw-r--r--src/se/leap/bitmaskclient/ProviderAPI.java12
4 files changed, 51 insertions, 10 deletions
diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java
index 012a444c..44d35370 100644
--- a/src/se/leap/bitmaskclient/ConfigurationWizard.java
+++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java
@@ -83,7 +83,6 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
public ProviderAPIResultReceiver providerAPI_result_receiver;
private ProviderAPIBroadcastReceiver_Update providerAPI_broadcast_receiver_update;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -355,6 +354,24 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
}
/**
+ * Open the new provider dialog with data
+ */
+ public void addAndSelectNewProvider(String main_url, boolean danger_on) {
+ FragmentTransaction fragment_transaction = getFragmentManager().beginTransaction();
+ Fragment previous_new_provider_dialog = getFragmentManager().findFragmentByTag(NewProviderDialog.TAG);
+ if (previous_new_provider_dialog != null) {
+ fragment_transaction.remove(previous_new_provider_dialog);
+ }
+
+ DialogFragment newFragment = NewProviderDialog.newInstance();
+ Bundle data = new Bundle();
+ data.putString(Provider.MAIN_URL, main_url);
+ data.putBoolean(ProviderItem.DANGER_ON, danger_on);
+ newFragment.setArguments(data);
+ newFragment.show(fragment_transaction, NewProviderDialog.TAG);
+ }
+
+ /**
* Once selected a provider, this fragment offers the user to log in,
* use it anonymously (if possible)
* or cancel his/her election pressing the back button.
@@ -422,9 +439,18 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
provider_API_command.setAction(ProviderAPI.SET_UP_PROVIDER);
provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters);
provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver);
-
- startService(provider_API_command);
- }
+
+ startService(provider_API_command);
+ }
+
+ public void retrySetUpProvider() {
+ removeLastProviderItem();
+ addAndSelectNewProvider(ProviderAPI.lastProviderMainUrl(), ProviderAPI.lastDangerOn());
+ /*
+ Intent provider_API_command = new Intent(this, ProviderAPI.class);
+ startService(provider_API_command);
+ */
+ }
public void retrySetUpProvider() {
Intent provider_API_command = new Intent(this, ProviderAPI.class);
@@ -478,7 +504,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD
provider_list_fragment.unhideAll();
}
- public void removeLastProviderItem() {
+ private void removeLastProviderItem() {
provider_list_fragment = (ProviderListFragment) getFragmentManager().findFragmentByTag(ProviderListFragment.TAG);
if(provider_list_fragment != null) {
provider_list_fragment.removeLastItem();
diff --git a/src/se/leap/bitmaskclient/DownloadFailedDialog.java b/src/se/leap/bitmaskclient/DownloadFailedDialog.java
index b759b1a3..4930da95 100644
--- a/src/se/leap/bitmaskclient/DownloadFailedDialog.java
+++ b/src/se/leap/bitmaskclient/DownloadFailedDialog.java
@@ -62,7 +62,7 @@ public class DownloadFailedDialog extends DialogFragment {
ConfigHelper.removeFromSharedPref(ProviderItem.DANGER_ON);
ConfigHelper.removeFromSharedPref(EIP.ALLOWED_ANON);
ConfigHelper.removeFromSharedPref(EIP.KEY);
- interface_with_ConfigurationWizard.removeLastProviderItem();
+ interface_with_ConfigurationWizard.retrySetUpProvider();
dialog.dismiss();
}
});
@@ -73,7 +73,6 @@ public class DownloadFailedDialog extends DialogFragment {
public interface DownloadFailedDialogInterface {
public void retrySetUpProvider();
- public void removeLastProviderItem();
}
DownloadFailedDialogInterface interface_with_ConfigurationWizard;
diff --git a/src/se/leap/bitmaskclient/NewProviderDialog.java b/src/se/leap/bitmaskclient/NewProviderDialog.java
index 98686bd2..5a20a355 100644
--- a/src/se/leap/bitmaskclient/NewProviderDialog.java
+++ b/src/se/leap/bitmaskclient/NewProviderDialog.java
@@ -16,7 +16,8 @@
*/
package se.leap.bitmaskclient;
-import se.leap.bitmaskclient.R;
+import se.leap.leapclient.ProviderListContent.ProviderItem;
+import se.leap.leapclient.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -71,7 +72,14 @@ public class NewProviderDialog extends DialogFragment {
LayoutInflater inflater = getActivity().getLayoutInflater();
View new_provider_dialog_view = inflater.inflate(R.layout.new_provider_dialog, null);
final EditText url_input_field = (EditText)new_provider_dialog_view.findViewById(R.id.new_provider_url);
+ if(getArguments() != null && getArguments().containsKey(Provider.MAIN_URL)) {
+ url_input_field.setText(getArguments().getString(Provider.MAIN_URL));
+ }
final CheckBox danger_checkbox = (CheckBox)new_provider_dialog_view.findViewById(R.id.danger_checkbox);
+ if(getArguments() != null && getArguments().containsKey(ProviderItem.DANGER_ON)) {
+ danger_checkbox.setActivated(getArguments().getBoolean(ProviderItem.DANGER_ON));
+ }
+
builder.setView(new_provider_dialog_view)
.setMessage(R.string.introduce_new_provider)
.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
diff --git a/src/se/leap/bitmaskclient/ProviderAPI.java b/src/se/leap/bitmaskclient/ProviderAPI.java
index e8f37c8a..39dd978a 100644
--- a/src/se/leap/bitmaskclient/ProviderAPI.java
+++ b/src/se/leap/bitmaskclient/ProviderAPI.java
@@ -122,8 +122,8 @@ public class ProviderAPI extends IntentService {
EIP_SERVICE_JSON_DOWNLOADED = false
;
- static private String last_provider_main_url;
- static private boolean last_danger_on = false;
+ private static String last_provider_main_url;
+ private static boolean last_danger_on = false;
public ProviderAPI() {
super("ProviderAPI");
@@ -137,6 +137,14 @@ public class ProviderAPI extends IntentService {
CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ORIGINAL_SERVER) );
}
+ public static String lastProviderMainUrl() {
+ return last_provider_main_url;
+ }
+
+ public static boolean lastDangerOn() {
+ return last_danger_on;
+ }
+
private String formatErrorMessage(final int toast_string_id) {
return "{ \"" + ERRORS + "\" : \""+getResources().getString(toast_string_id)+"\" }";
}