diff options
author | Parménides GV <parmegv@sdf.org> | 2013-09-02 19:52:17 +0200 |
---|---|---|
committer | cyBerta <richy@cyborgsociety.org> | 2013-11-15 23:25:16 +0100 |
commit | e865889715b8511dd432b89958e27975592d98ea (patch) | |
tree | 62496deb4f66cd3127b6511a9c5068557c5fb0cd /src/se/leap/bitmaskclient | |
parent | 1d57d052814b8d46f3bdc850893171f238cdb2ef (diff) |
New provider hides other providers.
If a new provider is added, it gets selected automatically hiding all
other providers, as if it had been selected clicking on it.
Diffstat (limited to 'src/se/leap/bitmaskclient')
4 files changed, 45 insertions, 24 deletions
diff --git a/src/se/leap/bitmaskclient/ConfigurationWizard.java b/src/se/leap/bitmaskclient/ConfigurationWizard.java index 0a0858ec..94400eaa 100644 --- a/src/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/src/se/leap/bitmaskclient/ConfigurationWizard.java @@ -61,6 +61,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn private ProviderItem mSelectedProvider;
private ProgressBar mProgressBar;
+ private ProviderListFragment provider_list_fragment;
private Intent mConfigState = new Intent();
final public static String TYPE_OF_CERTIFICATE = "type_of_certificate";
@@ -91,7 +92,7 @@ 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)
- ProviderListFragment provider_list_fragment = new ProviderListFragment();
+ provider_list_fragment = new ProviderListFragment();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
@@ -103,16 +104,23 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn }
public void refreshProviderList(int top_padding) {
- ProviderListFragment providerList = new ProviderListFragment();
+ ProviderListFragment new_provider_list_fragment = new ProviderListFragment();
Bundle top_padding_bundle = new Bundle();
top_padding_bundle.putInt(getResources().getString(R.string.top_padding), top_padding);
- providerList.setArguments(top_padding_bundle);
+ new_provider_list_fragment.setArguments(top_padding_bundle);
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
- .replace(R.id.configuration_wizard_layout, providerList, getResources().getString(R.string.provider_list_fragment_tag))
+ .replace(R.id.configuration_wizard_layout, new_provider_list_fragment, getResources().getString(R.string.provider_list_fragment_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))
+ .commit();
+ }
@Override
public void onReceiveResult(int resultCode, Bundle resultData) {
@@ -126,17 +134,21 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn ConfigHelper.saveSharedPref(EIP.ALLOWED_ANON, provider_json.getJSONObject(Provider.SERVICE).getBoolean(EIP.ALLOWED_ANON));
mConfigState.setAction(PROVIDER_SET);
-
if(resultData.containsKey(Provider.NAME)) {
String provider_id = resultData.getString(Provider.NAME);
mSelectedProvider = getProvider(provider_id);
-
+ provider_list_fragment.addItem(mSelectedProvider);
+ ProviderListContent.removeItem(mSelectedProvider);
+
if(mSelectedProvider.custom)
refreshProviderList(0);
-
+
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.hide(provider_index-2);
+ //setProviderList(provider_list_fragment);
}
mProgressBar.incrementProgressBy(1);
}
@@ -240,12 +252,6 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn return null;
}
- private void startProgressBar() {
- mProgressBar.setVisibility(ProgressBar.VISIBLE);
- mProgressBar.setProgress(0);
- mProgressBar.setMax(3);
- }
-
private void startProgressBar(int list_item_index) {
mProgressBar.setVisibility(ProgressBar.VISIBLE);
mProgressBar.setProgress(0);
@@ -509,6 +515,12 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn fragment_transaction.replace(R.id.configuration_wizard_layout, newFragment, AboutFragment.TAG).commit();
}
}
+
+ public void unhideAll() {
+ provider_list_fragment.unhideAll();
+ setProviderList(provider_list_fragment);
+ refreshProviderList(0);
+ }
@Override
public void login() {
diff --git a/src/se/leap/bitmaskclient/ProviderDetailFragment.java b/src/se/leap/bitmaskclient/ProviderDetailFragment.java index 2616cdbf..8ec7d154 100644 --- a/src/se/leap/bitmaskclient/ProviderDetailFragment.java +++ b/src/se/leap/bitmaskclient/ProviderDetailFragment.java @@ -82,19 +82,12 @@ public class ProviderDetailFragment extends DialogFragment { @Override
public void onCancel(DialogInterface dialog) {
- super.onCancel(dialog);
-<<<<<<< HEAD + super.onCancel(dialog); ConfigHelper.removeFromSharedPref(Provider.KEY);
ConfigHelper.removeFromSharedPref(ProviderItem.DANGER_ON);
ConfigHelper.removeFromSharedPref(EIP.ALLOWED_ANON);
- ConfigHelper.removeFromSharedPref(EIP.KEY);
-======= - ConfigHelper.removeFromSharedPref(ConfigHelper.PROVIDER_KEY);
- ConfigHelper.removeFromSharedPref(ConfigHelper.DANGER_ON);
- ConfigHelper.removeFromSharedPref(ConfigHelper.ALLOWED_ANON);
- ConfigHelper.removeFromSharedPref(ConfigHelper.EIP_SERVICE_KEY);
- interface_with_configuration_wizard.refreshProviderList(0);
->>>>>>> Only selected provider remain visible. + ConfigHelper.removeFromSharedPref(EIP.KEY); + interface_with_configuration_wizard.unhideAll(); }
public static DialogFragment newInstance() {
@@ -116,7 +109,7 @@ public class ProviderDetailFragment extends DialogFragment { public interface ProviderDetailFragmentInterface {
public void login();
public void use_anonymously();
- public void refreshProviderList(int top_padding);
+ public void unhideAll();
}
ProviderDetailFragmentInterface interface_with_configuration_wizard;
diff --git a/src/se/leap/bitmaskclient/ProviderListContent.java b/src/se/leap/bitmaskclient/ProviderListContent.java index 940a594d..75d91733 100644 --- a/src/se/leap/bitmaskclient/ProviderListContent.java +++ b/src/se/leap/bitmaskclient/ProviderListContent.java @@ -48,6 +48,10 @@ public class ProviderListContent { ITEMS.add(item);
ITEM_MAP.put(String.valueOf(ITEMS.size()), item);
}
+ public static void removeItem(ProviderItem item) {
+ ITEMS.remove(item);
+ ITEM_MAP.remove(item);
+ }
/**
* A provider item.
diff --git a/src/se/leap/bitmaskclient/ProviderListFragment.java b/src/se/leap/bitmaskclient/ProviderListFragment.java index d7ead700..8ccabd8f 100644 --- a/src/se/leap/bitmaskclient/ProviderListFragment.java +++ b/src/se/leap/bitmaskclient/ProviderListFragment.java @@ -182,4 +182,16 @@ public class ProviderListFragment extends ListFragment { mActivatedPosition = position;
}
+
+ public void addItem(ProviderItem provider) {
+ content_adapter.add(provider);
+ }
+
+ public void hide(int position) {
+ content_adapter.hide(position);
+ }
+
+ public void unhideAll() {
+ content_adapter.unHideAll();
+ }
}
|