|
|
@@ -144,13 +144,11 @@ public class LoginActivity extends Activity implements LoaderCallbacks<Cursor> {
|
|
|
}
|
|
|
|
|
|
private boolean isEmailValid(String email) {
|
|
|
- //TODO: Replace this with your own logic
|
|
|
- return email.contains("@");
|
|
|
+ return EmailValidator.validate(email);
|
|
|
}
|
|
|
|
|
|
private boolean isPasswordValid(String password) {
|
|
|
- //TODO: Replace this with your own logic
|
|
|
- return password.length() > 4;
|
|
|
+ return password.length() > 5;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -212,7 +210,7 @@ public class LoginActivity extends Activity implements LoaderCallbacks<Cursor> {
|
|
|
|
|
|
private final String mEmail;
|
|
|
private final String mPassword;
|
|
|
-
|
|
|
+ private String error="";
|
|
|
UserLoginTask(String email, String password) {
|
|
|
mEmail = email;
|
|
|
mPassword = password;
|
|
|
@@ -236,10 +234,13 @@ public class LoginActivity extends Activity implements LoaderCallbacks<Cursor> {
|
|
|
//execute http post
|
|
|
HttpResponse response = httpclient.execute(httppost);
|
|
|
int code = response.getStatusLine().getStatusCode();
|
|
|
- if(code==400){
|
|
|
+
|
|
|
+ if(code==401){
|
|
|
+ error = getString(R.string.error_incorrect_password);
|
|
|
return false; //User/pass invalidos
|
|
|
}
|
|
|
- if(code==401){
|
|
|
+ if(code==400){
|
|
|
+ error = getString(R.string.error_offline);
|
|
|
return false; //No hay ahora
|
|
|
}
|
|
|
HttpEntity entity = response.getEntity();
|
|
|
@@ -271,7 +272,8 @@ public class LoginActivity extends Activity implements LoaderCallbacks<Cursor> {
|
|
|
startActivity(intent);
|
|
|
finish();
|
|
|
} else {
|
|
|
- mPasswordView.setError(getString(R.string.error_incorrect_password));
|
|
|
+ mPasswordView.setError(error);
|
|
|
+ //mPasswordView.setError(getString(R.string.error_incorrect_password));
|
|
|
mPasswordView.requestFocus();
|
|
|
}
|
|
|
}
|