Browse Source

Before removing passive validation in KYC

master
Preyea Regmi 5 years ago
parent
commit
59b883e25d
  1. 6
      app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV2/presenter/kyc/KYCForm3ValidationListener.java
  2. 148
      app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV2/presenter/kyc/KYCV2Presenter.java
  3. 19
      app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV2/presenter/kyc/KYCV2PresenterInterface.java
  4. 6
      app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV2/view/view3/KYCView3Fragment.java

6
app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV2/presenter/kyc/KYCForm3ValidationListener.java

@ -0,0 +1,6 @@
package com.gmeremit.online.gmeremittance_native.kycV2.presenter.kyc;
public interface KYCForm3ValidationListener {
void onKYCForm3ValidationResult(boolean action);
}

148
app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV2/presenter/kyc/KYCV2Presenter.java

@ -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));
}
}
}
}
} }

19
app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV2/presenter/kyc/KYCV2PresenterInterface.java

@ -59,6 +59,11 @@ public interface KYCV2PresenterInterface extends BasePresenterInterface {
*/ */
KYCForm2Validator getKYCForm2Validator(); KYCForm2Validator getKYCForm2Validator();
/**
* Rx Validator for Second Screen Data
*/
KYCForm2Validator getKYCForm3Validator();
void checkImageStatus(int requestCode, int resultCode, Bitmap data); void checkImageStatus(int requestCode, int resultCode, Bitmap data);
void checkImageStatus(int requestCode, int resultCode, File data); void checkImageStatus(int requestCode, int resultCode, File data);
@ -208,6 +213,10 @@ public interface KYCV2PresenterInterface extends BasePresenterInterface {
void setSelfieImage(Bitmap bitmap); void setSelfieImage(Bitmap bitmap);
void enableForm3Button(boolean action);
} }
} }
@ -252,5 +261,15 @@ public interface KYCV2PresenterInterface extends BasePresenterInterface {
} }
interface KYCForm3Validator
{
boolean validateSelfie(File selfie);
boolean validateFrontDoc(File frontDoc);
boolean validateBackDoc(File backDoc);
boolean validatePassbook(File passbook);
boolean validatePassport(File passport);
}
} }

6
app/src/main/java/com/gmeremit/online/gmeremittance_native/kycV2/view/view3/KYCView3Fragment.java

@ -233,6 +233,7 @@ public class KYCView3Fragment extends BaseFragment implements View.OnClickListen
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.btn_submit: case R.id.btn_submit:
if (submit.isEnabled())
((KYCV2ActionListener) getActivity()).getPresenter().prepareToSendData(); ((KYCV2ActionListener) getActivity()).getPresenter().prepareToSendData();
break; break;
} }
@ -452,6 +453,11 @@ public class KYCView3Fragment extends BaseFragment implements View.OnClickListen
Utility.showImageFromBitmap(getActivity(), selfieImage, bitmap); Utility.showImageFromBitmap(getActivity(), selfieImage, bitmap);
} }
@Override
public void enableForm3Button(boolean action) {
submit.setEnabled(action);
}
@Override @Override
public KYCView3VModel getView3RelatedData() { public KYCView3VModel getView3RelatedData() {

Loading…
Cancel
Save