Browse Source

Forgot pass fixes

master
Preyea Regmi 4 years ago
parent
commit
38ec02d0c7
  1. BIN
      .idea/caches/build_file_checksums.ser
  2. 80
      app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/presenter/profilechange/ChangePasswordLiveData.java
  3. 315
      app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/presenter/profilechange/ChangePasswordV2Presenter.java
  4. 15
      app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/presenter/profilechange/ChangePasswordV2PresenterInterface.java
  5. 28
      app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/view/profilechange/ChangePasswordViewModelFactory.java
  6. 164
      app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/view/profilechange/UserPasswordChangeV2Activity.java
  7. 158
      app/src/main/res/layout/activity_change_password_v2.xml

BIN
.idea/caches/build_file_checksums.ser

80
app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/presenter/profilechange/ChangePasswordLiveData.java

@ -0,0 +1,80 @@
package com.gmeremit.online.gmeremittance_native.profile.presenter.profilechange;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import com.gmeremit.online.gmeremittance_native.common.model.FormInputStateDTO;
import io.reactivex.Observable;
public class ChangePasswordLiveData {
private MutableLiveData<FormInputStateDTO<String>> currentPasswordInputLiveData;
private MutableLiveData<FormInputStateDTO<String>> newPasswordInputLiveData;
private MutableLiveData<FormInputStateDTO<String>> confirmPasswordInputLiveData;
private MutableLiveData<FormInputStateDTO> allFormValidLiveData;
public ChangePasswordLiveData() {
currentPasswordInputLiveData = new MutableLiveData<>();
newPasswordInputLiveData = new MutableLiveData<>();
confirmPasswordInputLiveData = new MutableLiveData<>();
allFormValidLiveData = new MutableLiveData<>();
}
public LiveData<FormInputStateDTO<String>> getCurrentPasswordInputLiveData() {
return currentPasswordInputLiveData;
}
public void setCurrentPasswordInputLiveData(FormInputStateDTO<String> currentPasswordInputLiveData) {
this.currentPasswordInputLiveData.setValue(currentPasswordInputLiveData);
}
public LiveData<FormInputStateDTO<String>> getNewPasswordInputLiveData() {
return newPasswordInputLiveData;
}
public void setNewPasswordInputLiveData(FormInputStateDTO<String> newPasswordInputLiveData) {
this.newPasswordInputLiveData.setValue(newPasswordInputLiveData);
}
public LiveData<FormInputStateDTO<String>> getConfirmPasswordInputLiveData() {
return confirmPasswordInputLiveData;
}
public void setConfirmPasswordInputLiveData(FormInputStateDTO<String> confirmPasswordInputLiveData) {
this.confirmPasswordInputLiveData.setValue(confirmPasswordInputLiveData);
}
public LiveData<FormInputStateDTO> getAllFormValidLiveData() {
return allFormValidLiveData;
}
public void setAllFormValidLiveData(FormInputStateDTO allFormValidLiveData) {
this.allFormValidLiveData.setValue(allFormValidLiveData);
}
public static class ChangePasswordViewBindings {
private Observable<CharSequence> currentPasswordInputLiveData;
private Observable<CharSequence> newPasswordInputLiveData;
private Observable<CharSequence> confirmPasswordInputLiveData;
public ChangePasswordViewBindings(Observable<CharSequence> currentPasswordInputLiveData, Observable<CharSequence> newPasswordInputLiveData, Observable<CharSequence> confirmPasswordInputLiveData) {
this.currentPasswordInputLiveData = currentPasswordInputLiveData;
this.newPasswordInputLiveData = newPasswordInputLiveData;
this.confirmPasswordInputLiveData = confirmPasswordInputLiveData;
}
public Observable<CharSequence> getCurrentPasswordInputLiveData() {
return currentPasswordInputLiveData;
}
public Observable<CharSequence> getNewPasswordInputLiveData() {
return newPasswordInputLiveData;
}
public Observable<CharSequence> getConfirmPasswordInputLiveData() {
return confirmPasswordInputLiveData;
}
}
}

