From f6efff1a7ec06d68bad27cd65e66d33e72572c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Sat, 29 Jun 2013 17:07:44 +0200 Subject: Added menu to ConfigurationWizard. It only contains the "About LEAP" option. If the user clicks again that option while the About fragment is up, no new fragment is added and pressing 1 time the back button drives him/her to the ConfigurationWizard activity. --- res/menu/activity_configuration_wizard.xml | 9 ------ res/menu/configuration_wizard_activity.xml | 8 ++++++ src/se/leap/leapclient/ConfigHelper.java | 1 + src/se/leap/leapclient/ConfigurationWizard.java | 38 +++++++++++++++++++++++++ src/se/leap/openvpn/AboutFragment.java | 5 ++++ 5 files changed, 52 insertions(+), 9 deletions(-) delete mode 100644 res/menu/activity_configuration_wizard.xml create mode 100644 res/menu/configuration_wizard_activity.xml diff --git a/res/menu/activity_configuration_wizard.xml b/res/menu/activity_configuration_wizard.xml deleted file mode 100644 index 77f358b6..00000000 --- a/res/menu/activity_configuration_wizard.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/res/menu/configuration_wizard_activity.xml b/res/menu/configuration_wizard_activity.xml new file mode 100644 index 00000000..9e441a18 --- /dev/null +++ b/res/menu/configuration_wizard_activity.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java index acc4888a..10b3edf4 100644 --- a/src/se/leap/leapclient/ConfigHelper.java +++ b/src/se/leap/leapclient/ConfigHelper.java @@ -33,6 +33,7 @@ public class ConfigHelper { private static KeyStore keystore_trusted; final public static String + ABOUT_FRAGMENT = "aboutFragment", DOWNLOAD_JSON_FILES_BUNDLE_EXTRA = "downloadJSONFiles", UPDATE_PROVIDER_DOTJSON = "updateProviderDotJSON", DOWNLOAD_NEW_PROVIDER_DOTJSON = "downloadNewProviderDotJSON", diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java index 5eab3053..23220e79 100644 --- a/src/se/leap/leapclient/ConfigurationWizard.java +++ b/src/se/leap/leapclient/ConfigurationWizard.java @@ -9,6 +9,8 @@ import org.json.JSONObject; import se.leap.leapclient.ProviderAPIResultReceiver.Receiver; import se.leap.leapclient.ProviderListContent.ProviderItem; import se.leap.leapclient.R; +import se.leap.openvpn.AboutFragment; +import se.leap.openvpn.MainActivity; import android.app.Activity; import android.app.DialogFragment; import android.app.Fragment; @@ -19,7 +21,10 @@ import android.content.Intent; import android.content.res.AssetManager; import android.os.Bundle; import android.os.Handler; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; +import android.view.ViewGroup; /** * Activity that builds and shows the list of known available providers. @@ -329,6 +334,39 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn startService(provider_API_command); } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.configuration_wizard_activity, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item){ + switch (item.getItemId()){ + case R.id.about_leap: + showAboutFragment(getCurrentFocus()); + default: + return super.onOptionsItemSelected(item); + } + } + + /** + * Once selected a provider, this fragment offers the user to log in, + * use it anonymously (if possible) + * or cancel his/her election pressing the back button. + * @param view + */ + public void showAboutFragment(View view) { + FragmentTransaction fragment_transaction = getFragmentManager().beginTransaction(); + Fragment previous_about_fragment = getFragmentManager().findFragmentByTag(ConfigHelper.ABOUT_FRAGMENT); + if (previous_about_fragment == null) { + fragment_transaction.addToBackStack(null); + + Fragment newFragment = AboutFragment.newInstance(); + fragment_transaction.replace(R.id.configuration_wizard_layout, newFragment, ConfigHelper.ABOUT_FRAGMENT).commit(); + } + } @Override public void login() { diff --git a/src/se/leap/openvpn/AboutFragment.java b/src/se/leap/openvpn/AboutFragment.java index 3563528b..4f9f9f2e 100644 --- a/src/se/leap/openvpn/AboutFragment.java +++ b/src/se/leap/openvpn/AboutFragment.java @@ -15,6 +15,11 @@ import se.leap.leapclient.R; public class AboutFragment extends Fragment { + public static Fragment newInstance() { + AboutFragment instance = new AboutFragment(); + return instance; + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); -- cgit v1.2.3