From 0bb428a658f0680d04052fb7eff0cb07aa30bbd3 Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 02:22:43 -0500 Subject: [PATCH] Add listener to the class PinRequestActivity to reuse the on success or fail password event --- .../activities/PinRequestActivity.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java index b90ed6e..a725c46 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java @@ -31,6 +31,7 @@ import cy.agorise.crystalwallet.dialogs.material.DialogMaterial; import cy.agorise.crystalwallet.dialogs.material.NegativeResponse; import cy.agorise.crystalwallet.dialogs.material.PositiveResponse; import cy.agorise.crystalwallet.dialogs.material.QuestionDialog; +import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.models.AccountSeed; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.util.PasswordManager; @@ -55,6 +56,10 @@ public class PinRequestActivity extends AppCompatActivity { * */ private int seconds = 15; + /* + * External listener for success or fail + * */ + private static OnResponse onResponse; @@ -105,8 +110,19 @@ public class PinRequestActivity extends AppCompatActivity { if (PasswordManager.checkPassword(passwordEncrypted, etPassword.getText().toString())) { if (CrystalSecurityMonitor.getInstance(null).is2ndFactorSet()) { CrystalSecurityMonitor.getInstance(null).call2ndFactor(this); + + if(onResponse != null){ + onResponse.onSuccess(); + onResponse = null; + } + } else { this.finish(); + + if(onResponse != null){ + onResponse.onFailed(); + onResponse = null; + } } } else{ @@ -205,6 +221,11 @@ public class PinRequestActivity extends AppCompatActivity { } + public static void setOnResponse(OnResponse onResponse) { + PinRequestActivity.onResponse = onResponse; + } + + @OnTextChanged(value = R.id.etPassword, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) void afterPasswordChanged(Editable editable) {