Browse Source

Withdraw mock completed

master
Preyea Regmi 4 years ago
parent
commit
59785fc147
  1. 48
      app/src/main/AndroidManifest.xml
  2. 12
      app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/gateway/CashPickupToWalletGateway.java
  3. 18
      app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/model/CashPickupTxnDetailDTO.java
  4. 42
      app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/presenter/CashPickupToWalletPresenter.java
  5. 2
      app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/view/CashPickupToWalletActivity.java
  6. 24
      app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/view/CashPickupTxnDetailFragment.java
  7. 4
      app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/view/SearchCashPickupTxnFragment.java
  8. 12
      app/src/main/java/com/swifttech/remit/android/features/withdraw/gateway/WithdrawGateway.java
  9. 76
      app/src/main/java/com/swifttech/remit/android/features/withdraw/model/WithdrawStatusResponseDTO.java
  10. 10
      app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawGatewayInterface.java
  11. 204
      app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawPresenter.java
  12. 18
      app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawPresenterInterface.java
  13. 43
      app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawViewLiveData.java
  14. 49
      app/src/main/java/com/swifttech/remit/android/features/withdraw/view/WithdrawActivity.java
  15. 26
      app/src/main/res/layout/activity_cash_pickup_to_wallet.xml
  16. 68
      app/src/main/res/layout/activity_withdraw.xml
  17. 21
      app/src/main/res/layout/fragment_cash_pickup_txn_detail.xml

48
app/src/main/AndroidManifest.xml

@ -27,8 +27,36 @@
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning" tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:allowBackup,android:supportsRtl"> tools:replace="android:allowBackup,android:supportsRtl">
<activity android:name=".features.withdraw.view.WithdrawActivity"></activity>
<activity android:name=".features.cashpickuptowallet.view.CashPickupToWalletActivity" />
<activity android:name=".features.withdraw.view.WithdrawActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".features.cashpickuptowallet.view.CashPickupToWalletActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="stateAlwaysHidden">
<!-- <intent-filter>-->
<!-- <action android:name="HOME" />-->
<!-- <category android:name="android.intent.category.DEFAULT" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity <activity
android:name=".features.otpverification.view.OTPVerificationActivity" android:name=".features.otpverification.view.OTPVerificationActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"
@ -86,16 +114,16 @@
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/AppTheme.Launcher" android:theme="@style/AppTheme.Launcher"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"> android:windowSoftInputMode="adjustResize|stateAlwaysHidden">
<intent-filter>
<action android:name="HOME" />
<!-- <intent-filter>-->
<!-- <action android:name="HOME" />-->
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <category android:name="android.intent.category.DEFAULT" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity> </activity>
<activity <activity
android:name=".features.aboutscreen.view.AboutGME" android:name=".features.aboutscreen.view.AboutGME"

12
app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/gateway/CashPickupToWalletGateway.java

@ -3,5 +3,17 @@ package com.swifttech.remit.android.features.cashpickuptowallet.gateway;
import com.swifttech.remit.android.base.PrivilegedGateway; import com.swifttech.remit.android.base.PrivilegedGateway;
import com.swifttech.remit.android.features.cashpickuptowallet.presenter.CashPickupToWalletGatewayInterface; import com.swifttech.remit.android.features.cashpickuptowallet.presenter.CashPickupToWalletGatewayInterface;
import io.reactivex.Observable;
import okhttp3.ResponseBody;
public class CashPickupToWalletGateway extends PrivilegedGateway implements CashPickupToWalletGatewayInterface { public class CashPickupToWalletGateway extends PrivilegedGateway implements CashPickupToWalletGatewayInterface {
@Override
public Observable<ResponseBody> searchTxnByControlNo(String auth, String userID, String selectedControlNo) {
return null;
}
@Override
public Observable<ResponseBody> redeemCashPickupTxn(String auth, String userID, String selectedControlNo, String txnId, String password) {
return null;
}
} }

18
app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/model/CashPickupTxnDetailDTO.java

