diff options
Diffstat (limited to 'src/se/leap/leapclient')
-rw-r--r-- | src/se/leap/leapclient/Dashboard.java | 13 | ||||
-rw-r--r-- | src/se/leap/leapclient/LogInDialog.java | 8 | ||||
-rw-r--r-- | src/se/leap/leapclient/ProviderAPI.java | 12 |
3 files changed, 24 insertions, 9 deletions
diff --git a/src/se/leap/leapclient/Dashboard.java b/src/se/leap/leapclient/Dashboard.java index b652bb73..f666ae03 100644 --- a/src/se/leap/leapclient/Dashboard.java +++ b/src/se/leap/leapclient/Dashboard.java @@ -90,7 +90,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf buildDashboard(); if(data != null && data.hasExtra(ConfigHelper.LOG_IN)) { View view = ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0); - logInDialog(view, ""); + logInDialog(view, Bundle.EMPTY); } } else if(resultCode == RESULT_CANCELED && data.hasExtra(ConfigHelper.QUIT)) { finish(); @@ -195,7 +195,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf return true; case R.id.login_button: View view = ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0); - logInDialog(view, ""); + logInDialog(view, Bundle.EMPTY); return true; case R.id.logout_button: logOut(); @@ -267,7 +267,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf * Shows the log in dialog. * @param view from which the dialog is created. */ - public void logInDialog(View view, String user_message) { + public void logInDialog(View view, Bundle resultData) { FragmentTransaction fragment_transaction = getFragmentManager().beginTransaction(); Fragment previous_log_in_dialog = getFragmentManager().findFragmentByTag(ConfigHelper.LOG_IN_DIALOG); if (previous_log_in_dialog != null) { @@ -276,9 +276,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf fragment_transaction.addToBackStack(null); DialogFragment newFragment = LogInDialog.newInstance(); - if(user_message != null && !user_message.isEmpty()) { + if(resultData != null && !resultData.isEmpty()) { Bundle user_message_bundle = new Bundle(); + String user_message = resultData.getString(getResources().getString(R.string.user_message)); + String username = resultData.getString(ConfigHelper.USERNAME_KEY); user_message_bundle.putString(getResources().getString(R.string.user_message), user_message); + user_message_bundle.putString(ConfigHelper.USERNAME_KEY, username); newFragment.setArguments(user_message_bundle); } newFragment.show(fragment_transaction, ConfigHelper.LOG_IN_DIALOG); @@ -319,7 +322,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf downloadAuthedUserCertificate(session_id); } else if(resultCode == ConfigHelper.SRP_AUTHENTICATION_FAILED) { mProgressDialog.dismiss(); - logInDialog(getCurrentFocus(), resultData.getString(getResources().getString(R.string.user_message))); + logInDialog(getCurrentFocus(), resultData); } else if(resultCode == ConfigHelper.LOGOUT_SUCCESSFUL) { authed = false; invalidateOptionsMenu(); diff --git a/src/se/leap/leapclient/LogInDialog.java b/src/se/leap/leapclient/LogInDialog.java index 8b3f9e80..8e8bb65a 100644 --- a/src/se/leap/leapclient/LogInDialog.java +++ b/src/se/leap/leapclient/LogInDialog.java @@ -48,8 +48,16 @@ public class LogInDialog extends DialogFragment { if(getArguments() != null && getArguments().containsKey(getResources().getString(R.string.user_message))) { user_message.setText(getArguments().getString(getResources().getString(R.string.user_message))); } else user_message.setVisibility(View.GONE); + final EditText username_field = (EditText)log_in_dialog_view.findViewById(R.id.username_entered); + if(getArguments() != null && getArguments().containsKey(getResources().getString(R.string.user_message))) { + String username = getArguments().getString(ConfigHelper.USERNAME_KEY); + username_field.setText(username); + username_field.setHint(""); + } final EditText password_field = (EditText)log_in_dialog_view.findViewById(R.id.password_entered); + if(!username_field.getText().toString().isEmpty() && password_field.isFocusable()) + password_field.requestFocus(); builder.setView(log_in_dialog_view) .setPositiveButton(R.string.login_button, new DialogInterface.OnClickListener() { diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java index 11dfabf1..d41d7662 100644 --- a/src/se/leap/leapclient/ProviderAPI.java +++ b/src/se/leap/leapclient/ProviderAPI.java @@ -151,10 +151,7 @@ public class ProviderAPI extends IntentService { if(session_id_bundle.getBoolean(ConfigHelper.RESULT_KEY)) { receiver.send(ConfigHelper.SRP_AUTHENTICATION_SUCCESSFUL, session_id_bundle); } else { - Bundle user_message_bundle = new Bundle(); - String user_message_key = getResources().getString(R.string.user_message); - user_message_bundle.putString(user_message_key, session_id_bundle.getString(user_message_key)); - receiver.send(ConfigHelper.SRP_AUTHENTICATION_FAILED, user_message_bundle); + receiver.send(ConfigHelper.SRP_AUTHENTICATION_FAILED, session_id_bundle); } } else if (action.equalsIgnoreCase(LOG_OUT)) { if(logOut(parameters)) { @@ -222,27 +219,34 @@ public class ProviderAPI extends IntentService { } else { session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false); session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_bad_user_password_user_message)); + session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username); } } else { session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_bad_user_password_user_message)); + session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username); session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false); } } catch (ClientProtocolException e) { session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false); session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_client_http_user_message)); + session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username); } catch (IOException e) { session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false); session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_io_exception_user_message)); + session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username); } catch (JSONException e) { session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false); session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_json_exception_user_message)); + session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username); } catch (NoSuchAlgorithmException e) { session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false); session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_no_such_algorithm_exception_user_message)); + session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username); } } else { session_id_bundle.putBoolean(ConfigHelper.RESULT_KEY, false); session_id_bundle.putString(getResources().getString(R.string.user_message), getResources().getString(R.string.error_not_valid_password_user_message)); + session_id_bundle.putString(ConfigHelper.USERNAME_KEY, username); } return session_id_bundle; |