diff --git a/mifos-passcode/src/main/java/com/mifos/mobile/passcode/MifosPassCodeActivity.java b/mifos-passcode/src/main/java/com/mifos/mobile/passcode/MifosPassCodeActivity.java index 4088d21..3f41e94 100644 --- a/mifos-passcode/src/main/java/com/mifos/mobile/passcode/MifosPassCodeActivity.java +++ b/mifos-passcode/src/main/java/com/mifos/mobile/passcode/MifosPassCodeActivity.java @@ -4,6 +4,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.os.Handler; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; @@ -22,9 +23,15 @@ import androidx.core.content.ContextCompat; import androidx.core.widget.NestedScrollView; +import java.util.Timer; +import java.util.TimerTask; + public abstract class MifosPassCodeActivity extends AppCompatActivity implements MifosPassCodeView. PassCodeListener { + + + private static final int WAIT_TIME = 30 * 1000; NestedScrollView clRootview; AppCompatButton btnForgotPasscode; MifosPassCodeView mifosPassCodeView; @@ -207,25 +214,40 @@ public void passCodeEntered(String passcode) { return; } - if (counter == 3) { - Toast.makeText(getApplicationContext(), R.string.incorrect_passcode_more_than_three, + else if (counter == 5) { + Toast.makeText(getApplicationContext(), R.string.incorrect_passcode_more_than_five, Toast.LENGTH_SHORT).show(); - clearTokenPreferences(); + + + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + counter=0; + mifosPassCodeView.setEnabled(false); + } + }, WAIT_TIME); + // clearTokenPreferences(); startLoginActivity(); + mifosPassCodeView.setEnabled(true); return; } - if (isPassCodeLengthCorrect()) { + else if (isPassCodeLengthCorrect()) { String passwordEntered = encryptPassCode(mifosPassCodeView.getPasscode()); if (passcodePreferencesHelper.getPassCode().equals(passwordEntered)) { if (resetPasscode) { resetPasscode(); return; } + counter = 0; + Toast.makeText(getApplicationContext(), R.string.Login_successfully, + Toast.LENGTH_SHORT).show(); startHomeActivity(); } else { + + mifosPassCodeView.startAnimation(shakeAnimation); - counter++; + counter += 1; mifosPassCodeView.clearPasscodeField(); showToaster(clRootview, R.string.incorrect_passcode); } diff --git a/mifos-passcode/src/main/res/layout/activity_pass_code.xml b/mifos-passcode/src/main/res/layout/activity_pass_code.xml index 6b15861..8ba170b 100644 --- a/mifos-passcode/src/main/res/layout/activity_pass_code.xml +++ b/mifos-passcode/src/main/res/layout/activity_pass_code.xml @@ -34,7 +34,6 @@ android:layout_height="@dimen/login_height" android:layout_marginTop="@dimen/login_margin_top" android:layout_marginBottom="@dimen/login_padding_top" /> - Enter 4 digit Passcode Passcode should be of 4 digit Incorrect Passcode - You have entered incorrect Passcode more than 3 times + You have entered incorrect Passcode more than 5 times, pls wait till 30sec Skip Save Proceed @@ -36,4 +36,5 @@ Authentication Cancelled Fingerprint Do you want to enable Fingerprint Authentication? + Login Successfully \ No newline at end of file