toast for wrong password
This commit is contained in:
parent
3e4b3e88a4
commit
ef74f2cc82
@ -3,6 +3,7 @@ package com.utsmm.kbz.ui.core_ui;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -158,6 +159,7 @@ public class EmvTransactionFragment extends DataBindingFragment {
|
||||
}
|
||||
|
||||
observeEmvResultStatus();
|
||||
observePinWarning();
|
||||
}
|
||||
|
||||
private boolean isNotManualTransaction() {
|
||||
@ -349,6 +351,15 @@ public class EmvTransactionFragment extends DataBindingFragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void observePinWarning() {
|
||||
emvTransactionViewModel.pinRemainingCount.observe(getViewLifecycleOwner(), msg -> {
|
||||
if (!TextUtils.isEmpty(msg)) {
|
||||
Toast.makeText(requireContext(), msg, Toast.LENGTH_SHORT).show();
|
||||
emvTransactionViewModel.pinRemainingCount.setValue("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void observeEmvErrorCode() {
|
||||
dismissLoadingDialog();
|
||||
emvTransactionViewModel.errorCodeMsg.observe(getViewLifecycleOwner(), pair -> {
|
||||
|
||||
@ -120,16 +120,17 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txt_emv_remaining_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/margin_button"
|
||||
android:fontFamily="@font/rubik_regular"
|
||||
android:gravity="center"
|
||||
android:text="@{emv.pinRemainingCount}"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/pan_size"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/textView3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView20"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/txt_emv_pin_mode"
|
||||
app:layout_goneMarginTop="@dimen/margin_button"
|
||||
tools:text="3 LEFT" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.utsmyanmar.baselib.viewModel;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@ -8,6 +9,7 @@ import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
@ -106,6 +108,7 @@ public abstract class EmvBaseViewModel extends BaseViewModel {
|
||||
public MutableLiveData<Integer> pinPadVisibility = new MutableLiveData<>(8);
|
||||
|
||||
protected int pinEnterCount;
|
||||
private int offlinePinIncorrectPromptCount;
|
||||
public CustomPinPadKeyboard customPinPadKeyboard;
|
||||
|
||||
private int mWidth = 239; // Single item width of password keyboard
|
||||
@ -636,6 +639,9 @@ public abstract class EmvBaseViewModel extends BaseViewModel {
|
||||
public void onCardHolderInputPin(boolean isOnlinePin, int leftTimes) {
|
||||
LogUtil.d(TAG, "onCardHolderInputPin isOnlinePin = " + isOnlinePin);
|
||||
LogUtil.d(TAG, "onCardHolderInputPin leftTimes = " + leftTimes);
|
||||
if (isOnlinePin) {
|
||||
pinRemainingCount.postValue("");
|
||||
}
|
||||
// startPinProcess(isOnlinePin ? 1 : 0);
|
||||
mProcessStep = EMV_SHOW_PIN_PAD;
|
||||
// mHandler.obtainMessage(EMV_SHOW_PIN_PAD, isOnlinePin ? 1 : 0).sendToTarget();
|
||||
@ -675,7 +681,13 @@ public abstract class EmvBaseViewModel extends BaseViewModel {
|
||||
public void onPrompt(PromptEnum promptEnum) {
|
||||
LogUtil.d(TAG, "onPrompt->" + promptEnum);
|
||||
if( promptEnum == PromptEnum.OFFLINE_PIN_INCORRECT_TRY_AGAIN) {
|
||||
offlinePinIncorrectPromptCount++;
|
||||
pinEnterCount = 0;
|
||||
pinText.postValue("");
|
||||
int attemptLeft = Math.max(0, 3 - offlinePinIncorrectPromptCount);
|
||||
pinRemainingCount.postValue("Please try again!\n" + attemptLeft + " attempt left!");
|
||||
emvHandler.onSetPromptResponse(false);
|
||||
|
||||
} else {
|
||||
emvHandler.onSetPromptResponse(true);
|
||||
}
|
||||
@ -902,6 +914,7 @@ public abstract class EmvBaseViewModel extends BaseViewModel {
|
||||
emvCardType.postValue("");
|
||||
pinText.setValue("");
|
||||
pinEnterCount = 0;
|
||||
offlinePinIncorrectPromptCount = 0;
|
||||
}
|
||||
|
||||
protected void getCardInfo() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user