@ -48,6 +48,7 @@ public class CashPickupTxnDetailDTO {
@Expose @Expose
private String payoutAgent; private String payoutAgent;
public String getTxnId() { public String getTxnId() {
return txnId; return txnId;
} }
@ -182,4 +183,21 @@ public class CashPickupTxnDetailDTO {
return "Transaction Status Unknown"; return "Transaction Status Unknown";
} }
public void seedDummyValues() {
this.txnId = "1234";
this.sendingCountryCode = "KR";
this.sendingCountryName = "KOREA";
this.controlNo = "9123987123";
this.tranDate = "11/06/2020";
this.senderName = "Jhon Doe";
this.receiverName = "Jhon Doe Bro";
this.receiverAddress = "Jhon Home Address";
this.receiverMobile = "010-123-1234";
this.status = "UNPAID";
this.serviceFee = "12314 MNT";
this.exrate = "0.123";
this.receivedAmount = "124123123 MNT";
this.payoutAgent = "Merchant Trade";
}
} }

42
app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/presenter/CashPickupToWalletPresenter.java

@ -57,14 +57,23 @@ public class CashPickupToWalletPresenter extends BaseViewModel implements CashPi
@Override @Override
public void searchByControlNo() { public void searchByControlNo() {
useCaseSubs.add(
gateway.searchTxnByControlNo(gateway.getAuth(), gateway.getUserID(), selectedControlNo)
.doOnSubscribe(subs -> view.showProgressBar(true, ""))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doFinally(() -> view.showProgressBar(false, ""))
.subscribeWith(new CashPickupTxnSearchObserver())
);
// useCaseSubs.add(
// gateway.searchTxnByControlNo(gateway.getAuth(), gateway.getUserID(), selectedControlNo)
// .doOnSubscribe(subs -> view.showProgressBar(true, ""))
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .doFinally(() -> view.showProgressBar(false, ""))
// .subscribeWith(new CashPickupTxnSearchObserver())
// );
showDummyResponse();
}
private void showDummyResponse() {
CashPickupTxnDetailDTO dummy=new CashPickupTxnDetailDTO();
dummy.seedDummyValues();
currentCashPickupTxnDetail=dummy;
cashPickupTxnDetailDTOMutableLiveData.setValue(dummy);
view.showTxnDetailScreen();
} }
@Override @Override
@ -79,14 +88,15 @@ public class CashPickupToWalletPresenter extends BaseViewModel implements CashPi
).setListener(new RemitAuthManager.RemitAuthListener() { ).setListener(new RemitAuthManager.RemitAuthListener() {
@Override @Override
public void onRemitAuthSuccess(RemitAuthSuccessResult result) { public void onRemitAuthSuccess(RemitAuthSuccessResult result) {
useCaseSubs.add(
gateway.redeemCashPickupTxn(gateway.getAuth(), gateway.getUserID(), selectedControlNo, "", "")
.doOnSubscribe(subs -> view.showProgressBar(true, ""))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doFinally(() -> view.showProgressBar(false, ""))
.subscribeWith(new CashPickupTxnRedeemObserver())
);
// useCaseSubs.add(
// gateway.redeemCashPickupTxn(gateway.getAuth(), gateway.getUserID(), selectedControlNo, "", "")
// .doOnSubscribe(subs -> view.showProgressBar(true, ""))
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .doFinally(() -> view.showProgressBar(false, ""))
// .subscribeWith(new CashPickupTxnRedeemObserver())
// );
view.showPopUpMessage("Redeem Success", CustomAlertDialog.AlertType.SUCCESS, alertType -> view.exitView());
} }
@Override @Override

2
app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/view/CashPickupToWalletActivity.java

@ -28,7 +28,7 @@ import butterknife.OnClick;
public class CashPickupToWalletActivity extends BaseActivity implements CashPickupToWalletPresenterInterface.CashPickupToWalletContract { public class CashPickupToWalletActivity extends BaseActivity implements CashPickupToWalletPresenterInterface.CashPickupToWalletContract {
@BindView(R.id.otpVerificationViewPager)
@BindView(R.id.cashPickupViewPager)
ViewPager viewPager; ViewPager viewPager;

24
app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/view/CashPickupTxnDetailFragment.java

@ -5,21 +5,18 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import com.jakewharton.rxbinding3.widget.RxTextView;
import com.swifttech.remit.android.R; import com.swifttech.remit.android.R;
import com.swifttech.remit.android.base.BaseFragment; import com.swifttech.remit.android.base.BaseFragment;
import com.swifttech.remit.android.common.customwidgets.exchangecountrylistingdialog.CountryFlagMapper; import com.swifttech.remit.android.common.customwidgets.exchangecountrylistingdialog.CountryFlagMapper;
import com.swifttech.remit.android.features.cashpickuptowallet.model.CashPickupTxnDetailDTO; import com.swifttech.remit.android.features.cashpickuptowallet.model.CashPickupTxnDetailDTO;
import com.swifttech.remit.android.features.cashpickuptowallet.presenter.CashPickupToWalletPresenter; import com.swifttech.remit.android.features.cashpickuptowallet.presenter.CashPickupToWalletPresenter;
import com.swifttech.remit.android.features.cashpickuptowallet.presenter.CashPickupToWalletPresenterInterface; import com.swifttech.remit.android.features.cashpickuptowallet.presenter.CashPickupToWalletPresenterInterface;
import com.swifttech.remit.android.features.inboundreceipt.view.ProgressPathView;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
@ -94,9 +91,16 @@ public class CashPickupTxnDetailFragment extends BaseFragment {
viewModel.subscribeToCashPickupTxnDetailEvent().observe(getViewLifecycleOwner(), this::onCashPickupTxnDetailReceived); viewModel.subscribeToCashPickupTxnDetailEvent().observe(getViewLifecycleOwner(), this::onCashPickupTxnDetailReceived);
} }
private void init() {
viewModel = new ViewModelProvider(requireActivity()).get(CashPickupToWalletPresenter.class);
}
private void onCashPickupTxnDetailReceived(CashPickupTxnDetailDTO receiptViewModel) { private void onCashPickupTxnDetailReceived(CashPickupTxnDetailDTO receiptViewModel) {
tv_gme_control_no.setText(receiptViewModel.getControlNo());
tv_gme_control_no.setText("Control No: "+receiptViewModel.getControlNo());
transaction_date.setText(receiptViewModel.getTranDate()); transaction_date.setText(receiptViewModel.getTranDate());
tv_receiver.setText(receiptViewModel.getReceiverName()); tv_receiver.setText(receiptViewModel.getReceiverName());
tv_address.setText(receiptViewModel.getReceiverAddress()); tv_address.setText(receiptViewModel.getReceiverAddress());
@ -107,23 +111,15 @@ public class CashPickupTxnDetailFragment extends BaseFragment {
exrate_fee.setText(receiptViewModel.getExrate()); exrate_fee.setText(receiptViewModel.getExrate());
transfer_label.setText(receiptViewModel.getTransferStatusLabel()); transfer_label.setText(receiptViewModel.getTransferStatusLabel());
senderFlagImageview.setImageResource(CountryFlagMapper.getFlagFromCountryCode(receiptViewModel.getSendingCountryCode())); senderFlagImageview.setImageResource(CountryFlagMapper.getFlagFromCountryCode(receiptViewModel.getSendingCountryCode()));
btn_submit.setEnabled(receiptViewModel.isTxnValidForRedeem());
if (receiptViewModel.isTxnValidForRedeem()) if (receiptViewModel.isTxnValidForRedeem())
btn_submit.setVisibility(View.VISIBLE); btn_submit.setVisibility(View.VISIBLE);
else else
btn_submit.setVisibility(View.GONE); btn_submit.setVisibility(View.GONE);
} }
private void init() {
viewModel = new ViewModelProvider(requireActivity()).get(CashPickupToWalletPresenter.class);
}
@OnClick(R.id.btn_submit) @OnClick(R.id.btn_submit)
public void searchByControlNo() {
public void redeemCashPickup() {
viewModel.searchByControlNo();
viewModel.redeemCashPickup();
} }
} }

4
app/src/main/java/com/swifttech/remit/android/features/cashpickuptowallet/view/SearchCashPickupTxnFragment.java

@ -60,9 +60,7 @@ public class SearchCashPickupTxnFragment extends BaseFragment {
@OnClick(R.id.search_btn) @OnClick(R.id.search_btn)
public void searchByControlNo() public void searchByControlNo()
{ {
if(btnSearch.isEnabled())
{
viewModel.searchByControlNo(); viewModel.searchByControlNo();
}
} }
} }

12
app/src/main/java/com/swifttech/remit/android/features/withdraw/gateway/WithdrawGateway.java

@ -4,5 +4,17 @@ import com.swifttech.remit.android.base.PrivilegedGateway;
import com.swifttech.remit.android.features.cashpickuptowallet.presenter.CashPickupToWalletGatewayInterface; import com.swifttech.remit.android.features.cashpickuptowallet.presenter.CashPickupToWalletGatewayInterface;
import com.swifttech.remit.android.features.withdraw.presenter.WithdrawGatewayInterface; import com.swifttech.remit.android.features.withdraw.presenter.WithdrawGatewayInterface;
import io.reactivex.Observable;
import okhttp3.ResponseBody;
public class WithdrawGateway extends PrivilegedGateway implements WithdrawGatewayInterface { public class WithdrawGateway extends PrivilegedGateway implements WithdrawGatewayInterface {
@Override
public Observable<ResponseBody> checkWithdrawStatus(String auth, String userID) {
return null;
}
@Override
public Observable<ResponseBody> performWithdraw(String auth, String userID, String amount, String password) {
return null;
}
} }

76
app/src/main/java/com/swifttech/remit/android/features/withdraw/model/WithdrawStatusResponseDTO.java

@ -0,0 +1,76 @@
package com.swifttech.remit.android.features.withdraw.model;
import android.util.Log;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.swifttech.remit.android.utils.Utils;
public class WithdrawStatusResponseDTO {
@SerializedName("minAmount")
@Expose
private String minAmount;
@SerializedName("maxAmount")
@Expose
private String maxAmount;
@SerializedName("serviceCharge")
@Expose
private String serviceCharge;
@SerializedName("noticeMessage")
@Expose
private String noticeMessage;
public String getMinAmount() {
return minAmount;
}
public void setMinAmount(String minAmount) {
this.minAmount = minAmount;
}
public String getMaxAmount() {
return maxAmount;
}
public void setMaxAmount(String maxAmount) {
this.maxAmount = maxAmount;
}
public String getServiceCharge() {
return serviceCharge;
}
public void setServiceCharge(String serviceCharge) {
this.serviceCharge = serviceCharge;
}
public String getNoticeMessage() {
return noticeMessage;
}
public void setNoticeMessage(String noticeMessage) {
this.noticeMessage = noticeMessage;
}
public boolean isWithdrawAmountGreaterThanMinThreshold(double amount) {
Double minThreshold = Utils.formatCurrencyForComparision(this.minAmount);
Log.d("Withdraw","Entered amount: "+amount+" min threshold amount: "+minThreshold+" result: "+(minThreshold >= 0 && (amount > minThreshold)));
return minThreshold >= 0 && (amount > minThreshold);
}
public boolean isWithdrawAmountLessThanMaxThreshold(double amount) {
Double maxThreshold = Utils.formatCurrencyForComparision(this.maxAmount);
Log.d("Withdraw","Entered amount: "+amount+" max threshold amount: "+maxThreshold+" result: "+(maxThreshold > 0 && (amount >= maxThreshold)));
return maxThreshold > 0 && (amount <= maxThreshold);
}
public void seedDummyValues() {
this.minAmount="1,000";
this.maxAmount="10,000";
this.serviceCharge="1,000";
}
}

10
app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawGatewayInterface.java

@ -1,4 +1,12 @@
package com.swifttech.remit.android.features.withdraw.presenter; package com.swifttech.remit.android.features.withdraw.presenter;
public interface WithdrawGatewayInterface {
import com.swifttech.remit.android.base.PrivilegedGatewayInterface;
import io.reactivex.Observable;
import okhttp3.ResponseBody;
public interface WithdrawGatewayInterface extends PrivilegedGatewayInterface {
Observable<ResponseBody> checkWithdrawStatus(String auth,String userID);
Observable<ResponseBody> performWithdraw(String auth,String userID,String amount,String password);
} }

204
app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawPresenter.java

@ -1,15 +1,42 @@
package com.swifttech.remit.android.features.withdraw.presenter; package com.swifttech.remit.android.features.withdraw.presenter;
import androidx.appcompat.app.AppCompatActivity;
import com.swifttech.remit.android.base.BaseViewModel; import com.swifttech.remit.android.base.BaseViewModel;
import com.swifttech.remit.android.common.customwidgets.CustomAlertDialog;
import com.swifttech.remit.android.common.model.FormInputStateDTO;
import com.swifttech.remit.android.features.security.RemitAuthManager;
import com.swifttech.remit.android.features.security.model.RemitAuthFailedResult;
import com.swifttech.remit.android.features.security.model.RemitAuthSuccessResult;
import com.swifttech.remit.android.features.security.model.RemitTxnParam;
import com.swifttech.remit.android.features.withdraw.model.WithdrawStatusResponseDTO;
import com.swifttech.remit.android.utils.Constants;
import com.swifttech.remit.android.utils.Utils;
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 io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
public class WithdrawPresenter extends BaseViewModel {
public class WithdrawPresenter extends BaseViewModel implements WithdrawPresenterInterface {
private final WithdrawPresenterInterface.WithdrawContract view; private final WithdrawPresenterInterface.WithdrawContract view;
private final WithdrawGatewayInterface gateway; private final WithdrawGatewayInterface gateway;
private WithdrawViewLiveData withdrawViewLiveData;
private final CompositeDisposable useCaseSubs;
private final CompositeDisposable viewSubs;
private WithdrawStatusResponseDTO withdrawStatusDTO;
private String selectedWithdrawAmount;
public WithdrawPresenter(WithdrawPresenterInterface.WithdrawContract view, WithdrawGatewayInterface withdrawGateway) { public WithdrawPresenter(WithdrawPresenterInterface.WithdrawContract view, WithdrawGatewayInterface withdrawGateway) {
this.view=view;
this.gateway=withdrawGateway;
this.view = view;
this.gateway = withdrawGateway;
this.viewSubs = new CompositeDisposable();
this.useCaseSubs = new CompositeDisposable();
} }
@Override @Override
@ -21,4 +48,175 @@ public class WithdrawPresenter extends BaseViewModel {
public void onViewNotReady() { public void onViewNotReady() {
} }
@Override
public WithdrawViewLiveData subscribeToWithdrawAmountEventLiveData(Observable<CharSequence> specifiedAmount) {
viewSubs.add(
specifiedAmount.map(this::validateAmount)
.subscribeWith(new DisposableObserver<Boolean>() {
@Override
public void onNext(Boolean aBoolean) {
withdrawViewLiveData.setAllFieldValidLiveData(aBoolean);
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
})
);
if(withdrawViewLiveData==null)
{
this.withdrawViewLiveData = new WithdrawViewLiveData();
// useCaseSubs.add(
// gateway.checkWithdrawStatus(gateway.getAuth(), gateway.getUserID())
// .doOnSubscribe(subs -> view.showProgressBar(true, ""))
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .doFinally(() -> view.showProgressBar(false, ""))
// .subscribeWith(new WithdrawStatusObserver())
// );
WithdrawStatusResponseDTO withdrawStatusResponseDTO=new WithdrawStatusResponseDTO();
withdrawStatusResponseDTO.seedDummyValues();
onReceivingWithdrawStatus(withdrawStatusResponseDTO);
}
return withdrawViewLiveData;
}
@Override
public void proceedToWithdraw() {
RemitAuthManager.getGmeAuthManager((AppCompatActivity) view.getContext())
.fromPaymentSource(
new RemitTxnParam(
"wallet",
"",
""
).enableFallbackAuth()
).setListener(new RemitAuthManager.RemitAuthListener() {
@Override
public void onRemitAuthSuccess(RemitAuthSuccessResult result) {
// useCaseSubs.add(
// gateway.performWithdraw(gateway.getAuth(), gateway.getUserID(), selectedWithdrawAmount, result.getResult())
// .doOnSubscribe(subs -> view.showProgressBar(true, ""))
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .doFinally(() -> view.showProgressBar(false, ""))
// .subscribeWith(new WithdrawTxnbserver())
// );
view.showPopUpMessage("Withdraw Success", CustomAlertDialog.AlertType.SUCCESS, alertType -> view.exitView());
}
@Override
public void onRemitAuthFailed(RemitAuthFailedResult failedResult) {
view.showToastMessage(failedResult.getFailedReason());
}
@Override
public void onRemitAuthCancelled() {
}
}).prompt();
}
private Boolean validateAmount(CharSequence amount) {
double withDrawAmount = 0;
try {
withDrawAmount = Utils.formatCurrencyForComparision(amount.toString());
} catch (NumberFormatException ex) {
withdrawViewLiveData.setAmountLiveData(new FormInputStateDTO<>(false, "Invalid amount", null));
return false;
}
if (withdrawStatusDTO.isWithdrawAmountGreaterThanMinThreshold(withDrawAmount)&&withdrawStatusDTO.isWithdrawAmountLessThanMaxThreshold(withDrawAmount)) {
withdrawViewLiveData.setAmountLiveData(new FormInputStateDTO<>(true, "", null));
this.selectedWithdrawAmount=amount.toString();
return true;
} else {
withdrawViewLiveData.setAmountLiveData(new FormInputStateDTO<>(false, "Amount must be in between "+withdrawStatusDTO.getMinAmount()+ " and "+withdrawStatusDTO.getMaxAmount(), null));
this.selectedWithdrawAmount=null;
return false;
}
}
private void onReceivingWithdrawStatus(WithdrawStatusResponseDTO data) {
this.withdrawStatusDTO = data;
String serviceChargeMessage = "Service Charge Per Transaction:\n" + data.getServiceCharge() + " " + gateway.getUserPreferredCurrency();
withdrawViewLiveData.setServiceCharge(serviceChargeMessage);
}
public class WithdrawStatusObserver extends GenericApiObserverResponseV2<WithdrawStatusResponseDTO> {
@Override
protected void onSuccess(GenericResponseDataModel<WithdrawStatusResponseDTO> t) {
if (Constants.SUCCESS_CODE_V2.equalsIgnoreCase(t.getErrorCode()) && t.getData() != null) {
onReceivingWithdrawStatus(t.getData());
} else {
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView());
}
}
@Override
public void onFailed(String message) {
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView());
}
@Override
protected void onConnectionNotEstablished(String message) {
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView());
}
@Override
protected void unauthorizedAccess(String message) {
gateway.clearAllUserData();
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.logout());
}
}
public class WithdrawTxnbserver extends GenericApiObserverResponseV2<MessageResponseDataModel> {
@Override
protected void onSuccess(GenericResponseDataModel<MessageResponseDataModel> t) {
if (Constants.SUCCESS_CODE_V2.equalsIgnoreCase(t.getErrorCode()) ) {
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.SUCCESS, alertType -> view.exitView());
} else {
view.showPopUpMessage(t.getMsg(), CustomAlertDialog.AlertType.FAILED, alertType -> view.exitView());
}
}
@Override
public void onFailed(String message) {
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null);
}
@Override
protected void onConnectionNotEstablished(String message) {
view.showPopUpMessage(message, CustomAlertDialog.AlertType.FAILED, null);
}
@Override
protected void unauthorizedAccess(String message) {
gateway.clearAllUserData();
view.showPopUpMessage(message, CustomAlertDialog.AlertType.ALERT, alertType -> view.logout());
}
}
} }

