diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/se/leap/bitmaskclient/ConfigurationWizard.java | 32 | ||||
-rw-r--r-- | src/se/leap/bitmaskclient/ProviderAPI.java | 5 | ||||
-rw-r--r-- | src/se/leap/bitmaskclient/ProviderListAdapter.java | 20 | ||||
-rw-r--r-- | src/se/leap/bitmaskclient/ProviderListContent.java | 9 | ||||
-rw-r--r-- | src/se/leap/bitmaskclient/ProviderListFragment.java | 1 |
5 files changed, 33 insertions, 34 deletions
diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java index 43ac8dd8..36d90318 100644 --- a/src/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java @@ -149,16 +149,14 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn if(resultData.containsKey(Provider.NAME)) {
String provider_id = resultData.getString(Provider.NAME);
mSelectedProvider = getProvider(provider_id);
- provider_list_fragment.addItem(mSelectedProvider);
- ProviderListContent.removeItem(mSelectedProvider);
+ //provider_list_fragment.addItem(mSelectedProvider);
+ //ProviderListContent.removeItem(mSelectedProvider);
- if(mSelectedProvider.custom)
- refreshProviderList(0);
+ //refreshProviderList(0);
if(!mProgressBar.isShown()) {
int provider_index = getProviderIndex(provider_id);
startProgressBar(provider_index);
- provider_list_fragment = (ProviderListFragment) getFragmentManager().findFragmentByTag(ProviderListFragment.TAG);
provider_list_fragment.hide(provider_index-2);
//setProviderList(provider_list_fragment);
}
@@ -171,7 +169,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn e.printStackTrace();
mProgressBar.setVisibility(ProgressBar.GONE);
progressbar_description.setVisibility(TextView.GONE);
- refreshProviderList(0);
+ //refreshProviderList(0);
//Toast.makeText(this, getResources().getString(R.string.config_error_parsing), Toast.LENGTH_LONG);
setResult(RESULT_CANCELED, mConfigState);
}
@@ -194,7 +192,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn mProgressBar.incrementProgressBy(1);
mProgressBar.setVisibility(ProgressBar.GONE);
progressbar_description.setVisibility(TextView.GONE);
- refreshProviderList(0);
+ //refreshProviderList(0);
//Toast.makeText(getApplicationContext(), R.string.success, Toast.LENGTH_LONG).show();
setResult(RESULT_OK);
showProviderDetails(getCurrentFocus());
@@ -288,7 +286,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn while(providers_iterator.hasNext()) {
ProviderItem provider = providers_iterator.next();
index++;
- if(provider.id.equalsIgnoreCase(id)) {
+ if(provider.name().equalsIgnoreCase(id)) {
break;
}
}
@@ -447,18 +445,22 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn private void showProvider(final String provider_main_url, final boolean danger_on) {
String provider_name = provider_main_url.replaceFirst("http[s]?://", "").replaceFirst("\\/", "_");
- boolean custom = true;
- final ProviderItem added_provider = new ProviderItem(provider_name, provider_main_url, custom, danger_on);
+ final ProviderItem added_provider = new ProviderItem(provider_name, provider_main_url, danger_on);
+
+ //ProviderListContent.addItem(added_provider);
+ provider_list_fragment.addItem(added_provider);
+ /*ProviderListFragment provider_list_fragment = (ProviderListFragment) getFragmentManager().findFragmentByTag(ProviderListFragment.TAG);
+ //provider_list_fragment.notifyAdapter();
+ provider_list_fragment.addItem(added_provider);
+ refreshProviderList(0);
+
runOnUiThread(new Runnable() {
@Override
public void run() {
- // TODO Auto-generated method stub
- ProviderListContent.addItem(added_provider);
- ProviderListFragment provider_list_fragment = (ProviderListFragment) getFragmentManager().findFragmentByTag("providerlist");
- provider_list_fragment.notifyAdapter();
+ provider_list_fragment.addItem(added_provider);
}
- });
+ });*/
}
/**
diff --git a/src/se/leap/bitmaskclient/ProviderAPI.java b/src/se/leap/bitmaskclient/ProviderAPI.java index 268275e2..8542aa92 100644 --- a/src/se/leap/bitmaskclient/ProviderAPI.java +++ b/src/se/leap/bitmaskclient/ProviderAPI.java @@ -488,7 +488,9 @@ public class ProviderAPI extends IntentService { private Bundle updateProviderDotJSON(Bundle task) { Bundle result = new Bundle(); boolean danger_on = task.getBoolean(ProviderItem.DANGER_ON); - String provider_json_url = task.getString(Provider.MAIN_URL) + "/provider.json"; + String provider_main_url = task.getString(Provider.MAIN_URL); + String provider_name = provider_main_url.replaceFirst("http[s]?://", "").replaceFirst("\\/", "_"); + String provider_json_url = provider_main_url + "/provider.json"; try { String provider_dot_json_string = downloadWithCommercialCA(provider_json_url, danger_on); @@ -503,6 +505,7 @@ public class ProviderAPI extends IntentService { } else { ConfigHelper.saveSharedPref(EIP.ALLOWED_ANON, provider_json.getJSONObject(Provider.SERVICE).getBoolean(EIP.ALLOWED_ANON)); + result.putString(Provider.NAME, added_provider.name()); result.putBoolean(RESULT_KEY, true); result.putString(Provider.KEY, provider_json.toString()); result.putBoolean(ProviderItem.DANGER_ON, danger_on); diff --git a/src/se/leap/bitmaskclient/ProviderListAdapter.java b/src/se/leap/bitmaskclient/ProviderListAdapter.java index 19c4f72c..bb1318fc 100644 --- a/src/se/leap/bitmaskclient/ProviderListAdapter.java +++ b/src/se/leap/bitmaskclient/ProviderListAdapter.java @@ -1,5 +1,6 @@ package se.leap.bitmaskclient; +import java.lang.reflect.Array; import java.util.List; import android.content.Context; @@ -10,7 +11,6 @@ import android.widget.ArrayAdapter; import android.widget.TwoLineListItem; public class ProviderListAdapter<T> extends ArrayAdapter<T> { - private T[] items = null; private static boolean[] hidden = null; public void hide(int position) { @@ -42,7 +42,7 @@ public class ProviderListAdapter<T> extends ArrayAdapter<T> { } private int getHiddenCount() { int count = 0; - for(int i=0;i<items.length;i++) + for(int i=0;i<hidden.length;i++) if(hidden[i]) count++; return count; @@ -58,25 +58,23 @@ public class ProviderListAdapter<T> extends ArrayAdapter<T> { @Override public int getCount() { - return (items.length - getHiddenCount()); + return (hidden.length - getHiddenCount()); } public ProviderListAdapter(Context mContext, int layout, List<T> objects) { super(mContext, layout, objects); - items = objects.toArray((T[])new Object[0]); if(hidden == null) { - hidden = new boolean[items.length]; - for (int i = 0; i < items.length; i++) + hidden = new boolean[objects.size()]; + for (int i = 0; i < objects.size(); i++) hidden[i] = false; } } public ProviderListAdapter(Context mContext, int layout, List<T> objects, boolean show_all_providers) { super(mContext, layout, objects); - items = objects.toArray((T[])new Object[0]); if(show_all_providers) { - hidden = new boolean[items.length]; - for (int i = 0; i < items.length; i++) + hidden = new boolean[objects.size()]; + for (int i = 0; i < objects.size(); i++) hidden[i] = false; } } @@ -101,8 +99,8 @@ public class ProviderListAdapter<T> extends ArrayAdapter<T> { row = (TwoLineListItem)convertView; } ProviderListContent.ProviderItem data = ProviderListContent.ITEMS.get(position); - row.getText1().setText(data.domain); - row.getText2().setText(data.name); + row.getText1().setText(data.domain()); + row.getText2().setText(data.name()); return row; } diff --git a/src/se/leap/bitmaskclient/ProviderListContent.java b/src/se/leap/bitmaskclient/ProviderListContent.java index 3695066c..af61dbd6 100644 --- a/src/se/leap/bitmaskclient/ProviderListContent.java +++ b/src/se/leap/bitmaskclient/ProviderListContent.java @@ -61,7 +61,6 @@ public class ProviderListContent { public static class ProviderItem {
final public static String CUSTOM = "custom";
final public static String DANGER_ON = "danger_on";
- private boolean custom = false;
private String provider_main_url;
private String name;
private boolean danger_on = false; @@ -80,8 +79,7 @@ public class ProviderListContent { String urls_file_content = new String(urls_file_bytes);
JSONObject file_contents = new JSONObject(urls_file_content); provider_main_url = file_contents.getString(Provider.MAIN_URL);
- this.name = name; - this.custom = custom;
+ this.name = name;
this.danger_on = danger_on;
} catch (JSONException e) {
// TODO Auto-generated catch block
@@ -99,17 +97,14 @@ public class ProviderListContent { * @param custom if it's a new provider entered by the user or not
* @param danger_on if the user trusts completely the new provider
*/ - public ProviderItem(String name, String provider_main_url, boolean custom, boolean danger_on) {
+ public ProviderItem(String name, String provider_main_url, boolean danger_on) {
this.name = name;
this.provider_main_url = provider_main_url;
- this.custom = custom;
this.danger_on = danger_on; }
public String name() { return name; }
- public boolean custom() { return custom; }
-
public String providerMainUrl() { return provider_main_url; }
public String domain() {
diff --git a/src/se/leap/bitmaskclient/ProviderListFragment.java b/src/se/leap/bitmaskclient/ProviderListFragment.java index 62dcef7a..6a0f2a05 100644 --- a/src/se/leap/bitmaskclient/ProviderListFragment.java +++ b/src/se/leap/bitmaskclient/ProviderListFragment.java @@ -199,6 +199,7 @@ public class ProviderListFragment extends ListFragment { public void addItem(ProviderItem provider) {
content_adapter.add(provider);
+ content_adapter.notifyDataSetChanged();
}
public void hide(int position) {
|