Browse Source

Countdown fixes

master
preyearegmi 6 years ago
parent
commit
220420fbc2
  1. 10
      app/src/main/java/com/gmeremit/online/gmeremittance_native/resendV2/presenter/resend/ReSendMoneyV2Presenter.java
  2. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/resendV2/presenter/resend/ReSendMoneyV2PresenterInterface.java
  3. 34
      app/src/main/java/com/gmeremit/online/gmeremittance_native/resendV2/view/ReSendMoneyV2Activity.java
  4. 10
      app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/presenter/SendMoneyV2Presenter.java
  5. 5
      app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/presenter/SendMoneyV2PresenterInterface.java
  6. 31
      app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyV2Activity.java
  7. 43
      app/src/main/java/com/gmeremit/online/gmeremittance_native/transactionpasspromt/presenter/TransactionPasswordPromptV2Presenter.java
  8. 8
      app/src/main/java/com/gmeremit/online/gmeremittance_native/transactionpasspromt/presenter/TransactionPasswordPromptV2PresenterInterface.java
  9. 53
      app/src/main/java/com/gmeremit/online/gmeremittance_native/transactionpasspromt/view/TransactionPasswordPromptActivity.java

10
app/src/main/java/com/gmeremit/online/gmeremittance_native/resendV2/presenter/resend/ReSendMoneyV2Presenter.java