18
app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawPresenterInterface.java

@ -1,8 +1,22 @@
package com.swifttech.remit.android.features.withdraw.presenter; package com.swifttech.remit.android.features.withdraw.presenter;
public interface WithdrawPresenterInterface {
import androidx.lifecycle.LiveData;
interface WithdrawContract
import com.swifttech.remit.android.base.BaseContractInterface;
import com.swifttech.remit.android.base.BasePresenterInterface;
import com.swifttech.remit.android.common.model.FormInputStateDTO;
import io.reactivex.Observable;
public interface WithdrawPresenterInterface extends BasePresenterInterface {
WithdrawViewLiveData subscribeToWithdrawAmountEventLiveData(Observable<CharSequence> specifiedAmount);
void proceedToWithdraw();
interface WithdrawContract extends BaseContractInterface
{ {
} }

43
app/src/main/java/com/swifttech/remit/android/features/withdraw/presenter/WithdrawViewLiveData.java

@ -0,0 +1,43 @@
package com.swifttech.remit.android.features.withdraw.presenter;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import com.swifttech.remit.android.common.model.FormInputStateDTO;
public class WithdrawViewLiveData {
MutableLiveData<FormInputStateDTO<String>> amountLiveData;
MutableLiveData<String> serviceCharge;
MutableLiveData<Boolean> allFieldValidLiveData;
public WithdrawViewLiveData() {
amountLiveData = new MutableLiveData<>();
serviceCharge = new MutableLiveData<>();
allFieldValidLiveData = new MutableLiveData<>();
}
public LiveData<FormInputStateDTO<String>> getAmountLiveData() {
return amountLiveData;
}
public void setAmountLiveData(FormInputStateDTO<String> amountLiveData) {
this.amountLiveData.setValue(amountLiveData);
}
public LiveData<String> getServiceCharge() {
return serviceCharge;
}
public void setServiceCharge(String serviceCharge) {
this.serviceCharge.setValue(serviceCharge);
}
public LiveData<Boolean> getAllFieldValidLiveData() {
return allFieldValidLiveData;
}
public void setAllFieldValidLiveData(Boolean allFieldValidLiveData) {
this.allFieldValidLiveData.setValue(allFieldValidLiveData);
}
}

49
app/src/main/java/com/swifttech/remit/android/features/withdraw/view/WithdrawActivity.java

@ -5,19 +5,27 @@ import androidx.lifecycle.ViewModelProvider;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import com.jakewharton.rxbinding3.widget.RxTextView;
import com.swifttech.remit.android.R; import com.swifttech.remit.android.R;
import com.swifttech.remit.android.base.BaseActivity;
import com.swifttech.remit.android.common.model.FormInputStateDTO;
import com.swifttech.remit.android.features.cashpickuptowallet.CashPickupViewModelFactory; import com.swifttech.remit.android.features.cashpickuptowallet.CashPickupViewModelFactory;
import com.swifttech.remit.android.features.cashpickuptowallet.presenter.CashPickupToWalletPresenter; import com.swifttech.remit.android.features.cashpickuptowallet.presenter.CashPickupToWalletPresenter;
import com.swifttech.remit.android.features.withdraw.WithdrawViewModelFactory; import com.swifttech.remit.android.features.withdraw.WithdrawViewModelFactory;
import com.swifttech.remit.android.features.withdraw.presenter.WithdrawPresenter; import com.swifttech.remit.android.features.withdraw.presenter.WithdrawPresenter;
import com.swifttech.remit.android.features.withdraw.presenter.WithdrawPresenterInterface; import com.swifttech.remit.android.features.withdraw.presenter.WithdrawPresenterInterface;
import com.swifttech.remit.android.features.withdraw.presenter.WithdrawViewLiveData;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick;
public class WithdrawActivity extends AppCompatActivity implements WithdrawPresenterInterface.WithdrawContract {
public class WithdrawActivity extends BaseActivity implements WithdrawPresenterInterface.WithdrawContract {
@BindView(R.id.iv_back) @BindView(R.id.iv_back)
View iv_back; View iv_back;
@ -25,6 +33,19 @@ public class WithdrawActivity extends AppCompatActivity implements WithdrawPrese
@BindView(R.id.toolbar_title) @BindView(R.id.toolbar_title)
TextView toolbarTitle; TextView toolbarTitle;
@BindView(R.id.amount_TxtInputLayout)
TextInputLayout amount_TxtInputLayout;
@BindView(R.id.amount_edTxt)
TextInputEditText amount_edTxt;
@BindView(R.id.service_charge_txt)
TextView service_charge_txt;
@BindView(R.id.proceedBtn)
Button proceedBtn;
private WithdrawPresenter viewModel; private WithdrawPresenter viewModel;
@Override @Override
@ -33,6 +54,7 @@ public class WithdrawActivity extends AppCompatActivity implements WithdrawPrese
setContentView(R.layout.activity_withdraw); setContentView(R.layout.activity_withdraw);
ButterKnife.bind(this); ButterKnife.bind(this);
init(); init();
performDefaultAction(savedInstanceState);
} }
private void init() { private void init() {
@ -41,4 +63,29 @@ public class WithdrawActivity extends AppCompatActivity implements WithdrawPrese
} }
private void performDefaultAction(Bundle savedInstanceState) {
WithdrawViewLiveData liveData = viewModel.subscribeToWithdrawAmountEventLiveData(RxTextView.textChanges(amount_edTxt).skipInitialValue());
liveData.getAmountLiveData().observe(this, this::onAmountDataReceived);
liveData.getServiceCharge().observe(this, this::onServiceChargeReceived);
liveData.getAllFieldValidLiveData().observe(this, proceedBtn::setEnabled);
}
private void onServiceChargeReceived(String serviceCharge) {
service_charge_txt.setText(serviceCharge);
}
private void onAmountDataReceived(FormInputStateDTO<String> amountData) {
if (amountData.isValid()) {
amount_TxtInputLayout.setError(null);
} else {
amount_TxtInputLayout.setError(amountData.getErrorMessage());
}
}
@OnClick(R.id.proceedBtn)
public void proceedToWithdraw() {
viewModel.proceedToWithdraw();
}
} }