315
app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/presenter/profilechange/ChangePasswordV2Presenter.java

@ -1,173 +1,150 @@
package com.gmeremit.online.gmeremittance_native.profile.presenter.profilechange;
import androidx.appcompat.app.AppCompatActivity;
import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.base.BasePresenter;
import com.gmeremit.online.gmeremittance_native.base.BaseViewModel;
import com.gmeremit.online.gmeremittance_native.common.model.FormInputStateDTO;
import com.gmeremit.online.gmeremittance_native.profile.gateway.profilechange.ChangePasswordV2Gateway;
import com.gmeremit.online.gmeremittance_native.profile.model.ChangePasswordActivityV2APIResponse;
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog;
import com.gmeremit.online.gmeremittance_native.security.GMEAuthManager;
import com.gmeremit.online.gmeremittance_native.utils.Constants;
import com.gmeremit.online.gmeremittance_native.utils.Utils;
import com.gmeremit.online.gmeremittance_native.utils.https.GenericApiObserverResponse;
import com.gmeremit.online.gmeremittance_native.security.utils.SecurityUtils;
import io.reactivex.CompletableObserver;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
public class ChangePasswordV2Presenter extends BasePresenter implements ChangePasswordV2InteractorInterface, ChangePasswordV2PresenterInterface {
public class ChangePasswordV2Presenter extends BaseViewModel implements ChangePasswordV2InteractorInterface, ChangePasswordV2PresenterInterface {
private final ChangePasswordV2PresenterInterface.ChangePasswordV2ContractInterface view;
private final ChangePasswordV2Gateway gateway;
private String encCurrentPassword;
private String encNewPassword;
private String encConfirmPassword;
private final ChangePasswordLiveData changePasswordLiveData;
private final CompositeDisposable useCaseCompositeDisposable;
private final CompositeDisposable viewEventCompositeDisposable;
private final ChangePasswordValidator changePasswordValidator;
public ChangePasswordV2Presenter(ChangePasswordV2PresenterInterface.ChangePasswordV2ContractInterface view,ChangePasswordV2Gateway gateway) {
public ChangePasswordV2Presenter(ChangePasswordV2PresenterInterface.ChangePasswordV2ContractInterface view, ChangePasswordV2Gateway gateway) {
this.view = view;
this.gateway = gateway;
this.encCurrentPassword = "";
this.encNewPassword = "";
this.encConfirmPassword = "";
this.changePasswordValidator = new ChangePasswordValidator();
changePasswordLiveData = new ChangePasswordLiveData();
useCaseCompositeDisposable = new CompositeDisposable();
viewEventCompositeDisposable = new CompositeDisposable();
}
@Deprecated
@Override
public boolean validateData(String currentPass, String newPwd, String pwdConfrimString) {
boolean currentPwdValidation = true;
boolean confirmPwdValidation = true;
boolean newPwdValidation = true;
if (currentPass.trim().length() < 1) {
this.view.setCurrentPasswordError(getStringfromStringId(R.string.password_empty_error));
currentPwdValidation = false;
}
if (!Utils.hasSpecialCharacters(newPwd)) {
this.view.setNewPasswordError(getStringfromStringId(R.string.password_symbol_required_error));
newPwdValidation = false;
}
if (!Utils.hasNumbers(newPwd)) {
this.view.setNewPasswordError(getStringfromStringId(R.string.password_number_required_error));
newPwdValidation = false;
}
if (newPwd.length() > 1 && newPwd.length() < 9) {
this.view.setNewPasswordError(getStringfromStringId(R.string.password_length_error));
newPwdValidation = false;
}
if (!Utils.hasAtleastOnCapitalLetter(newPwd)) {
this.view.setNewPasswordError(getStringfromStringId(R.string.password_capital_letter_required_error));
newPwdValidation = false;
}
if (newPwd.trim().length() < 1) {
this.view.setNewPasswordError(getStringfromStringId(R.string.password_empty_error));
newPwdValidation = false;
}
if (!newPwd.equals(pwdConfrimString)) {
this.view.setConfirmPasswordError(getStringfromStringId(R.string.confirm_password_mismatch_error));
confirmPwdValidation = false;
}
if (pwdConfrimString == null || pwdConfrimString.trim().length() < 1) {
this.view.setConfirmPasswordError(getStringfromStringId(R.string.confirm_passowrd_empty_error));
confirmPwdValidation = false;
}
public ChangePasswordLiveData getChangePasswordRelatedViewEvents(ChangePasswordLiveData.ChangePasswordViewBindings viewBindings) {
bindView(viewBindings);
return changePasswordLiveData;
}
if (currentPwdValidation) {
view.setCurrentPasswordError(null);
}
if (confirmPwdValidation) {
view.setConfirmPasswordError(null);
private void bindView(ChangePasswordLiveData.ChangePasswordViewBindings viewBindings) {
viewEventCompositeDisposable.add(
Observable.combineLatest(
viewBindings.getCurrentPasswordInputLiveData().map(this.changePasswordValidator::isCurrentPasswordValid),
viewBindings.getNewPasswordInputLiveData().map(this.changePasswordValidator::isNewPasswordValid),
viewBindings.getConfirmPasswordInputLiveData().map(this.changePasswordValidator::isConfirmPasswordValid),
(isCurrentPassValid, isNewPasswordValid, isConfirmPasswordValid) ->
isCurrentPassValid && isNewPasswordValid && isConfirmPasswordValid)
.subscribeWith(new DisposableObserver<Boolean>() {
@Override
public void onNext(Boolean result) {
changePasswordLiveData.setAllFormValidLiveData(new FormInputStateDTO(result, ""));
}
@Override
public void onError(Throwable e) {
changePasswordLiveData.setAllFormValidLiveData(new FormInputStateDTO(false, ""));
}
@Override
public void onComplete() {
}
}));
}
}
@Override
public void onViewReady() {
if (newPwdValidation) {
view.setNewPasswordError(null);
}
}
@Override
public void onViewNotReady() {
return currentPwdValidation && confirmPwdValidation && newPwdValidation;
}
@Override
public boolean validateAll() {
boolean currentPwdValidation = true;
boolean confirmPwdValidation = true;
boolean newPwdValidation = true;
if (encCurrentPassword == null || encCurrentPassword.trim().length() < 1) {
this.view.setCurrentPasswordError(getStringfromStringId(R.string.password_empty_error));
currentPwdValidation = false;
}
public void changePassword() {
useCaseCompositeDisposable.add(
this.gateway.performChangePassRequest(this.gateway.getAuth(), this.gateway.getUserID(), this.changePasswordValidator.currentPassword, this.changePasswordValidator.newPassword, this.changePasswordValidator.confirmPassword)
.doOnSubscribe(d -> view.showProgressBar(true, getStringfromStringId(R.string.processing_request_text)))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doFinally(() -> view.showProgressBar(false, ""))
.subscribeWith(new ChangePasswordObserver(this.changePasswordValidator.newPassword)));
}
if (encNewPassword == null || encNewPassword.trim().length() < 1) {
this.view.setNewPasswordError(getStringfromStringId(R.string.password_empty_error));
newPwdValidation = false;
}
if (encConfirmPassword == null || encConfirmPassword.trim().length() < 1) {
this.view.setConfirmPasswordError(getStringfromStringId(R.string.confirm_passowrd_empty_error));
confirmPwdValidation = false;
}
private class ChangePasswordValidator {
if (currentPwdValidation) {
view.setCurrentPasswordError(null);
}
if (confirmPwdValidation) {
view.setConfirmPasswordError(null);
private String currentPassword;
private String newPassword;
private String confirmPassword;
}
boolean isCurrentPasswordValid(CharSequence password) {
if (password != null && password.length() > 0) {
this.currentPassword = password.toString();
changePasswordLiveData.setCurrentPasswordInputLiveData(new FormInputStateDTO<>(true, null));
return true;
} else {
this.currentPassword = null;
changePasswordLiveData.setCurrentPasswordInputLiveData(new FormInputStateDTO<>(false, getStringfromStringId(R.string.password_empty_error)));
return false;
}
if (newPwdValidation) {
view.setNewPasswordError(null);
}
return currentPwdValidation && confirmPwdValidation && newPwdValidation;
}
@Override
public void changePassword(String currentPass, String newPass) {
boolean isNewPasswordValid(CharSequence password) {
if (password != null && password.length() > 0) {
this.newPassword = password.toString();
changePasswordLiveData.setNewPasswordInputLiveData(new FormInputStateDTO<>(true, null));
return true;
} else {
this.newPassword = null;
changePasswordLiveData.setNewPasswordInputLiveData(new FormInputStateDTO<>(false, getStringfromStringId(R.string.password_empty_error)));
return false;
}
this.gateway.performChangePassRequest(this.gateway.getAuth(), this.gateway.getUserID(), this.encCurrentPassword, this.encNewPassword, this.encConfirmPassword)
.doOnSubscribe(d -> view.showProgressBar(true, getStringfromStringId(R.string.processing_request_text)))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new ChangePasswordObserver(this.encNewPassword));
}
}
@Override
public void updateCurrentPassword(String encCurrentPassword) {
this.encCurrentPassword = encCurrentPassword;
}
@Override
public void updateNewPassword(String encNewPassword) {
this.encNewPassword = encNewPassword;
}
@Override
public void updateConfirmPassword(String encConfirmPassword) {
this.encConfirmPassword = encConfirmPassword;
}
boolean isConfirmPasswordValid(CharSequence password) {
if (password != null && password.length() > 0) {
this.confirmPassword = password.toString();
changePasswordLiveData.setConfirmPasswordInputLiveData(new FormInputStateDTO<>(true, null));
return true;
} else {
this.currentPassword = null;
changePasswordLiveData.setConfirmPasswordInputLiveData(new FormInputStateDTO<>(false, getStringfromStringId(R.string.password_empty_error)));
return false;
}
private void encryptPassword(String newPassword, String pwdChangeMessage) {
SecurityUtils.generateKey()
.flatMap(key -> Observable.zip(
SecurityUtils.encryptUsingAES(newPassword, key).subscribeOn(Schedulers.io()),
encryptToKeyStore(key).subscribeOn(Schedulers.io()),
Observable.just(pwdChangeMessage),
FingerprintEncResult::new)
).observeOn(AndroidSchedulers.mainThread())
.subscribe(new FingerprintEncResultObserver());
}
}
private Observable<String> encryptToKeyStore(String data) {
return SecurityUtils.encryptUsingKeyStore(view.getContext(), data)
.flatMap(encKey ->Observable.just(encKey.getEncrypted()));
}
@ -181,99 +158,59 @@ public class ChangePasswordV2Presenter extends BasePresenter implements ChangePa
@Override
protected void onSuccess(ChangePasswordActivityV2APIResponse changePasswordActivityV2APIResponse) {
view.showProgressBar(false,"");
if (changePasswordActivityV2APIResponse.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) {
if (SecurityUtils.checkFingerPrintUsablity(view.getContext())) {
encryptPassword(newPassword, changePasswordActivityV2APIResponse.getData().getMessage());
} else {
GMEAuthManager gmeAuthManager = GMEAuthManager.getGmeAuthManager((AppCompatActivity) view.getContext());
if (gmeAuthManager.isBiometricSupportedByDevice())
gmeAuthManager.persistUserCredentialForFingerprintAuth(gateway.getUserID(), this.newPassword)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
useCaseCompositeDisposable.add(d);
}
@Override
public void onComplete() {
view.showPopUpMessage(changePasswordActivityV2APIResponse.getMsg(), CustomAlertDialog.AlertType.SUCCESS, alertType -> view.exitView());
}
@Override
public void onError(Throwable e) {
view.showPopUpMessage(changePasswordActivityV2APIResponse.getMsg(), CustomAlertDialog.AlertType.SUCCESS, alertType -> view.exitView());
}
});
else {
view.showPopUpMessage(changePasswordActivityV2APIResponse.getMsg(), CustomAlertDialog.AlertType.SUCCESS, alertType -> view.exitView());
}
} else
view.showPopUpMessage(changePasswordActivityV2APIResponse.getMsg(), CustomAlertDialog.AlertType.FAILED, null);
}
@Override
public void onFailed(String message) {
view.showProgressBar(false,"");
view.showProgressBar(false, "");
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null);
}
@Override
protected void onConnectionNotEstablished(String message) {
view.showProgressBar(false,"");
view.showProgressBar(false, "");
view.showPopUpMessage(message, CustomAlertDialog.AlertType.NO_INTERNET, null);
}
@Override
protected void unauthorizedAccess(String message) {
view.showProgressBar(false,"");
view.showProgressBar(false, "");
gateway.clearAllUserData();
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.logout());
}
}
public class FingerprintEncResult {
String encPwd;
String key;
String pwdChangeServerMessage;
public FingerprintEncResult(String encPwd,String key, String pwdChangeServerMessage) {
this.encPwd = encPwd;
this.key=key;
this.pwdChangeServerMessage = pwdChangeServerMessage;
}
public String getEncPwd() {
return encPwd;
}
public String getPwdChangeServerMessage() {
return pwdChangeServerMessage;
}
public String getKey() {
return key;
}
@Override
public String toString() {
return "UserCredentialEncryptionResultDTO{" +
"encPwd='" + encPwd + '\'' +
", key='" + key + '\'' +
", pwdChangeServerMessage='" + pwdChangeServerMessage + '\'' +
'}';
}
}
public class FingerprintEncResultObserver extends DisposableObserver<FingerprintEncResult> {
@Override
public void onNext(FingerprintEncResult fingerprintEncResult) {
view.showProgressBar(false,"");
if (fingerprintEncResult.getEncPwd() == null) {
gateway.flushBiometricData();
view.showPopUpMessage(fingerprintEncResult.getPwdChangeServerMessage(), CustomAlertDialog.AlertType.SUCCESS, alertType -> view.exitView());
} else {
gateway.persistUserPwdForBiometric(fingerprintEncResult.getEncPwd());
gateway.persistSecretKeyForBiometric(fingerprintEncResult.getKey());
view.showPopUpMessage(fingerprintEncResult.getPwdChangeServerMessage(), CustomAlertDialog.AlertType.SUCCESS, alertType -> view.exitView());
}
}
@Override
public void onError(Throwable e) {
view.showProgressBar(false,"");
gateway.flushBiometricData();
}
@Override
public void onComplete() {
}
}

