From e29d924f9ed1029234e169c75994e323f09edcbe Mon Sep 17 00:00:00 2001 From: Omer Habib Date: Fri, 29 May 2020 16:12:10 +0500 Subject: [PATCH 1/2] Update http status for valid exception msg --- .../src/main/java/org/edx/mobile/view/LoginActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/LoginActivity.java b/OpenEdXMobile/src/main/java/org/edx/mobile/view/LoginActivity.java index 524ca0c008..52207a2bb7 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/LoginActivity.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/LoginActivity.java @@ -250,7 +250,7 @@ public void onSuccess(@NonNull AuthResponse result) { @Override public void onException(Exception ex) { if (ex instanceof HttpStatusException && - ((HttpStatusException) ex).getStatusCode() == HttpStatus.UNAUTHORIZED) { + ((HttpStatusException) ex).getStatusCode() == HttpStatus.BAD_REQUEST) { onUserLoginFailure(new LoginException(new LoginErrorMessage( getString(R.string.login_error), getString(R.string.login_failed))), null, null); From 85174f787bdb3d7d2e907437851936d1cee909bb Mon Sep 17 00:00:00 2001 From: Omer Habib Date: Fri, 29 May 2020 16:16:25 +0500 Subject: [PATCH 2/2] Update field validation errors msg from alert dialog to in-line --- .../org/edx/mobile/view/LoginActivity.java | 52 ++++++++++++++++--- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/LoginActivity.java b/OpenEdXMobile/src/main/java/org/edx/mobile/view/LoginActivity.java index 52207a2bb7..4bd53121a1 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/LoginActivity.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/LoginActivity.java @@ -4,6 +4,8 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; import android.text.method.LinkMovementMethod; import android.view.View; import android.view.View.OnClickListener; @@ -110,6 +112,40 @@ public void onClick(View v) { } }); + activityLoginBinding.emailEt.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int start, int before, int after) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int start, int before, int after) { + + } + + @Override + public void afterTextChanged(Editable editable) { + activityLoginBinding.usernameWrapper.setError(null); + } + }); + + activityLoginBinding.passwordEt.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int start, int before, int after) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int start, int before, int after) { + + } + + @Override + public void afterTextChanged(Editable editable) { + activityLoginBinding.passwordWrapper.setError(null); + } + }); + activityLoginBinding.endUserAgreementTv.setMovementMethod(LinkMovementMethod.getInstance()); activityLoginBinding.endUserAgreementTv.setText(TextUtils.generateLicenseText(getResources(), R.string.by_signing_in)); @@ -226,15 +262,15 @@ public void callServerForLogin() { final String emailStr = activityLoginBinding.emailEt.getText().toString().trim(); final String passwordStr = activityLoginBinding.passwordEt.getText().toString().trim(); - if (activityLoginBinding.emailEt != null && emailStr.length() == 0) { - showAlertDialog(getString(R.string.login_error), - getString(R.string.error_enter_email)); - activityLoginBinding.emailEt.requestFocus(); - } else if (activityLoginBinding.passwordEt != null && passwordStr.length() == 0) { - showAlertDialog(getString(R.string.login_error), - getString(R.string.error_enter_password)); + if (passwordStr.length() == 0) { + activityLoginBinding.passwordWrapper.setError(getString(R.string.error_enter_password)); activityLoginBinding.passwordEt.requestFocus(); - } else { + } + if (emailStr.length() == 0) { + activityLoginBinding.usernameWrapper.setError(getString(R.string.error_enter_email)); + activityLoginBinding.emailEt.requestFocus(); + } + if (emailStr.length() > 0 && passwordStr.length() > 0) { activityLoginBinding.emailEt.setEnabled(false); activityLoginBinding.passwordEt.setEnabled(false); activityLoginBinding.forgotPasswordTv.setEnabled(false);