From 310d4332f7f526a1409ea6652ea94039b8e4d508 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Tue, 3 Oct 2017 20:58:41 -0400 Subject: [PATCH] - Adjusting import seed validators --- .../activities/ImportSeedActivity.java | 20 +++++++------ .../validators/ImportSeedValidator.java | 29 ++++++++++++------- .../validators/ValidationField.java | 20 +++++++++++-- 3 files changed, 48 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java index 6fc947a..597abd0 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java @@ -61,21 +61,23 @@ public class ImportSeedActivity extends AppCompatActivity implements ImportSeedV @OnTextChanged(value = R.id.etAccountName, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) void afterAccountNameChanged(Editable editable) { - this.validator.validateAccountName(editable.getT); + this.importSeedValidator.validateAccountName(editable.toString()); } @OnClick(R.id.btnImport) public void importSeed(){ - if (this.validator) - AccountSeed seed = new AccountSeed(); + if (this.importSeedValidator.isValid()) { + AccountSeed seed = new AccountSeed(); - //TODO verify if PIN and PIN confirmation are not null and are the same - //TODO verify if words are already in the db - //TODO check if name has been asigned to other seed - seed.setMasterSeed(etSeedWords.getText().toString()); - seed.setName(etAccountName.getText().toString()); + //TODO verify if PIN and PIN confirmation are not null and are the same + //TODO verify if words are already in the db + //TODO check if name has been asigned to other seed + seed.setMasterSeed(etSeedWords.getText().toString()); + seed.setName(etAccountName.getText().toString()); - accountSeedViewModel.addSeed(seed); + accountSeedViewModel.addSeed(seed); + //TODO get back to the previous activity + } } @Override diff --git a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/ImportSeedValidator.java b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/ImportSeedValidator.java index 392852d..6f7137e 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/ImportSeedValidator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/ImportSeedValidator.java @@ -1,6 +1,7 @@ package cy.agorise.crystalwallet.viewmodels.validators; import android.accounts.Account; +import android.content.res.Resources; import java.util.ArrayList; import java.util.List; @@ -18,13 +19,14 @@ import cy.agorise.crystalwallet.models.AccountSeed; public class ImportSeedValidator { private ImportSeedValidatorListener listener; - private List validationFields; private AccountSeed accountSeed; + private Resources res; private boolean isValid = false; - public ImportSeedValidator(AccountSeed seed){ + public ImportSeedValidator(Resources res, AccountSeed seed){ + this.res = res; this.accountSeed = seed; this.validationFields = new ArrayList(); //this.validationFields.add(new ValidationField("pin")); @@ -36,10 +38,16 @@ public class ImportSeedValidator { this.listener = listener; } - public void validate(){ - //validatePin(); - //validatePinConfirmation(); - validateAccountName(); + public boolean isValid(){ + for(int i=0;i