From 63a915b80ff347a6b32f6f791e1f3480a123434a Mon Sep 17 00:00:00 2001 From: Amit Yadav Date: Tue, 24 Mar 2020 22:19:52 +0530 Subject: [PATCH 1/2] solves issue #24 --- .../java/com/mifos/mobile/passcode/MifosPassCodeActivity.java | 2 ++ mifos-passcode/src/main/res/values/strings.xml | 1 + 2 files changed, 3 insertions(+) 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..9c22fba 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 @@ -222,6 +222,8 @@ public void passCodeEntered(String passcode) { resetPasscode(); return; } + Toast.makeText(getApplicationContext(), R.string.Login_successfully, + Toast.LENGTH_SHORT).show(); startHomeActivity(); } else { mifosPassCodeView.startAnimation(shakeAnimation); diff --git a/mifos-passcode/src/main/res/values/strings.xml b/mifos-passcode/src/main/res/values/strings.xml index 8fadea8..7e7bfb3 100644 --- a/mifos-passcode/src/main/res/values/strings.xml +++ b/mifos-passcode/src/main/res/values/strings.xml @@ -36,4 +36,5 @@ Authentication Cancelled Fingerprint Do you want to enable Fingerprint Authentication? + Login Successfully \ No newline at end of file From e0feec8e6176c1a321f3c5096944bdfdf7268c65 Mon Sep 17 00:00:00 2001 From: Amit Yadav Date: Fri, 27 Mar 2020 15:05:36 +0530 Subject: [PATCH 2/2] solves issue #23 and #35 --- .../passcode/MifosPassCodeActivity.java | 30 +++++++++++++++---- .../main/res/layout/activity_pass_code.xml | 1 - .../src/main/res/values/strings.xml | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) 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 9c22fba..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,27 +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