From a4c6b1cfb1f1bb5a3806564a54c863272352f53f Mon Sep 17 00:00:00 2001 From: dtvv Date: Wed, 17 Oct 2018 01:06:35 -0500 Subject: [PATCH] -When the PIN does not match in the screen of import seed it does not show error message -Set a button in the PIN request activity to clic when the complete PIN is completely typed -In the PIN request activity, the OK button should not be enabled till a valid PIN is on it -Change the button style in the PIN request screen --- .../activities/PinRequestActivity.java | 48 +++++++++++++++++-- .../main/res/layout/activity_pin_request.xml | 26 ++++++++-- 2 files changed, 67 insertions(+), 7 deletions(-) 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 289d899..8155501 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java @@ -7,15 +7,25 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.text.Editable; +import android.view.View; +import android.widget.Button; import android.widget.EditText; +import android.widget.Toast; + +import org.jetbrains.annotations.NotNull; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; +import butterknife.OnClick; import butterknife.OnTextChanged; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; +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.models.AccountSeed; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.util.PasswordManager; @@ -24,6 +34,12 @@ import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; public class PinRequestActivity extends AppCompatActivity { private String passwordEncrypted; + @BindView(R.id.btnOK) + Button btnOK; + + + + @Override public void onBackPressed() { //Do nothing to prevent the user to use the back button @@ -38,6 +54,11 @@ public class PinRequestActivity extends AppCompatActivity { setContentView(R.layout.activity_pin_request); ButterKnife.bind(this); + /* + * Initially the button is disabled till the user type a valid PIN + * */ + btnOK.setEnabled(false); + GeneralSettingListViewModel generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class); LiveData> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList(); generalSettingsLiveData.observe(this, new Observer>() { @@ -59,9 +80,10 @@ public class PinRequestActivity extends AppCompatActivity { }); } - @OnTextChanged(value = R.id.etPassword, - callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) - void afterPasswordChanged(Editable editable) { + + @OnClick(R.id.btnOK) + void okClic(final View view) { + if (PasswordManager.checkPassword(passwordEncrypted, etPassword.getText().toString())) { if (CrystalSecurityMonitor.getInstance(null).is2ndFactorSet()) { CrystalSecurityMonitor.getInstance(null).call2ndFactor(this); @@ -69,6 +91,26 @@ public class PinRequestActivity extends AppCompatActivity { this.finish(); } } + else{ + Toast.makeText(getBaseContext(),this.getResources().getString(R.string.invalid_pin), + Toast.LENGTH_SHORT).show(); + } + } + + + @OnTextChanged(value = R.id.etPassword, + callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) + void afterPasswordChanged(Editable editable) { + + /* + * If it is valid length enable button + * */ + if(etPassword.getText().length()>=6){ + btnOK.setEnabled(true); + } + else{ + btnOK.setEnabled(false); + } } } diff --git a/app/src/main/res/layout/activity_pin_request.xml b/app/src/main/res/layout/activity_pin_request.xml index 6651876..aa4c3b3 100644 --- a/app/src/main/res/layout/activity_pin_request.xml +++ b/app/src/main/res/layout/activity_pin_request.xml @@ -1,16 +1,19 @@ - + + android:layout_centerInParent="true" + android:padding="5dp"> + + - \ No newline at end of file + +