From a904408946b058496e6c34e4987212ede32e469a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 14 Oct 2013 13:23:51 +0200 Subject: Going back from providerdetails show all providers I missed a notifyDataSetChanged. --- src/se/leap/bitmaskclient/Dashboard.java | 8 +- src/se/leap/bitmaskclient/EipServiceFragment.java | 5 +- src/se/leap/bitmaskclient/ProviderListAdapter.java | 109 +++++++++++++++++++++ .../leap/bitmaskclient/ProviderListFragment.java | 4 +- src/se/leap/leapclient/ProviderListAdapter.java | 109 --------------------- 5 files changed, 120 insertions(+), 115 deletions(-) create mode 100644 src/se/leap/bitmaskclient/ProviderListAdapter.java delete mode 100644 src/se/leap/leapclient/ProviderListAdapter.java (limited to 'src') 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 extends ArrayAdapter { + 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 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 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(); + } } /** diff --git a/src/se/leap/leapclient/ProviderListAdapter.java b/src/se/leap/leapclient/ProviderListAdapter.java deleted file mode 100644 index baaa10ba..00000000 --- a/src/se/leap/leapclient/ProviderListAdapter.java +++ /dev/null @@ -1,109 +0,0 @@ -package se.leap.leapclient; - -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 extends ArrayAdapter { - 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 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 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; - } -} -- cgit v1.2.3