summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/LogInDialog.java
diff options
context:
space:
mode:
authorSean Leonard <meanderingcode@aetherislands.net>2013-10-03 16:54:00 -0700
committerSean Leonard <meanderingcode@aetherislands.net>2013-10-03 16:54:00 -0700
commit04fedee9f6be1e3e46a8c91c9a39343513cc6fe1 (patch)
treecb221b9304905e25695c59be60f0eeb62fe25a36 /src/se/leap/leapclient/LogInDialog.java
parent697e7da6e1379ac23cd8dbb47a1246547abafda6 (diff)
parent37bb23c5549ffe690f65b1c04cf432bd3153bf04 (diff)
Merge branch 'bug/login_dialog_should_require_username' into develop
Diffstat (limited to 'src/se/leap/leapclient/LogInDialog.java')
-rw-r--r--src/se/leap/leapclient/LogInDialog.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/se/leap/leapclient/LogInDialog.java b/src/se/leap/leapclient/LogInDialog.java
index 73833a13..7dd1c732 100644
--- a/src/se/leap/leapclient/LogInDialog.java
+++ b/src/se/leap/leapclient/LogInDialog.java
@@ -17,13 +17,18 @@
package se.leap.leapclient;
import se.leap.leapclient.R;
+import android.R.color;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
+import android.content.res.ColorStateList;
import android.os.Bundle;
+import android.provider.CalendarContract.Colors;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.animation.AlphaAnimation;
+import android.view.animation.BounceInterpolator;
import android.widget.EditText;
import android.widget.TextView;
@@ -44,6 +49,8 @@ public class LogInDialog extends DialogFragment {
final public static String VERB = "log in";
final public static String USERNAME = "username";
final public static String PASSWORD = "password";
+ final public static String USERNAME_MISSING = "username missing";
+ final public static String PASSWORD_INVALID_LENGTH = "password_invalid_length";
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
@@ -54,23 +61,34 @@ public class LogInDialog extends DialogFragment {
final TextView user_message = (TextView)log_in_dialog_view.findViewById(R.id.user_message);
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);
+ } 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))) {
+ if(getArguments() != null && getArguments().containsKey(USERNAME)) {
String username = getArguments().getString(USERNAME);
username_field.setText(username);
- username_field.setHint("");
}
+ if (getArguments() != null && getArguments().containsKey(USERNAME_MISSING)) {
+ username_field.setError(getResources().getString(R.string.username_ask));
+ }
+
final EditText password_field = (EditText)log_in_dialog_view.findViewById(R.id.password_entered);
- if(!username_field.getText().toString().isEmpty() && password_field.isFocusable())
+ if(!username_field.getText().toString().isEmpty() && password_field.isFocusable()) {
password_field.requestFocus();
+ }
+ if (getArguments() != null && getArguments().containsKey(PASSWORD_INVALID_LENGTH)) {
+ password_field.setError(getResources().getString(R.string.error_not_valid_password_user_message));
+ }
+
builder.setView(log_in_dialog_view)
.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();
+ dialog.dismiss();
interface_with_Dashboard.authenticate(username, password);
}
})