diff options
| author | Parménides GV <parmegv@sdf.org> | 2013-06-27 20:29:33 +0200 | 
|---|---|---|
| committer | Sean Leonard <meanderingcode@aetherislands.net> | 2013-07-12 11:38:44 -0600 | 
| commit | 9e7693c112a7c85cae998ae538643cda9660ff7c (patch) | |
| tree | 93f97ee5d8c1f1f3ef34c61c3953270ade4c2d72 | |
| parent | 872bcd1e5044b3b0119ae8ff2eff5509c5ee3274 (diff) | |
Coded new fragment appearance
Domain, name and description come from provider.json
Next step: code buttons to login or to use anonymously.
| -rw-r--r--[l---------] | README | 66 | ||||
| -rw-r--r-- | res/layout/configuration_wizard_activity.xml (renamed from res/layout/activity_configuration_wizard.xml) | 0 | ||||
| -rw-r--r-- | res/layout/provider_detail_fragment.xml | 40 | ||||
| -rwxr-xr-x | res/values/strings.xml | 7 | ||||
| -rw-r--r-- | src/se/leap/leapclient/ConfigHelper.java | 6 | ||||
| -rw-r--r-- | src/se/leap/leapclient/ConfigurationWizard.java | 23 | ||||
| -rw-r--r-- | src/se/leap/leapclient/LogInDialog.java | 2 | ||||
| -rw-r--r-- | src/se/leap/leapclient/ProviderDetailFragment.java | 54 | 
8 files changed, 191 insertions, 7 deletions
| @@ -1 +1,65 @@ -README.txt
\ No newline at end of file +Compiling +========= + +Preconditions +---------------- + +1. Android SDK installed (follow instructions from http://developer.android.com/sdk/index.html) +2. API version 16 or version installed. +2. Ant 1.6 or greater + +Instructions to compile +----------------------- + +1. cd $PROJECT_LOCATION/leap_android +2. ./compile.sh + +Postconditions +-------------- + +1. $PROJECT_LOCATION/leap_android/bin/LEAP Android-debug.apk exists + +Running on the emulator +========================= + +Preconditions +----------------- + +1. Android SDK is installed, and its tools are in the PATH. +2. leap_android has been compiled. +3. An avd exists in ~/.android/avd/ (if you do not have one, follow instructions from http://developer.android.com/tools/devices/managing-avds-cmdline.html) + +Instructions to run on the emulator +----------------------------------- + +1. cd $PROJECT_LOCATION/leap_android +1. Run script: ./run.sh @AVD-NAME . (avd names are the names of the files in ~/.android/avd with extension .avd). + +Postconditions +-------------- + +1. LEAP Android is running. + +Debugging from console +====================== + +Preconditions +----------------- + +1. Android SDK is installed, and its tools are in the PATH. +2. leap_android has been compiled. +3. An avd exists in ~/.android/avd/ (if you do not have one, follow instructions from http://developer.android.com/tools/devices/managing-avds-cmdline.html). +4. jdb is installed (this program is part of OpenJDK 7) + +Instructions to debug from the console +----------------------------------- + +1. cd $PROJECT_LOCATION/leap_android +2. Run script: ./debug.sh @AVD-NAME . (avd names are the names of the files in ~/.android/avd with extension .avd). + +Postconditions +-------------- + +1. LEAP Android is running. +2. LEAP Android does not show the message "Application LEAP for Android (process se.leap.leapclient) is waiting for the debugger to attach". +3. You are in a jdb debuggin session. diff --git a/res/layout/activity_configuration_wizard.xml b/res/layout/configuration_wizard_activity.xml index 264ccf9..264ccf9 100644 --- a/res/layout/activity_configuration_wizard.xml +++ b/res/layout/configuration_wizard_activity.xml diff --git a/res/layout/provider_detail_fragment.xml b/res/layout/provider_detail_fragment.xml new file mode 100644 index 0000000..eb90fad --- /dev/null +++ b/res/layout/provider_detail_fragment.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +    android:layout_width="match_parent" +    android:layout_height="match_parent" +    android:orientation="vertical" > + +    <TextView +        android:id="@+id/provider_detail_domain" +        android:layout_width="wrap_content" +        android:layout_height="wrap_content" +        android:layout_marginBottom="4dp" +        android:layout_marginLeft="4dp" +        android:layout_marginRight="4dp" +        android:layout_marginTop="16dp" +        android:textAppearance="?android:attr/textAppearanceLarge" +        android:textStyle="bold" /> + +    <TextView +        android:id="@+id/provider_detail_name" +        android:layout_width="wrap_content" +        android:layout_height="wrap_content" +        android:layout_marginTop="16dp" +        android:layout_marginLeft="4dp" +        android:layout_marginRight="4dp" +        android:layout_marginBottom="4dp" +        android:textStyle="italic" +        android:textAppearance="?android:attr/textAppearanceMedium" /> + +    <TextView +        android:id="@+id/provider_detail_description" +        android:layout_width="wrap_content" +        android:layout_height="wrap_content" +        android:layout_marginTop="16dp" +        android:layout_marginLeft="4dp" +        android:layout_marginRight="4dp" +        android:layout_marginBottom="4dp" +        android:textStyle="normal" +        android:textAppearance="?android:attr/textAppearanceSmall" /> + +</LinearLayout>
\ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 80dd85b..0cc3593 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -268,9 +268,13 @@      <string name="new_provider_uri">New provider\'s main URL</string>      <string name="valid_url_entered">It seems your URL is well formed</string>      <string name="not_valid_url_entered">It seems your URL is not well formed</string> +    <string name="provider_details_fragment_title">Provider details</string> +    <string name="domain">Domain</string> +    <string name="name">Name</string> +    <string name="description">Description</string> +    <string name="use_anonymously_button">Use anonymously</string>      <string name="username_ask">Introduce your username</string>      <string name="password_ask">Enter your password</string> -    <string name="log_in_button">Log in</string>      <string name="login_button">Log In</string>      <string name="logout_button">Log Out</string>      <string name="danger_checkbox">Trust completely</string> @@ -295,6 +299,5 @@      <string name="log_out_failed_message">Didn\'t logged out.</string>      <string name="successful_authed_cert_downloaded_message">Your own cert has been correctly downloaded.</string>      <string name="authed_cert_download_failed_message">Your own cert has incorrectly been downloaded.</string> -      </resources> diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java index 9a3bd99..e049642 100644 --- a/src/se/leap/leapclient/ConfigHelper.java +++ b/src/se/leap/leapclient/ConfigHelper.java @@ -76,7 +76,11 @@ public class ConfigHelper {      EIP_SERVICE_API_PATH = "config/eip-service.json",      ERRORS_KEY = "errors",      RECEIVER_TAG = "receiverTag", -    REQUEST_TAG = "requestTag"; +    REQUEST_TAG = "requestTag", +    PROVIDER_DETAILS_DIALOG = "providerDetailsFragment", +    DOMAIN = "domain", +    NAME = "name", +    DESCRIPTION = "description"      ;      final public static String NG_1024 = diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java index 6bf94ca..6c01620 100644 --- a/src/se/leap/leapclient/ConfigurationWizard.java +++ b/src/se/leap/leapclient/ConfigurationWizard.java @@ -46,7 +46,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
 -        setContentView(R.layout.activity_configuration_wizard);
 +        setContentView(R.layout.configuration_wizard_activity);
          providerAPI_result_receiver = new ProviderAPIResultReceiver(new Handler());
          providerAPI_result_receiver.setReceiver(this);
 @@ -124,7 +124,8 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn  			Toast.makeText(getApplicationContext(), R.string.success, Toast.LENGTH_LONG).show();
  			//mConfigState.putExtra(CERTIFICATE_RETRIEVED, true); // If this isn't the last step and finish() is moved...
  			setResult(RESULT_OK);
 -			finish();
 +			//finish();
 +			showProviderDetails(getCurrentFocus());
  		} else if(resultCode == ConfigHelper.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
  			mProgressDialog.dismiss();
  			Toast.makeText(getApplicationContext(), R.string.incorrectly_downloaded_certificate_message, Toast.LENGTH_LONG).show();
 @@ -268,6 +269,24 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn  		DialogFragment newFragment = NewProviderDialog.newInstance();
  		newFragment.show(fragment_transaction, ConfigHelper.NEW_PROVIDER_DIALOG);
  	}
 +	
 +	/**
 +	 * 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 showProviderDetails(View view) {
 +		FragmentTransaction fragment_transaction = getFragmentManager().beginTransaction();
 +		Fragment previous_provider_details_dialog = getFragmentManager().findFragmentByTag(ConfigHelper.PROVIDER_DETAILS_DIALOG);
 +		if (previous_provider_details_dialog != null) {
 +			fragment_transaction.remove(previous_provider_details_dialog);
 +		}
 +		fragment_transaction.addToBackStack(null);
 +		
 +		DialogFragment newFragment = ProviderDetailFragment.newInstance();
 +		newFragment.show(fragment_transaction, ConfigHelper.PROVIDER_DETAILS_DIALOG);
 +	}
  	@Override
  	public void saveAndSelectProvider(String provider_main_url, boolean danger_on) {
 diff --git a/src/se/leap/leapclient/LogInDialog.java b/src/se/leap/leapclient/LogInDialog.java index dcb92d8..3b240ba 100644 --- a/src/se/leap/leapclient/LogInDialog.java +++ b/src/se/leap/leapclient/LogInDialog.java @@ -32,7 +32,7 @@ public class LogInDialog extends DialogFragment {  		final EditText password_field = (EditText)log_in_dialog_view.findViewById(R.id.password_entered);  		builder.setView(log_in_dialog_view) -			.setPositiveButton(R.string.log_in_button, new DialogInterface.OnClickListener() { +			.setPositiveButton(R.string.login_button, new DialogInterface.OnClickListener() {  				public void onClick(DialogInterface dialog, int id) {  					String username = username_field.getText().toString().trim();  					String password = password_field.getText().toString().trim(); diff --git a/src/se/leap/leapclient/ProviderDetailFragment.java b/src/se/leap/leapclient/ProviderDetailFragment.java new file mode 100644 index 0000000..d061a70 --- /dev/null +++ b/src/se/leap/leapclient/ProviderDetailFragment.java @@ -0,0 +1,54 @@ +package se.leap.leapclient;
 +
 +import org.json.JSONException;
 +import org.json.JSONObject;
 +
 +import android.app.AlertDialog;
 +import android.app.Dialog;
 +import android.app.DialogFragment;
 +import android.content.DialogInterface;
 +import android.os.Bundle;
 +import android.view.LayoutInflater;
 +import android.view.View;
 +import android.widget.TextView;
 +
 +public class ProviderDetailFragment extends DialogFragment {
 +	@Override
 +	public Dialog onCreateDialog(Bundle savedInstanceState) {
 +		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
 +		try {
 +
 +			LayoutInflater inflater = getActivity().getLayoutInflater();
 +			View provider_detail_view = inflater.inflate(R.layout.provider_detail_fragment, null);
 +			
 +			JSONObject provider_json = ConfigHelper.getJsonFromSharedPref(ConfigHelper.PROVIDER_KEY);
 +			
 +			final TextView domain = (TextView)provider_detail_view.findViewById(R.id.provider_detail_domain);
 +			domain.setText(provider_json.getString(ConfigHelper.DOMAIN));
 +			final TextView name = (TextView)provider_detail_view.findViewById(R.id.provider_detail_name);
 +			name.setText(provider_json.getJSONObject(ConfigHelper.NAME).getString("en"));
 +			final TextView description = (TextView)provider_detail_view.findViewById(R.id.provider_detail_description);
 +			description.setText(provider_json.getJSONObject(ConfigHelper.DESCRIPTION).getString("en"));
 +			
 +			builder.setView(provider_detail_view);
 +			builder.setTitle(R.string.provider_details_fragment_title);
 +			builder.setPositiveButton(R.string.use_anonymously_button, new DialogInterface.OnClickListener() {
 +				public void onClick(DialogInterface dialog, int id) {
 +				}
 +			});
 +			builder.setNegativeButton(R.string.login_button, new DialogInterface.OnClickListener() {
 +				public void onClick(DialogInterface dialog, int id) {
 +				}
 +			});
 +			
 +			return builder.create();
 +		} catch (JSONException e) {
 +			return null;
 +		}
 +	}
 +
 +	public static DialogFragment newInstance() {
 +		ProviderDetailFragment provider_detail_fragment = new ProviderDetailFragment();
 +		return provider_detail_fragment;
 +	}
 +}
 | 