@ -39,6 +39,7 @@ public class ReSendMoneyV2Presenter extends BasePresenter implements ReSendMoney
ReSendMoneyV2GatewayInterface gateway; ReSendMoneyV2GatewayInterface gateway;
private ResendRelatedDataModel resendRelatedData; private ResendRelatedDataModel resendRelatedData;
private final BehaviorSubject<ExchangeCalculationApiResponse> exRateSubject; private final BehaviorSubject<ExchangeCalculationApiResponse> exRateSubject;
private long countDownRemainingValue;
public ReSendMoneyV2Presenter(ReSendMoneyV2ContractInterface view, PreviousTransactionRelatedData previousTransactionRelatedData) { public ReSendMoneyV2Presenter(ReSendMoneyV2ContractInterface view, PreviousTransactionRelatedData previousTransactionRelatedData) {
@ -52,7 +53,7 @@ public class ReSendMoneyV2Presenter extends BasePresenter implements ReSendMoney
private void init() private void init()
{ {
countDownRemainingValue=-1;
} }
@Override @Override
@ -115,7 +116,7 @@ public class ReSendMoneyV2Presenter extends BasePresenter implements ReSendMoney
public void onCancelled() { public void onCancelled() {
} }
});
},this.countDownRemainingValue);
} }
@ -155,6 +156,11 @@ public class ReSendMoneyV2Presenter extends BasePresenter implements ReSendMoney
return resendRelatedData.getReceiver().getRCountryCode(); return resendRelatedData.getReceiver().getRCountryCode();
} }
@Override
public void updateRemainingCountDownValue(long value) {
this.countDownRemainingValue=value;
}
public void performSendMoneyTransaction(String password) { public void performSendMoneyTransaction(String password) {

4
app/src/main/java/com/gmeremit/online/gmeremittance_native/resendV2/presenter/resend/ReSendMoneyV2PresenterInterface.java

@ -45,9 +45,11 @@ public interface ReSendMoneyV2PresenterInterface extends BasePresenterInterface
String getSelectedCountry(); String getSelectedCountry();
void updateRemainingCountDownValue(long value);
interface ReSendMoneyV2ContractInterface extends BaseContractInterface interface ReSendMoneyV2ContractInterface extends BaseContractInterface
{ {
void promptPassword(PasswordPromptListener listener);
void promptPassword(PasswordPromptListener listener,long countDownValue);
void showReceiptOnTransactionComplete(String transactionId); void showReceiptOnTransactionComplete(String transactionId);

34
app/src/main/java/com/gmeremit/online/gmeremittance_native/resendV2/view/ReSendMoneyV2Activity.java

@ -2,9 +2,10 @@ package com.gmeremit.online.gmeremittance_native.resendV2.view;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.LayoutRes; import android.support.annotation.LayoutRes;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.os.Bundle;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
@ -20,11 +21,11 @@ import com.gmeremit.online.gmeremittance_native.sendmoneyV2.view.SendMoneyV2Tran
import com.gmeremit.online.gmeremittance_native.transactionpasspromt.PasswordPromptListener; import com.gmeremit.online.gmeremittance_native.transactionpasspromt.PasswordPromptListener;
import com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity; import com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import static com.gmeremit.online.gmeremittance_native.resendV2.view.TransactionListingV2Activity.PREV_TXN_RELATED_DATA_BUNDLE_KEY; import static com.gmeremit.online.gmeremittance_native.resendV2.view.TransactionListingV2Activity.PREV_TXN_RELATED_DATA_BUNDLE_KEY;
import static com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity.OTP_COUNTDOWN_VALUE;
import static com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity.PAYMENT_TYPE_BUNDLE_KEY; import static com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity.PAYMENT_TYPE_BUNDLE_KEY;
import static com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity.TRANSACTION_PWD_ENC_DATA; import static com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity.TRANSACTION_PWD_ENC_DATA;
@ -152,7 +153,7 @@ public class ReSendMoneyV2Activity extends BaseActivity implements ReSendMoneyV2
@Override @Override
public ReSendMoneyV2PresenterInterface getPresenter() { public ReSendMoneyV2PresenterInterface getPresenter() {
if (this.presenter == null) if (this.presenter == null)
this.presenter = new ReSendMoneyV2Presenter(this,reSendMoneyRequiredData);
this.presenter = new ReSendMoneyV2Presenter(this, reSendMoneyRequiredData);
return this.presenter; return this.presenter;
} }
@ -165,12 +166,13 @@ public class ReSendMoneyV2Activity extends BaseActivity implements ReSendMoneyV2
@Override @Override
public void promptPassword(PasswordPromptListener listener) {
String paymentType=presenter.getPaymentType();
this.passwordPromptListener=listener;
Intent passwordRequestIntent=new Intent(this, TransactionPasswordPromptActivity.class);
passwordRequestIntent.putExtra(PAYMENT_TYPE_BUNDLE_KEY,paymentType);
startActivityForResult(passwordRequestIntent,PASSWORD_PROMPT_REQUEST);
public void promptPassword(PasswordPromptListener listener, long countDownValue) {
String paymentType = presenter.getPaymentType();
this.passwordPromptListener = listener;
Intent passwordRequestIntent = new Intent(this, TransactionPasswordPromptActivity.class);
passwordRequestIntent.putExtra(PAYMENT_TYPE_BUNDLE_KEY, paymentType);
passwordRequestIntent.putExtra(OTP_COUNTDOWN_VALUE, countDownValue);
startActivityForResult(passwordRequestIntent, PASSWORD_PROMPT_REQUEST);
} }
@Override @Override
@ -178,10 +180,18 @@ public class ReSendMoneyV2Activity extends BaseActivity implements ReSendMoneyV2
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PASSWORD_PROMPT_REQUEST) { if (requestCode == PASSWORD_PROMPT_REQUEST) {
if (resultCode == Activity.RESULT_OK) { if (resultCode == Activity.RESULT_OK) {
String encData=data.getStringExtra(TRANSACTION_PWD_ENC_DATA);
if(this.passwordPromptListener!=null)
String encData = data.getStringExtra(TRANSACTION_PWD_ENC_DATA);
presenter.updateRemainingCountDownValue(-1);
if (this.passwordPromptListener != null)
passwordPromptListener.onPasswordSubmit(encData); passwordPromptListener.onPasswordSubmit(encData);
this.passwordPromptListener=null;
this.passwordPromptListener = null;
} else if (resultCode == Activity.RESULT_CANCELED&&data!=null) {
presenter.updateRemainingCountDownValue(data.getLongExtra(OTP_COUNTDOWN_VALUE, -1));
}
else if(resultCode==RESULT_CANCELED)
{
presenter.updateRemainingCountDownValue(-1);
} }
} }
} }

10
app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/presenter/SendMoneyV2Presenter.java

@ -58,6 +58,8 @@ public class SendMoneyV2Presenter extends BasePresenter implements SendMoneyV2Pr
private String selectedForexId = null; private String selectedForexId = null;
private String selectedTransferAmount = null; private String selectedTransferAmount = null;
private long countDownRemainingValue;
public SendMoneyV2Presenter(SendMoneyV2ContractInterface view, SendMoneyRequiredData sendMoneyRequiredData) { public SendMoneyV2Presenter(SendMoneyV2ContractInterface view, SendMoneyRequiredData sendMoneyRequiredData) {
this.view = view; this.view = view;
@ -65,6 +67,7 @@ public class SendMoneyV2Presenter extends BasePresenter implements SendMoneyV2Pr
this.selectedPaymentType = sendMoneyRequiredData.getSelectedAutoDebitAccount(); this.selectedPaymentType = sendMoneyRequiredData.getSelectedAutoDebitAccount();
this.gateway = new SendMoneyV2Gateway(this); this.gateway = new SendMoneyV2Gateway(this);
this.compositeObservable = new CompositeDisposable(); this.compositeObservable = new CompositeDisposable();
countDownRemainingValue=-1;
} }
@ -200,7 +203,7 @@ public class SendMoneyV2Presenter extends BasePresenter implements SendMoneyV2Pr
public void onCancelled() { public void onCancelled() {
} }
});
},countDownRemainingValue);
} }
@ -217,6 +220,11 @@ public class SendMoneyV2Presenter extends BasePresenter implements SendMoneyV2Pr
return ""; return "";
} }
@Override
public void updateRemainingCountDownValue(long value) {
this.countDownRemainingValue=value;
}
public void performSendMoneyTransaction(String password) { public void performSendMoneyTransaction(String password) {

5
app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/presenter/SendMoneyV2PresenterInterface.java

@ -47,9 +47,12 @@ public interface SendMoneyV2PresenterInterface extends BasePresenterInterface {
String getPaymentType(); String getPaymentType();
void updateRemainingCountDownValue(long value);
interface SendMoneyV2ContractInterface extends BaseContractInterface interface SendMoneyV2ContractInterface extends BaseContractInterface
{ {
void promptPassword(PasswordPromptListener listener);
void promptPassword(PasswordPromptListener listener,long countDownValue);
void showReceiptOnTransactionComplete(String transactionId); void showReceiptOnTransactionComplete(String transactionId);

31
app/src/main/java/com/gmeremit/online/gmeremittance_native/sendmoneyV2/view/SendMoneyV2Activity.java

@ -2,9 +2,9 @@ package com.gmeremit.online.gmeremittance_native.sendmoneyV2.view;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.LayoutRes; import android.support.annotation.LayoutRes;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
@ -22,6 +22,7 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import static com.gmeremit.online.gmeremittance_native.recipientV2.view.recipientadd.RecipientAddV2Activity.RECIPIENT_INFO_BUNDLE_KEY; import static com.gmeremit.online.gmeremittance_native.recipientV2.view.recipientadd.RecipientAddV2Activity.RECIPIENT_INFO_BUNDLE_KEY;
import static com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity.OTP_COUNTDOWN_VALUE;
import static com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity.PAYMENT_TYPE_BUNDLE_KEY; import static com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity.PAYMENT_TYPE_BUNDLE_KEY;
import static com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity.TRANSACTION_PWD_ENC_DATA; import static com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionPasswordPromptActivity.TRANSACTION_PWD_ENC_DATA;
@ -259,12 +260,13 @@ public class SendMoneyV2Activity extends BaseActivity implements SendMoneyAction
} }
@Override @Override
public void promptPassword(PasswordPromptListener listener) {
String paymentType=presenter.getPaymentType();
this.passwordPromptListener=listener;
Intent passwordRequestIntent=new Intent(this, TransactionPasswordPromptActivity.class);
passwordRequestIntent.putExtra(PAYMENT_TYPE_BUNDLE_KEY,paymentType);
startActivityForResult(passwordRequestIntent,PASSWORD_PROMPT_REQUEST);
public void promptPassword(PasswordPromptListener listener, long countDownValue) {
String paymentType = presenter.getPaymentType();
this.passwordPromptListener = listener;
Intent passwordRequestIntent = new Intent(this, TransactionPasswordPromptActivity.class);
passwordRequestIntent.putExtra(PAYMENT_TYPE_BUNDLE_KEY, paymentType);
passwordRequestIntent.putExtra(OTP_COUNTDOWN_VALUE, countDownValue);
startActivityForResult(passwordRequestIntent, PASSWORD_PROMPT_REQUEST);
} }
@Override @Override
@ -272,10 +274,17 @@ public class SendMoneyV2Activity extends BaseActivity implements SendMoneyAction
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PASSWORD_PROMPT_REQUEST) { if (requestCode == PASSWORD_PROMPT_REQUEST) {
if (resultCode == Activity.RESULT_OK) { if (resultCode == Activity.RESULT_OK) {
String encData=data.getStringExtra(TRANSACTION_PWD_ENC_DATA);
if(this.passwordPromptListener!=null)
passwordPromptListener.onPasswordSubmit(encData);
this.passwordPromptListener=null;
String encData = data.getStringExtra(TRANSACTION_PWD_ENC_DATA);
presenter.updateRemainingCountDownValue(-1);
if (this.passwordPromptListener != null)
passwordPromptListener.onPasswordSubmit(encData);
this.passwordPromptListener = null;
} else if (resultCode == Activity.RESULT_CANCELED && data != null) {
presenter.updateRemainingCountDownValue(data.getLongExtra(OTP_COUNTDOWN_VALUE, -1));
}
else if(resultCode == Activity.RESULT_CANCELED)
{
presenter.updateRemainingCountDownValue(-1);
} }
} }
} }

