From fcde21d29fc1e72182ea63ae30d8b94281094fa9 Mon Sep 17 00:00:00 2001 From: Santosh Bhandary Date: Mon, 9 Aug 2021 14:38:54 +0545 Subject: [PATCH] Existing Kyc form validation in button Clicked done --- .../ExistingKYCV3PresenterInterface.java | 2 + .../presenter/ExistingKYCV3ViewModel.java | 227 ++++++++++++------ .../ExistingCustomerDetailFragment.java | 107 +++++++-- .../newCustomer/presenter/KYCV3ViewModel.java | 14 +- .../sendmoney/view/SendMoneyV2Activity.java | 1 - .../fragment_existing_kyc_customer_detail.xml | 1 + 6 files changed, 249 insertions(+), 103 deletions(-) diff --git a/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/presenter/ExistingKYCV3PresenterInterface.java b/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/presenter/ExistingKYCV3PresenterInterface.java index 7b872bc8..4582e9fb 100644 --- a/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/presenter/ExistingKYCV3PresenterInterface.java +++ b/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/presenter/ExistingKYCV3PresenterInterface.java @@ -27,6 +27,8 @@ public interface ExistingKYCV3PresenterInterface extends BasePresenterInterface boolean getBackAdditionalRequired(); + boolean validateAllDetailForm(); + diff --git a/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/presenter/ExistingKYCV3ViewModel.java b/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/presenter/ExistingKYCV3ViewModel.java index 04eb70f9..0db79e19 100644 --- a/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/presenter/ExistingKYCV3ViewModel.java +++ b/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/presenter/ExistingKYCV3ViewModel.java @@ -18,6 +18,8 @@ import com.swifttech.remit.jmecustomer.features.kyc.existingCustomer.model.Exist import com.swifttech.remit.jmecustomer.features.kyc.existingCustomer.view.documents.ExistingKYCIDTypeFragment; import com.swifttech.remit.jmecustomer.features.kyc.existingCustomer.view.documents.ExistingKYCIDTypeViewLiveData; import com.swifttech.remit.jmecustomer.features.kyc.existingCustomer.view.personal.ExistingCustomerDetailViewLiveData; +import com.swifttech.remit.jmecustomer.features.kyc.newCustomer.model.IDTextDTO; +import com.swifttech.remit.jmecustomer.features.kyc.newCustomer.model.PersonalInfoDTO; import com.swifttech.remit.jmecustomer.features.login.model.LoginV2DataApiResponse; import com.swifttech.remit.jmecustomer.features.login.presenter.LoginV2InteractorInterface; import com.swifttech.remit.jmecustomer.utils.Constants; @@ -58,10 +60,10 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC private final CompositeDisposable compositeDisposable; private final String userId; private final String userPwd; - ExistingCustomerDetailViewLiveData.CustomerDetailViewBinding viewBindings; - private CustomerDetailViewValidator validator; private final PublishSubject form1ValidationSubject; private final PublishSubject form2ValidationSubject; + ExistingCustomerDetailViewLiveData.CustomerDetailViewBinding viewBindings; + private CustomerDetailViewValidator validator; private String newToken; public ExistingKYCV3ViewModel(KYCV3ViewContractInterface view, ExistingKYCV3GatewayInterface gatewayInterface, ExistingFileDownloadGateway existingFileDownloadGateway, LoginV2InteractorInterface.Login2GatewayInterface loginGateway, String userId, String userPwd) { @@ -214,10 +216,10 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC } - String selectedIdTypeText=existingPersonalInfoDTO.getIdType(); - ExistingIDTextDTO selectedIdType=data.getIDTypeFromId(selectedIdTypeText); - if(selectedIdType==null && selectedIdTypeText!=null){ - selectedIdType = new ExistingIDTextDTO(selectedIdTypeText,selectedIdTypeText); + String selectedIdTypeText = existingPersonalInfoDTO.getIdType(); + ExistingIDTextDTO selectedIdType = data.getIDTypeFromId(selectedIdTypeText); + if (selectedIdType == null && selectedIdTypeText != null) { + selectedIdType = new ExistingIDTextDTO(selectedIdTypeText, selectedIdTypeText); } @@ -238,7 +240,7 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC customerDetailLiveData.getPurposeOfRegistrationLiveData().postValue(new FormInputStateDTO<>(true, null, purposeOfRegistration)); customerDetailLiveData.getMonthlyIncomeLiveData().postValue(new FormInputStateDTO<>(true, null, existingPersonalInfoDTO.getMonthlyIncome())); customerDetailLiveData.getBusinessTypeLiveData().postValue(new FormInputStateDTO<>(true, null, data.getBusinessTypeFromId(existingPersonalInfoDTO.getBusinessType()))); - customerDetailLiveData.getIdTypeLiveData().postValue(new FormInputStateDTO<>(true, null,selectedIdType)); + customerDetailLiveData.getIdTypeLiveData().postValue(new FormInputStateDTO<>(true, null, selectedIdType)); customerDetailLiveData.getMobileNumberLiveData().postValue(new FormInputStateDTO<>(true, null, mobileNumber)); customerDetailLiveData.getAddressLiveData().postValue(new FormInputStateDTO<>(true, null, existingPersonalInfoDTO.getAdditionalAddress())); customerDetailLiveData.getVisaStatusLiveData().postValue(new FormInputStateDTO<>(true, null, data.getVisaStatusFromId(existingPersonalInfoDTO.getVisaStatus()))); @@ -448,7 +450,7 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC @Override public void termsAndConditionAccept() { this.compositeDisposable.add( - this.gateway.agreeToUserTermsAndConditions(this.gateway.getBasicAuth(view.getContext()), this.gateway.getUserID(),"Y") + this.gateway.agreeToUserTermsAndConditions(this.gateway.getBasicAuth(view.getContext()), this.gateway.getUserID(), "Y") .doOnSubscribe(sub -> view.showProgressBar(true, "")) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -463,6 +465,39 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC return false; } + @Override + public boolean validateAllDetailForm() { + ExistingKYCRelatedDataDTO existingKYCRelatedDataDTO = validator.getExistingKycRelatedDataDTO(); + ExistingIDTextDTO visaStatus = existingKYCRelatedDataDTO.getVisaStatusFromId(existingKYCRelatedDataDTO.getPersonalInformation().getVisaStatus()); + ExistingIDTextDTO occupation = existingKYCRelatedDataDTO.getOccupationFromId(existingKYCRelatedDataDTO.getPersonalInformation().getOccupation()); + ExistingIDTextDTO purposeOfRegistration = existingKYCRelatedDataDTO.getPurposeOfRegistrationFromId(existingKYCRelatedDataDTO.getPersonalInformation().getPurposeOfRegistration()); + CharSequence address = existingKYCRelatedDataDTO.getPersonalInformation().getAdditionalAddress(); + ExistingIDTextDTO businessType = existingKYCRelatedDataDTO.getBusinessTypeFromId(existingKYCRelatedDataDTO.getPersonalInformation().getBusinessType()); + ExistingIDTextDTO selectedIdType = existingKYCRelatedDataDTO.getIDTypeFromId(existingKYCRelatedDataDTO.getPersonalInformation().getIdType()); + CharSequence mobileNumber = existingKYCRelatedDataDTO.getPersonalInformation().getMobile(); + CharSequence monthlyIncome = existingKYCRelatedDataDTO.getPersonalInformation().getMonthlyIncome(); + CharSequence employerName = existingKYCRelatedDataDTO.getPersonalInformation().getEmployeerName(); + + if ( + validator.validateEmployerName(employerName) && + validator.validateOccupation(occupation) && + validator.validateMonthlyIncome(monthlyIncome) && + validator.validateMobileNumber(mobileNumber) && + validator.validateBusinessType(businessType) && + validator.validateAddress(address) && + validator.validatePurposeOfRegistration(purposeOfRegistration) && + validator.validateSelectedIDType(selectedIdType) && + validator.validateVisaStatus(visaStatus) + + ) { + return true; + } else { + return false; + } + + + } + @Override public List getOccupationList() { return validator.getExistingKycRelatedDataDTO().getOccupationList(); @@ -614,31 +649,37 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC } boolean validateOccupation(ExistingIDTextDTO data) { - if (existingKycRelatedDataDTO.getPersonalInformation() == null) - existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); - - if (shouldPromptToInputAnswer(data)) { - view.promptToInputAnswer(view.getContext().getResources().getString(R.string.specifyOccupation_text), new AnswerInputDialog.AnswerInputDialogListener() { - @Override - public void onAnswerSubmitted(String answer) { + if (data != null) { + if (existingKycRelatedDataDTO.getPersonalInformation() == null) + existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); + + if (shouldPromptToInputAnswer(data)) { + view.promptToInputAnswer(view.getContext().getResources().getString(R.string.specifyOccupation_text), new AnswerInputDialog.AnswerInputDialogListener() { + @Override + public void onAnswerSubmitted(String answer) { + existingKycRelatedDataDTO.getPersonalInformation().setOccupation(""); + existingKycRelatedDataDTO.getPersonalInformation().setOtherOccupation(answer); + customerDetailLiveData.getOccupationsLiveData().postValue(new FormInputStateDTO<>(true, null, ExistingIDTextDTO.createFromUserAnswerInput(answer))); + } + }); + } else { + if (!data.getId().equalsIgnoreCase(data.getText())) { + existingKycRelatedDataDTO.getPersonalInformation().setOccupation(data.getId()); + existingKycRelatedDataDTO.getPersonalInformation().setOtherOccupation(""); + } else { existingKycRelatedDataDTO.getPersonalInformation().setOccupation(""); - existingKycRelatedDataDTO.getPersonalInformation().setOtherOccupation(answer); - customerDetailLiveData.getOccupationsLiveData().postValue(new FormInputStateDTO<>(true, null, ExistingIDTextDTO.createFromUserAnswerInput(answer))); + existingKycRelatedDataDTO.getPersonalInformation().setOtherOccupation(data.getId()); } - }); - } else { - if(!data.getId().equalsIgnoreCase(data.getText())){ - existingKycRelatedDataDTO.getPersonalInformation().setOccupation(data.getId()); - existingKycRelatedDataDTO.getPersonalInformation().setOtherOccupation(""); - }else{ - existingKycRelatedDataDTO.getPersonalInformation().setOccupation(""); - existingKycRelatedDataDTO.getPersonalInformation().setOtherOccupation(data.getId()); } - } - if (existingKycRelatedDataDTO.getPersonalInformation().isOccupationValid()||existingKycRelatedDataDTO.getPersonalInformation().isOtherOccupationValid()) { - return true; + if (existingKycRelatedDataDTO.getPersonalInformation().isOccupationValid() || existingKycRelatedDataDTO.getPersonalInformation().isOtherOccupationValid()) { + customerDetailLiveData.getOccupationsLiveData().setValue(new FormInputStateDTO<>(true, null, null)); + return true; + } else { + customerDetailLiveData.getOccupationsLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidOccupation_text), null)); + return false; + } } else { customerDetailLiveData.getOccupationsLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidOccupation_text), null)); return false; @@ -647,13 +688,18 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC boolean validateAddress(CharSequence data) { - if (existingKycRelatedDataDTO.getPersonalInformation() == null) - existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); + if (data != null) { + if (existingKycRelatedDataDTO.getPersonalInformation() == null) + existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); - existingKycRelatedDataDTO.getPersonalInformation().setAdditionalAddress(data != null ? data.toString() : null); - if (existingKycRelatedDataDTO.getPersonalInformation().isAdditionalAddressValid()) { - customerDetailLiveData.getAddressLiveData().setValue(new FormInputStateDTO<>(true, null, null)); - return true; + existingKycRelatedDataDTO.getPersonalInformation().setAdditionalAddress(data != null ? data.toString() : null); + if (existingKycRelatedDataDTO.getPersonalInformation().isAdditionalAddressValid()) { + customerDetailLiveData.getAddressLiveData().setValue(new FormInputStateDTO<>(true, null, null)); + return true; + } else { + customerDetailLiveData.getAddressLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.InvalidAddress_text), null)); + return false; + } } else { customerDetailLiveData.getAddressLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.InvalidAddress_text), null)); return false; @@ -661,12 +707,18 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC } boolean validateBusinessType(ExistingIDTextDTO data) { - if (existingKycRelatedDataDTO.getPersonalInformation() == null) - existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); + if (data != null) { + if (existingKycRelatedDataDTO.getPersonalInformation() == null) + existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); - existingKycRelatedDataDTO.getPersonalInformation().setBusinessType(data.getId()); - if (existingKycRelatedDataDTO.getPersonalInformation().isBusinessTypeValid()) { - return true; + existingKycRelatedDataDTO.getPersonalInformation().setBusinessType(data.getId()); + if (existingKycRelatedDataDTO.getPersonalInformation().isBusinessTypeValid()) { + customerDetailLiveData.getBusinessTypeLiveData().setValue(new FormInputStateDTO<>(true, null, null)); + return true; + } else { + customerDetailLiveData.getBusinessTypeLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidBusinessType_text), null)); + return false; + } } else { customerDetailLiveData.getBusinessTypeLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidBusinessType_text), null)); return false; @@ -675,53 +727,75 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC boolean validateSelectedIDType(ExistingIDTextDTO data) { - if (existingKycRelatedDataDTO.getPersonalInformation() == null) - existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); + if (data != null) { + if (existingKycRelatedDataDTO.getPersonalInformation() == null) + existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); + + if (shouldPromptToInputAnswer(data)) { + view.promptToInputAnswer(view.getContext().getResources().getString(R.string.specifyIdType), answer -> { + existingKycRelatedDataDTO.getPersonalInformation().setIdType(""); + existingKycRelatedDataDTO.getPersonalInformation().setOtherIdType(answer); + customerDetailLiveData.getIdTypeLiveData().postValue(new FormInputStateDTO<>(true, null, ExistingIDTextDTO.createFromUserAnswerInput(answer))); + }); + } else { + if (!data.getId().equalsIgnoreCase(data.getText())) { + existingKycRelatedDataDTO.getPersonalInformation().setIdType(data.getId()); + existingKycRelatedDataDTO.getPersonalInformation().setOtherIdType(""); + } else { + existingKycRelatedDataDTO.getPersonalInformation().setIdType(""); + existingKycRelatedDataDTO.getPersonalInformation().setOtherIdType(data.getId()); + } - if (shouldPromptToInputAnswer(data)) { - view.promptToInputAnswer(view.getContext().getResources().getString(R.string.specifyIdType), answer -> { - existingKycRelatedDataDTO.getPersonalInformation().setIdType(""); - existingKycRelatedDataDTO.getPersonalInformation().setOtherIdType(answer); - customerDetailLiveData.getIdTypeLiveData().postValue(new FormInputStateDTO<>(true, null, ExistingIDTextDTO.createFromUserAnswerInput(answer))); - }); - } else { - if(!data.getId().equalsIgnoreCase(data.getText())){ - existingKycRelatedDataDTO.getPersonalInformation().setIdType(data.getId()); - existingKycRelatedDataDTO.getPersonalInformation().setOtherIdType(""); - }else{ - existingKycRelatedDataDTO.getPersonalInformation().setIdType(""); - existingKycRelatedDataDTO.getPersonalInformation().setOtherIdType(data.getId()); } - } - if (existingKycRelatedDataDTO.getPersonalInformation().isIdTypeValid()||existingKycRelatedDataDTO.getPersonalInformation().isOtherIdTypeValid()) { - return true; + + + if (existingKycRelatedDataDTO.getPersonalInformation().isIdTypeValid() || existingKycRelatedDataDTO.getPersonalInformation().isOtherIdTypeValid()) { + customerDetailLiveData.getIdTypeLiveData().setValue(new FormInputStateDTO<>(true, null, null)); + return true; + } else { + customerDetailLiveData.getIdTypeLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidIdType_text), null)); + return false; + } } else { customerDetailLiveData.getIdTypeLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidIdType_text), null)); return false; } + } boolean validateVisaStatus(ExistingIDTextDTO data) { - if (existingKycRelatedDataDTO.getPersonalInformation() == null) - existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); + if(data!=null){ + if (existingKycRelatedDataDTO.getPersonalInformation() == null) + existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); - existingKycRelatedDataDTO.getPersonalInformation().setVisaStatus(data.getId()); - if (existingKycRelatedDataDTO.getPersonalInformation().isVisaStatusValid()) { - return true; - } else { + existingKycRelatedDataDTO.getPersonalInformation().setVisaStatus(data.getId()); + if (existingKycRelatedDataDTO.getPersonalInformation().isVisaStatusValid()) { + return true; + } else { + customerDetailLiveData.getVisaStatusLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidVisaStatus_text), null)); + return false; + } + }else{ customerDetailLiveData.getVisaStatusLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidVisaStatus_text), null)); return false; } + } boolean validatePurposeOfRegistration(ExistingIDTextDTO data) { - if (existingKycRelatedDataDTO.getPersonalInformation() == null) - existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); + if(data!=null){ + if (existingKycRelatedDataDTO.getPersonalInformation() == null) + existingKycRelatedDataDTO.setPersonalInformation(new ExistingPersonalInfoDTO()); - existingKycRelatedDataDTO.getPersonalInformation().setPurposeOfRegistration(data.getId()); - if (existingKycRelatedDataDTO.getPersonalInformation().isPurposeOfRegistrationValid()) { - return true; - } else { + existingKycRelatedDataDTO.getPersonalInformation().setPurposeOfRegistration(data.getId()); + if (existingKycRelatedDataDTO.getPersonalInformation().isPurposeOfRegistrationValid()) { + customerDetailLiveData.getPurposeOfRegistrationLiveData().setValue(new FormInputStateDTO<>(true, null, null)); + return true; + } else { + customerDetailLiveData.getPurposeOfRegistrationLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidPuropseOfReg_text), null)); + return false; + } + }else{ customerDetailLiveData.getPurposeOfRegistrationLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getResources().getString(R.string.invalidPuropseOfReg_text), null)); return false; } @@ -904,32 +978,31 @@ public class ExistingKYCV3ViewModel extends BaseViewModel implements ExistingKYC task.run(); } } + public class TermsAndConditionResultObserver extends GenericApiObserverResponseV2 { @Override protected void onSuccess(GenericResponseDataModel t) { - if(t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) - { + if (t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { view.onTermsPostSuccess(); - } - else - view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED,null); + } else + view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, null); } @Override public void onFailed(String message) { - view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED,null); + view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); } @Override protected void onConnectionNotEstablished(String message) { - view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED,null); + view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); } @Override protected void unauthorizedAccess(String message) { - view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED,null); + view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null); } } } diff --git a/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailFragment.java b/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailFragment.java index 84cac535..d9d96c6a 100644 --- a/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailFragment.java +++ b/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailFragment.java @@ -1,6 +1,7 @@ package com.swifttech.remit.jmecustomer.features.kyc.existingCustomer.view.personal; import android.annotation.SuppressLint; +import android.graphics.Rect; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; @@ -20,6 +21,7 @@ import com.swifttech.remit.jmecustomer.R; import com.swifttech.remit.jmecustomer.base.BaseFragment; import com.swifttech.remit.jmecustomer.common.customwidgets.common.GenericTextListingDialog; import com.swifttech.remit.jmecustomer.common.model.FormInputStateDTO; +import com.swifttech.remit.jmecustomer.common.view.MTextInputLayout; import com.swifttech.remit.jmecustomer.features.kyc.existingCustomer.model.ExistingIDTextDTO; import com.swifttech.remit.jmecustomer.features.kyc.existingCustomer.presenter.ExistingKYCV3PresenterInterface; import com.swifttech.remit.jmecustomer.features.kyc.existingCustomer.presenter.ExistingKYCV3ViewModel; @@ -92,6 +94,22 @@ public class ExistingCustomerDetailFragment extends BaseFragment implements Exis @BindView(R.id.btn_submit1) Button btnSubmit1; + @BindView(R.id.visaStatusWrapper) + MTextInputLayout visaStatusWrapper; + + + @BindView(R.id.businessTypeSelectionWrapper) + MTextInputLayout businessTypeSelectionWrapper; + + @BindView(R.id.idTypeSelectionWrapper) + MTextInputLayout idTypeSelectionWrapper; + +@BindView(R.id.occupationSelectionWrapper) + MTextInputLayout occupationSelectionWrapper; + +@BindView(R.id.purposeOfRegistrationWrapper) + MTextInputLayout purposeOfRegistrationWrapper; + private GenericTextListingDialog occupationSelectionDialog; private GenericTextListingDialog businessTypeSelectionDialog; @@ -162,109 +180,134 @@ public class ExistingCustomerDetailFragment extends BaseFragment implements Exis existingCustomerDetailViewLiveData.getOccupationsLiveData().observe(getViewLifecycleOwner(), this::onOccupationSelected); existingCustomerDetailViewLiveData.getVisaStatusLiveData().observe(getViewLifecycleOwner(), this::onVisaStatusSelected); existingCustomerDetailViewLiveData.getPurposeOfRegistrationLiveData().observe(getViewLifecycleOwner(), this::onPurposeOfRegistrationSelected); - existingCustomerDetailViewLiveData.getAllFieldsValidLiveData().observe(getViewLifecycleOwner(), areAllFieldsValid -> btnSubmit1.setEnabled(areAllFieldsValid)); - - + existingCustomerDetailViewLiveData.getAllFieldsValidLiveData().observe(getViewLifecycleOwner(), areAllFieldsValid -> { +// btnSubmit1.setEnabled(areAllFieldsValid); + }); } private void onOccupationSelected(FormInputStateDTO data) { if (data.isValid()) { + occupationSelectionWrapper.setError(null); + occupationSelectionWrapper.setErrorEnabled(false); if (data.hasData()) { ed_occupation.setText(data.getData().getText()); occupationSelectSubject.onNext(data.getData()); } + }else{ + occupationSelectionWrapper.setErrorEnabled(true); + occupationSelectionWrapper.setError(data.getErrorMessage()); + focusOnView(occupationSelectionWrapper); } } private void onEmployerNameSelected(FormInputStateDTO data) { if (data.isValid()) { + employerNameWrapper.setError(null); + employerNameWrapper.setErrorEnabled(false); if (data.hasData()) { ed_employerName.setText(data.getData()); - } else{ - employerNameWrapper.setError(null); - employerNameWrapper.setErrorEnabled(false); } } else{ employerNameWrapper.setErrorEnabled(true); employerNameWrapper.setError(data.getErrorMessage()); + focusOnView(employerNameWrapper); } + } private void onMonthlyIncomeSelected(FormInputStateDTO data) { if (data.isValid()) { + monthlyIncomeSelectionWrapper.setError(null); + monthlyIncomeSelectionWrapper.setErrorEnabled(false); if (data.hasData()) { ed_monthlyIncome.setText(data.getData()); - } else{ - monthlyIncomeSelectionWrapper.setError(null); - monthlyIncomeSelectionWrapper.setErrorEnabled(false); } } else{ monthlyIncomeSelectionWrapper.setErrorEnabled(true); monthlyIncomeSelectionWrapper.setError(data.getErrorMessage()); - + focusOnView(monthlyIncomeSelectionWrapper); } + } private void onMobileNumberSelected(FormInputStateDTO data) { if (data.isValid()) { + mobileNumberWrapper.setError(null); + mobileNumberWrapper.setErrorEnabled(false); if (data.hasData()) { ed_mobileNumber.setText(data.getData()); - } else{ - mobileNumberWrapper.setError(null); - mobileNumberWrapper.setErrorEnabled(false); - } } else{ mobileNumberWrapper.setErrorEnabled(true); mobileNumberWrapper.setError(data.getErrorMessage()); + focusOnView(mobileNumberWrapper); } } private void onIdTypeSelected(FormInputStateDTO data) { if (data.isValid()) { + idTypeSelectionWrapper.setError(null); + idTypeSelectionWrapper.setErrorEnabled(false); if (data.hasData()) { ed_idType.setText(data.getData().getText()); idTypeSelectSubject.onNext(data.getData()); } + }else{ + idTypeSelectionWrapper.setErrorEnabled(true); + idTypeSelectionWrapper.setError(data.getErrorMessage()); + focusOnView(idTypeSelectionWrapper); } } private void onBusinessTypeSelected(FormInputStateDTO data) { if (data.isValid()) { + businessTypeSelectionWrapper.setError(null); + businessTypeSelectionWrapper.setErrorEnabled(false); if (data.hasData()) { ed_businesstype.setText(data.getData().getText()); businessTypeSelectSubject.onNext(data.getData()); } + }else{ + businessTypeSelectionWrapper.setErrorEnabled(true); + businessTypeSelectionWrapper.setError(data.getErrorMessage()); + focusOnView(businessTypeSelectionWrapper); } } private void onPurposeOfRegistrationSelected(FormInputStateDTO data) { if (data.isValid()) { + purposeOfRegistrationWrapper.setError(null); + purposeOfRegistrationWrapper.setErrorEnabled(false); if (data.hasData()) { ed_purposeOfRegistration.setText(data.getData().getText()); purposeOfRegistrationSubject.onNext(data.getData()); } + } else { + purposeOfRegistrationWrapper.setErrorEnabled(true); + purposeOfRegistrationWrapper.setError(data.getErrorMessage()); + focusOnView(purposeOfRegistrationWrapper); } } private void onAddressSelected(FormInputStateDTO data) { if (data.isValid()) { + addressWrapper.setError(null); + addressWrapper.setErrorEnabled(false); if (data.hasData()) { ed_address.setText(data.getData()); - } else{ - addressWrapper.setError(null); - addressWrapper.setErrorEnabled(false); } } else{ addressWrapper.setErrorEnabled(true); addressWrapper.setError(data.getErrorMessage()); + focusOnView(addressWrapper); + } @@ -273,17 +316,26 @@ public class ExistingCustomerDetailFragment extends BaseFragment implements Exis private void onVisaStatusSelected(FormInputStateDTO data) { if (data.isValid()) { + visaStatusWrapper.setError(null); + visaStatusWrapper.setErrorEnabled(false); if (data.hasData()) { ed_visaStatus.setText(data.getData().getText()); visaStatusSelectionSubject.onNext(data.getData()); } + }else{ + visaStatusWrapper.setErrorEnabled(true); + visaStatusWrapper.setError(getString(R.string.invalidVisaStatus_text)); + focusOnView(visaStatusWrapper); } } @OnClick(R.id.btn_submit1) public void onClick() { - new ViewModelProvider(requireActivity()).get(ExistingKYCV3ViewModel.class).sendForm1KYCUpdate(); + if(kycv3ViewModel.validateAllDetailForm()){ + new ViewModelProvider(requireActivity()).get(ExistingKYCV3ViewModel.class).sendForm1KYCUpdate(); + } + } @@ -469,6 +521,25 @@ public class ExistingCustomerDetailFragment extends BaseFragment implements Exis purposeOfRegistrationDialog.show(getActivity().getSupportFragmentManager(), "PURPOSE_OF_REGISTRATION_CHOOSER"); } + private void focusOnView(View view){ + boolean isVisible=isViewVisible(view); + if(isVisible==false){ + scrollView.post(() -> scrollView.setScrollY(view.getTop()+25)); + } + } + public boolean isViewVisible( View view) { + Rect scrollBounds = new Rect(); + scrollView.getDrawingRect(scrollBounds); + + float top = view.getY(); + float bottom = top + view.getHeight(); + + if (scrollBounds.top < top && scrollBounds.bottom > bottom) { + return true; + } else { + return false; + } + } } diff --git a/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/newCustomer/presenter/KYCV3ViewModel.java b/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/newCustomer/presenter/KYCV3ViewModel.java index d89d10b7..d2d98c88 100644 --- a/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/newCustomer/presenter/KYCV3ViewModel.java +++ b/app/src/main/java/com/swifttech/remit/jmecustomer/features/kyc/newCustomer/presenter/KYCV3ViewModel.java @@ -127,16 +127,16 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter CharSequence monthlyIncome = kycRelatedDataDTO.getPersonalInformation().getMonthlyIncome(); CharSequence employerName = kycRelatedDataDTO.getPersonalInformation().getEmployeerName(); - if (validator.validateAdditionalIdType(additionalIdType) && + if ( + validator.validateEmployerName(employerName)&& validator.validateOccupation(occupation) && - validator.validatePurposeOfRegistration(purposeOfRegistration) && - validator.validateAddress(address) && + validator.validateMonthlyIncome(monthlyIncome)&& + validator.validateMobileNumber(mobileNumber) && validator.validateBusinessType(businessType) && + validator.validateAddress(address) && + validator.validatePurposeOfRegistration(purposeOfRegistration) && validator.validateSelectedIDType(selectedIdType) && - validator.validateMobileNumber(mobileNumber) && - validator.validateMonthlyIncome(monthlyIncome) && - validator.validateEmployerName(employerName) - + validator.validateAdditionalIdType(additionalIdType) ) { return true; } else { diff --git a/app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/view/SendMoneyV2Activity.java b/app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/view/SendMoneyV2Activity.java index c8ff1fd1..196f29c4 100644 --- a/app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/view/SendMoneyV2Activity.java +++ b/app/src/main/java/com/swifttech/remit/jmecustomer/features/sendmoney/view/SendMoneyV2Activity.java @@ -137,7 +137,6 @@ public class SendMoneyV2Activity extends BaseActivity implements SendMoneyAction public boolean popFragmentFromStack() { if (fragmentManager.getBackStackEntryCount() == 1) { - Log.d("===", "CCDI data cleared : "); presenter.clearCCDIFormData(); } return fragmentManager.getBackStackEntryCount() > 0; diff --git a/app/src/main/res/layout/fragment_existing_kyc_customer_detail.xml b/app/src/main/res/layout/fragment_existing_kyc_customer_detail.xml index 70c789e0..6ceb9da2 100644 --- a/app/src/main/res/layout/fragment_existing_kyc_customer_detail.xml +++ b/app/src/main/res/layout/fragment_existing_kyc_customer_detail.xml @@ -235,6 +235,7 @@