|
|
@ -11,7 +11,6 @@ import com.gmeremit.online.gmeremittance_native.R; |
|
|
|
import com.gmeremit.online.gmeremittance_native.addautodebitV2.view.AddPrimaryAccounAsAutoDebitActivity; |
|
|
|
import com.gmeremit.online.gmeremittance_native.base.BaseViewModel; |
|
|
|
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog; |
|
|
|
import com.gmeremit.online.gmeremittance_native.customwidgets.banklistingdialog.BankIconMapper; |
|
|
|
import com.gmeremit.online.gmeremittance_native.kycV3.model.IDTextDTO; |
|
|
|
import com.gmeremit.online.gmeremittance_native.kycV3.model.IDTypeDTO; |
|
|
|
import com.gmeremit.online.gmeremittance_native.kycV3.model.KYCRelatedDataDTO; |
|
|
@ -38,6 +37,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers; |
|
|
|
import io.reactivex.disposables.CompositeDisposable; |
|
|
|
import io.reactivex.observers.DisposableObserver; |
|
|
|
import io.reactivex.schedulers.Schedulers; |
|
|
|
import io.reactivex.subjects.BehaviorSubject; |
|
|
|
|
|
|
|
import static android.app.Activity.RESULT_OK; |
|
|
|
|
|
|
@ -54,11 +54,11 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
private MutableLiveData<Boolean> customerDetailForm1Button; |
|
|
|
private MutableLiveData<Boolean> customerDetailForm2Button; |
|
|
|
private MutableLiveData<Boolean> customerDetailForm3Button; |
|
|
|
private MutableLiveData<Boolean> customerDetailAlternateIDFieldAccessLiveData; |
|
|
|
private MutableLiveData<Boolean> customerDetailAlternateIDFieldEnableLiveData; |
|
|
|
private MutableLiveData<Bitmap> passportImageLiveData; |
|
|
|
private MutableLiveData<Bitmap> alternateIDImageLiveData; |
|
|
|
private MutableLiveData<Boolean> alternateIDIssueDateRequireLiveData; |
|
|
|
private MutableLiveData<Boolean> alternateIDExpiryDateRequireLiveData; |
|
|
|
private MutableLiveData<Boolean> alternateIDIssueVisibilityDateRequireLiveData; |
|
|
|
private MutableLiveData<Boolean> alternateIDExpiryDateVisibilityLiveData; |
|
|
|
|
|
|
|
private CustomerDetailErrorLiveDataDTO customerDetailErrorLiveDataDTO; |
|
|
|
|
|
|
@ -89,8 +89,8 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
private static final String ID_TYPE_NATIONAL_ID_CARD = "National ID"; |
|
|
|
private static final String ID_TYPE_DRIVING_LICENSE = "Driving License"; |
|
|
|
|
|
|
|
//Since we cannot propogate null in rxStream. So using a randomKey. |
|
|
|
public static final String VALID_STRING_DATA = "validStringData!!@@##"; |
|
|
|
|
|
|
|
private BehaviorSubject<Boolean> alternateIdRelatedValidationSubject; |
|
|
|
|
|
|
|
|
|
|
|
public KYCV3ViewModel(KYCV3PresenterInterface.KYCV3ViewContractInterface view, KYCV3GatewayInterface gatewayInterface) { |
|
|
@ -101,11 +101,11 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
this.customerDetailForm1Button = new MutableLiveData<>(); |
|
|
|
this.customerDetailForm2Button = new MutableLiveData<>(); |
|
|
|
this.customerDetailForm3Button = new MutableLiveData<>(); |
|
|
|
this.customerDetailAlternateIDFieldAccessLiveData = new MutableLiveData<>(); |
|
|
|
this.customerDetailAlternateIDFieldEnableLiveData = new MutableLiveData<>(); |
|
|
|
this.passportImageLiveData = new MutableLiveData<>(); |
|
|
|
this.alternateIDImageLiveData = new MutableLiveData<>(); |
|
|
|
this.alternateIDIssueDateRequireLiveData = new MutableLiveData<>(); |
|
|
|
this.alternateIDExpiryDateRequireLiveData = new MutableLiveData<>(); |
|
|
|
this.alternateIDIssueVisibilityDateRequireLiveData = new MutableLiveData<>(); |
|
|
|
this.alternateIDExpiryDateVisibilityLiveData = new MutableLiveData<>(); |
|
|
|
this.customerDetailViewSubscriptions = new CompositeDisposable(); |
|
|
|
this.customerDetailErrorLiveDataDTO = new CustomerDetailErrorLiveDataDTO(); |
|
|
|
|
|
|
@ -119,6 +119,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
|
|
|
|
this.penntestReferenceSubmissionLiveData = new MutableLiveData<>(); |
|
|
|
this.penntestReferenceErrorMessageLiveData = new MutableLiveData<>(); |
|
|
|
alternateIdRelatedValidationSubject = BehaviorSubject.createDefault(true); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
@ -145,6 +146,25 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
Observable.combineLatest(setUpForm1Validation(), setUpForm2Validation(), setUpForm3Validation(), (form1Result, form2Result, form3Result) -> form1Result && form2Result && form3Result) |
|
|
|
.subscribeOn(AndroidSchedulers.mainThread()) |
|
|
|
.subscribeWith(new CustomerDetailFormViewBindingObserver())); |
|
|
|
|
|
|
|
this.customerDetailViewSubscriptions.add( |
|
|
|
setupAlternateIDDependenciesValidation() |
|
|
|
.subscribeWith(new DisposableObserver<Boolean>() { |
|
|
|
@Override |
|
|
|
public void onNext(Boolean aBoolean) { |
|
|
|
alternateIdRelatedValidationSubject.onNext(aBoolean); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError(Throwable e) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onComplete() { |
|
|
|
|
|
|
|
} |
|
|
|
})); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -198,6 +218,8 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
boolean result = isFullNameValid && isEmailValid && isAddressValid && isDobValid && isGenderValid && isCityValid; |
|
|
|
Log.d(TAG, "Form 1 valid: " + result); |
|
|
|
customerDetailForm1Button.setValue(result); |
|
|
|
if (!result) |
|
|
|
customerDetailForm2Button.setValue(false); |
|
|
|
return result; |
|
|
|
} |
|
|
|
); |
|
|
@ -214,24 +236,21 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
list.add(this.view.getCustomerDetailViewContract().getForm2ViewBindings().getPassportExpiryDateChangeEvent().map(val -> validator.validatePassportExpiryDate(val.toString()))); |
|
|
|
list.add(this.view.getCustomerDetailViewContract().getForm2ViewBindings().getGMEBranchChangeEvent().map(val -> validator.validateGmeBranch(val))); |
|
|
|
list.add(this.view.getCustomerDetailViewContract().getForm2ViewBindings().getReferralCodeChangeEvent().map(val -> validator.validateReferralCode(val))); |
|
|
|
list.add(alternateIdRelatedValidationSubject); |
|
|
|
|
|
|
|
return this.setupAlternateIDDependenciesValidation().withLatestFrom( |
|
|
|
Observable.combineLatest( |
|
|
|
list, |
|
|
|
args -> |
|
|
|
{ |
|
|
|
boolean result = ((boolean) args[0]) && ((boolean) args[1]) && ((boolean) args[2]) |
|
|
|
&& ((boolean) args[3]) && ((boolean) args[4]) && ((boolean) args[5]) && ((boolean) args[6]); |
|
|
|
customerDetailForm2Button.setValue(result); |
|
|
|
log("Form 2 isValid : " + result); |
|
|
|
return result; |
|
|
|
} |
|
|
|
), (alternateIdValidation, form2Validation) -> { |
|
|
|
boolean result = form2Validation && alternateIdValidation; |
|
|
|
log("Form 2 All isValid : " + result); |
|
|
|
|
|
|
|
return Observable.combineLatest( |
|
|
|
list, |
|
|
|
args -> |
|
|
|
{ |
|
|
|
boolean result = ((boolean) args[0]) && ((boolean) args[1]) && ((boolean) args[2]) |
|
|
|
&& ((boolean) args[3]) && ((boolean) args[4]) && ((boolean) args[5]) && ((boolean) args[6]) |
|
|
|
&& ((boolean) args[7]); |
|
|
|
customerDetailForm2Button.setValue(result); |
|
|
|
log("Form 2 isValid : " + result); |
|
|
|
return result; |
|
|
|
}); |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
@ -246,7 +265,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIDIssuedDateChangeEvent().map(val -> validator.validateAlternateIDIssuedDate2(val.toString())), |
|
|
|
this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIDExpiryDateChangeEvent().map(val -> validator.validateAlternateIDExpiryDate2(val.toString())), |
|
|
|
(isAlternateIdNoValid, isAlternateIdIssuedDateValid, isAlternatedIDExpiryDateValid) -> isAlternateIdNoValid && isAlternateIdIssuedDateValid && isAlternatedIDExpiryDateValid |
|
|
|
).withLatestFrom(this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIdTypeChangeEvent().map(val -> validator.validateAlternateIdType2(val)), |
|
|
|
).withLatestFrom(this.view.getCustomerDetailViewContract().getForm2ViewBindings().getAlternateIdTypeChangeEvent().map(val -> validator.validateAlternateIdType(val)), |
|
|
|
(isAlternatedTypeDependenciesValid, isAlternateIdTypeValid) -> { |
|
|
|
log("AlternatedIDDependencies isValid : " + isAlternatedTypeDependenciesValid); |
|
|
|
log("AlternateIDType isValid : " + isAlternateIdTypeValid); |
|
|
@ -310,7 +329,14 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
|
|
|
|
@Override |
|
|
|
public void clearAlternateIDFields() { |
|
|
|
|
|
|
|
alternateIDIssueVisibilityDateRequireLiveData.setValue(false); |
|
|
|
alternateIDExpiryDateVisibilityLiveData.setValue(false); |
|
|
|
customerDetailAlternateIDFieldEnableLiveData.setValue(false); |
|
|
|
|
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError(null); |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDIssuedDateError(null); |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDExpiryDateError(null); |
|
|
|
alternateIdRelatedValidationSubject.onNext(true); |
|
|
|
} |
|
|
|
|
|
|
|
public void checkImageStatus(int requestCode, int resultCode, File data, float thumbnailHeight, float thumbnailWidth) { |
|
|
@ -366,7 +392,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
|
|
|
|
@Override |
|
|
|
public LiveData<Boolean> getForm2AlternateIdNumberFieldAccessLiveData() { |
|
|
|
return customerDetailAlternateIDFieldAccessLiveData; |
|
|
|
return customerDetailAlternateIDFieldEnableLiveData; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -381,12 +407,12 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
|
|
|
|
@Override |
|
|
|
public LiveData<Boolean> getAlternateIdIssueDateRequireLiveData() { |
|
|
|
return alternateIDIssueDateRequireLiveData; |
|
|
|
return alternateIDIssueVisibilityDateRequireLiveData; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public LiveData<Boolean> getAlternateIdExpiryDateRequireLiveData() { |
|
|
|
return alternateIDExpiryDateRequireLiveData; |
|
|
|
return alternateIDExpiryDateVisibilityLiveData; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -433,7 +459,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
public void getKycRelatedData() { |
|
|
|
|
|
|
|
compositeDisposable.add( |
|
|
|
this.gateway.getKycRelatedData(gateway.getBasicAuth(view.getContext()), gateway.getUserID(), "kyc") |
|
|
|
this.gateway.getKycRelatedData(gateway.getBasicAuth(view.getContext()), "sdf", "kyc") |
|
|
|
.doOnSubscribe(sub -> view.showProgressBar(true, "")) |
|
|
|
.subscribeOn(Schedulers.io()) |
|
|
|
.observeOn(AndroidSchedulers.mainThread()) |
|
|
@ -770,27 +796,27 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
|
|
|
|
} |
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation().isAnotherIDTypeValid()) { |
|
|
|
alternateIDIssueDateRequireLiveData.setValue(false); |
|
|
|
alternateIDExpiryDateRequireLiveData.setValue(false); |
|
|
|
alternateIDIssueVisibilityDateRequireLiveData.setValue(false); |
|
|
|
alternateIDExpiryDateVisibilityLiveData.setValue(false); |
|
|
|
boolean hasIssuedDateRequiredField = false; |
|
|
|
boolean hasExpiryDateRequiredField = false; |
|
|
|
for (String dependent : val.getDependent()) { |
|
|
|
if ("docIssueDate".equalsIgnoreCase(dependent)) { |
|
|
|
alternateIDIssueDateRequireLiveData.setValue(true); |
|
|
|
alternateIDIssueVisibilityDateRequireLiveData.setValue(true); |
|
|
|
hasIssuedDateRequiredField = true; |
|
|
|
|
|
|
|
} else if ("docExpiryDate".equalsIgnoreCase(dependent)) { |
|
|
|
alternateIDExpiryDateRequireLiveData.setValue(true); |
|
|
|
alternateIDExpiryDateVisibilityLiveData.setValue(true); |
|
|
|
hasExpiryDateRequiredField = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!hasExpiryDateRequiredField) |
|
|
|
anotherIdExpDateLiveData.setValue(VALID_STRING_DATA); |
|
|
|
anotherIdExpDateLiveData.setValue("Asf"); |
|
|
|
else |
|
|
|
anotherIdExpDateLiveData.setValue(""); |
|
|
|
|
|
|
|
if (!hasIssuedDateRequiredField) |
|
|
|
anotherIdIssuedDateLiveData.setValue(VALID_STRING_DATA); |
|
|
|
anotherIdIssuedDateLiveData.setValue("asf"); |
|
|
|
else |
|
|
|
anotherIdIssuedDateLiveData.setValue(""); |
|
|
|
result = true; |
|
|
@ -798,7 +824,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdTypeError("Select different ID Type"); |
|
|
|
} |
|
|
|
} |
|
|
|
customerDetailAlternateIDFieldAccessLiveData.setValue(result); |
|
|
|
customerDetailAlternateIDFieldEnableLiveData.setValue(result); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@ -822,13 +848,13 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
|
|
|
|
} |
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation().isAnotherIDTypeValid()) { |
|
|
|
alternateIDIssueDateRequireLiveData.setValue(false); |
|
|
|
alternateIDExpiryDateRequireLiveData.setValue(false); |
|
|
|
alternateIDIssueVisibilityDateRequireLiveData.setValue(false); |
|
|
|
alternateIDExpiryDateVisibilityLiveData.setValue(false); |
|
|
|
for (String dependent : val.getDependent()) { |
|
|
|
if ("docIssueDate".equalsIgnoreCase(dependent)) { |
|
|
|
alternateIDIssueDateRequireLiveData.setValue(true); |
|
|
|
alternateIDIssueVisibilityDateRequireLiveData.setValue(true); |
|
|
|
} else if ("docExpiryDate".equalsIgnoreCase(dependent)) { |
|
|
|
alternateIDExpiryDateRequireLiveData.setValue(true); |
|
|
|
alternateIDExpiryDateVisibilityLiveData.setValue(true); |
|
|
|
} |
|
|
|
} |
|
|
|
result = true; |
|
|
@ -836,7 +862,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdTypeError("Select different ID Type"); |
|
|
|
} |
|
|
|
} |
|
|
|
customerDetailAlternateIDFieldAccessLiveData.setValue(result); |
|
|
|
customerDetailAlternateIDFieldEnableLiveData.setValue(result); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@ -897,12 +923,9 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
public boolean validateAlternateIdNo2(String alternateID) { |
|
|
|
|
|
|
|
Log.d("AlternateIdValidation", "Alternate ID : " + alternateID); |
|
|
|
|
|
|
|
|
|
|
|
kycRelatedDataDTO.getPrimaryInformation().setAnotherIDNumber(alternateID); |
|
|
|
if(kycRelatedDataDTO.getPrimaryInformation().getAnotherIDType()==null||kycRelatedDataDTO.getPrimaryInformation().getAnotherIDType().length()==0) |
|
|
|
{ |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError(null); |
|
|
|
return true; |
|
|
|
} |
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation().isAnotherIDNoValid()) { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIdNoError(null); |
|
|
|
view.getCustomerDetailViewContract().enableAlternateIdFocusChangeAndImeOptionListener(true); |
|
|
@ -921,19 +944,6 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation() == null) |
|
|
|
kycRelatedDataDTO.setPrimaryInformation(new PrimaryInformationDTO()); |
|
|
|
|
|
|
|
if(kycRelatedDataDTO.getPrimaryInformation().getAnotherIDType()==null||kycRelatedDataDTO.getPrimaryInformation().getAnotherIDType().length()==0) |
|
|
|
{ |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDIssuedDateError(null); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (VALID_STRING_DATA.equalsIgnoreCase(alternateIDIssuedDate)) { |
|
|
|
kycRelatedDataDTO.getPrimaryInformation().setAnotherIDIssueDate(""); |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDIssuedDateError(null); |
|
|
|
Log.d("AlternateIdValidation", "Issued Date : " + "Valid"); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
kycRelatedDataDTO.getPrimaryInformation().setAnotherIDIssueDate(alternateIDIssuedDate); |
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation().isAnotherIDIssuedDateValid()) { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDIssuedDateError(null); |
|
|
@ -955,26 +965,13 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter |
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation() == null) |
|
|
|
kycRelatedDataDTO.setPrimaryInformation(new PrimaryInformationDTO()); |
|
|
|
|
|
|
|
if(kycRelatedDataDTO.getPrimaryInformation().getAnotherIDType()==null||kycRelatedDataDTO.getPrimaryInformation().getAnotherIDType().length()==0) |
|
|
|
{ |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDExpiryDateError(null); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (VALID_STRING_DATA.equalsIgnoreCase(alternateIDIExpiryDate)) { |
|
|
|
kycRelatedDataDTO.getPrimaryInformation().setAnotherIDIssueDate(""); |
|
|
|
Log.d("AlternateIdValidation", "Expiry Date : " + "Valid"); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
kycRelatedDataDTO.getPrimaryInformation().setAnotherIDExpiryDate(alternateIDIExpiryDate); |
|
|
|
|
|
|
|
if (kycRelatedDataDTO.getPrimaryInformation().isAnotherIDExpiryDateValid()) { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDExpiryDateError(null); |
|
|
|
Log.d("AlternateIdValidation", "Expiry Date : " + "Valid"); |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
customerDetailErrorLiveDataDTO.setValueToAnotherIDExpiryDateError(getStringfromStringId(R.string.empty_field_error_text)); |
|
|
|
Log.d("AlternateIdValidation", "Expiry Date : " + "InValid"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|