43
app/src/main/java/com/gmeremit/online/gmeremittance_native/transactionpasspromt/presenter/TransactionPasswordPromptV2Presenter.java

@ -21,31 +21,44 @@ public class TransactionPasswordPromptV2Presenter extends BasePresenter implemen
private final TransactionPasswordPromptV2PresenterInterface.TransactionPasswordPromptV2ContractInterface view; private final TransactionPasswordPromptV2PresenterInterface.TransactionPasswordPromptV2ContractInterface view;
private final TransactionPasswordPromptV2InteractorInterface.TransactionPasswordPromptV2GatewayInterface gateway; private final TransactionPasswordPromptV2InteractorInterface.TransactionPasswordPromptV2GatewayInterface gateway;
private final CompositeDisposable compositeDisposable; private final CompositeDisposable compositeDisposable;
private long updateCountdownValue;
public TransactionPasswordPromptV2Presenter(TransactionPasswordPromptV2PresenterInterface.TransactionPasswordPromptV2ContractInterface view) { public TransactionPasswordPromptV2Presenter(TransactionPasswordPromptV2PresenterInterface.TransactionPasswordPromptV2ContractInterface view) {
this.view=view; this.view=view;
this.gateway=new TransactionPasswordPromptV2Gateway(this); this.gateway=new TransactionPasswordPromptV2Gateway(this);
this.compositeDisposable = new CompositeDisposable(); this.compositeDisposable = new CompositeDisposable();
this.updateCountdownValue =-1;
} }
@Override @Override
public void getOtp() { public void getOtp() {
this.compositeDisposable.add(
this.gateway.requestOtp(this.gateway.getAuth(),this.gateway.getUserID())
.doOnSubscribe(disposable -> view.showProgressBar(true, getStringfromStringId(R.string.requesting_otp_text)))
.doFinally(() -> view.showProgressBar(false, ""))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new ResendRequestObserver())
);
// new Handler().postDelayed(()->{
// view.showPopUpMessage("Please check your mobile for OTP", CustomAlertDialog.AlertType.SUCCESS, alertType -> {
// view.showResendRequestView(false);
// view.startCountdownView(120000);
// });
// },2000);
if(updateCountdownValue==-1) {
this.compositeDisposable.add(
this.gateway.requestOtp(this.gateway.getAuth(), this.gateway.getUserID())
.doOnSubscribe(disposable -> view.showProgressBar(true, getStringfromStringId(R.string.requesting_otp_text)))
.doFinally(() -> view.showProgressBar(false, ""))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new ResendRequestObserver())
);
}
else
{
view.showResendRequestView(false);
view.startCountdownView(updateCountdownValue);
}
}
@Override
public void updateCountdown(long millisUntilFinished) {
this.updateCountdownValue =millisUntilFinished;
}
@Override
public long getLatestCountDownValue() {
return updateCountdownValue;
} }

