diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailViewLiveData.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailViewLiveData.java index 6a19047e..1eb035ce 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailViewLiveData.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/existingCustomer/view/personal/ExistingCustomerDetailViewLiveData.java @@ -24,8 +24,8 @@ public class ExistingCustomerDetailViewLiveData { public ExistingCustomerDetailViewLiveData() { employerNameLiveData = new MutableLiveData<>(); - sourceOfFundLiveData = new MutableLiveData<>(); occupationsLiveData = new MutableLiveData<>(); + sourceOfFundLiveData = new MutableLiveData<>(); monthlyIncomeLiveData = new MutableLiveData<>(); mobileNumberLiveData = new MutableLiveData<>(); businessTypeLiveData = new MutableLiveData<>(); diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/gateway/KYCV3Gateway.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/gateway/KYCV3Gateway.java index c2b5909f..3ae26905 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/gateway/KYCV3Gateway.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/gateway/KYCV3Gateway.java @@ -3,6 +3,8 @@ package com.swifttech.remit.android.features.kyc.newCustomer.gateway; import android.content.Context; import android.content.SharedPreferences; +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; import com.swifttech.remit.android.RemitApplication; import com.swifttech.remit.android.base.PrefKeys; import com.swifttech.remit.android.base.PrivilegedGateway; @@ -14,8 +16,6 @@ import com.swifttech.remit.android.features.kyc.newCustomer.model.PersonalInfoDT import com.swifttech.remit.android.features.kyc.newCustomer.model.PicturesDTO; import com.swifttech.remit.android.features.kyc.newCustomer.presenter.KYCV3GatewayInterface; import com.swifttech.remit.android.utils.https.HttpClientV2; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; import java.io.File; import java.util.ArrayList; @@ -62,6 +62,7 @@ public class KYCV3Gateway extends PrivilegedGateway implements KYCV3GatewayInter if (personalInfoDTO != null) { map.put("employeerName", createStringUploadValue(personalInfoDTO.getEmployeerName())); + map.put("occupation", createStringUploadValue(personalInfoDTO.getOccupation())); map.put("sourceOfFund", createStringUploadValue(personalInfoDTO.getSourceOfFund())); map.put("monthlyIncome", createStringUploadValue(personalInfoDTO.getMonthlyIncome())); map.put("businessType", createStringUploadValue(personalInfoDTO.getBusinessType())); @@ -135,6 +136,7 @@ public class KYCV3Gateway extends PrivilegedGateway implements KYCV3GatewayInter mockedDAta.add(new IDTextDTO("5", "Mocked Data 5")); kycRelatedDataDTO.setAdditionalIdType(mockedDAta); + kycRelatedDataDTO.setOccupationList(mockedDAta); kycRelatedDataDTO.setBusniessType(mockedDAta); kycRelatedDataDTO.setIdType(mockedDAta); kycRelatedDataDTO.setSourceOfFund(mockedDAta); @@ -145,6 +147,7 @@ public class KYCV3Gateway extends PrivilegedGateway implements KYCV3GatewayInter "John Doe", "2", "3", + "3", "123134123", "asdf@asd.com", "NP", diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/model/KYCRelatedDataDTO.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/model/KYCRelatedDataDTO.java index 15d37875..12396697 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/model/KYCRelatedDataDTO.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/model/KYCRelatedDataDTO.java @@ -2,6 +2,7 @@ package com.swifttech.remit.android.features.kyc.newCustomer.model; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; +import com.swifttech.remit.android.features.kyc.existingCustomer.model.ExistingIDTextDTO; import java.util.List; @@ -9,6 +10,10 @@ public class KYCRelatedDataDTO { @SerializedName("MonthlyIncome") @Expose private List monthlyIncome = null; + @SerializedName("OccupationList") + @Expose + private List occupationList = null; + @SerializedName("SourceOfFund") @Expose private List sourceOfFund = null; @@ -72,7 +77,13 @@ public class KYCRelatedDataDTO { this.additionalIdType = additionalIdType; } + public List getOccupationList() { + return occupationList; + } + public void setOccupationList(List occupationList) { + this.occupationList = occupationList; + } public PersonalInfoDTO getPersonalInformation() { return personalInformation; @@ -139,7 +150,15 @@ public class KYCRelatedDataDTO { } return null; } - + public IDTextDTO getOccupationFromId(String id) { + if (id == null || id.length() < 1) + return null; + for (IDTextDTO item : occupationList) { + if (id.equalsIgnoreCase(item.getId())) + return item; + } + return null; + } public IDTextDTO getSourceOfFundFromId(String id) { diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/model/PersonalInfoDTO.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/model/PersonalInfoDTO.java index a69cceb0..319aaef4 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/model/PersonalInfoDTO.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/model/PersonalInfoDTO.java @@ -9,6 +9,9 @@ public class PersonalInfoDTO { @SerializedName("employeerName") @Expose private String employeerName; + @SerializedName("occupation") + @Expose + private String occupation; @SerializedName("sourceOfFund") @Expose @@ -42,6 +45,7 @@ public class PersonalInfoDTO { } public PersonalInfoDTO(String employeerName, + String occupation, String sourceOfFund, String monthlyIncome, String mobile, @@ -52,6 +56,7 @@ public class PersonalInfoDTO { String additionalIdType, String businessType) { this.employeerName = employeerName; + this.occupation = occupation; this.sourceOfFund = sourceOfFund; this.monthlyIncome = monthlyIncome; this.mobile = mobile; @@ -135,6 +140,14 @@ public class PersonalInfoDTO { this.additionalIdType = additionalIdType; } + public String getOccupation() { + return occupation; + } + + public void setOccupation(String occupation) { + this.occupation = occupation; + } + public String getBusinessType() { return businessType; } @@ -158,6 +171,7 @@ public class PersonalInfoDTO { public PersonalInfoDTO clone() { return new PersonalInfoDTO( this.employeerName, + this.occupation, this.sourceOfFund, this.monthlyIncome, this.mobile, @@ -174,6 +188,7 @@ public class PersonalInfoDTO { return new PersonalInfoDTO( Utils.formatToUpperCaseSafely(this.employeerName), + this.occupation, this.sourceOfFund, this.monthlyIncome, Utils.formatToUpperCaseSafely(this.mobile), @@ -194,6 +209,9 @@ public class PersonalInfoDTO { public boolean isSourceOfFundValid() { return Utils.isStringNotNullOrEmpty(this.sourceOfFund); } + public boolean isOccupationValid() { + return Utils.isStringNotNullOrEmpty(this.occupation); + } public boolean isMonthlyIncomeValid() { return Utils.isStringNotNullOrEmpty(this.monthlyIncome); diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/presenter/KYCV3PresenterInterface.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/presenter/KYCV3PresenterInterface.java index 7907a711..0520c255 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/presenter/KYCV3PresenterInterface.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/presenter/KYCV3PresenterInterface.java @@ -21,6 +21,7 @@ public interface KYCV3PresenterInterface extends BasePresenterInterface { void getKycRelatedData(); + List getOccupationList(); List getSourceOfFundList(); List getMonthlyIncomeList(); List getBusinessTypeList(); diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/presenter/KYCV3ViewModel.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/presenter/KYCV3ViewModel.java index b1a7cb8b..4c6750df 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/presenter/KYCV3ViewModel.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/presenter/KYCV3ViewModel.java @@ -3,6 +3,7 @@ package com.swifttech.remit.android.features.kyc.newCustomer.presenter; import android.annotation.SuppressLint; import android.util.Log; +import com.google.gson.reflect.TypeToken; import com.swifttech.remit.android.R; import com.swifttech.remit.android.base.BaseViewModel; import com.swifttech.remit.android.common.customwidgets.CustomAlertDialog; @@ -13,10 +14,9 @@ import com.swifttech.remit.android.features.kyc.newCustomer.model.KYCRelatedData import com.swifttech.remit.android.features.kyc.newCustomer.model.KYCRequestDataDTO; import com.swifttech.remit.android.features.kyc.newCustomer.model.PersonalInfoDTO; import com.swifttech.remit.android.features.kyc.newCustomer.model.PicturesDTO; -import com.swifttech.remit.android.features.kyc.newCustomer.view.documents.KYCIDTypeViewLiveData; import com.swifttech.remit.android.features.kyc.newCustomer.view.documents.KYCIDTypeFragment; +import com.swifttech.remit.android.features.kyc.newCustomer.view.documents.KYCIDTypeViewLiveData; import com.swifttech.remit.android.features.kyc.newCustomer.view.personal.CustomerDetailViewLiveData; - import com.swifttech.remit.android.features.login.model.LoginV2DataApiResponse; import com.swifttech.remit.android.features.login.presenter.LoginV2InteractorInterface; import com.swifttech.remit.android.utils.Constants; @@ -25,10 +25,10 @@ import com.swifttech.remit.android.utils.https.GenericApiObserverResponse; import com.swifttech.remit.android.utils.https.GenericApiObserverResponseV2; import com.swifttech.remit.android.utils.https.GenericResponseDataModel; import com.swifttech.remit.android.utils.https.MessageResponseDataModel; -import com.google.gson.reflect.TypeToken; import java.io.File; import java.lang.reflect.Type; +import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; @@ -44,34 +44,22 @@ import static android.app.Activity.RESULT_OK; public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInterface { + public static final String TAG = "KYCV3Process"; private static final int THUMBNAIL_HEIGHT = 150; private static final int THUMBNAIL_WIDTH = 150; private final KYCV3PresenterInterface.KYCV3ViewContractInterface view; private final KYCV3GatewayInterface gateway; private final FileDownloadGateway fileDownloadGateway; private final LoginV2InteractorInterface.Login2GatewayInterface loginGateway; - private CustomerDetailViewValidator validator; - - - private PublishSubject form1ValidationSubject; - private PublishSubject form2ValidationSubject; - private final CompositeDisposable viewSubscriptions; - private final CustomerDetailViewLiveData customerDetailLiveData; private final KYCIDTypeViewLiveData idTypeLiveData; - - private final CompositeDisposable compositeDisposable; - - public static final String TAG = "KYCV3Process"; private final String userId; private final String userPwd; - - public static void log(String message) { - Log.d(TAG, message); - } - + private CustomerDetailViewValidator validator; + private PublishSubject form1ValidationSubject; + private PublishSubject form2ValidationSubject; public KYCV3ViewModel(KYCV3ViewContractInterface view, KYCV3GatewayInterface gatewayInterface, FileDownloadGateway fileDownloadGateway, LoginV2InteractorInterface.Login2GatewayInterface loginGateway, String userId, String userPwd) { this.compositeDisposable = new CompositeDisposable(); @@ -95,6 +83,10 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } + public static void log(String message) { + Log.d(TAG, message); + } + @Override public void onViewReady() { @@ -121,21 +113,26 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } private void bindCustomerDetailView(CustomerDetailViewLiveData.CustomerDetailViewBinding viewBindings) { + List> list = Arrays.asList( + viewBindings.getAdditionalIdTypeObservable().map(validator::validateAdditionalIdType), + viewBindings.getOccupationObservable().map(validator::validateOccupation), + viewBindings.getSourceOfFundObservable().map(validator::validateSourceOfFund), + viewBindings.getAddressObservable().map(validator::validateAddress), + viewBindings.getBusinessTypeObservable().map(validator::validateBusineesType), + viewBindings.getEmailObservable().map(validator::validateEmail), + viewBindings.getIdTypeObservable().map(validator::validateSelectedIDType), + viewBindings.getMobileNumberObservable().map(validator::validateMobileNumber), + viewBindings.getMonthlyIncomeObservable().map(validator::validateMonthlyIncome), + viewBindings.getEmployerNameObservable().map(validator::validateEmployerName) + ); viewSubscriptions.add( - Observable.combineLatest( - viewBindings.getAdditionalIdTypeObservable().map(validator::validateAdditionalIdType), - viewBindings.getSourceOfFundObservable().map(validator::validateSourceOfFund), - viewBindings.getAddressObservable().map(validator::validateAddress), - viewBindings.getBusinessTypeObservable().map(validator::validateBusineesType), - viewBindings.getEmailObservable().map(validator::validateEmail), - viewBindings.getIdTypeObservable().map(validator::validateSelectedIDType), - viewBindings.getMobileNumberObservable().map(validator::validateMobileNumber), - viewBindings.getMonthlyIncomeObservable().map(validator::validateMonthlyIncome), - viewBindings.getEmployerNameObservable().map(validator::validateEmployerName), - (isAdditionalTypeValid, isSourceOfFundValid, isAddressValid, isBusinessTypeValid, isEmailValid, isIdTypeValid, isMobileNumberValid, isMonthlyIncomeValid, isEmployerNameValid) -> - isAdditionalTypeValid && isSourceOfFundValid && isAddressValid && isBusinessTypeValid && isEmailValid && isIdTypeValid && isMobileNumberValid && isMonthlyIncomeValid && isEmployerNameValid - - ).subscribeWith(new DisposableObserver() { + Observable.combineLatest(list, objects -> { + for (Object value : objects) { + if (!(value instanceof Boolean)) return false; + if (!((Boolean) value)) return false; + } + return true; + }).subscribeWith(new DisposableObserver() { @Override public void onNext(Boolean form1ValidationResult) { @@ -172,7 +169,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter viewBindings.getIdTypeSideDocImageLoadedResultObservable(), viewBindings.getAdditionalidTypeDocImageLoadedResultObservable(), viewBindings.getAdditionalidBackTypeDocImageLoadedResultObservable(), - (isFacePictureValid, isFrontIdPictureValid, isBackIdPictureValid, isSideIdPictureValid, isAdditionalIdValid,isAdditionalIdBackValid) -> + (isFacePictureValid, isFrontIdPictureValid, isBackIdPictureValid, isSideIdPictureValid, isAdditionalIdValid, isAdditionalIdBackValid) -> isFacePictureValid && isFrontIdPictureValid && isBackIdPictureValid && isSideIdPictureValid && isAdditionalIdValid && isAdditionalIdBackValid ).subscribeWith(new DisposableObserver() { @@ -208,24 +205,25 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } private void updateCustomerDetailData(KYCRelatedDataDTO data) { - PersonalInfoDTO personalInfoDTO=data.getPersonalInformation(); - - if(personalInfoDTO!=null){ - String mobileNumber=personalInfoDTO.getMobile(); - if(mobileNumber!=null &&mobileNumber.startsWith(view.getContext().getResources().getString(R.string.mobile_prefix))){ - mobileNumber=mobileNumber.substring(3); - } - customerDetailLiveData.getEmployerNameLiveData().postValue(new FormInputStateDTO<>(true,null, personalInfoDTO.getEmployeerName())); - customerDetailLiveData.getSourceOfFundLiveData().postValue(new FormInputStateDTO<>(true,null, data.getSourceOfFundFromId(personalInfoDTO.getSourceOfFund()))); - customerDetailLiveData.getMonthlyIncomeLiveData().postValue(new FormInputStateDTO<>(true,null, data.getMonthlyIncomeFromId(personalInfoDTO.getMonthlyIncome()))); - customerDetailLiveData.getBusinessTypeLiveData().postValue(new FormInputStateDTO<>(true,null, data.getBusinessTypeFromId(personalInfoDTO.getBusinessType()))); - customerDetailLiveData.getIdTypeLiveData().postValue(new FormInputStateDTO<>(true,null, data.getIDypeFromId(personalInfoDTO.getIdType()))); - customerDetailLiveData.getAdditionalIdTypeLiveData().postValue(new FormInputStateDTO<>(true,null, data.getAdditionalIdTypeFromId(personalInfoDTO.getAdditionalIdType()))); - - customerDetailLiveData.getMobileNumberLiveData().postValue(new FormInputStateDTO<>(true,null, mobileNumber)); - customerDetailLiveData.getEmailLiveData().postValue(new FormInputStateDTO<>(true,null, personalInfoDTO.getEmail())); - customerDetailLiveData.getAddressLiveData().postValue(new FormInputStateDTO<>(true,null, personalInfoDTO.getAdditionalAddress())); - } + PersonalInfoDTO personalInfoDTO = data.getPersonalInformation(); + + if (personalInfoDTO != null) { + String mobileNumber = personalInfoDTO.getMobile(); + if (mobileNumber != null && mobileNumber.startsWith(view.getContext().getResources().getString(R.string.mobile_prefix))) { + mobileNumber = mobileNumber.substring(3); + } + customerDetailLiveData.getEmployerNameLiveData().postValue(new FormInputStateDTO<>(true, null, personalInfoDTO.getEmployeerName())); + customerDetailLiveData.getOccupationsLiveData().postValue(new FormInputStateDTO<>(true, null, data.getOccupationFromId(personalInfoDTO.getOccupation()))); + customerDetailLiveData.getSourceOfFundLiveData().postValue(new FormInputStateDTO<>(true, null, data.getSourceOfFundFromId(personalInfoDTO.getSourceOfFund()))); + customerDetailLiveData.getMonthlyIncomeLiveData().postValue(new FormInputStateDTO<>(true, null, data.getMonthlyIncomeFromId(personalInfoDTO.getMonthlyIncome()))); + customerDetailLiveData.getBusinessTypeLiveData().postValue(new FormInputStateDTO<>(true, null, data.getBusinessTypeFromId(personalInfoDTO.getBusinessType()))); + customerDetailLiveData.getIdTypeLiveData().postValue(new FormInputStateDTO<>(true, null, data.getIDypeFromId(personalInfoDTO.getIdType()))); + customerDetailLiveData.getAdditionalIdTypeLiveData().postValue(new FormInputStateDTO<>(true, null, data.getAdditionalIdTypeFromId(personalInfoDTO.getAdditionalIdType()))); + + customerDetailLiveData.getMobileNumberLiveData().postValue(new FormInputStateDTO<>(true, null, mobileNumber)); + customerDetailLiveData.getEmailLiveData().postValue(new FormInputStateDTO<>(true, null, personalInfoDTO.getEmail())); + customerDetailLiveData.getAddressLiveData().postValue(new FormInputStateDTO<>(true, null, personalInfoDTO.getAdditionalAddress())); + } } @@ -453,6 +451,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } } + @Override public void checkImageStatus(int requestCode, int resultCode, File data) { if (data == null) { @@ -564,6 +563,10 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter ); } + @Override + public List getOccupationList() { + return validator.getKycRelatedDataDTO().getOccupationList(); + } @Override @@ -618,8 +621,18 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter postKYCFormToServer(validator.getKycRelatedDataDTO().getForm1PostData(gateway.getUserID()), view::showDocumentDetailForm); } + private void getNewAccessToken(Runnable task) { + compositeDisposable.add( + loginGateway.loginUser(loginGateway.getBasicAuth(view.getContext()), this.userId, this.userPwd) + .doOnSubscribe(sub -> view.showProgressBar(true, "")) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .doFinally(() -> view.showProgressBar(false, "")) + .subscribeWith(new AccessTokenGenerationObserver(task))); + } + public class KycRelatedDataObserver extends GenericApiObserverResponseV2 { @Override @@ -630,9 +643,14 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter @Override protected void onSuccess(GenericResponseDataModel t) { if (t.getErrorCode().equalsIgnoreCase(Constants.SUCCESS_CODE_V2)) { - onReceivingKycRelatedData(t.getData()); + /* onReceivingKycRelatedData(t.getData()); view.lazyLoadForms(); if (t.getData().areAnyPicturesAvailableFromServer()) + view.showDocumentDetailForm();*/ + + onReceivingKycRelatedData(gateway.getMockedData()); + view.lazyLoadForms(); + if (true) view.showDocumentDetailForm(); } else @@ -657,7 +675,6 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - public class CustomerDetailViewValidator { /** @@ -693,7 +710,20 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - boolean validateSourceOfFund(IDTextDTO data) { + boolean validateOccupation(IDTextDTO data) { + if (kycRelatedDataDTO.getPersonalInformation() == null) + kycRelatedDataDTO.setPersonalInformation(new PersonalInfoDTO()); + + kycRelatedDataDTO.getPersonalInformation().setOccupation(data.getId()); + if (kycRelatedDataDTO.getPersonalInformation().isOccupationValid()) { + return true; + } else { + customerDetailLiveData.getOccupationsLiveData().setValue(new FormInputStateDTO<>(false, view.getContext().getString(R.string.invalidOccupation), null)); + return false; + } + } + + boolean validateSourceOfFund(IDTextDTO data) { if (kycRelatedDataDTO.getPersonalInformation() == null) kycRelatedDataDTO.setPersonalInformation(new PersonalInfoDTO()); @@ -706,11 +736,11 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - boolean validateAddress(CharSequence data) { + boolean validateAddress(CharSequence data) { if (kycRelatedDataDTO.getPersonalInformation() == null) kycRelatedDataDTO.setPersonalInformation(new PersonalInfoDTO()); - kycRelatedDataDTO.getPersonalInformation().setAdditionalAddress(data!=null?data.toString():null); + kycRelatedDataDTO.getPersonalInformation().setAdditionalAddress(data != null ? data.toString() : null); if (kycRelatedDataDTO.getPersonalInformation().isAdditionalAddressValid()) { customerDetailLiveData.getAddressLiveData().setValue(new FormInputStateDTO<>(true, null, null)); return true; @@ -720,7 +750,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - boolean validateBusineesType(IDTextDTO data) { + boolean validateBusineesType(IDTextDTO data) { if (kycRelatedDataDTO.getPersonalInformation() == null) kycRelatedDataDTO.setPersonalInformation(new PersonalInfoDTO()); @@ -733,11 +763,11 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - boolean validateEmail(CharSequence data) { + boolean validateEmail(CharSequence data) { if (kycRelatedDataDTO.getPersonalInformation() == null) kycRelatedDataDTO.setPersonalInformation(new PersonalInfoDTO()); - kycRelatedDataDTO.getPersonalInformation().setEmail(data!=null?data.toString():null); + kycRelatedDataDTO.getPersonalInformation().setEmail(data != null ? data.toString() : null); if (kycRelatedDataDTO.getPersonalInformation().isEmailValid()) { customerDetailLiveData.getEmailLiveData().setValue(new FormInputStateDTO<>(true, null, null)); return true; @@ -747,7 +777,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - boolean validateSelectedIDType(IDTextDTO data) { + boolean validateSelectedIDType(IDTextDTO data) { if (kycRelatedDataDTO.getPersonalInformation() == null) kycRelatedDataDTO.setPersonalInformation(new PersonalInfoDTO()); @@ -760,11 +790,11 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - boolean validateMobileNumber(CharSequence data) { + boolean validateMobileNumber(CharSequence data) { if (kycRelatedDataDTO.getPersonalInformation() == null) kycRelatedDataDTO.setPersonalInformation(new PersonalInfoDTO()); - kycRelatedDataDTO.getPersonalInformation().setMobile(data!=null?data.toString():null); + kycRelatedDataDTO.getPersonalInformation().setMobile(data != null ? data.toString() : null); if (kycRelatedDataDTO.getPersonalInformation().isMobileNumberValid()) { customerDetailLiveData.getMobileNumberLiveData().setValue(new FormInputStateDTO<>(true, null, null)); return true; @@ -774,7 +804,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - boolean validateMonthlyIncome(IDTextDTO data) { + boolean validateMonthlyIncome(IDTextDTO data) { if (kycRelatedDataDTO.getPersonalInformation() == null) kycRelatedDataDTO.setPersonalInformation(new PersonalInfoDTO()); @@ -787,11 +817,11 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - boolean validateEmployerName(CharSequence data) { + boolean validateEmployerName(CharSequence data) { if (kycRelatedDataDTO.getPersonalInformation() == null) kycRelatedDataDTO.setPersonalInformation(new PersonalInfoDTO()); - kycRelatedDataDTO.getPersonalInformation().setEmployeerName(data!=null?data.toString():null); + kycRelatedDataDTO.getPersonalInformation().setEmployeerName(data != null ? data.toString() : null); if (kycRelatedDataDTO.getPersonalInformation().isEmployerNameValid()) { customerDetailLiveData.getEmployerNameLiveData().setValue(new FormInputStateDTO<>(true, null, null)); return true; @@ -801,7 +831,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - boolean validateFacePicture(File data) { + boolean validateFacePicture(File data) { if (kycRelatedDataDTO.getPictures() == null) kycRelatedDataDTO.setPictures(new PicturesDTO()); @@ -816,7 +846,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } - boolean validateFrontIdTypePicture(File data) { + boolean validateFrontIdTypePicture(File data) { if (kycRelatedDataDTO.getPictures() == null) kycRelatedDataDTO.setPictures(new PicturesDTO()); @@ -830,7 +860,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } - boolean validateBackIdTypePicture(File data) { + boolean validateBackIdTypePicture(File data) { if (kycRelatedDataDTO.getPictures() == null) kycRelatedDataDTO.setPictures(new PicturesDTO()); @@ -844,7 +874,7 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } - boolean validateSideIdTypePicture(File data) { + boolean validateSideIdTypePicture(File data) { if (kycRelatedDataDTO.getPictures() == null) kycRelatedDataDTO.setPictures(new PicturesDTO()); @@ -884,20 +914,6 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter } } - - private void getNewAccessToken(Runnable task) { - compositeDisposable.add( - loginGateway.loginUser(loginGateway.getBasicAuth(view.getContext()), this.userId, this.userPwd) - .doOnSubscribe(sub -> view.showProgressBar(true, "")) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .doFinally(() -> view.showProgressBar(false, "")) - .subscribeWith(new AccessTokenGenerationObserver(task))); - - - } - - public class KYCFormUploadObserver extends GenericApiObserverResponseV2 { Runnable task; @@ -917,15 +933,15 @@ public class KYCV3ViewModel extends BaseViewModel implements KYCV3PresenterInter if ((userId != null && userId.length() > 0) && userPwd != null && userPwd.length() > 0) getNewAccessToken(task); else if (task != null) - view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.SUCCESS,alertType -> { - if(task!=null) + view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.SUCCESS, alertType -> { + if (task != null) task.run(); }); - } else if(task!=null) + } else if (task != null) task.run(); } else - view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED,null); + view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, null); } @Override diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/view/personal/CustomerDetailFragment.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/view/personal/CustomerDetailFragment.java index 381c587b..c54647fe 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/view/personal/CustomerDetailFragment.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/view/personal/CustomerDetailFragment.java @@ -21,6 +21,7 @@ import com.swifttech.remit.android.R; import com.swifttech.remit.android.base.BaseFragment; import com.swifttech.remit.android.common.model.FormInputStateDTO; import com.swifttech.remit.android.common.customwidgets.common.GenericTextListingDialog; +import com.swifttech.remit.android.features.kyc.existingCustomer.model.ExistingIDTextDTO; import com.swifttech.remit.android.features.kyc.newCustomer.model.IDTextDTO; import com.swifttech.remit.android.features.kyc.newCustomer.presenter.KYCV3PresenterInterface; import com.swifttech.remit.android.features.kyc.newCustomer.presenter.KYCV3ViewModel; @@ -57,6 +58,9 @@ public class CustomerDetailFragment extends BaseFragment implements KYCV3Present @BindView(R.id.ed_employerName) EditText ed_employerName; + @BindView(R.id.ed_occupation) + EditText ed_occupation; + @BindView(R.id.ed_sourceOfFund) EditText ed_sourceOfFund; @@ -98,14 +102,14 @@ public class CustomerDetailFragment extends BaseFragment implements KYCV3Present @BindView(R.id.btn_submit1) Button btnSubmit1; - + private GenericTextListingDialog occupationSelectionDialog; private GenericTextListingDialog sourceOfFundSelectionDialog; private GenericTextListingDialog monthlyIncomeSelectionDialog; private GenericTextListingDialog busineessTypeSelectionDialog; private GenericTextListingDialog idTypeSelectionDialog; private GenericTextListingDialog additionalIdTypeSelectionDialog; - + private PublishSubject occupationSelectSubject; private PublishSubject sourceOfFundSelectSubject; private PublishSubject monthlyIncomeSelectSubject; private PublishSubject businessTypeSelectSubject; @@ -132,6 +136,7 @@ public class CustomerDetailFragment extends BaseFragment implements KYCV3Present private void init() { + occupationSelectSubject = PublishSubject.create(); sourceOfFundSelectSubject = PublishSubject.create(); monthlyIncomeSelectSubject = PublishSubject.create(); businessTypeSelectSubject = PublishSubject.create(); @@ -142,6 +147,7 @@ public class CustomerDetailFragment extends BaseFragment implements KYCV3Present customerDetailViewBinding = new CustomerDetailViewLiveData.CustomerDetailViewBinding( RxTextView.textChanges(ed_employerName).skipInitialValue(), + occupationSelectSubject, sourceOfFundSelectSubject, monthlyIncomeSelectSubject, RxTextView.textChanges(ed_mobileNumber).skipInitialValue(), @@ -167,12 +173,22 @@ public class CustomerDetailFragment extends BaseFragment implements KYCV3Present customerDetailViewLiveData.getMobileNumberLiveData().observe(getViewLifecycleOwner(), this::onMobileNumberSelected); customerDetailViewLiveData.getMonthlyIncomeLiveData().observe(getViewLifecycleOwner(), this::onMonthlyIncomeSelected); customerDetailViewLiveData.getEmployerNameLiveData().observe(getViewLifecycleOwner(), this::onEmployerNameSelected); + customerDetailViewLiveData.getOccupationsLiveData().observe(getViewLifecycleOwner(), this::onOccupationSelected); customerDetailViewLiveData.getSourceOfFundLiveData().observe(getViewLifecycleOwner(), this::onSourceOfFundSelected); customerDetailViewLiveData.getAllFieldsValidLiveData().observe(getViewLifecycleOwner(), areAllFieldsValid -> btnSubmit1.setEnabled(areAllFieldsValid)); } + private void onOccupationSelected(FormInputStateDTO data) { + if (data.isValid()) { + if (data.hasData()) { + ed_occupation.setText(data.getData().getText()); + occupationSelectSubject.onNext(data.getData()); + } + } + } + private void onSourceOfFundSelected(FormInputStateDTO data) { if (data.isValid()) { if (data.hasData()) { @@ -389,8 +405,27 @@ public class CustomerDetailFragment extends BaseFragment implements KYCV3Present if (!additionalIdTypeSelectionDialog.isAdded()) additionalIdTypeSelectionDialog.show(getActivity().getSupportFragmentManager(), "ADDITIONALIDTYPECHOOSER"); } + @OnClick(R.id.ed_occupation) + public void promptOccupation() { + hideKeyBoard(); + if (occupationSelectionDialog == null) + occupationSelectionDialog = new GenericTextListingDialog<>(); + occupationSelectionDialog.setData(kycv3ViewModel.getOccupationList()); + occupationSelectionDialog.disableSearch(true); + occupationSelectionDialog.setListener(occupation -> + { + occupationSelectionDialog.dismiss(); + ed_occupation.setText(occupation.toString()); + occupationSelectSubject.onNext(occupation); + }); + + occupationSelectionDialog.setHintAndTitle(getString(R.string.searchOccupation), getString(R.string.selectOccupation), getString(R.string.no_result_found_text)); + if (!occupationSelectionDialog.isAdded()) + occupationSelectionDialog.show(getActivity().getSupportFragmentManager(), "OCCUPATIONCHOOSER"); + } + @OnClick(R.id.ed_sourceOfFund) public void promptSourceOfFund() { diff --git a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/view/personal/CustomerDetailViewLiveData.java b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/view/personal/CustomerDetailViewLiveData.java index 691ee1aa..4da6942c 100644 --- a/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/view/personal/CustomerDetailViewLiveData.java +++ b/app/src/main/java/com/swifttech/remit/android/features/kyc/newCustomer/view/personal/CustomerDetailViewLiveData.java @@ -11,6 +11,7 @@ import io.reactivex.Observable; public class CustomerDetailViewLiveData { private MutableLiveData> employerNameLiveData; + private MutableLiveData> occupationsLiveData; private MutableLiveData> sourceOfFundLiveData; private MutableLiveData> monthlyIncomeLiveData; private MutableLiveData> mobileNumberLiveData; @@ -23,6 +24,7 @@ public class CustomerDetailViewLiveData { public CustomerDetailViewLiveData() { employerNameLiveData = new MutableLiveData<>(); + occupationsLiveData = new MutableLiveData<>(); sourceOfFundLiveData = new MutableLiveData<>(); monthlyIncomeLiveData = new MutableLiveData<>(); mobileNumberLiveData = new MutableLiveData<>(); @@ -54,6 +56,14 @@ public class CustomerDetailViewLiveData { this.allFieldsValid.setValue(allFieldsValid); } + public MutableLiveData> getOccupationsLiveData() { + return occupationsLiveData; + } + + public void setOccupationsLiveData(MutableLiveData> occupationsLiveData) { + this.occupationsLiveData = occupationsLiveData; + } + public MutableLiveData> getSourceOfFundLiveData() { return sourceOfFundLiveData; } @@ -132,9 +142,11 @@ public class CustomerDetailViewLiveData { private Observable addressObservable; private Observable idTypeObservable; private Observable additionalIdTypeObservable; + private Observable occupationObservable; public CustomerDetailViewBinding( Observable employerNameObservable, + Observable occupationObservable, Observable sourceOfFundObservable, Observable monthlyIncomeObservable, Observable mobileNumberObservable, @@ -145,6 +157,7 @@ public class CustomerDetailViewLiveData { Observable additionalIdTypeObservable) { this.employerNameObservable = employerNameObservable; + this.occupationObservable = occupationObservable; this.sourceOfFundObservable = sourceOfFundObservable; this.monthlyIncomeObservable = monthlyIncomeObservable; this.mobileNumberObservable = mobileNumberObservable; @@ -190,5 +203,9 @@ public class CustomerDetailViewLiveData { public Observable getAdditionalIdTypeObservable() { return additionalIdTypeObservable; } + + public Observable getOccupationObservable() { + return occupationObservable; + } } } diff --git a/app/src/main/res/layout/fragment_kyc_customer_detail.xml b/app/src/main/res/layout/fragment_kyc_customer_detail.xml index 9fb56553..9b17e2c6 100644 --- a/app/src/main/res/layout/fragment_kyc_customer_detail.xml +++ b/app/src/main/res/layout/fragment_kyc_customer_detail.xml @@ -57,6 +57,21 @@ + + + + + +