26
app/src/main/res/layout/activity_cash_pickup_to_wallet.xml

@ -1,9 +1,27 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".features.cashpickuptowallet.view.CashPickupToWalletActivity">
android:background="@color/background_gray"
android:orientation="vertical"
android:fitsSystemWindows="true">
<include layout="@layout/layout_sendmoney_toolbar" />
<com.swifttech.remit.android.common.customwidgets.SwipeDisabledViewPager
android:id="@+id/cashPickupViewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

68
app/src/main/res/layout/activity_withdraw.xml

@ -1,9 +1,69 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".features.withdraw.view.WithdrawActivity">
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/m_layout_bg_color"
android:orientation="vertical"
tools:context=".features.sendmoney.view.SendMoneyV2Activity">
<include layout="@layout/layout_sendmoney_toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:id="@+id/rootView"
style="@style/MFormBoundWithCornerRadius"
android:orientation="vertical"
>
<com.swifttech.remit.android.common.customwidgets.GmeTextView
android:layout_marginTop="@dimen/_5sdp"
android:layout_marginBottom="@dimen/_10sdp"
style="@style/MFormTitleDescriptionTextView"
android:text="Please enter the required amount to withdraw from your wallet to your bank."
/>
<com.swifttech.remit.android.common.view.MTextInputLayout
android:id="@+id/amount_TxtInputLayout"
app:errorEnabled="true"
style="@style/MTextInputLayoutForm"
app:endIconMode="clear_text"
android:hint="Enter Amount(MNT)"
>
<com.swifttech.remit.android.common.view.MTextInputEditText
android:id="@+id/amount_edTxt"
style="@style/MTextInputEditText"
android:inputType="phone"
android:imeOptions="actionDone"
/>
</com.swifttech.remit.android.common.view.MTextInputLayout>
<com.swifttech.remit.android.common.customwidgets.GmeTextView
android:layout_marginBottom="@dimen/_10sdp"
style="@style/MFormTitleDescriptionTextView"
android:id="@+id/service_charge_txt"
android:gravity="center"
tools:text="Per Transaction Service Charge: \n 1,000 MNT"
/>
<com.swifttech.remit.android.common.customwidgets.GmeButton
android:id="@+id/proceedBtn"
style="@style/MButton"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:text="@string/proceed_text"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>