15
app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/presenter/profilechange/ChangePasswordV2PresenterInterface.java

@ -9,27 +9,16 @@ import com.gmeremit.online.gmeremittance_native.base.BasePresenterInterface;
public interface ChangePasswordV2PresenterInterface extends BasePresenterInterface {
boolean validateData(String currentPass, String newPass, String repeatPassword);
boolean validateAll();
void changePassword(String currentPass,String newPass);
void changePassword();
void updateCurrentPassword(String encCurrentPassword);
ChangePasswordLiveData getChangePasswordRelatedViewEvents(ChangePasswordLiveData.ChangePasswordViewBindings viewBindings);
void updateNewPassword(String encNewPassword);
void updateConfirmPassword(String encConfirmPassword);
interface ChangePasswordV2ContractInterface extends BaseContractInterface
{
void setNewPasswordError(String errorString);
void setConfirmPasswordError(String passwords_does_not_match);
void setCurrentPasswordError(String s);
Context getContext();
}
}

28
app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/view/profilechange/ChangePasswordViewModelFactory.java

@ -0,0 +1,28 @@
package com.gmeremit.online.gmeremittance_native.profile.view.profilechange;
import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import com.gmeremit.online.gmeremittance_native.loginV2.gateway.LoginV2Gateway;
import com.gmeremit.online.gmeremittance_native.loginV2.presenter.LoginV2Presenter;
import com.gmeremit.online.gmeremittance_native.loginV2.presenter.LoginV2PresenterInterface;
import com.gmeremit.online.gmeremittance_native.profile.gateway.profilechange.ChangePasswordV2Gateway;
import com.gmeremit.online.gmeremittance_native.profile.presenter.profilechange.ChangePasswordV2Presenter;
import com.gmeremit.online.gmeremittance_native.profile.presenter.profilechange.ChangePasswordV2PresenterInterface;
public class ChangePasswordViewModelFactory implements ViewModelProvider.Factory {
private final ChangePasswordV2PresenterInterface.ChangePasswordV2ContractInterface view;
public ChangePasswordViewModelFactory(ChangePasswordV2PresenterInterface.ChangePasswordV2ContractInterface view) {
this.view=view;
}
@SuppressWarnings("unchecked")
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
return (T) new ChangePasswordV2Presenter(view,new ChangePasswordV2Gateway());
}
}

