summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/ConfigurationWizard.java
diff options
context:
space:
mode:
authorparmegv <parmegv@sdf.org>2013-02-12 19:33:19 +0100
committerparmegv <parmegv@sdf.org>2013-02-12 19:33:19 +0100
commitc01aa98a1d43ae0d6b56f0d13a8782dbb6a3e35e (patch)
treee09fc92c435813ce09eda7993c7bdddeb4ea8f2a /src/se/leap/leapclient/ConfigurationWizard.java
parent162afa5bfa6485f3aacb3f60e9c92fa0c3bfa7a7 (diff)
New custom provider dialog effectively adds the new provider to the
ProviderListFragment, and then the user can choose it.
Diffstat (limited to 'src/se/leap/leapclient/ConfigurationWizard.java')
-rw-r--r--src/se/leap/leapclient/ConfigurationWizard.java34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java
index 39ada310..422f9968 100644
--- a/src/se/leap/leapclient/ConfigurationWizard.java
+++ b/src/se/leap/leapclient/ConfigurationWizard.java
@@ -8,7 +8,7 @@ import java.util.Scanner;
import org.json.JSONException;
import org.json.JSONObject;
-import se.leap.leapclient.NewProviderDialog.NewProviderDialogInterface;
+import se.leap.leapclient.ProviderAPIResultReceiver.Receiver;
import se.leap.leapclient.ProviderListContent.ProviderItem;
import android.app.Activity;
import android.app.DialogFragment;
@@ -19,6 +19,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.AssetManager;
import android.os.Bundle;
+import android.os.Handler;
import android.view.View;
@@ -39,18 +40,19 @@ import android.view.View;
* to listen for item selections.
*/
public class ConfigurationWizard extends Activity
- implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogInterface{
+ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogInterface, Receiver {
+
/**
* Whether or not the activity is in two-pane mode, i.e. running on a tablet
* device.
*/
private boolean mTwoPane;
-
- private int mStackLevel;
static SharedPreferences shared_preferences;
+ public ProviderAPIResultReceiver providerAPI_result_receiver;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -86,9 +88,10 @@ public class ConfigurationWizard extends Activity
String provider_name = "";
for(String url_filepath : urls_filepaths)
{
+ boolean custom = false;
provider_name = url_filepath.subSequence(0, url_filepath.indexOf(".")).toString();
if(ProviderListContent.ITEMS.isEmpty()) //TODO I have to implement a way of checking if a provider new or is already present in that ITEMS list
- ProviderListContent.addItem(new ProviderItem(provider_name, asset_manager.open(url_files_folder + "/" + url_filepath)));
+ ProviderListContent.addItem(new ProviderItem(provider_name, asset_manager.open(url_files_folder + "/" + url_filepath), custom));
}
} catch (IOException e) {
// TODO Auto-generated catch block
@@ -115,7 +118,8 @@ public class ConfigurationWizard extends Activity
if(current_provider_item.id.equalsIgnoreCase(id))
{
try {
- processAssetsFiles(current_provider_item);
+ if(current_provider_item.custom)
+ processAssetsFiles(current_provider_item);
// TODO ask Provider class to save provider.json, setResult(OK), finish() to ConfigurationWizard
downloadJSONFiles(current_provider_item);
} catch (IOException e) {
@@ -174,13 +178,29 @@ public class ConfigurationWizard extends Activity
@Override
public void saveProvider(String provider_url) {
+ providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
+ providerAPI_result_receiver.setReceiver(this);
+
Intent provider_API_command = new Intent(this, ProviderAPI.class);
Bundle method_and_parameters = new Bundle();
method_and_parameters.putString(ConfigHelper.provider_key_url, provider_url);
provider_API_command.putExtra(ConfigHelper.downloadNewProviderDotJSON, method_and_parameters);
-
+ provider_API_command.putExtra("receiver", providerAPI_result_receiver);
startService(provider_API_command);
}
+
+ @Override
+ public void onReceiveResult(int resultCode, Bundle resultData) {
+ // TODO Auto-generated method stub
+ if(resultCode == ConfigHelper.CUSTOM_PROVIDER_ADDED){
+ ProviderListFragment providerList = new ProviderListFragment();
+
+ FragmentManager fragmentManager = getFragmentManager();
+ fragmentManager.beginTransaction()
+ .replace(R.id.configuration_wizard_layout, providerList, "providerlist")
+ .commit();
+ }
+ }
}