summaryrefslogtreecommitdiff
path: root/src/se/leap/bitmaskclient
diff options
context:
space:
mode:
Diffstat (limited to 'src/se/leap/bitmaskclient')
-rw-r--r--src/se/leap/bitmaskclient/Dashboard.java8
-rw-r--r--src/se/leap/bitmaskclient/EipServiceFragment.java5
-rw-r--r--src/se/leap/bitmaskclient/ProviderListAdapter.java109
-rw-r--r--src/se/leap/bitmaskclient/ProviderListFragment.java4
4 files changed, 120 insertions, 6 deletions
diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java
index 5066f286..103310bb 100644
--- a/src/se/leap/bitmaskclient/Dashboard.java
+++ b/src/se/leap/bitmaskclient/Dashboard.java
@@ -89,7 +89,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
app = this;
PRNGFixes.apply();
- mProgressBar = (ProgressBar) findViewById(R.id.progressbar_dashboard);
+ //mProgressBar = (ProgressBar) findViewById(R.id.progressbar_dashboard);
providerAPI_broadcast_receiver_update = new ProviderAPIBroadcastReceiver_Update();
@@ -434,7 +434,13 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
public static Context getAppContext() {
return app;
}
+
+ @Override
+ public void startActivityForResult(Intent intent, int requestCode) {
+ intent.putExtra(Dashboard.REQUEST_CODE, requestCode);
+ super.startActivityForResult(intent, requestCode);
+ }
/**
* Send a command to EIP
*
diff --git a/src/se/leap/bitmaskclient/EipServiceFragment.java b/src/se/leap/bitmaskclient/EipServiceFragment.java
index 0d73f544..4d778b1a 100644
--- a/src/se/leap/bitmaskclient/EipServiceFragment.java
+++ b/src/se/leap/bitmaskclient/EipServiceFragment.java
@@ -178,11 +178,8 @@ public class EipServiceFragment extends Fragment implements StateListener, OnCli
String statusMessage = "";
String prefix = getString(localizedResId);
if (state.equals("CONNECTED")){
-<<<<<<< HEAD
+
statusMessage = getString(R.string.eip_state_connected);
-=======
- statusMessage = getResources().getString(R.string.connection_secure);
->>>>>>> Dashboard asks for real VPN state.
getActivity().findViewById(R.id.eipProgress).setVisibility(View.GONE);
mEipStartPending = false;
} else if (state.equals("BYTECOUNT")) {
diff --git a/src/se/leap/bitmaskclient/ProviderListAdapter.java b/src/se/leap/bitmaskclient/ProviderListAdapter.java
new file mode 100644
index 00000000..19c4f72c
--- /dev/null
+++ b/src/se/leap/bitmaskclient/ProviderListAdapter.java
@@ -0,0 +1,109 @@
+package se.leap.bitmaskclient;
+
+import java.util.List;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+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) {
+ hidden[getRealPosition(position)] = true;
+ notifyDataSetChanged();
+ notifyDataSetInvalidated();
+ }
+
+ public void unHide(int position) {
+ hidden[getRealPosition(position)] = false;
+ notifyDataSetChanged();
+ notifyDataSetInvalidated();
+ }
+
+ public void unHideAll() {
+ for (int provider_index = 0; provider_index < hidden.length; provider_index++)
+ hidden[provider_index] = false;
+ }
+
+ private int getRealPosition(int position) {
+ int hElements = getHiddenCountUpTo(position);
+ int diff = 0;
+ for(int i=0;i<hElements;i++) {
+ diff++;
+ if(hidden[position+diff])
+ i--;
+ }
+ return (position + diff);
+ }
+ private int getHiddenCount() {
+ int count = 0;
+ for(int i=0;i<items.length;i++)
+ if(hidden[i])
+ count++;
+ return count;
+ }
+ private int getHiddenCountUpTo(int location) {
+ int count = 0;
+ for(int i=0;i<=location;i++) {
+ if(hidden[i])
+ count++;
+ }
+ return count;
+ }
+
+ @Override
+ public int getCount() {
+ return (items.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[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[i] = false;
+ }
+ }
+
+ @Override
+ public void add(T item) {
+ super.add(item);
+ boolean[] new_hidden = new boolean[hidden.length+1];
+ System.arraycopy(hidden, 0, new_hidden, 0, hidden.length);
+ new_hidden[hidden.length] = false;
+ hidden = new_hidden;
+ }
+
+ @Override
+ public View getView(int index, View convertView, ViewGroup parent) {
+ TwoLineListItem row;
+ int position = getRealPosition(index);
+ if (convertView == null) {
+ LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ row = (TwoLineListItem)inflater.inflate(android.R.layout.simple_list_item_2, null);
+ } else {
+ row = (TwoLineListItem)convertView;
+ }
+ ProviderListContent.ProviderItem data = ProviderListContent.ITEMS.get(position);
+ row.getText1().setText(data.domain);
+ row.getText2().setText(data.name);
+
+ return row;
+ }
+}
diff --git a/src/se/leap/bitmaskclient/ProviderListFragment.java b/src/se/leap/bitmaskclient/ProviderListFragment.java
index 61ed040a..84d46a11 100644
--- a/src/se/leap/bitmaskclient/ProviderListFragment.java
+++ b/src/se/leap/bitmaskclient/ProviderListFragment.java
@@ -203,8 +203,10 @@ public class ProviderListFragment extends ListFragment {
}
public void unhideAll() {
- if(content_adapter != null)
+ if(content_adapter != null) {
content_adapter.unHideAll();
+ content_adapter.notifyDataSetChanged();
+ }
}
/**