164
app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/view/profilechange/UserPasswordChangeV2Activity.java

@ -4,22 +4,25 @@ import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.lifecycle.ViewModelProvider;
import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.base.BaseActivity;
import com.gmeremit.online.gmeremittance_native.customwidgets.GmeErrorTextView;
import com.gmeremit.online.gmeremittance_native.profile.gateway.profilechange.ChangePasswordV2Gateway;
import com.gmeremit.online.gmeremittance_native.common.model.FormInputStateDTO;
import com.gmeremit.online.gmeremittance_native.profile.presenter.profilechange.ChangePasswordLiveData;
import com.gmeremit.online.gmeremittance_native.profile.presenter.profilechange.ChangePasswordV2Presenter;
import com.gmeremit.online.gmeremittance_native.profile.presenter.profilechange.ChangePasswordV2PresenterInterface;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import com.jakewharton.rxbinding3.widget.RxTextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class UserPasswordChangeV2Activity extends BaseActivity implements ChangePasswordV2PresenterInterface.ChangePasswordV2ContractInterface, View.OnClickListener {
public class UserPasswordChangeV2Activity extends BaseActivity implements ChangePasswordV2PresenterInterface.ChangePasswordV2ContractInterface {
@BindView(R.id.toolbar_title)
@ -29,47 +32,31 @@ public class UserPasswordChangeV2Activity extends BaseActivity implements Change
View iv_cancel;
@BindView(R.id.iv_back)
View iv_back;
@BindView(R.id.btn_submit)
Button btn_submit;
@BindView(R.id.currentPasswordErrorTxt)
GmeErrorTextView currentPasswordErrorTxt;
@BindView(R.id.newPasswordErrorTxt)
GmeErrorTextView newPasswordErrorTxt;
@BindView(R.id.confirmPasswordErrorTxt)
GmeErrorTextView confirmPasswordErrorTxt;
@BindView(R.id.currentPassword_edTxt)
TextInputEditText currentPassword_edTxt;
@BindView(R.id.keypadContainer)
FrameLayout keypadContainer;
@BindView(R.id.currentPassword_TxtInputLayout)
TextInputLayout currentPassword_TxtInputLayout;
@BindView(R.id.keypadBallon)
RelativeLayout ballonView;
@BindView(R.id.newPassword_edTxt)
TextInputEditText newPassword_edTxt;
@BindView(R.id.scrollView)
ScrollView scrollView;
@BindView(R.id.newPassword_TxtInputLayout)
TextInputLayout newPassword_TxtInputLayout;
@BindView(R.id.confirmPassword_edTxt)
TextInputEditText confirmPassword_edTxt;
@BindView(R.id.newPasswordText)
TextView newPasswordText;
@BindView(R.id.confirmPasswordText)
TextView confirmPasswordText;
@BindView(R.id.currentPasswordText)
TextView currentPasswordText;
@BindView(R.id.rootViewChangePassword)
View rootView;
@BindView(R.id.confirmPassword_TxtInputLayout)
TextInputLayout confirmPassword_TxtInputLayout;
@BindView(R.id.btn_submit)
Button btn_submit;
private ChangePasswordV2PresenterInterface presenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
enableActivityToTakeScreenShot(false);
@ -83,77 +70,76 @@ public class UserPasswordChangeV2Activity extends BaseActivity implements Change
private void initialize() {
this.presenter=new ChangePasswordV2Presenter(this,new ChangePasswordV2Gateway());
this.presenter=new ViewModelProvider(this,new ChangePasswordViewModelFactory(this)).get(ChangePasswordV2Presenter.class);
ChangePasswordLiveData changePasswordViewModel = presenter.getChangePasswordRelatedViewEvents(new ChangePasswordLiveData.ChangePasswordViewBindings(
RxTextView.textChanges(currentPassword_edTxt).skipInitialValue(),
RxTextView.textChanges(newPassword_edTxt).skipInitialValue(),
RxTextView.textChanges(confirmPassword_edTxt).skipInitialValue()
));
changePasswordViewModel.getCurrentPasswordInputLiveData().observe(this,this::onCurrentPasswordStateChanged);
changePasswordViewModel.getNewPasswordInputLiveData().observe(this,this::onNewPasswordStateChanged);
changePasswordViewModel.getConfirmPasswordInputLiveData().observe(this,this::onConfirmPasswordStateChanged);
changePasswordViewModel.getAllFormValidLiveData().observe(this, result->btn_submit.setEnabled(result.isValid()));
}
private void performDefaultAction(Bundle savedInstanceState) {
if(savedInstanceState==null)
private void onConfirmPasswordStateChanged(FormInputStateDTO<String> state) {
if(state.isValid())
{
toolbarTitle.setText(getString(R.string.change_password_title_text));
iv_cancel.setVisibility(View.INVISIBLE);
confirmPassword_TxtInputLayout.setError(null);
if(state.hasData())
{
confirmPassword_edTxt.setText(state.getData());
}
}
else
confirmPassword_TxtInputLayout.setError(state.getErrorMessage());
}
@Override
protected void onStart() {
super.onStart();
iv_back.setOnClickListener(this);
btn_submit.setOnClickListener(this);
private void onNewPasswordStateChanged(FormInputStateDTO<String> state) {
if(state.isValid())
{
newPassword_TxtInputLayout.setError(null);
if(state.hasData())
{
newPassword_edTxt.setText(state.getData());
}
}
else
newPassword_TxtInputLayout.setError(state.getErrorMessage());
}
@Override
protected void onStop() {
super.onStop();
iv_back.setOnClickListener(null);
btn_submit.setOnClickListener(null);
private void onCurrentPasswordStateChanged(FormInputStateDTO<String> state) {
if(state.isValid())
{
currentPassword_TxtInputLayout.setError(null);
if(state.hasData())
{
currentPassword_edTxt.setText(state.getData());
}
}
else
currentPassword_TxtInputLayout.setError(state.getErrorMessage());
}
@Override
public void onClick(View v) {
switch(v.getId())
private void performDefaultAction(Bundle savedInstanceState) {
if(savedInstanceState==null)
{
case R.id.iv_back:
onBackPressed();
break;
case R.id.btn_submit:
if(this.presenter.validateAll())
{
hideKeyBoard();
this.presenter.changePassword(null,null);
}
break;
toolbarTitle.setText(getString(R.string.change_password_title_text));
iv_cancel.setVisibility(View.INVISIBLE);
}
}
@Override
public void setNewPasswordError(String error) {
newPasswordErrorTxt.setErrorText(error);
}
@Override
public void setConfirmPasswordError(String error) {
confirmPasswordErrorTxt.setErrorText(error);
}
@Override
public void setCurrentPasswordError(String error) {
currentPasswordErrorTxt.setErrorText(error);
@OnClick(R.id.btn_submit)
public void onBtnSubmitClicked()
{
presenter.changePassword();
}
@Override
public Context getContext() {
return this;
}
}

158
app/src/main/res/layout/activity_change_password_v2.xml

@ -1,22 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rootViewChangePassword"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/background_gray">
<include layout="@layout/layout_sendmoney_toolbar"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
@ -32,107 +24,67 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/password_policy_text"
android:textSize="@dimen/_10ssp"
android:visibility="gone"
android:textColor="@color/darkgray"
android:layout_gravity="center"/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:id="@+id/currentPasswordText"
android:layout_marginTop="@dimen/_15sdp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/_2sdp"
android:text="@string/current_password_text"
android:textSize="@dimen/_10ssp"
app:txtfontName="@string/regular" />
<com.gmeremit.online.gmeremittance_native.security.securitykeypad.SecurityKeyboardView
android:id="@+id/securityKeyboardCurrentPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeErrorTextView
android:layout_marginStart="@dimen/_2sdp"
android:id="@+id/currentPasswordErrorTxt"
android:paddingTop="@dimen/_2sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:id="@+id/newPasswordText"
android:layout_marginTop="@dimen/_4sdp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/_2sdp"
android:text="@string/new_password_text"
android:textSize="@dimen/_10ssp"
app:txtfontName="@string/regular" />
<com.gmeremit.online.gmeremittance_native.security.securitykeypad.SecurityKeyboardView
android:id="@+id/securityKeyboardNewPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeErrorTextView
android:layout_marginStart="@dimen/_2sdp"
android:id="@+id/newPasswordErrorTxt"
android:paddingTop="@dimen/_2sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:id="@+id/confirmPasswordText"
android:layout_marginTop="@dimen/_4sdp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/_2sdp"
android:text="@string/confirm_password_text"
android:textSize="@dimen/_10ssp"
app:txtfontName="@string/regular" />
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeEditText
android:id="@+id/securityKeyboardConfirmPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeErrorTextView
android:layout_marginStart="@dimen/_2sdp"
android:id="@+id/confirmPasswordErrorTxt"
android:paddingTop="@dimen/_2sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.gmeremit.online.gmeremittance_native.common.view.MTextInputLayout
android:id="@+id/currentPassword_TxtInputLayout"
app:errorEnabled="true"
style="@style/MTextInputLayoutForm"
app:endIconMode="password_toggle"
android:hint="@string/current_password_text"
app:startIconDrawable="@drawable/vd_lock"
>
<com.gmeremit.online.gmeremittance_native.common.view.MTextInputEditText
android:inputType="textPassword"
android:id="@+id/currentPassword_edTxt"
style="@style/MTextInputEditText"/>
</com.gmeremit.online.gmeremittance_native.common.view.MTextInputLayout>
<com.gmeremit.online.gmeremittance_native.common.view.MTextInputLayout
android:id="@+id/newPassword_TxtInputLayout"
app:errorEnabled="true"
style="@style/MTextInputLayoutForm"
app:endIconMode="password_toggle"
android:hint="@string/new_password_text"
app:startIconDrawable="@drawable/vd_lock"
>
<com.gmeremit.online.gmeremittance_native.common.view.MTextInputEditText
android:inputType="textPassword"
android:id="@+id/newPassword_edTxt"
style="@style/MTextInputEditText"/>
</com.gmeremit.online.gmeremittance_native.common.view.MTextInputLayout>
<com.gmeremit.online.gmeremittance_native.common.view.MTextInputLayout
android:id="@+id/confirmPassword_TxtInputLayout"
app:errorEnabled="true"
style="@style/MTextInputLayoutForm"
app:endIconMode="password_toggle"
android:hint="@string/confirm_password_text"
app:startIconDrawable="@drawable/vd_lock"
>
<com.gmeremit.online.gmeremittance_native.common.view.MTextInputEditText
android:inputType="textPassword"
android:id="@+id/confirmPassword_edTxt"
style="@style/MTextInputEditText"/>
</com.gmeremit.online.gmeremittance_native.common.view.MTextInputLayout>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeButton
style="@style/gme_button"
android:id="@+id/btn_submit"
android:text="@string/save_password_text"
android:background="@drawable/ic_rounded_background_red_coloured"
android:textColor="@color/white"
android:textAllCaps="false"
android:enabled="false"
android:layout_gravity="center"
android:layout_marginTop="20dp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
<FrameLayout
android:id="@+id/keypadContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<RelativeLayout
android:id="@+id/keypadBallon"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
Loading…
Cancel
Save