diff options
author | Parménides GV <parmegv@sdf.org> | 2013-03-13 21:01:53 +0100 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2013-03-13 21:01:53 +0100 |
commit | 929fa9a3b7621e0a956ed8d7beffb87ed7f16249 (patch) | |
tree | 26e3dbb8c9662b63e72c096bf0a0e54edefcd49a /src/se/leap/leapclient/ConfigurationWizard.java | |
parent | a8274e8b2649481f22bfc6d205d2ca7599fea065 (diff) |
ConfigurationWizard sets provider.json correctly for Dashboard once a
custom provider is selected.
Tested using https://bitmask.net as url for custom provider.
Diffstat (limited to 'src/se/leap/leapclient/ConfigurationWizard.java')
-rw-r--r-- | src/se/leap/leapclient/ConfigurationWizard.java | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java index e252fa6b..dcefb271 100644 --- a/src/se/leap/leapclient/ConfigurationWizard.java +++ b/src/se/leap/leapclient/ConfigurationWizard.java @@ -59,7 +59,7 @@ public class ConfigurationWizard extends Activity setContentView(R.layout.activity_configuration_wizard);
- shared_preferences = getSharedPreferences(ConfigHelper.PREFERENCES_KEY,MODE_PRIVATE);
+ ConfigHelper.setSharedPreferences(getSharedPreferences(ConfigHelper.PREFERENCES_KEY,MODE_PRIVATE));
loadPreseededProviders();
@@ -118,10 +118,9 @@ public class ConfigurationWizard extends Activity if(current_provider_item.id.equalsIgnoreCase(id))
{
try {
- 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);
+ saveProviderJson(current_provider_item);
+ downloadJSONFiles(current_provider_item);
+
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -136,11 +135,15 @@ public class ConfigurationWizard extends Activity }
}
- private void processAssetsFiles(ProviderItem current_provider_item) {
+ private void saveProviderJson(ProviderItem current_provider_item) {
AssetManager assets_manager = getAssets();
JSONObject provider_json = new JSONObject();
try {
- String provider_contents = new Scanner(new InputStreamReader(assets_manager.open(current_provider_item.provider_json_assets))).useDelimiter("\\A").next();
+ String provider_contents = "";
+ if(!current_provider_item.custom)
+ provider_contents = new Scanner(new InputStreamReader(assets_manager.open(current_provider_item.provider_json_filename))).useDelimiter("\\A").next();
+ else
+ provider_contents = new Scanner(ConfigHelper.openFileInputStream(current_provider_item.provider_json_filename)).useDelimiter("\\A").next();
provider_json = new JSONObject(provider_contents);
} catch (IOException e) {
// TODO Auto-generated catch block
@@ -152,16 +155,20 @@ public class ConfigurationWizard extends Activity }
private void downloadJSONFiles(ProviderItem current_provider_item) throws IOException {
+ 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, current_provider_item.name);
method_and_parameters.putString(ConfigHelper.cert_key, current_provider_item.cert_json_url);
method_and_parameters.putString(ConfigHelper.eip_service_key, current_provider_item.eip_service_json_url);
provider_API_command.putExtra(ConfigHelper.downloadJsonFilesBundleExtra, method_and_parameters);
-
+ provider_API_command.putExtra("receiver", providerAPI_result_receiver);
startService(provider_API_command);
-
}
public void addNewProvider(View view) {
@@ -193,7 +200,6 @@ public class ConfigurationWizard extends Activity @Override
public void onReceiveResult(int resultCode, Bundle resultData) {
- // TODO Auto-generated method stub
if(resultCode == ConfigHelper.CUSTOM_PROVIDER_ADDED){
ProviderListFragment providerList = new ProviderListFragment();
|