21
app/src/main/res/layout/fragment_cash_pickup_txn_detail.xml

@ -51,7 +51,7 @@
app:layout_constraintEnd_toStartOf="@+id/view13" app:layout_constraintEnd_toStartOf="@+id/view13"
app:layout_constraintStart_toEndOf="@+id/view12" app:layout_constraintStart_toEndOf="@+id/view12"
app:layout_constraintTop_toBottomOf="@+id/transfer_label" app:layout_constraintTop_toBottomOf="@+id/transfer_label"
app:layout_constraintBottom_toBottomOf="parent"/>
app:layout_constraintBottom_toTopOf="@+id/tv_control_no"/>
<com.swifttech.remit.android.features.inboundreceipt.view.ProgressPathView <com.swifttech.remit.android.features.inboundreceipt.view.ProgressPathView
android:id="@+id/view13" android:id="@+id/view13"
@ -69,7 +69,7 @@
android:id="@+id/receiverFlagImageview" android:id="@+id/receiverFlagImageview"
android:layout_width="@dimen/_30sdp" android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp" android:layout_height="@dimen/_30sdp"
android:src="@drawable/flag_south_korea"
android:src="@drawable/flag_mongolia"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintEnd_toStartOf="@+id/guideline4" app:layout_constraintEnd_toStartOf="@+id/guideline4"
@ -112,6 +112,23 @@
app:layout_constraintGuide_percent="0.1" /> app:layout_constraintGuide_percent="0.1" />
<com.swifttech.remit.android.common.customwidgets.GmeTextView
android:id="@+id/tv_control_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/_6sdp"
android:layout_marginEnd="@dimen/_6sdp"
android:layout_marginTop="@dimen/_6sdp"
android:padding="@dimen/_4sdp"
android:textColor="@color/white"
android:textSize="@dimen/_12ssp"
android:layout_marginBottom="@dimen/_8sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/gmeIconImageview"
app:layout_constraintBottom_toBottomOf="parent"
app:txtfontName="@string/semibold" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout <LinearLayout

Loading…
Cancel
Save