8
app/src/main/java/com/gmeremit/online/gmeremittance_native/transactionpasspromt/presenter/TransactionPasswordPromptV2PresenterInterface.java

@ -6,8 +6,14 @@ import com.gmeremit.online.gmeremittance_native.base.BasePresenterInterface;
public interface TransactionPasswordPromptV2PresenterInterface extends BasePresenterInterface { public interface TransactionPasswordPromptV2PresenterInterface extends BasePresenterInterface {
void getOtp(); void getOtp();
void updateCountdown(long millisUntilFinished);
long getLatestCountDownValue();
interface TransactionPasswordPromptV2ContractInterface extends BaseContractInterface { interface TransactionPasswordPromptV2ContractInterface extends BaseContractInterface {
void startCountdownView(int durationMillisecond);
void startCountdownView(long durationMillisecond);
void showResendRequestView(boolean action); void showResendRequestView(boolean action);
} }
} }

53
app/src/main/java/com/gmeremit/online/gmeremittance_native/transactionpasspromt/view/TransactionPasswordPromptActivity.java

@ -3,7 +3,6 @@ package com.gmeremit.online.gmeremittance_native.transactionpasspromt.view;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -29,7 +28,6 @@ import com.gmeremit.online.gmeremittance_native.base.BaseActivity;
import com.gmeremit.online.gmeremittance_native.customwidgets.GmeErrorTextView; import com.gmeremit.online.gmeremittance_native.customwidgets.GmeErrorTextView;
import com.gmeremit.online.gmeremittance_native.transactionpasspromt.presenter.TransactionPasswordPromptV2Presenter; import com.gmeremit.online.gmeremittance_native.transactionpasspromt.presenter.TransactionPasswordPromptV2Presenter;
import com.gmeremit.online.gmeremittance_native.transactionpasspromt.presenter.TransactionPasswordPromptV2PresenterInterface; import com.gmeremit.online.gmeremittance_native.transactionpasspromt.presenter.TransactionPasswordPromptV2PresenterInterface;
import com.gmeremit.online.gmeremittance_native.utils.security.securitykeypad.EncryptionManager;
import com.gmeremit.online.gmeremittance_native.utils.security.securitykeypad.SecurityKeyboardManager; import com.gmeremit.online.gmeremittance_native.utils.security.securitykeypad.SecurityKeyboardManager;
import com.gmeremit.online.gmeremittance_native.utils.security.securitykeypad.SecurityKeyboardView; import com.gmeremit.online.gmeremittance_native.utils.security.securitykeypad.SecurityKeyboardView;
import com.gmeremit.online.gmeremittance_native.utils.security.securitykeypad.SecurityKeypadRequestParamBuilder; import com.gmeremit.online.gmeremittance_native.utils.security.securitykeypad.SecurityKeypadRequestParamBuilder;
@ -42,6 +40,7 @@ import butterknife.ButterKnife;
public class TransactionPasswordPromptActivity extends BaseActivity implements SecurityKeyboardView.SecurityKeyboardFocusStateListener, TransactionPasswordPromptV2PresenterInterface.TransactionPasswordPromptV2ContractInterface, View.OnClickListener { public class TransactionPasswordPromptActivity extends BaseActivity implements SecurityKeyboardView.SecurityKeyboardFocusStateListener, TransactionPasswordPromptV2PresenterInterface.TransactionPasswordPromptV2ContractInterface, View.OnClickListener {
public static final String OTP_COUNTDOWN_VALUE = "bundleCountdownValue";
SecurityKeyboardManager securityKeyboardManager; SecurityKeyboardManager securityKeyboardManager;
@BindView(R.id.securityKeyboard) @BindView(R.id.securityKeyboard)
@ -93,13 +92,16 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
window.setBackgroundDrawableResource(R.drawable.ic_rounded_password_prompt); window.setBackgroundDrawableResource(R.drawable.ic_rounded_password_prompt);
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
} }
presenter = new TransactionPasswordPromptV2Presenter(this);
paymentType = getIntent().getStringExtra(PAYMENT_TYPE_BUNDLE_KEY); paymentType = getIntent().getStringExtra(PAYMENT_TYPE_BUNDLE_KEY);
if (checkIfRequiredOTPScreen())
presenter.updateCountdown(getIntent().getLongExtra(OTP_COUNTDOWN_VALUE, -1));
init(); init();
performDefaultAction(savedInstanceState); performDefaultAction(savedInstanceState);
} }
private void init() { private void init() {
presenter = new TransactionPasswordPromptV2Presenter(this);
securityKeyboardView.setKeyboardContainerView(keypadContainer); securityKeyboardView.setKeyboardContainerView(keypadContainer);
securityKeyboardView.setKeyboardBallonView(ballonView); securityKeyboardView.setKeyboardBallonView(ballonView);
securityKeypadListener = new SecurityKeypadListener(); securityKeypadListener = new SecurityKeypadListener();
@ -115,11 +117,12 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
title.setText(getString(R.string.enter_otp_password_text)); title.setText(getString(R.string.enter_otp_password_text));
request.setMaxLength(4); request.setMaxLength(4);
ballonView.setVisibility(View.INVISIBLE); ballonView.setVisibility(View.INVISIBLE);
resendRequest.setVisibility(View.VISIBLE);
} else { } else {
request.setHintString(getString(R.string.password_text)); request.setHintString(getString(R.string.password_text));
title.setText(getString(R.string.enter_login_password_text)); title.setText(getString(R.string.enter_login_password_text));
resendRequest.setVisibility(View.INVISIBLE);
} }
securityKeyboardManager.bindWithSecurityWidgetView(securityKeyboardView) securityKeyboardManager.bindWithSecurityWidgetView(securityKeyboardView)
.setBallonView(ballonView) .setBallonView(ballonView)
@ -137,9 +140,9 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
private void performDefaultAction(Bundle savedInstanceState) { private void performDefaultAction(Bundle savedInstanceState) {
securityKeyboardManager.showKeyboard(); securityKeyboardManager.showKeyboard();
if (checkIfRequiredOTPScreen()) if (checkIfRequiredOTPScreen())
new Handler().postDelayed(()->{
new Handler().postDelayed(() -> {
presenter.getOtp(); presenter.getOtp();
},400);
}, 400);
} }
@ -175,7 +178,7 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
securityKeyboardView.setSecurityKeyboardFocusStateListener(this); securityKeyboardView.setSecurityKeyboardFocusStateListener(this);
if(checkIfRequiredOTPScreen())
if (checkIfRequiredOTPScreen())
resendRequest.setOnClickListener(this); resendRequest.setOnClickListener(this);
} }
@ -183,7 +186,7 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
securityKeyboardView.setSecurityKeyboardFocusStateListener(null); securityKeyboardView.setSecurityKeyboardFocusStateListener(null);
if(checkIfRequiredOTPScreen())
if (checkIfRequiredOTPScreen())
resendRequest.setOnClickListener(null); resendRequest.setOnClickListener(null);
} }
@ -200,13 +203,15 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
} }
@Override @Override
public void startCountdownView(int durationMillisecond) {
public void startCountdownView(long durationMillisecond) {
countDownTimer = new CountDownTimer(durationMillisecond, 1000) { countDownTimer = new CountDownTimer(durationMillisecond, 1000) {
int redColor=ContextCompat.getColor(TransactionPasswordPromptActivity.this, R.color.colorPrimary);
int grayColor=ContextCompat.getColor(TransactionPasswordPromptActivity.this, R.color.darkgray2);
int redColor = ContextCompat.getColor(TransactionPasswordPromptActivity.this, R.color.colorPrimary);
int grayColor = ContextCompat.getColor(TransactionPasswordPromptActivity.this, R.color.darkgray2);
@Override @Override
public void onTick(long millisUntilFinished) { public void onTick(long millisUntilFinished) {
presenter.updateCountdown(millisUntilFinished);
int seconds = (int) (millisUntilFinished / 1000); int seconds = (int) (millisUntilFinished / 1000);
int hours = seconds / (60 * 60); int hours = seconds / (60 * 60);
@ -221,7 +226,7 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
tryInText.setSpan(new ForegroundColorSpan(grayColor), 0, tryInText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); tryInText.setSpan(new ForegroundColorSpan(grayColor), 0, tryInText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
resendRequest.setText(tryInText); resendRequest.setText(tryInText);
Spannable timeText = new SpannableString(" "+timeRemaining);
Spannable timeText = new SpannableString(" " + timeRemaining);
timeText.setSpan(new ForegroundColorSpan(redColor), 0, timeText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); timeText.setSpan(new ForegroundColorSpan(redColor), 0, timeText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
resendRequest.append(timeText); resendRequest.append(timeText);
@ -230,11 +235,24 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
@Override @Override
public void onFinish() { public void onFinish() {
showResendRequestView(true); showResendRequestView(true);
presenter.updateCountdown(-1);
} }
}; };
countDownTimer.start(); countDownTimer.start();
} }
private void updateIntentOnCanellationAndFinish() {
boolean result = checkIfRequiredOTPScreen();
if (result) {
Intent backIntent = new Intent();
setResult(RESULT_CANCELED, backIntent);
backIntent.putExtra(OTP_COUNTDOWN_VALUE, presenter.getLatestCountDownValue());
}
finish();
}
@Override @Override
public void showResendRequestView(boolean action) { public void showResendRequestView(boolean action) {
if (resendRequest.getVisibility() != View.VISIBLE) if (resendRequest.getVisibility() != View.VISIBLE)
@ -242,6 +260,7 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
if (action) { if (action) {
if (countDownTimer != null) if (countDownTimer != null)
countDownTimer.cancel(); countDownTimer.cancel();
presenter.updateCountdown(-1);
resendRequest.setText(getString(R.string.resend_request_text)); resendRequest.setText(getString(R.string.resend_request_text));
resendRequest.setOnClickListener(this); resendRequest.setOnClickListener(this);
@ -251,6 +270,12 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
} }
} }
@Override
public void onBackPressed() {
updateIntentOnCanellationAndFinish();
}
@Override @Override
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
@ -284,7 +309,7 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
@Override @Override
public void cancel(Intent intent) { public void cancel(Intent intent) {
finish();
updateIntentOnCanellationAndFinish();
} }
private boolean validateStringNotEmpty(String data) { private boolean validateStringNotEmpty(String data) {
@ -315,7 +340,7 @@ public class TransactionPasswordPromptActivity extends BaseActivity implements S
boolean hasToucheOutsideTheView = checkIfTouchOutsiedRootView(e.getX(), e.getY()); boolean hasToucheOutsideTheView = checkIfTouchOutsiedRootView(e.getX(), e.getY());
if (hasToucheOutsideTheView) if (hasToucheOutsideTheView)
finish();
updateIntentOnCanellationAndFinish();
return hasToucheOutsideTheView; return hasToucheOutsideTheView;
} }
return super.onSingleTapUp(e); return super.onSingleTapUp(e);

Loading…
Cancel
Save