|
@ -35,7 +35,7 @@ import io.reactivex.schedulers.Schedulers; |
|
|
|
|
|
|
|
|
import static android.app.Activity.RESULT_OK; |
|
|
import static android.app.Activity.RESULT_OK; |
|
|
|
|
|
|
|
|
public class KYCV2Presenter extends BasePresenter implements KYCV2PresenterInterface, KYCV2InteractorInterface, KYCForm1ValidationListener, KYCForm2ValidationListener { |
|
|
|
|
|
|
|
|
public class KYCV2Presenter extends BasePresenter implements KYCV2PresenterInterface, KYCV2InteractorInterface, KYCForm1ValidationListener, KYCForm2ValidationListener, KYCForm3ValidationListener { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final KYCV2ContractInterface view; |
|
|
private final KYCV2ContractInterface view; |
|
@ -46,23 +46,24 @@ public class KYCV2Presenter extends BasePresenter implements KYCV2PresenterInter |
|
|
CompositeDisposable compositeDisposable; |
|
|
CompositeDisposable compositeDisposable; |
|
|
private final KYCV2GatewayInterface gateway; |
|
|
private final KYCV2GatewayInterface gateway; |
|
|
|
|
|
|
|
|
private Bitmap selfie = null; |
|
|
|
|
|
private Bitmap front_doc = null; |
|
|
|
|
|
private Bitmap back_doc = null; |
|
|
|
|
|
private Bitmap passbook = null; |
|
|
|
|
|
private Bitmap passport = null; |
|
|
|
|
|
|
|
|
|
|
|
private File selfieFile = null; |
|
|
|
|
|
private File frontdocFile = null; |
|
|
|
|
|
private File backdocFile = null; |
|
|
|
|
|
private File passbookFile = null; |
|
|
|
|
|
private File passportFile = null; |
|
|
|
|
|
|
|
|
// private Bitmap selfie = null; |
|
|
|
|
|
// private Bitmap front_doc = null; |
|
|
|
|
|
// private Bitmap back_doc = null; |
|
|
|
|
|
// private Bitmap passbook = null; |
|
|
|
|
|
// private Bitmap passport = null; |
|
|
|
|
|
// |
|
|
|
|
|
// private File selfieFile = null; |
|
|
|
|
|
// private File frontdocFile = null; |
|
|
|
|
|
// private File backdocFile = null; |
|
|
|
|
|
// private File passbookFile = null; |
|
|
|
|
|
// private File passportFile = null; |
|
|
|
|
|
|
|
|
public static final String ISSUE_DATE_KEY = "docIssueDate"; |
|
|
public static final String ISSUE_DATE_KEY = "docIssueDate"; |
|
|
public static final String EXPIRY_DATE_KEY = "docExpiryDate"; |
|
|
public static final String EXPIRY_DATE_KEY = "docExpiryDate"; |
|
|
|
|
|
|
|
|
private final KYCForm1Validator kycForm1Validator; |
|
|
private final KYCForm1Validator kycForm1Validator; |
|
|
private final KYCForm2Validator kycForm2Validator; |
|
|
private final KYCForm2Validator kycForm2Validator; |
|
|
|
|
|
private final KYCForm3Validator kycForm3Validator; |
|
|
|
|
|
|
|
|
private final KYCView1VModel kycForm1DataModel; |
|
|
private final KYCView1VModel kycForm1DataModel; |
|
|
private final KYCView2VModel kycForm2DataModel; |
|
|
private final KYCView2VModel kycForm2DataModel; |
|
@ -76,6 +77,7 @@ public class KYCV2Presenter extends BasePresenter implements KYCV2PresenterInter |
|
|
this.thumbnailWidth = width; |
|
|
this.thumbnailWidth = width; |
|
|
this.kycForm1Validator = new KYCForm1Validator(this); |
|
|
this.kycForm1Validator = new KYCForm1Validator(this); |
|
|
this.kycForm2Validator = new KYCForm2Validator(this); |
|
|
this.kycForm2Validator = new KYCForm2Validator(this); |
|
|
|
|
|
this.kycForm3Validator = new KYCForm3Validator(this); |
|
|
this.kycForm1DataModel = new KYCView1VModel(); |
|
|
this.kycForm1DataModel = new KYCView1VModel(); |
|
|
this.kycForm2DataModel = new KYCView2VModel(); |
|
|
this.kycForm2DataModel = new KYCView2VModel(); |
|
|
|
|
|
|
|
@ -248,6 +250,11 @@ public class KYCV2Presenter extends BasePresenter implements KYCV2PresenterInter |
|
|
return kycForm2Validator; |
|
|
return kycForm2Validator; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public KYCV2PresenterInterface.KYCForm2Validator getKYCForm3Validator() { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Deprecated |
|
|
@Deprecated |
|
|
@Override |
|
|
@Override |
|
@ -441,6 +448,12 @@ public class KYCV2Presenter extends BasePresenter implements KYCV2PresenterInter |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onKYCForm3ValidationResult(boolean action) { |
|
|
|
|
|
view.getView3Contract().enableForm3Button(action); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public class KycRelatedDataObserver extends GenericApiObserverResponse<KYCRelatedDataResponse> { |
|
|
public class KycRelatedDataObserver extends GenericApiObserverResponse<KYCRelatedDataResponse> { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -693,9 +706,12 @@ public class KYCV2Presenter extends BasePresenter implements KYCV2PresenterInter |
|
|
return kycView1VModel; |
|
|
return kycView1VModel; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void checkAllFieldValidation() { |
|
|
|
|
|
listener.onKYCForm1ValidationResult(this.isAddressValid && this.isFullNameValid && this.isDOBValid && this.isEmailAddressValid |
|
|
|
|
|
&& this.isGenderValid && this.isNativeCountryValid && this.isOccupationValid && this.isProvinceValid); |
|
|
|
|
|
|
|
|
private boolean checkAllFieldValidation() { |
|
|
|
|
|
boolean result = this.isAddressValid && this.isFullNameValid && this.isDOBValid && this.isEmailAddressValid |
|
|
|
|
|
&& this.isGenderValid && this.isNativeCountryValid && this.isOccupationValid && this.isProvinceValid; |
|
|
|
|
|
|
|
|
|
|
|
listener.onKYCForm1ValidationResult(result); |
|
|
|
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -966,16 +982,19 @@ public class KYCV2Presenter extends BasePresenter implements KYCV2PresenterInter |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void checkAllFieldValidation() { |
|
|
|
|
|
this.listener.onKYCForm2ValidationResult( |
|
|
|
|
|
isPrimaryBankValid && |
|
|
|
|
|
|
|
|
private boolean checkAllFieldValidation() { |
|
|
|
|
|
boolean result = isPrimaryBankValid && |
|
|
isPrimaryAccountNumberValid && |
|
|
isPrimaryAccountNumberValid && |
|
|
isIdTypeValid && |
|
|
isIdTypeValid && |
|
|
isVerificationIdNumberValid && |
|
|
isVerificationIdNumberValid && |
|
|
isSelectedIssueDateValid && |
|
|
isSelectedIssueDateValid && |
|
|
isSelectedExpiryDateValid && |
|
|
isSelectedExpiryDateValid && |
|
|
isSourceOfFundValid |
|
|
|
|
|
|
|
|
isSourceOfFundValid; |
|
|
|
|
|
this.listener.onKYCForm2ValidationResult( |
|
|
|
|
|
result |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public KYCView2VModel getKycView2VModel() { |
|
|
public KYCView2VModel getKycView2VModel() { |
|
@ -984,4 +1003,95 @@ public class KYCV2Presenter extends BasePresenter implements KYCV2PresenterInter |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class KYCForm3Validator implements KYCV2PresenterInterface.KYCForm3Validator { |
|
|
|
|
|
|
|
|
|
|
|
private boolean isSelfieValid; |
|
|
|
|
|
private boolean isFrontdocValid; |
|
|
|
|
|
private boolean isBackdocValid; |
|
|
|
|
|
private boolean isPassbookValid; |
|
|
|
|
|
private boolean isPassportValid; |
|
|
|
|
|
|
|
|
|
|
|
private File selfieFile = null; |
|
|
|
|
|
private File frontdocFile = null; |
|
|
|
|
|
private File backdocFile = null; |
|
|
|
|
|
private File passbookFile = null; |
|
|
|
|
|
private File passportFile = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final KYCForm3ValidationListener listener; |
|
|
|
|
|
|
|
|
|
|
|
public KYCForm3Validator(KYCForm3ValidationListener listener) { |
|
|
|
|
|
this.listener = listener; |
|
|
|
|
|
isSelfieValid = true; |
|
|
|
|
|
isFrontdocValid = false; |
|
|
|
|
|
isBackdocValid = false; |
|
|
|
|
|
isPassbookValid = true; |
|
|
|
|
|
isPassportValid = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean validateSelfie(File selfie) { |
|
|
|
|
|
this.selfieFile = selfie; |
|
|
|
|
|
isSelfieValid = selfieFile != null; |
|
|
|
|
|
checkAllFieldValidation(); |
|
|
|
|
|
return isSelfieValid; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean validateFrontDoc(File frontDoc) { |
|
|
|
|
|
this.frontdocFile = frontDoc; |
|
|
|
|
|
isFrontdocValid = frontdocFile != null; |
|
|
|
|
|
checkAllFieldValidation(); |
|
|
|
|
|
return isFrontdocValid; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean validateBackDoc(File backDoc) { |
|
|
|
|
|
this.backdocFile = backDoc; |
|
|
|
|
|
isBackdocValid = backdocFile != null; |
|
|
|
|
|
checkAllFieldValidation(); |
|
|
|
|
|
return isBackdocValid; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean validatePassbook(File passbook) { |
|
|
|
|
|
this.passbookFile = passbook; |
|
|
|
|
|
isPassbookValid = passbookFile != null; |
|
|
|
|
|
checkAllFieldValidation(); |
|
|
|
|
|
return isPassbookValid; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean validatePassport(File passport) { |
|
|
|
|
|
this.passportFile = passport; |
|
|
|
|
|
isPassportValid = passportFile != null; |
|
|
|
|
|
checkAllFieldValidation(); |
|
|
|
|
|
return isPassportValid; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void checkAllFieldValidation() { |
|
|
|
|
|
boolean form1Validaiton = kycForm1Validator.checkAllFieldValidation(); |
|
|
|
|
|
boolean form2Validation = kycForm2Validator.checkAllFieldValidation(); |
|
|
|
|
|
|
|
|
|
|
|
boolean form3Validation = isSelfieValid && |
|
|
|
|
|
isFrontdocValid && |
|
|
|
|
|
isBackdocValid && |
|
|
|
|
|
isPassbookValid && |
|
|
|
|
|
isPassportValid; |
|
|
|
|
|
|
|
|
|
|
|
if (form3Validation) { |
|
|
|
|
|
if (form1Validaiton && form2Validation) |
|
|
|
|
|
listener.onKYCForm3ValidationResult(true); |
|
|
|
|
|
else { |
|
|
|
|
|
listener.onKYCForm3ValidationResult(false); |
|
|
|
|
|
view.showToastMessage(getStringfromStringId(R.string.kyc_form_fill_up_number_error)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |