diff options
author | Parménides GV <parmegv@sdf.org> | 2013-10-03 16:41:53 +0200 |
---|---|---|
committer | cyBerta <richy@cyborgsociety.org> | 2013-11-15 23:25:17 +0100 |
commit | 76d52773a237da8fcae3670a959bbe2bfe609796 (patch) | |
tree | 9c55428d69537f98b4bdb7b7ff668fc0eb4c3a9b /src/se/leap | |
parent | 180b4d31526e442dd4978ca321a304f26b32240c (diff) |
Switching provider offers all providers from list.
This fixes bug #4004: With new progress bars branch, if user switches provider the list of providers is not complete.
Diffstat (limited to 'src/se/leap')
-rw-r--r-- | src/se/leap/bitmaskclient/ConfigurationWizard.java | 33 | ||||
-rw-r--r-- | src/se/leap/bitmaskclient/Dashboard.java | 10 | ||||
-rw-r--r-- | src/se/leap/bitmaskclient/ProviderDetailFragment.java | 4 | ||||
-rw-r--r-- | src/se/leap/bitmaskclient/ProviderListFragment.java | 29 | ||||
-rw-r--r-- | src/se/leap/leapclient/ProviderListAdapter.java | 10 |
5 files changed, 65 insertions, 21 deletions
diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java index 5839816b..28a8a44a 100644 --- a/src/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java @@ -31,6 +31,7 @@ import android.app.DialogFragment; import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
+import android.app.ListFragment;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetManager;
@@ -96,12 +97,18 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn if ( savedInstanceState == null ){
// TODO Some welcome screen?
// We will need better flow control when we have more Fragments (e.g. user auth)
- provider_list_fragment = new ProviderListFragment();
-
- FragmentManager fragmentManager = getFragmentManager();
- fragmentManager.beginTransaction()
- .add(R.id.configuration_wizard_layout, provider_list_fragment, getResources().getString(R.string.provider_list_fragment_tag))
- .commit();
+ provider_list_fragment = ProviderListFragment.newInstance();
+ Bundle arguments = new Bundle();
+ int configuration_wizard_request_code = getIntent().getIntExtra(Dashboard.REQUEST_CODE, -1);
+ if(configuration_wizard_request_code == Dashboard.SWITCH_PROVIDER) {
+ arguments.putBoolean(ProviderListFragment.SHOW_ALL_PROVIDERS, true);
+ }
+ provider_list_fragment.setArguments(arguments);
+
+ FragmentManager fragmentManager = getFragmentManager();
+ fragmentManager.beginTransaction()
+ .replace(R.id.configuration_wizard_layout, provider_list_fragment, ProviderListFragment.TAG)
+ .commit();
}
// TODO: If exposing deep links into your app, handle intents here.
@@ -115,14 +122,14 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
- .replace(R.id.configuration_wizard_layout, new_provider_list_fragment, getResources().getString(R.string.provider_list_fragment_tag))
+ .replace(R.id.configuration_wizard_layout, new_provider_list_fragment, ProviderListFragment.TAG)
.commit();
}
private void setProviderList(ProviderListFragment new_provider_list_fragment) {
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
- .replace(R.id.configuration_wizard_layout, new_provider_list_fragment, getResources().getString(R.string.provider_list_fragment_tag))
+ .replace(R.id.configuration_wizard_layout, new_provider_list_fragment, ProviderListFragment.TAG)
.commit();
}
@@ -150,7 +157,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn if(!mProgressBar.isShown()) {
int provider_index = getProviderIndex(provider_id);
startProgressBar(provider_index);
- provider_list_fragment = (ProviderListFragment) getFragmentManager().findFragmentByTag(getResources().getString(R.string.provider_list_fragment_tag));
+ provider_list_fragment = (ProviderListFragment) getFragmentManager().findFragmentByTag(ProviderListFragment.TAG);
provider_list_fragment.hide(provider_index-2);
//setProviderList(provider_list_fragment);
}
@@ -528,10 +535,10 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn }
}
- public void unhideAll() {
- provider_list_fragment.unhideAll();
- setProviderList(provider_list_fragment);
- refreshProviderList(0);
+ public void showAllProviders() {
+ provider_list_fragment = (ProviderListFragment) getFragmentManager().findFragmentByTag(ProviderListFragment.TAG);
+ if(provider_list_fragment != null)
+ provider_list_fragment.unhideAll();
}
@Override
diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java index 5a2417ff..68b7d248 100644 --- a/src/se/leap/bitmaskclient/Dashboard.java +++ b/src/se/leap/bitmaskclient/Dashboard.java @@ -61,10 +61,12 @@ import android.widget.Toast; public class Dashboard extends Activity implements LogInDialog.LogInDialogInterface,Receiver { protected static final int CONFIGURE_LEAP = 0; + protected static final int SWITCH_PROVIDER = 1; private static final String TAG_EIP_FRAGMENT = "EIP_DASHBOARD_FRAGMENT"; final public static String SHARED_PREFERENCES = "LEAPPreferences"; final public static String ACTION_QUIT = "quit"; + public static final String REQUEST_CODE = "request_code"; private ProgressBar mProgressBar; private TextView eipStatus; @@ -225,7 +227,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf startActivity(intent); return true; case R.id.switch_provider: - startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP); + startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER); return true; case R.id.login_button: View view = ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0); @@ -403,6 +405,12 @@ 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); + } public class ProviderAPIBroadcastReceiver_Update extends BroadcastReceiver { diff --git a/src/se/leap/bitmaskclient/ProviderDetailFragment.java b/src/se/leap/bitmaskclient/ProviderDetailFragment.java index 8ec7d154..fd8b29d9 100644 --- a/src/se/leap/bitmaskclient/ProviderDetailFragment.java +++ b/src/se/leap/bitmaskclient/ProviderDetailFragment.java @@ -87,7 +87,7 @@ public class ProviderDetailFragment extends DialogFragment { ConfigHelper.removeFromSharedPref(ProviderItem.DANGER_ON);
ConfigHelper.removeFromSharedPref(EIP.ALLOWED_ANON);
ConfigHelper.removeFromSharedPref(EIP.KEY); - interface_with_configuration_wizard.unhideAll(); + interface_with_configuration_wizard.showAllProviders(); }
public static DialogFragment newInstance() {
@@ -109,7 +109,7 @@ public class ProviderDetailFragment extends DialogFragment { public interface ProviderDetailFragmentInterface {
public void login();
public void use_anonymously();
- public void unhideAll();
+ public void showAllProviders();
}
ProviderDetailFragmentInterface interface_with_configuration_wizard;
diff --git a/src/se/leap/bitmaskclient/ProviderListFragment.java b/src/se/leap/bitmaskclient/ProviderListFragment.java index 8ccabd8f..61ed040a 100644 --- a/src/se/leap/bitmaskclient/ProviderListFragment.java +++ b/src/se/leap/bitmaskclient/ProviderListFragment.java @@ -19,6 +19,7 @@ import se.leap.bitmaskclient.R;
import se.leap.bitmaskclient.ProviderListContent.ProviderItem;
import android.app.Activity;
+import android.app.DialogFragment;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -37,6 +38,9 @@ import android.widget.ListView; */
public class ProviderListFragment extends ListFragment {
+ public static String TAG = "provider_list_fragment";
+ public static String SHOW_ALL_PROVIDERS = "show_all_providers";
+
private ProviderListAdapter<ProviderItem> content_adapter;
/**
@@ -88,10 +92,17 @@ public class ProviderListFragment extends ListFragment { @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- content_adapter = new ProviderListAdapter<ProviderListContent.ProviderItem>(
- getActivity(),
- android.R.layout.simple_list_item_activated_2,
- ProviderListContent.ITEMS);
+ if(getArguments().containsKey(SHOW_ALL_PROVIDERS))
+ content_adapter = new ProviderListAdapter<ProviderListContent.ProviderItem>(
+ getActivity(),
+ android.R.layout.simple_list_item_activated_2,
+ ProviderListContent.ITEMS, getArguments().getBoolean(SHOW_ALL_PROVIDERS));
+ else
+ content_adapter = new ProviderListAdapter<ProviderListContent.ProviderItem>(
+ getActivity(),
+ android.R.layout.simple_list_item_activated_2,
+ ProviderListContent.ITEMS);
+
setListAdapter(content_adapter);
}
@@ -192,6 +203,14 @@ public class ProviderListFragment extends ListFragment { }
public void unhideAll() {
- content_adapter.unHideAll();
+ if(content_adapter != null)
+ content_adapter.unHideAll();
}
+
+ /**
+ * @return a new instance of this ListFragment.
+ */
+ public static ProviderListFragment newInstance() {
+ return new ProviderListFragment();
+ }
}
diff --git a/src/se/leap/leapclient/ProviderListAdapter.java b/src/se/leap/leapclient/ProviderListAdapter.java index e8782130..baaa10ba 100644 --- a/src/se/leap/leapclient/ProviderListAdapter.java +++ b/src/se/leap/leapclient/ProviderListAdapter.java @@ -70,6 +70,16 @@ public class ProviderListAdapter<T> extends ArrayAdapter<T> { 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) { |