Skip to content

Commit

Permalink
Manually added code from refactor branch onto main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Ansel-Hong committed Aug 8, 2021
1 parent 6c58102 commit 9f52697
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
38 changes: 13 additions & 25 deletions app/src/main/java/com/example/b07project/LoginPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,31 +129,19 @@ public void login(){
}

public void userLogin(String email, String password) {
/*
if (email.isEmpty()) {
loginEmail.setError("Email is required!");
loginEmail.requestFocus();
return;
}
if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
loginEmail.setError("Please enter a valid email!");
loginEmail.requestFocus();
return;
}
if (password.isEmpty()) {
loginPassword.setError("Password is required!");
loginPassword.requestFocus();
return;
}
if (password.length() < 6) {
loginPassword.setError("The minimum password length is 6 characters");
loginPassword.requestFocus();
return;
}
*/
// String[] printmsg;
// printmsg = Presenter.checkLoginDetails(email, password);
//
// if(!printmsg[0].equals("")) {
// loginEmail.setError(printmsg[0]);
// loginEmail.requestFocus();
// return;
// }
// if(!printmsg[1].equals("")) {
// loginPassword.setError(printmsg[1]);
// loginPassword.requestFocus();
// return;
// }

progressBar.setVisibility(View.VISIBLE);

Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/com/example/b07project/Presenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,27 @@ else if(model.userIsFound(email, password) == true)
else
view.displayMessage("invalid login");
}

public static String[] checkLoginDetails(String email, String password){

String[] retVal = new String[2];

if (email.isEmpty()) {
retVal[0] = "Email is required!";
}

if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
retVal[0] = "Please enter a valid email!";
}

if (password.isEmpty()) {
retVal[1] = "Password is required!";
}

if (password.length() < 6) {
retVal[1] = "The minimum password length is 6 characters";
}

return retVal;
}
}

0 comments on commit 9f52697

Please sign in to comment.