summaryrefslogtreecommitdiff
path: root/src/se
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-06-20 16:52:43 +0200
committerParménides GV <parmegv@sdf.org>2013-06-20 16:53:14 +0200
commitf4956bb818fb9ed04760e6de3b53b876272da5cc (patch)
tree94b7b8629ea75a6e4db730aa20232103799ae7a0 /src/se
parentd475ae617d8dc0994a1294be7c8cca338a68fd9e (diff)
User messages are now in string.xml
Some more constants added to ConfigHelper. This solves #2908.
Diffstat (limited to 'src/se')
-rw-r--r--src/se/leap/leapclient/ConfigHelper.java6
-rw-r--r--src/se/leap/leapclient/ConfigurationWizard.java16
-rw-r--r--src/se/leap/leapclient/Dashboard.java18
-rw-r--r--src/se/leap/leapclient/LogInDialog.java2
-rw-r--r--src/se/leap/leapclient/NewProviderDialog.java4
-rw-r--r--src/se/leap/leapclient/ProviderAPI.java6
-rw-r--r--src/se/leap/leapclient/ProviderListContent.java6
7 files changed, 31 insertions, 27 deletions
diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java
index 5838f529..cb4a550f 100644
--- a/src/se/leap/leapclient/ConfigHelper.java
+++ b/src/se/leap/leapclient/ConfigHelper.java
@@ -40,11 +40,14 @@ public class ConfigHelper {
NEW_PROVIDER_DIALOG = "logInDialog",
SRP_REGISTER = "srpRegister",
SRP_AUTH = "srpAuth",
+ M1_KEY = "M1",
+ M2_KEY = "M2",
LOG_IN = "logIn",
LOG_OUT = "logOut",
DOWNLOAD_CERTIFICATE = "downloadUserAuthedCertificate",
API_VERSION_KEY = "api_version",
RESULT_KEY = "result",
+ RECEIVER_KEY = "receiver",
PROVIDER_KEY = "provider",
SERVICE_KEY = "service",
ALLOWED_ANON = "allow_anonymous",
@@ -68,7 +71,8 @@ public class ConfigHelper {
USERNAME_KEY = "username",
PASSWORD_KEY = "password",
ALLOW_REGISTRATION_KEY = "allow_registration",
- EIP_SERVICE_API_PATH = "config/eip-service.json"
+ EIP_SERVICE_API_PATH = "config/eip-service.json",
+ ERRORS_KEY = "errors"
;
final public static String NG_1024 =
diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java
index 91b92d65..ce279425 100644
--- a/src/se/leap/leapclient/ConfigurationWizard.java
+++ b/src/se/leap/leapclient/ConfigurationWizard.java
@@ -105,7 +105,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
}
else if(resultCode == ConfigHelper.INCORRECTLY_UPDATED_PROVIDER_DOT_JSON) {
mProgressDialog.dismiss();
- Toast.makeText(getApplicationContext(), "Install a new version of this app.", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.incorrectly_updated_provider_dot_json_message, Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, mConfigState);
finish();
}
@@ -122,20 +122,20 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
}
}
else if(resultCode == ConfigHelper.INCORRECTLY_DOWNLOADED_JSON_FILES) {
- Toast.makeText(getApplicationContext(), "You have not entered a LEAP provider URL or it is unavailable", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.incorrectly_downloaded_json_files_message, Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, mConfigState);
finish();
}
else if(resultCode == ConfigHelper.CORRECTLY_DOWNLOADED_CERTIFICATE) {
mProgressDialog.dismiss();
- Toast.makeText(getApplicationContext(), "Your anon cert has been correctly downloaded", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.correctly_downloaded_json_files_message, Toast.LENGTH_LONG).show();
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();
} else if(resultCode == ConfigHelper.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
mProgressDialog.dismiss();
- Toast.makeText(getApplicationContext(), "Your anon cert was not downloaded", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.incorrectly_downloaded_certificate_message, Toast.LENGTH_LONG).show();
setResult(RESULT_CANCELED, mConfigState);
finish();
}
@@ -236,7 +236,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
method_and_parameters.putBoolean(ConfigHelper.DANGER_ON, provider.danger_on);
provider_API_command.putExtra(ConfigHelper.DOWNLOAD_JSON_FILES_BUNDLE_EXTRA, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -252,7 +252,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
method_and_parameters.putString(ConfigHelper.TYPE_OF_CERTIFICATE, ConfigHelper.ANON_CERTIFICATE);
provider_API_command.putExtra(ConfigHelper.DOWNLOAD_CERTIFICATE, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -282,7 +282,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
method_and_parameters.putBoolean(ConfigHelper.DANGER_ON, danger_on);
provider_API_command.putExtra(ConfigHelper.DOWNLOAD_NEW_PROVIDER_DOTJSON, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -302,7 +302,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialog.NewProviderDialogIn
method_and_parameters.putBoolean(ConfigHelper.DANGER_ON, danger_on);
provider_API_command.putExtra(ConfigHelper.UPDATE_PROVIDER_DOTJSON, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
diff --git a/src/se/leap/leapclient/Dashboard.java b/src/se/leap/leapclient/Dashboard.java
index e8ea2705..dd8ee335 100644
--- a/src/se/leap/leapclient/Dashboard.java
+++ b/src/se/leap/leapclient/Dashboard.java
@@ -224,7 +224,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
}
provider_API_command.putExtra(ConfigHelper.SRP_AUTH, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -249,7 +249,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
}
provider_API_command.putExtra(ConfigHelper.LOG_OUT, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -286,7 +286,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
method_and_parameters.putString(ConfigHelper.SESSION_ID_KEY, session_id.getValue());
provider_API_command.putExtra(ConfigHelper.DOWNLOAD_CERTIFICATE, method_and_parameters);
- provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+ provider_API_command.putExtra(ConfigHelper.RECEIVER_KEY, providerAPI_result_receiver);
startService(provider_API_command);
}
@@ -297,25 +297,25 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
String session_id_cookie_key = resultData.getString(ConfigHelper.SESSION_ID_COOKIE_KEY);
String session_id_string = resultData.getString(ConfigHelper.SESSION_ID_KEY);
setResult(RESULT_OK);
- Toast.makeText(getApplicationContext(), "Authentication succeeded", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.succesful_authentication_message, Toast.LENGTH_LONG).show();
Cookie session_id = new BasicClientCookie(session_id_cookie_key, session_id_string);
downloadAuthedUserCertificate(session_id);
} else if(resultCode == ConfigHelper.SRP_AUTHENTICATION_FAILED) {
setResult(RESULT_CANCELED);
- Toast.makeText(getApplicationContext(), "Authentication failed", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.authentication_failed_message, Toast.LENGTH_LONG).show();
} else if(resultCode == ConfigHelper.LOGOUT_SUCCESSFUL) {
setResult(RESULT_OK);
- Toast.makeText(getApplicationContext(), "Logged out", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.successful_log_out_message, Toast.LENGTH_LONG).show();
} else if(resultCode == ConfigHelper.LOGOUT_FAILED) {
setResult(RESULT_CANCELED);
- Toast.makeText(getApplicationContext(), "Didn't logged out", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.log_out_failed_message, Toast.LENGTH_LONG).show();
} else if(resultCode == ConfigHelper.CORRECTLY_DOWNLOADED_CERTIFICATE) {
setResult(RESULT_CANCELED);
- Toast.makeText(getApplicationContext(), "Your own cert has been correctly downloaded", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.successful_authed_cert_downloaded_message, Toast.LENGTH_LONG).show();
} else if(resultCode == ConfigHelper.INCORRECTLY_DOWNLOADED_CERTIFICATE) {
setResult(RESULT_CANCELED);
- Toast.makeText(getApplicationContext(), "Your own cert has incorrectly been downloaded", Toast.LENGTH_LONG).show();
+ Toast.makeText(getApplicationContext(), R.string.authed_cert_download_failed_message, Toast.LENGTH_LONG).show();
}
}
diff --git a/src/se/leap/leapclient/LogInDialog.java b/src/se/leap/leapclient/LogInDialog.java
index 00429d10..dcb92d89 100644
--- a/src/se/leap/leapclient/LogInDialog.java
+++ b/src/se/leap/leapclient/LogInDialog.java
@@ -40,7 +40,7 @@ public class LogInDialog extends DialogFragment {
interface_with_Dashboard.authenticate(username, password);
} else {
password_field.setText("");
- Toast.makeText(getActivity().getApplicationContext(), "Your password is not well-formed: it should have at least 8 characters", Toast.LENGTH_LONG).show();
+ Toast.makeText(getActivity().getApplicationContext(), R.string.not_valid_password_message, Toast.LENGTH_LONG).show();
}
}
})
diff --git a/src/se/leap/leapclient/NewProviderDialog.java b/src/se/leap/leapclient/NewProviderDialog.java
index 5b84ec03..678e805f 100644
--- a/src/se/leap/leapclient/NewProviderDialog.java
+++ b/src/se/leap/leapclient/NewProviderDialog.java
@@ -65,10 +65,10 @@ public class NewProviderDialog extends DialogFragment {
boolean danger_on = danger_checkbox.isChecked();
if(validURL(entered_url)) {
interface_with_ConfigurationWizard.saveProvider(entered_url, danger_on);
- Toast.makeText(getActivity().getApplicationContext(), "It seems your URL is well formed", Toast.LENGTH_LONG).show();
+ Toast.makeText(getActivity().getApplicationContext(), R.string.valid_url_entered, Toast.LENGTH_LONG).show();
} else {
url_input_field.setText("");
- Toast.makeText(getActivity().getApplicationContext(), "It seems your URL is not well formed", Toast.LENGTH_LONG).show();
+ Toast.makeText(getActivity().getApplicationContext(), R.string.not_valid_password_message, Toast.LENGTH_LONG).show();
}
}
})
diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java
index f8d730e7..4dfe200a 100644
--- a/src/se/leap/leapclient/ProviderAPI.java
+++ b/src/se/leap/leapclient/ProviderAPI.java
@@ -219,11 +219,11 @@ public class ProviderAPI extends IntentService {
JSONObject session_idAndM2 = new JSONObject();
if(json_response.length() > 0) {
- byte[] M2_not_trimmed = new BigInteger(json_response.getString("M2"), 16).toByteArray();
+ byte[] M2_not_trimmed = new BigInteger(json_response.getString(ConfigHelper.M2_KEY), 16).toByteArray();
Cookie session_id_cookie = LeapHttpClient.getInstance(getApplicationContext()).getCookieStore().getCookies().get(0);
session_idAndM2.put(ConfigHelper.SESSION_ID_COOKIE_KEY, session_id_cookie.getName());
session_idAndM2.put(ConfigHelper.SESSION_ID_KEY, session_id_cookie.getValue());
- session_idAndM2.put("M2", Util.trim(M2_not_trimmed));
+ session_idAndM2.put(ConfigHelper.M2_KEY, Util.trim(M2_not_trimmed));
}
return session_idAndM2;
}
@@ -245,7 +245,7 @@ public class ProviderAPI extends IntentService {
HttpEntity responseEntity = getResponse.getEntity();
String plain_response = new Scanner(responseEntity.getContent()).useDelimiter("\\A").next();
JSONObject json_response = new JSONObject(plain_response);
- if(!json_response.isNull("errors") || json_response.has("errors")) {
+ if(!json_response.isNull(ConfigHelper.ERRORS_KEY) || json_response.has(ConfigHelper.ERRORS_KEY)) {
return new JSONObject();
}
diff --git a/src/se/leap/leapclient/ProviderListContent.java b/src/se/leap/leapclient/ProviderListContent.java
index 4ae46099..8727b16b 100644
--- a/src/se/leap/leapclient/ProviderListContent.java
+++ b/src/se/leap/leapclient/ProviderListContent.java
@@ -60,10 +60,10 @@ public class ProviderListContent {
JSONObject file_contents = new JSONObject(urls_file_content);
id = name;
this.name = name;
- provider_json_url = file_contents.getString("json_provider");
+ provider_json_url = file_contents.getString(ConfigHelper.PROVIDER_JSON_URL);
provider_json_filename = file_contents.getString("assets_json_provider");
eip_service_json_url = file_contents.getString("json_eip_service");
- cert_json_url = file_contents.getString("cert");
+ cert_json_url = file_contents.getString(ConfigHelper.CERT_KEY);
this.custom = custom;
this.danger_on = danger_on;
} catch (JSONException e) {
@@ -89,7 +89,7 @@ public class ProviderListContent {
this.name = name;
this.provider_json_url = provider_json_url;
this.provider_json = provider_json;
- eip_service_json_url = provider_json.getString("api_uri") + "/" + provider_json.getString("api_version") + "/" + ConfigHelper.EIP_SERVICE_API_PATH;
+ eip_service_json_url = provider_json.getString(ConfigHelper.API_URL_KEY) + "/" + provider_json.getString(ConfigHelper.API_VERSION_KEY) + "/" + ConfigHelper.EIP_SERVICE_API_PATH;
cert_json_url = (String) provider_json.get("ca_cert_uri");
this.custom = custom;
this.danger_on = danger_on;