Skip to content

Commit

Permalink
Validate fields mail and password
Browse files Browse the repository at this point in the history
  • Loading branch information
oaliaga committed Feb 20, 2015
1 parent 7ab5a34 commit fc29635
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
19 changes: 14 additions & 5 deletions src/com/prey/activities/AddDeviceToAccountActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.app.Dialog;
import android.app.ProgressDialog;
import android.app.Service;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
Expand Down Expand Up @@ -93,11 +94,19 @@ public void onClick(View v) {
error = null;
final String email = ((EditText) findViewById(R.id.add_device_email)).getText().toString();
final String password = ((EditText) findViewById(R.id.add_device_pass)).getText().toString();

if (email.equals("") || password.equals("")) {
Toast.makeText(AddDeviceToAccountActivity.this, R.string.error_all_fields_are_required, Toast.LENGTH_LONG).show();
} else {
new AddDeviceToAccount().execute(email, password, getDeviceType(AddDeviceToAccountActivity.this));
final Context ctx=getApplicationContext();
if (email==null||email.equals("") || password==null|| password.equals("")) {
Toast.makeText(ctx, R.string.error_all_fields_are_required, Toast.LENGTH_LONG).show();
} else{
if(email.length()<6||email.length()>100){
Toast.makeText(ctx, ctx.getString(R.string.error_mail_out_of_range,6,100) , Toast.LENGTH_LONG).show();
}else{
if(password.length()<6||password.length()>32){
Toast.makeText(ctx, ctx.getString(R.string.error_password_out_of_range,6,32), Toast.LENGTH_LONG).show();
}else{
new AddDeviceToAccount().execute(email, password, getDeviceType(ctx));
}
}
}
}
});
Expand Down
19 changes: 14 additions & 5 deletions src/com/prey/activities/CreateAccountActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.prey.R;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
Expand Down Expand Up @@ -86,11 +87,19 @@ public void onClick(View v) {
name = ((EditText) findViewById(R.id.new_account_name)).getText().toString();
email = ((EditText) findViewById(R.id.new_account_email)).getText().toString();
password = ((EditText) findViewById(R.id.new_account_pass)).getText().toString();

if (name.equals("") || email.equals("") || password.equals(""))
Toast.makeText(CreateAccountActivity.this, R.string.error_all_fields_are_required, Toast.LENGTH_LONG).show();
else {
new CreateAccount().execute(name, email, password);
Context ctx=getApplicationContext();
if (email==null||email.equals("") || password==null|| password.equals("")) {
Toast.makeText(ctx, R.string.error_all_fields_are_required, Toast.LENGTH_LONG).show();
} else{
if(email.length()<6||email.length()>100){
Toast.makeText(ctx, ctx.getString(R.string.error_mail_out_of_range,6,100) , Toast.LENGTH_LONG).show();
}else{
if(password.length()<6||password.length()>32){
Toast.makeText(ctx, ctx.getString(R.string.error_password_out_of_range,6,32), Toast.LENGTH_LONG).show();
}else{
new CreateAccount().execute(name, email, password);
}
}
}
}
});
Expand Down
13 changes: 10 additions & 3 deletions src/com/prey/activities/PasswordActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.prey.activities;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
Expand Down Expand Up @@ -35,10 +36,16 @@ protected void bindPasswordControls() {

public void onClick(View v) {
final String passwordtyped = pass1.getText().toString();
final Context ctx=getApplicationContext();
if (passwordtyped.equals(""))
Toast.makeText(PasswordActivity.this, R.string.preferences_password_length_error, Toast.LENGTH_LONG).show();
else
new CheckPassword().execute(passwordtyped);
Toast.makeText(ctx, R.string.preferences_password_length_error, Toast.LENGTH_LONG).show();
else{
if(passwordtyped.length()<6||passwordtyped.length()>32){
Toast.makeText(ctx, ctx.getString(R.string.error_password_out_of_range,6,32), Toast.LENGTH_LONG).show();
}else{
new CheckPassword().execute(passwordtyped);
}
}

}
});
Expand Down

0 comments on commit fc29635

Please sign in to comment.