From 418749ea6a9ff75f94e290366352dfc5c8e3d05b Mon Sep 17 00:00:00 2001 From: dtvv Date: Wed, 24 Oct 2018 16:18:01 -0500 Subject: [PATCH 01/17] Pocket security functionality disable for now --- .../crystalwallet/fragments/SecuritySettingsFragment.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java index a61d330..d3ed69a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java @@ -83,6 +83,11 @@ public class SecuritySettingsFragment extends Fragment { View v = inflater.inflate(R.layout.fragment_security_settings, container, false); ButterKnife.bind(this, v); + /* + * For now this will not be implemented + * */ + sPocketSecurity.setEnabled(false); + securityPagerAdapter = new SecurityPagerAdapter(getChildFragmentManager()); mPager.setAdapter(securityPagerAdapter); From 04d3a0d2e662b8e7be3734813d3d350dd427242a Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Wed, 24 Oct 2018 22:53:51 -0400 Subject: [PATCH 02/17] - Change the import bitshares account request to avoid using the name of the account --- .../activities/ImportSeedActivity.java | 23 ++-- .../ImportBitsharesAccountRequest.java | 115 ++++++++++++++++++ app/src/main/res/layout/import_seed.xml | 6 +- 3 files changed, 132 insertions(+), 12 deletions(-) create mode 100644 app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ImportBitsharesAccountRequest.java 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 954b06c..cba3f15 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java @@ -31,6 +31,7 @@ import cy.agorise.crystalwallet.dialogs.material.PositiveResponse; import cy.agorise.crystalwallet.dialogs.material.QuestionDialog; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests; +import cy.agorise.crystalwallet.requestmanagers.ImportBitsharesAccountRequest; import cy.agorise.crystalwallet.requestmanagers.ValidateImportBitsharesAccountRequest; import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel; import cy.agorise.crystalwallet.viewmodels.validators.ImportSeedValidator; @@ -203,6 +204,7 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator txtErrorAccount.setVisibility(View.INVISIBLE); } }); + /* etAccountName.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -217,9 +219,9 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator @Override public void afterTextChanged(Editable s) { - /* - * If all is ready to continue enable the button, contrarie case disable it - * */ + // + // If all is ready to continue enable the button, contrarie case disable it + // if(allFieldsAreFill()){ enableCreate(); } @@ -228,6 +230,7 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator } } }); + */ accountSeedViewModel = ViewModelProviders.of(this).get(AccountSeedViewModel.class); importSeedValidator = new ImportSeedValidator(this.getApplicationContext(),etPin,etPinConfirmation,etAccountName,etSeedWords); @@ -263,8 +266,8 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator boolean complete = false; if( etPin.getText().toString().trim().compareTo("")!=0 && etPinConfirmation.getText().toString().trim().compareTo("")!=0 && - etSeedWords.getText().toString().trim().compareTo("")!=0 && - etAccountName.getText().toString().trim().compareTo("")!=0){ + etSeedWords.getText().toString().trim().compareTo("")!=0 /*&& + etAccountName.getText().toString().trim().compareTo("")!=0*/){ complete = true; } return complete; @@ -287,11 +290,11 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator void afterSeedWordsChanged(Editable editable) { this.importSeedValidator.validate(); } - @OnTextChanged(value = R.id.etAccountName, + /*@OnTextChanged(value = R.id.etAccountName, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) void afterAccountNameChanged(Editable editable) { this.importSeedValidator.validate(); - } + }*/ @OnClick(R.id.btnCancel) public void cancel(){ @@ -327,7 +330,7 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator /* * Validate mnemonic with the server * */ - final ValidateImportBitsharesAccountRequest request = new ValidateImportBitsharesAccountRequest(etAccountName.getText().toString().trim(),etSeedWords.getText().toString().trim(),activity); + final ImportBitsharesAccountRequest request = new ImportBitsharesAccountRequest(etSeedWords.getText().toString().trim(),activity); request.setListener(new CryptoNetInfoRequestListener() { @Override public void onCarryOut() { @@ -365,8 +368,8 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator final ImportSeedActivity thisActivity = this; - final ValidateImportBitsharesAccountRequest validatorRequest = - new ValidateImportBitsharesAccountRequest(etAccountName.getText().toString(), etSeedWords.getText().toString(), getApplicationContext(), true); + final ImportBitsharesAccountRequest validatorRequest = + new ImportBitsharesAccountRequest(etSeedWords.getText().toString(), getApplicationContext(), true); validatorRequest.setListener(new CryptoNetInfoRequestListener() { @Override diff --git a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ImportBitsharesAccountRequest.java b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ImportBitsharesAccountRequest.java new file mode 100644 index 0000000..cf83d4b --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ImportBitsharesAccountRequest.java @@ -0,0 +1,115 @@ +package cy.agorise.crystalwallet.requestmanagers; + +import android.content.Context; + +import cy.agorise.crystalwallet.enums.CryptoCoin; +import cy.agorise.crystalwallet.enums.SeedType; + +/** + * Imports a bitshares accounts, + * + * return true if the account exist, and the mnemonic (brainkey provide is for that account + * Created by Henry Varona on 10/24/2018. + */ + +public class ImportBitsharesAccountRequest extends CryptoNetInfoRequest { + + /** + * The status code of this request + */ + public enum StatusCode{ + NOT_STARTED, + SUCCEEDED, + NO_INTERNET, + NO_SERVER_CONNECTION, + ACCOUNT_DOESNT_EXIST, + BAD_SEED, + NO_ACCOUNT_DATA, + PETITION_FAILED + } + + /** + * The name of the account + */ + private String accountName; + + /** + * The mnemonic words + */ + private final String mnemonic; + + /** + * True - the account must be added if the accountName and mnemonic are correct + */ + private boolean addAccountIfValid = false; + + /** + * If this seed is BIP39 or Brainkey + */ + private SeedType seedType; + + /** + * The status of this request + */ + private StatusCode status = StatusCode.NOT_STARTED; + + private Context context; + + public ImportBitsharesAccountRequest(String mnemonic, Context context){ + super(CryptoCoin.BITSHARES); + this.accountName = ""; + this.mnemonic = mnemonic; + this.context = context; + } + + public ImportBitsharesAccountRequest(String mnemonic, Context context, boolean addAccountIfValid){ + super(CryptoCoin.BITSHARES); + this.accountName = ""; + this.mnemonic = mnemonic; + this.addAccountIfValid = addAccountIfValid; + this.context = context; + } + + public void validate(){ + if (!(this.status.equals(StatusCode.NOT_STARTED))){ + this._fireOnCarryOutEvent(); + } + } + + public String getAccountName() { + return accountName; + } + + public String getMnemonic() { + return mnemonic; + } + + public SeedType getSeedType() { + return seedType; + } + + public Context getContext() { + return context; + } + + public boolean addAccountIfValid(){ + return this.addAccountIfValid; + } + + public void setAccountName(String accountName){ + this.accountName = accountName; + } + + public void setSeedType(SeedType seedType) { + this.seedType = seedType; + } + + public void setStatus(StatusCode status) { + this.status = status; + this._fireOnCarryOutEvent(); + } + + public StatusCode getStatus() { + return status; + } +} diff --git a/app/src/main/res/layout/import_seed.xml b/app/src/main/res/layout/import_seed.xml index 59e5f6e..5b29d02 100644 --- a/app/src/main/res/layout/import_seed.xml +++ b/app/src/main/res/layout/import_seed.xml @@ -84,8 +84,9 @@ android:layout_width="330dp" android:layout_height="wrap_content" android:layout_below="@+id/etSeedWordsLayout" + android:layout_centerHorizontal="true" android:layout_marginTop="8dp" - android:layout_centerHorizontal="true"> + android:visibility="gone"> + android:singleLine="true" + android:visibility="gone" /> From ac95b6651109ac89d7cfafbd725cb5af98e05016 Mon Sep 17 00:00:00 2001 From: hvarona Date: Thu, 25 Oct 2018 00:22:13 -0400 Subject: [PATCH 03/17] Added the import rrequest with only the mnemonic words of the seed --- .../manager/BitsharesAccountManager.java | 75 ++++++++++++++++++- .../ImportBitsharesAccountRequest.java | 25 ------- 2 files changed, 74 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java index ec5edb2..8d47661 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java @@ -28,6 +28,7 @@ import cy.agorise.crystalwallet.requestmanagers.CryptoNetEquivalentRequest; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequest; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestsListener; import cy.agorise.crystalwallet.requestmanagers.GetBitsharesAccountNameCacheRequest; +import cy.agorise.crystalwallet.requestmanagers.ImportBitsharesAccountRequest; import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesLTMUpgradeRequest; import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest; import cy.agorise.crystalwallet.requestmanagers.ValidateCreateBitsharesAccountRequest; @@ -222,7 +223,9 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI @Override public void onNewRequest(CryptoNetInfoRequest request) { if(request.getCoin().equals(CryptoCoin.BITSHARES)) { - if (request instanceof ValidateImportBitsharesAccountRequest) { + if (request instanceof ImportBitsharesAccountRequest) { + this.importAccount((ImportBitsharesAccountRequest) request); + } else if (request instanceof ValidateImportBitsharesAccountRequest) { this.validateImportAccount((ValidateImportBitsharesAccountRequest) request); } else if (request instanceof ValidateExistBitsharesAccountRequest) { this.validateExistAcccount((ValidateExistBitsharesAccountRequest) request); @@ -244,6 +247,76 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI } } + private void importAccount(final ImportBitsharesAccountRequest importRequest){ + final CrystalDatabase db = CrystalDatabase.getAppDatabase(importRequest.getContext()); + final AccountSeedDao accountSeedDao = db.accountSeedDao(); + ApiRequest getAccountNamesBK = new ApiRequest(0, new ApiRequestListener() { + @Override + public void success(Object answer, int idPetition) { + if(answer != null) { + UserAccount userAccount = (UserAccount) answer; + importRequest.setSeedType(SeedType.BRAINKEY); + importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.SUCCEEDED); + + AccountSeed seed = new AccountSeed(); + seed.setName(userAccount.getName()); + seed.setType(importRequest.getSeedType()); + seed.setMasterSeed(importRequest.getMnemonic()); + long idSeed = accountSeedDao.insertAccountSeed(seed); + if (idSeed >= 0) { + GrapheneAccount account = new GrapheneAccount(); + account.setCryptoNet(CryptoNet.BITSHARES); + account.setAccountIndex(0); + account.setSeedId(idSeed); + account.setName(userAccount.getName()); + importAccountFromSeed(account, importRequest.getContext()); + } + } + } + + @Override + public void fail(int idPetition) { + importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.PETITION_FAILED); + } + }); + + ApiRequest getAccountNamesBP39 = new ApiRequest(0, new ApiRequestListener() { + @Override + public void success(Object answer, int idPetition) { + if(answer != null) { + UserAccount userAccount = (UserAccount) answer; + importRequest.setSeedType(SeedType.BIP39); + importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.SUCCEEDED); + + AccountSeed seed = new AccountSeed(); + seed.setName(userAccount.getName()); + seed.setType(importRequest.getSeedType()); + seed.setMasterSeed(importRequest.getMnemonic()); + long idSeed = accountSeedDao.insertAccountSeed(seed); + if (idSeed >= 0) { + GrapheneAccount account = new GrapheneAccount(); + account.setCryptoNet(CryptoNet.BITSHARES); + account.setAccountIndex(0); + account.setSeedId(idSeed); + account.setName(userAccount.getName()); + importAccountFromSeed(account, importRequest.getContext()); + } + } + } + + @Override + public void fail(int idPetition) { + importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.PETITION_FAILED); + } + }); + + BrainKey bk = new BrainKey(importRequest.getMnemonic(), 0); + BIP39 bip39 = new BIP39(-1, importRequest.getMnemonic()); + GrapheneApiGenerator.getAccountByOwnerOrActiveAddress(bk.getPublicAddress("BTS"),getAccountNamesBK); + GrapheneApiGenerator.getAccountByOwnerOrActiveAddress(new Address(ECKey.fromPublicOnly(bip39.getBitsharesActiveKey(0).getPubKey())),getAccountNamesBP39); + + } + /** * Process the import account request */ diff --git a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ImportBitsharesAccountRequest.java b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ImportBitsharesAccountRequest.java index cf83d4b..14113b2 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ImportBitsharesAccountRequest.java +++ b/app/src/main/java/cy/agorise/crystalwallet/requestmanagers/ImportBitsharesAccountRequest.java @@ -28,21 +28,11 @@ public class ImportBitsharesAccountRequest extends CryptoNetInfoRequest { PETITION_FAILED } - /** - * The name of the account - */ - private String accountName; - /** * The mnemonic words */ private final String mnemonic; - /** - * True - the account must be added if the accountName and mnemonic are correct - */ - private boolean addAccountIfValid = false; - /** * If this seed is BIP39 or Brainkey */ @@ -57,16 +47,13 @@ public class ImportBitsharesAccountRequest extends CryptoNetInfoRequest { public ImportBitsharesAccountRequest(String mnemonic, Context context){ super(CryptoCoin.BITSHARES); - this.accountName = ""; this.mnemonic = mnemonic; this.context = context; } public ImportBitsharesAccountRequest(String mnemonic, Context context, boolean addAccountIfValid){ super(CryptoCoin.BITSHARES); - this.accountName = ""; this.mnemonic = mnemonic; - this.addAccountIfValid = addAccountIfValid; this.context = context; } @@ -76,10 +63,6 @@ public class ImportBitsharesAccountRequest extends CryptoNetInfoRequest { } } - public String getAccountName() { - return accountName; - } - public String getMnemonic() { return mnemonic; } @@ -92,14 +75,6 @@ public class ImportBitsharesAccountRequest extends CryptoNetInfoRequest { return context; } - public boolean addAccountIfValid(){ - return this.addAccountIfValid; - } - - public void setAccountName(String accountName){ - this.accountName = accountName; - } - public void setSeedType(SeedType seedType) { this.seedType = seedType; } From e8ceb88c6eeec2fc7c3b71c8c5ef67ca123fdfb7 Mon Sep 17 00:00:00 2001 From: hvarona Date: Thu, 25 Oct 2018 00:58:42 -0400 Subject: [PATCH 04/17] Added the import rrequest with only the mnemonic words of the seed --- .../manager/BitsharesAccountManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java index 8d47661..4baf5d9 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java @@ -253,7 +253,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI ApiRequest getAccountNamesBK = new ApiRequest(0, new ApiRequestListener() { @Override public void success(Object answer, int idPetition) { - if(answer != null) { + if(answer != null && importRequest.getStatus().equals(ImportBitsharesAccountRequest.StatusCode.NOT_STARTED)) { UserAccount userAccount = (UserAccount) answer; importRequest.setSeedType(SeedType.BRAINKEY); importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.SUCCEEDED); @@ -268,7 +268,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI account.setCryptoNet(CryptoNet.BITSHARES); account.setAccountIndex(0); account.setSeedId(idSeed); - account.setName(userAccount.getName()); + account.setAccountId(userAccount.getObjectId()); importAccountFromSeed(account, importRequest.getContext()); } } @@ -276,14 +276,14 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI @Override public void fail(int idPetition) { - importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.PETITION_FAILED); + //importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.PETITION_FAILED); } }); ApiRequest getAccountNamesBP39 = new ApiRequest(0, new ApiRequestListener() { @Override public void success(Object answer, int idPetition) { - if(answer != null) { + if(answer != null && importRequest.getStatus().equals(ImportBitsharesAccountRequest.StatusCode.NOT_STARTED)) { UserAccount userAccount = (UserAccount) answer; importRequest.setSeedType(SeedType.BIP39); importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.SUCCEEDED); @@ -298,7 +298,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI account.setCryptoNet(CryptoNet.BITSHARES); account.setAccountIndex(0); account.setSeedId(idSeed); - account.setName(userAccount.getName()); + account.setAccountId(userAccount.getObjectId()); importAccountFromSeed(account, importRequest.getContext()); } } @@ -306,7 +306,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI @Override public void fail(int idPetition) { - importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.PETITION_FAILED); + //importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.PETITION_FAILED); } }); From 2ca94de24156f592fa8f7840228285e320808124 Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 01:34:48 -0500 Subject: [PATCH 05/17] -In the send assets screen it crashes when type an amount --- .../validators/validationfields/AmountValidationField.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/AmountValidationField.java b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/AmountValidationField.java index 3b44223..a01f1a8 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/AmountValidationField.java +++ b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/validationfields/AmountValidationField.java @@ -48,7 +48,12 @@ public class AmountValidationField extends ValidationField { CryptoCoinBalance balance = CrystalDatabase.getAppDatabase(amountField.getContext()).cryptoCoinBalanceDao().getBalanceFromAccount(this.account.getId(),cryptoCurrency.getId()); - if (newAmountValue > balance.getBalance()){ + double balanceDouble = 0; + if(balance != null){ + balanceDouble = balance.getBalance(); + } + + if (newAmountValue > balanceDouble){ setMessageForValue(mixedValues, validator.getContext().getResources().getString(R.string.insufficient_amount)); setValidForValue(mixedValues, false); } else if (newAmountValue == 0){ From b05cf62daf996ea267af2896c4d99dede90c12e4 Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 01:55:58 -0500 Subject: [PATCH 06/17] -After henrry updated the file ImportSeedActivity i found some errors and i had to fix it again so it does not use 2 equeals services --- .../agorise/crystalwallet/activities/ImportSeedActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 56603fe..fa3cd44 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java @@ -358,7 +358,7 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator /* * Validate mnemonic with the server * */ - final ImportBitsharesAccountRequest request = new ImportBitsharesAccountRequest(etSeedWords.getText().toString().trim(),activity); + /*final ImportBitsharesAccountRequest request = new ImportBitsharesAccountRequest(etSeedWords.getText().toString().trim(),activity); request.setListener(new CryptoNetInfoRequestListener() { @Override public void onCarryOut() { @@ -378,7 +378,7 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator } } }); - CryptoNetInfoRequests.getInstance().addRequest(request); + CryptoNetInfoRequests.getInstance().addRequest(request);*/ } }); From a21796d2d00cc25e9f07f6e951ea6fc68026a192 Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 02:04:02 -0500 Subject: [PATCH 07/17] -The GrapheneAccount class is crasing, now it is fixed --- .../crystalwallet/models/GrapheneAccount.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/models/GrapheneAccount.java b/app/src/main/java/cy/agorise/crystalwallet/models/GrapheneAccount.java index dfb4cb0..fd3e2c7 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/models/GrapheneAccount.java +++ b/app/src/main/java/cy/agorise/crystalwallet/models/GrapheneAccount.java @@ -31,9 +31,16 @@ public class GrapheneAccount extends CryptoNetAccount { } public void loadInfo(GrapheneAccountInfo info){ - this.name = info.getName(); - this.accountId = info.getAccountId(); - this.upgradedToLtm = info.getUpgradedToLtm(); + if(info != null){ + this.name = info.getName(); + this.accountId = info.getAccountId(); + this.upgradedToLtm = info.getUpgradedToLtm(); + } + else{ + this.name = ""; + this.accountId = "-1"; + this.upgradedToLtm = false; + } } public String getName() { From ba96d999ff85ff4bf098d55274785a1bb8c62aff Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 02:13:11 -0500 Subject: [PATCH 08/17] Add listener to the class PatternRequestActivity to reuse the on success or fail password event --- .../activities/PatternRequestActivity.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java index 56ec8b1..41b7b9a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java @@ -39,6 +39,11 @@ public class PatternRequestActivity extends AppCompatActivity { @BindView(R.id.txtBadtry) TextView txtBadtry; + /* + * External listener for success or fail + * */ + private OnResponse onResponse; + /* * Contains the bad tries * */ @@ -100,11 +105,24 @@ public class PatternRequestActivity extends AppCompatActivity { if (CrystalSecurityMonitor.getInstance(null).is2ndFactorSet()) { //CrystalSecurityMonitor.getInstance(null).call2ndFactor(thisActivity); thisActivity.finish(); + + if(onResponse != null){ + onResponse.onSuccess(); + } + } else { thisActivity.finish(); + + if(onResponse != null){ + onResponse.onSuccess(); + } } } else { incorrect(); + + if(onResponse != null){ + onResponse.onFailed(); + } } } @@ -122,6 +140,10 @@ public class PatternRequestActivity extends AppCompatActivity { }); } + public void setOnResponse(OnResponse onResponse) { + this.onResponse = onResponse; + } + private void incorrect(){ /* @@ -224,6 +246,14 @@ public class PatternRequestActivity extends AppCompatActivity { return patternString; } + + /* + * Listener events for success and fail + * */ + public interface OnResponse{ + void onSuccess(); + void onFailed(); + } } From 753a4a5943a8e91417f26799e92f88e0d706c6fc Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 02:16:38 -0500 Subject: [PATCH 09/17] Fix to this commmit: Add listener to the class PatternRequestActivity to reuse the on success or fail password event --- .../crystalwallet/activities/PatternRequestActivity.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java index 41b7b9a..09e4bb8 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java @@ -42,7 +42,7 @@ public class PatternRequestActivity extends AppCompatActivity { /* * External listener for success or fail * */ - private OnResponse onResponse; + private static OnResponse onResponse; /* * Contains the bad tries @@ -108,6 +108,7 @@ public class PatternRequestActivity extends AppCompatActivity { if(onResponse != null){ onResponse.onSuccess(); + onResponse = null; } } else { @@ -115,6 +116,7 @@ public class PatternRequestActivity extends AppCompatActivity { if(onResponse != null){ onResponse.onSuccess(); + onResponse = null; } } } else { @@ -122,6 +124,7 @@ public class PatternRequestActivity extends AppCompatActivity { if(onResponse != null){ onResponse.onFailed(); + onResponse = null; } } } @@ -140,8 +143,8 @@ public class PatternRequestActivity extends AppCompatActivity { }); } - public void setOnResponse(OnResponse onResponse) { - this.onResponse = onResponse; + public static void setOnResponse(OnResponse onResponse) { + onResponse = onResponse; } private void incorrect(){ From 0bb428a658f0680d04052fb7eff0cb07aa30bbd3 Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 02:22:43 -0500 Subject: [PATCH 10/17] 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) { From 71c26c0ddfd0dd704bb6f72db2cf633080cb321a Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 02:24:15 -0500 Subject: [PATCH 11/17] -Add listener to the class PatternRequestActivity to reuse the on success or fail password event -Add listener to the class PinRequestActivity to reuse the on success or fail password event --- .../application/CrystalSecurityMonitor.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java index e027107..0d2da76 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java @@ -16,6 +16,8 @@ import java.util.List; import cy.agorise.crystalwallet.activities.PatternRequestActivity; import cy.agorise.crystalwallet.activities.PinRequestActivity; import cy.agorise.crystalwallet.activities.PocketRequestActivity; +import cy.agorise.crystalwallet.fragments.PatternSecurityFragment; +import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.notifiers.CrystalWalletNotifier; import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; @@ -129,7 +131,7 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall public void onActivityStarted(Activity activity) { if (numStarted == 0) { if (!actualSecurity().equals("")){ - callPasswordRequest(activity); + callPasswordRequest(activity,null); } } numStarted++; @@ -140,17 +142,33 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall numStarted--; if (numStarted == 0) { if (!actualSecurity().equals("")){ - callPasswordRequest(activity); + callPasswordRequest(activity,null); } } } - public void callPasswordRequest(Activity activity){ + public void callPasswordRequest(Activity activity, final OnResponse onResponsePattern){ if ((!activity.getIntent().hasExtra("ACTIVITY_TYPE")) || (!activity.getIntent().getStringExtra("ACTIVITY_TYPE").equals("PASSWORD_REQUEST"))) { Intent intent = null; if ((this.passwordEncrypted != null) && (!this.passwordEncrypted.equals(""))) { intent = new Intent(activity, PinRequestActivity.class); + + /* + * Connect error and success listeners + * */ + if(onResponsePattern != null){ + PinRequestActivity.setOnResponse(onResponsePattern); + } + } else if ((this.patternEncrypted != null) && (!this.patternEncrypted.equals(""))) { + + /* + * Connect error and success listeners + * */ + if(onResponsePattern != null){ + PatternRequestActivity.setOnResponse(onResponsePattern); + } + intent = new Intent(activity, PatternRequestActivity.class); } if (intent != null) { From ae3ed3725dca64d0d5645e25d4f41c6216cdf766 Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 02:48:18 -0500 Subject: [PATCH 12/17] Security mode is only used when the user try to send assets in the send assets screen --- .../activities/PatternRequestActivity.java | 16 +--- .../activities/PinRequestActivity.java | 4 +- .../activities/SendTransactionActivity.java | 2 + .../application/CrystalSecurityMonitor.java | 9 +- .../fragments/PatternSecurityFragment.java | 20 ++++- .../fragments/SendTransactionFragment.java | 86 ++++++++----------- 6 files changed, 68 insertions(+), 69 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java index 09e4bb8..3612ff8 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java @@ -25,6 +25,7 @@ import butterknife.ButterKnife; import butterknife.OnTextChanged; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; +import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.util.PasswordManager; import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; @@ -72,6 +73,8 @@ public class PatternRequestActivity extends AppCompatActivity { setContentView(R.layout.activity_pattern_request); ButterKnife.bind(this); + //onResponse = null; + GeneralSettingListViewModel generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class); LiveData> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList(); @@ -108,7 +111,6 @@ public class PatternRequestActivity extends AppCompatActivity { if(onResponse != null){ onResponse.onSuccess(); - onResponse = null; } } else { @@ -116,7 +118,6 @@ public class PatternRequestActivity extends AppCompatActivity { if(onResponse != null){ onResponse.onSuccess(); - onResponse = null; } } } else { @@ -124,7 +125,6 @@ public class PatternRequestActivity extends AppCompatActivity { if(onResponse != null){ onResponse.onFailed(); - onResponse = null; } } } @@ -144,7 +144,7 @@ public class PatternRequestActivity extends AppCompatActivity { } public static void setOnResponse(OnResponse onResponse) { - onResponse = onResponse; + PatternRequestActivity.onResponse = onResponse; } private void incorrect(){ @@ -249,14 +249,6 @@ public class PatternRequestActivity extends AppCompatActivity { return patternString; } - - /* - * Listener events for success and fail - * */ - public interface OnResponse{ - void onSuccess(); - void onFailed(); - } } 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 a725c46..2f93f18 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java @@ -77,6 +77,8 @@ public class PinRequestActivity extends AppCompatActivity { setContentView(R.layout.activity_pin_request); ButterKnife.bind(this); + //onResponse = null; + /* * Initially the button is disabled till the user type a valid PIN * */ @@ -113,7 +115,6 @@ public class PinRequestActivity extends AppCompatActivity { if(onResponse != null){ onResponse.onSuccess(); - onResponse = null; } } else { @@ -121,7 +122,6 @@ public class PinRequestActivity extends AppCompatActivity { if(onResponse != null){ onResponse.onFailed(); - onResponse = null; } } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/SendTransactionActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/SendTransactionActivity.java index adfa17c..26adfa1 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/SendTransactionActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/SendTransactionActivity.java @@ -1,5 +1,6 @@ package cy.agorise.crystalwallet.activities; +import android.app.Activity; import android.arch.lifecycle.LiveData; import android.arch.lifecycle.Observer; import android.os.Bundle; @@ -11,6 +12,7 @@ import android.widget.Button; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; +import android.widget.Toast; import com.jaredrummler.materialspinner.MaterialSpinner; diff --git a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java index 0d2da76..3ed54da 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java @@ -151,8 +151,11 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall if ((!activity.getIntent().hasExtra("ACTIVITY_TYPE")) || (!activity.getIntent().getStringExtra("ACTIVITY_TYPE").equals("PASSWORD_REQUEST"))) { Intent intent = null; if ((this.passwordEncrypted != null) && (!this.passwordEncrypted.equals(""))) { + intent = new Intent(activity, PinRequestActivity.class); + PinRequestActivity.setOnResponse(null); + /* * Connect error and success listeners * */ @@ -162,14 +165,16 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall } else if ((this.patternEncrypted != null) && (!this.patternEncrypted.equals(""))) { + intent = new Intent(activity, PatternRequestActivity.class); + + PatternRequestActivity.setOnResponse(null); + /* * Connect error and success listeners * */ if(onResponsePattern != null){ PatternRequestActivity.setOnResponse(onResponsePattern); } - - intent = new Intent(activity, PatternRequestActivity.class); } if (intent != null) { intent.putExtra("ACTIVITY_TYPE", "PASSWORD_REQUEST"); diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java index 63e15d7..c23306f 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java @@ -1,5 +1,6 @@ package cy.agorise.crystalwallet.fragments; +import android.app.Activity; import android.arch.lifecycle.LiveData; import android.arch.lifecycle.Observer; import android.arch.lifecycle.ViewModelProviders; @@ -8,6 +9,7 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.text.Editable; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -27,7 +29,10 @@ import butterknife.ButterKnife; import butterknife.OnTextChanged; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; +import cy.agorise.crystalwallet.dialogs.material.CrystalDialog; +import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.models.GeneralSetting; +import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests; import cy.agorise.crystalwallet.util.ChildViewPager; import cy.agorise.crystalwallet.util.PasswordManager; import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; @@ -199,7 +204,20 @@ public class PatternSecurityFragment extends Fragment { public void savePattern(String pattern){ String patternEncripted = PasswordManager.encriptPassword(pattern); CrystalSecurityMonitor.getInstance(null).setPatternEncrypted(patternEncripted); - //CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity()); + /*CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity(), new OnResponse() { + @Override + public void onSuccess() { + + Log.i("onSuccess","onSuccess"); + Toast.makeText(getActivity(), "onSuccess", Toast.LENGTH_LONG).show(); + } + + @Override + public void onFailed() { + Log.i("onFailed","onFailed"); + Toast.makeText(getActivity(), "onFailed", Toast.LENGTH_LONG).show(); + } + });*/ /* * Show success diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java index eaa4445..45b5185 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java @@ -58,8 +58,10 @@ import butterknife.OnClick; import butterknife.OnItemSelected; import butterknife.OnTextChanged; import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; import cy.agorise.crystalwallet.dialogs.material.CrystalDialog; import cy.agorise.crystalwallet.dialogs.material.ToastIt; +import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests; import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest; @@ -180,53 +182,10 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat View view = inflater.inflate(R.layout.send_transaction, null); ButterKnife.bind(this, view); - - /* - * Detet scroll changes - * */ - /*scrollMain.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { - @Override - public void onScrollChanged() { - - View view = scrollMain.getChildAt(scrollMain.getChildCount() - 1); - - int diff = (view.getBottom() - (scrollMain.getHeight() + scrollMain.getScrollY())); - - float traslationY = btnSend.getTranslationY(); - - if(diff<=266 && diff>128){ - //btnSend.setTranslationY(0); - //viewSend.setTranslationY(0); - - btnSend.animate().y(880); - viewSend.animate().y(800); - } - else if(diff<=128 && diff>10){ - //btnSend.setTranslationY(-130); - //viewSend.setTranslationY(-130); - - btnSend.animate().y(880); - viewSend.animate().y(800); - } - else if(diff<=10 && diff>0){ - //btnSend.setTranslationY(-170); - //viewSend.setTranslationY(-170); - - btnSend.animate().y(680); - viewSend.animate().y(600); - } - else if(diff==0){ - //btnSend.setTranslationY(-190); - //viewSend.setTranslationY(-190); - - btnSend.animate().y(680); - viewSend.animate().y(600); - } - } - });*/ - this.cryptoNetAccountId = getArguments().getLong("CRYPTO_NET_ACCOUNT_ID",-1); + final Activity activity = getActivity(); + /* * Add style to the spinner android * */ @@ -253,6 +212,15 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat } List cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds); + /* + * Test + * */ + /*CryptoCurrency crypto1 = new CryptoCurrency(); + crypto1.setId(1); + crypto1.setName("BITCOIN"); + crypto1.setPrecision(1); + cryptoCurrencyList.add(crypto1);*/ + assetAdapter = new CryptoCurrencyAdapter(getContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList); spAsset.setAdapter(assetAdapter); } @@ -653,14 +621,28 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat }); /* - * Show loading dialog - * */ - crystalDialog = new CrystalDialog((Activity) getContext()); - crystalDialog.setText("Sending"); - crystalDialog.progress(); - crystalDialog.show(); + * If exists mode scurity show it and valide events in case of success or fail + * */ + CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity(), new OnResponse() { + @Override + public void onSuccess() { - CryptoNetInfoRequests.getInstance().addRequest(sendRequest); + /* + * Show loading dialog + * */ + crystalDialog = new CrystalDialog((Activity) getContext()); + crystalDialog.setText("Sending"); + crystalDialog.progress(); + crystalDialog.show(); + + CryptoNetInfoRequests.getInstance().addRequest(sendRequest); + } + + @Override + public void onFailed() { + + } + }); } } From c4ac6b4a29fc198cd3bddffbabbc4a91ff7cc540 Mon Sep 17 00:00:00 2001 From: hvarona Date: Thu, 25 Oct 2018 08:09:54 -0400 Subject: [PATCH 13/17] Fixed error feedback on import request --- .../apigenerator/GrapheneApiGenerator.java | 9 ++- .../manager/BitsharesAccountManager.java | 62 ++++++++++--------- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java index b654b48..d4b0cb4 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java @@ -129,8 +129,13 @@ public abstract class GrapheneApiGenerator { List accounts = resp.get(0); if(accounts.size() > 0){ for(UserAccount account : accounts) { - request.getListener().success(account,request.getId());}}} - request.getListener().fail(request.getId()); + request.getListener().success(account, request.getId()); + break; + } + } + }else{ + request.getListener().fail(request.getId()); + } } @Override diff --git a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java index 4baf5d9..7f08e20 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java @@ -276,44 +276,46 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI @Override public void fail(int idPetition) { - //importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.PETITION_FAILED); - } - }); + BIP39 bip39 = new BIP39(-1, importRequest.getMnemonic()); + ApiRequest getAccountNamesBP39 = new ApiRequest(0, new ApiRequestListener() { + @Override + public void success(Object answer, int idPetition) { + if(answer != null && importRequest.getStatus().equals(ImportBitsharesAccountRequest.StatusCode.NOT_STARTED)) { + UserAccount userAccount = (UserAccount) answer; + importRequest.setSeedType(SeedType.BIP39); + importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.SUCCEEDED); - ApiRequest getAccountNamesBP39 = new ApiRequest(0, new ApiRequestListener() { - @Override - public void success(Object answer, int idPetition) { - if(answer != null && importRequest.getStatus().equals(ImportBitsharesAccountRequest.StatusCode.NOT_STARTED)) { - UserAccount userAccount = (UserAccount) answer; - importRequest.setSeedType(SeedType.BIP39); - importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.SUCCEEDED); - - AccountSeed seed = new AccountSeed(); - seed.setName(userAccount.getName()); - seed.setType(importRequest.getSeedType()); - seed.setMasterSeed(importRequest.getMnemonic()); - long idSeed = accountSeedDao.insertAccountSeed(seed); - if (idSeed >= 0) { - GrapheneAccount account = new GrapheneAccount(); - account.setCryptoNet(CryptoNet.BITSHARES); - account.setAccountIndex(0); - account.setSeedId(idSeed); - account.setAccountId(userAccount.getObjectId()); - importAccountFromSeed(account, importRequest.getContext()); + AccountSeed seed = new AccountSeed(); + seed.setName(userAccount.getName()); + seed.setType(importRequest.getSeedType()); + seed.setMasterSeed(importRequest.getMnemonic()); + long idSeed = accountSeedDao.insertAccountSeed(seed); + if (idSeed >= 0) { + GrapheneAccount account = new GrapheneAccount(); + account.setCryptoNet(CryptoNet.BITSHARES); + account.setAccountIndex(0); + account.setSeedId(idSeed); + account.setAccountId(userAccount.getObjectId()); + importAccountFromSeed(account, importRequest.getContext()); + } + } } - } - } - @Override - public void fail(int idPetition) { - //importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.PETITION_FAILED); + @Override + public void fail(int idPetition) { + importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.PETITION_FAILED); + } + }); + GrapheneApiGenerator.getAccountByOwnerOrActiveAddress(new Address(ECKey.fromPublicOnly(bip39.getBitsharesActiveKey(0).getPubKey())),getAccountNamesBP39); } }); + + BrainKey bk = new BrainKey(importRequest.getMnemonic(), 0); - BIP39 bip39 = new BIP39(-1, importRequest.getMnemonic()); + GrapheneApiGenerator.getAccountByOwnerOrActiveAddress(bk.getPublicAddress("BTS"),getAccountNamesBK); - GrapheneApiGenerator.getAccountByOwnerOrActiveAddress(new Address(ECKey.fromPublicOnly(bip39.getBitsharesActiveKey(0).getPubKey())),getAccountNamesBP39); + } From b426076eea2f906c7d6d5fde795e2003bfb4b58c Mon Sep 17 00:00:00 2001 From: hvarona Date: Thu, 25 Oct 2018 08:30:32 -0400 Subject: [PATCH 14/17] commented the OnResponse interface Fixed error feedback on import request --- .../activities/PatternRequestActivity.java | 20 +++++++++---------- .../activities/PinRequestActivity.java | 16 +++++++-------- .../apigenerator/GrapheneApiGenerator.java | 19 ++++++++++++------ .../application/CrystalSecurityMonitor.java | 20 +++++++++---------- .../fragments/PatternSecurityFragment.java | 2 +- .../fragments/SendTransactionFragment.java | 8 ++++---- .../manager/BitsharesAccountManager.java | 2 +- 7 files changed, 47 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java index 3612ff8..ef54cd1 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java @@ -25,7 +25,7 @@ import butterknife.ButterKnife; import butterknife.OnTextChanged; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; -import cy.agorise.crystalwallet.interfaces.OnResponse; +//import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.util.PasswordManager; import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; @@ -43,7 +43,7 @@ public class PatternRequestActivity extends AppCompatActivity { /* * External listener for success or fail * */ - private static OnResponse onResponse; + //private static OnResponse onResponse; /* * Contains the bad tries @@ -109,23 +109,23 @@ public class PatternRequestActivity extends AppCompatActivity { //CrystalSecurityMonitor.getInstance(null).call2ndFactor(thisActivity); thisActivity.finish(); - if(onResponse != null){ + /*if(onResponse != null){ onResponse.onSuccess(); - } + }*/ } else { thisActivity.finish(); - if(onResponse != null){ + /*if(onResponse != null){ onResponse.onSuccess(); - } + }*/ } } else { incorrect(); - if(onResponse != null){ + /*if(onResponse != null){ onResponse.onFailed(); - } + }*/ } } @@ -143,9 +143,9 @@ public class PatternRequestActivity extends AppCompatActivity { }); } - public static void setOnResponse(OnResponse onResponse) { + /*public static void setOnResponse(OnResponse onResponse) { PatternRequestActivity.onResponse = onResponse; - } + }*/ private void incorrect(){ 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 2f93f18..0b2d3aa 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java @@ -31,7 +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.interfaces.OnResponse; import cy.agorise.crystalwallet.models.AccountSeed; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.util.PasswordManager; @@ -59,7 +59,7 @@ public class PinRequestActivity extends AppCompatActivity { /* * External listener for success or fail * */ - private static OnResponse onResponse; + //private static OnResponse onResponse; @@ -113,16 +113,16 @@ public class PinRequestActivity extends AppCompatActivity { if (CrystalSecurityMonitor.getInstance(null).is2ndFactorSet()) { CrystalSecurityMonitor.getInstance(null).call2ndFactor(this); - if(onResponse != null){ + /*if(onResponse != null){ onResponse.onSuccess(); - } + }*/ } else { this.finish(); - if(onResponse != null){ + /*if(onResponse != null){ onResponse.onFailed(); - } + }*/ } } else{ @@ -221,9 +221,9 @@ public class PinRequestActivity extends AppCompatActivity { } - public static void setOnResponse(OnResponse onResponse) { + /*public static void setOnResponse(OnResponse onResponse) { PinRequestActivity.onResponse = onResponse; - } + }*/ @OnTextChanged(value = R.id.etPassword, diff --git a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java index d4b0cb4..d2451f4 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java @@ -124,16 +124,23 @@ public abstract class GrapheneApiGenerator { new WitnessResponseListener() { @Override public void onSuccess(WitnessResponse response) { - final List> resp = (List>) response.result; - if(resp.size() > 0){ - List accounts = resp.get(0); - if(accounts.size() > 0){ - for(UserAccount account : accounts) { + try { + final List> resp = (List>) response.result; + if (resp.size() > 0) { + List accounts = resp.get(0); + if (accounts.size() > 0) { + for (UserAccount account : accounts) { request.getListener().success(account, request.getId()); break; + } + }else{ + request.getListener().fail(request.getId()); } + } else { + request.getListener().fail(request.getId()); } - }else{ + }catch(Exception e){ + e.printStackTrace(); request.getListener().fail(request.getId()); } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java index 3ed54da..b7235aa 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java @@ -17,7 +17,7 @@ import cy.agorise.crystalwallet.activities.PatternRequestActivity; import cy.agorise.crystalwallet.activities.PinRequestActivity; import cy.agorise.crystalwallet.activities.PocketRequestActivity; import cy.agorise.crystalwallet.fragments.PatternSecurityFragment; -import cy.agorise.crystalwallet.interfaces.OnResponse; +//import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.notifiers.CrystalWalletNotifier; import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; @@ -131,7 +131,7 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall public void onActivityStarted(Activity activity) { if (numStarted == 0) { if (!actualSecurity().equals("")){ - callPasswordRequest(activity,null); + callPasswordRequest(activity); } } numStarted++; @@ -142,39 +142,39 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall numStarted--; if (numStarted == 0) { if (!actualSecurity().equals("")){ - callPasswordRequest(activity,null); + callPasswordRequest(activity); } } } - public void callPasswordRequest(Activity activity, final OnResponse onResponsePattern){ + public void callPasswordRequest(Activity activity){ if ((!activity.getIntent().hasExtra("ACTIVITY_TYPE")) || (!activity.getIntent().getStringExtra("ACTIVITY_TYPE").equals("PASSWORD_REQUEST"))) { Intent intent = null; if ((this.passwordEncrypted != null) && (!this.passwordEncrypted.equals(""))) { intent = new Intent(activity, PinRequestActivity.class); - PinRequestActivity.setOnResponse(null); + //PinRequestActivity.setOnResponse(null); /* * Connect error and success listeners * */ - if(onResponsePattern != null){ + /*if(onResponsePattern != null){ PinRequestActivity.setOnResponse(onResponsePattern); - } + }*/ } else if ((this.patternEncrypted != null) && (!this.patternEncrypted.equals(""))) { intent = new Intent(activity, PatternRequestActivity.class); - PatternRequestActivity.setOnResponse(null); + //PatternRequestActivity.setOnResponse(null); /* * Connect error and success listeners * */ - if(onResponsePattern != null){ + /*if(onResponsePattern != null){ PatternRequestActivity.setOnResponse(onResponsePattern); - } + }*/ } if (intent != null) { intent.putExtra("ACTIVITY_TYPE", "PASSWORD_REQUEST"); diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java index c23306f..66732c1 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java @@ -30,7 +30,7 @@ import butterknife.OnTextChanged; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; import cy.agorise.crystalwallet.dialogs.material.CrystalDialog; -import cy.agorise.crystalwallet.interfaces.OnResponse; +//import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests; import cy.agorise.crystalwallet.util.ChildViewPager; diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java index 45b5185..bc97df5 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java @@ -61,7 +61,7 @@ import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; import cy.agorise.crystalwallet.dialogs.material.CrystalDialog; import cy.agorise.crystalwallet.dialogs.material.ToastIt; -import cy.agorise.crystalwallet.interfaces.OnResponse; +//import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests; import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest; @@ -623,14 +623,14 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat /* * If exists mode scurity show it and valide events in case of success or fail * */ - CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity(), new OnResponse() { + /*CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity(), new OnResponse() { @Override public void onSuccess() { /* * Show loading dialog * */ - crystalDialog = new CrystalDialog((Activity) getContext()); +/* crystalDialog = new CrystalDialog((Activity) getContext()); crystalDialog.setText("Sending"); crystalDialog.progress(); crystalDialog.show(); @@ -642,7 +642,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat public void onFailed() { } - }); + });*/ } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java index 7f08e20..32ae22e 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java +++ b/app/src/main/java/cy/agorise/crystalwallet/manager/BitsharesAccountManager.java @@ -303,7 +303,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI @Override public void fail(int idPetition) { - importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.PETITION_FAILED); + importRequest.setStatus(ImportBitsharesAccountRequest.StatusCode.BAD_SEED); } }); GrapheneApiGenerator.getAccountByOwnerOrActiveAddress(new Address(ECKey.fromPublicOnly(bip39.getBitsharesActiveKey(0).getPubKey())),getAccountNamesBP39); From b5bc9e88c727cae9d7f1bdcdb3b2c0ed2102fb50 Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 09:54:42 -0500 Subject: [PATCH 15/17] In the Receive assets screen change the layout to relative to get more controle over position --- .../main/res/layout/receive_transaction.xml | 85 ++++++++----------- 1 file changed, 36 insertions(+), 49 deletions(-) diff --git a/app/src/main/res/layout/receive_transaction.xml b/app/src/main/res/layout/receive_transaction.xml index fba49b2..38ee0ff 100644 --- a/app/src/main/res/layout/receive_transaction.xml +++ b/app/src/main/res/layout/receive_transaction.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - @@ -18,11 +18,10 @@ android:layout_marginEnd="0dp" android:layout_marginStart="0dp" android:layout_marginTop="0dp" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + android:layout_alignParentTop="true"/> + android:layout_alignParentTop="true" /> + android:layout_marginTop="30dp" + android:src="@drawable/avatar_placeholder" /> + android:layout_width="200dp" + android:layout_height="50dp" + android:layout_marginTop="30dp" + android:layout_below="@+id/txtTittle" + android:layout_alignParentRight="true" + android:layout_marginRight="20dp"/> + android:layout_below="@+id/gravatar" + android:layout_marginTop="10dp"/> + android:inputType="numberDecimal" + android:textSize="20sp" /> + android:layout_below="@+id/etAmount"/> + android:layout_alignParentRight="true" + android:layout_marginRight="20dp"/> + android:background="@color/gray" /> + android:layout_below="@+id/spAsset"/> + android:layout_below="@+id/tvAmountError" + android:layout_centerHorizontal="true"/> + android:layout_below="@+id/ivQrCode" /> + android:layout_below="@+id/ivQrCode" + android:layout_alignParentRight="true"/> - + \ No newline at end of file From 10cc88c8d3c606b37dab4cfa2b08dce0d0a98ab0 Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 10:03:45 -0500 Subject: [PATCH 16/17] Fixes from henrry code --- .../activities/PatternRequestActivity.java | 7 +- .../activities/PinRequestActivity.java | 52 ++++++------ .../application/CrystalSecurityMonitor.java | 29 +++---- .../fragments/PatternSecurityFragment.java | 32 ++++---- .../fragments/ReceiveTransactionFragment.java | 10 +++ .../fragments/SendTransactionFragment.java | 80 +++++++++---------- 6 files changed, 108 insertions(+), 102 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java index ef54cd1..f9378bf 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/PatternRequestActivity.java @@ -26,6 +26,7 @@ import butterknife.OnTextChanged; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; //import cy.agorise.crystalwallet.interfaces.OnResponse; +import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.util.PasswordManager; import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; @@ -43,7 +44,7 @@ public class PatternRequestActivity extends AppCompatActivity { /* * External listener for success or fail * */ - //private static OnResponse onResponse; + private static OnResponse onResponse; /* * Contains the bad tries @@ -143,9 +144,9 @@ public class PatternRequestActivity extends AppCompatActivity { }); } - /*public static void setOnResponse(OnResponse onResponse) { + public static void setOnResponse(OnResponse onResponse) { PatternRequestActivity.onResponse = onResponse; - }*/ + } private void incorrect(){ 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 0b2d3aa..1f6d546 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/PinRequestActivity.java @@ -31,7 +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.interfaces.OnResponse; import cy.agorise.crystalwallet.models.AccountSeed; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.util.PasswordManager; @@ -47,19 +47,19 @@ public class PinRequestActivity extends AppCompatActivity { TextView txtBadtry; /* - * Contains the bad tries - * */ + * Contains the bad tries + * */ private int tries = 0; /* - * Seconds counter - * */ + * Seconds counter + * */ private int seconds = 15; /* * External listener for success or fail * */ - //private static OnResponse onResponse; + private static OnResponse onResponse; @@ -80,8 +80,8 @@ public class PinRequestActivity extends AppCompatActivity { //onResponse = null; /* - * Initially the button is disabled till the user type a valid PIN - * */ + * Initially the button is disabled till the user type a valid PIN + * */ btnOK.setEnabled(false); GeneralSettingListViewModel generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class); @@ -113,23 +113,23 @@ public class PinRequestActivity extends AppCompatActivity { if (CrystalSecurityMonitor.getInstance(null).is2ndFactorSet()) { CrystalSecurityMonitor.getInstance(null).call2ndFactor(this); - /*if(onResponse != null){ + if(onResponse != null){ onResponse.onSuccess(); - }*/ + } } else { this.finish(); - /*if(onResponse != null){ + if(onResponse != null){ onResponse.onFailed(); - }*/ + } } } else{ /* - * One more bad try - * */ + * One more bad try + * */ ++tries; final Activity activity = this; @@ -137,8 +137,8 @@ public class PinRequestActivity extends AppCompatActivity { etPassword.setTextColor(Color.RED); /* - * User can not go more up to 5 bad tries - * */ + * User can not go more up to 5 bad tries + * */ if(tries==4){ tries = 0; @@ -193,8 +193,8 @@ public class PinRequestActivity extends AppCompatActivity { } /* - * Set in red the rext and reset the password after a period of time - * */ + * Set in red the rext and reset the password after a period of time + * */ final Timer t = new Timer(); //Set the schedule function and rate t.scheduleAtFixedRate(new TimerTask() { @@ -213,17 +213,17 @@ public class PinRequestActivity extends AppCompatActivity { } }, - //Set how long before to start calling the TimerTask (in milliseconds) + //Set how long before to start calling the TimerTask (in milliseconds) 500, - //Set the amount of time between each execution (in milliseconds) + //Set the amount of time between each execution (in milliseconds) 500); } } - /*public static void setOnResponse(OnResponse onResponse) { + public static void setOnResponse(OnResponse onResponse) { PinRequestActivity.onResponse = onResponse; - }*/ + } @OnTextChanged(value = R.id.etPassword, @@ -231,8 +231,8 @@ public class PinRequestActivity extends AppCompatActivity { void afterPasswordChanged(Editable editable) { /* - * If it is valid length enable button - * */ + * If it is valid length enable button + * */ if(etPassword.getText().length()>=6){ btnOK.setEnabled(true); } @@ -240,6 +240,4 @@ public class PinRequestActivity extends AppCompatActivity { btnOK.setEnabled(false); } } -} - - +} \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java index b7235aa..9f6297b 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java @@ -17,7 +17,7 @@ import cy.agorise.crystalwallet.activities.PatternRequestActivity; import cy.agorise.crystalwallet.activities.PinRequestActivity; import cy.agorise.crystalwallet.activities.PocketRequestActivity; import cy.agorise.crystalwallet.fragments.PatternSecurityFragment; -//import cy.agorise.crystalwallet.interfaces.OnResponse; +import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.notifiers.CrystalWalletNotifier; import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; @@ -131,7 +131,7 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall public void onActivityStarted(Activity activity) { if (numStarted == 0) { if (!actualSecurity().equals("")){ - callPasswordRequest(activity); + callPasswordRequest(activity,null); } } numStarted++; @@ -142,39 +142,39 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall numStarted--; if (numStarted == 0) { if (!actualSecurity().equals("")){ - callPasswordRequest(activity); + callPasswordRequest(activity,null); } } } - public void callPasswordRequest(Activity activity){ + public void callPasswordRequest(Activity activity, final OnResponse onResponsePattern){ if ((!activity.getIntent().hasExtra("ACTIVITY_TYPE")) || (!activity.getIntent().getStringExtra("ACTIVITY_TYPE").equals("PASSWORD_REQUEST"))) { Intent intent = null; if ((this.passwordEncrypted != null) && (!this.passwordEncrypted.equals(""))) { intent = new Intent(activity, PinRequestActivity.class); - //PinRequestActivity.setOnResponse(null); + PinRequestActivity.setOnResponse(null); /* - * Connect error and success listeners - * */ - /*if(onResponsePattern != null){ + * Connect error and success listeners + * */ + if(onResponsePattern != null){ PinRequestActivity.setOnResponse(onResponsePattern); - }*/ + } } else if ((this.patternEncrypted != null) && (!this.patternEncrypted.equals(""))) { intent = new Intent(activity, PatternRequestActivity.class); - //PatternRequestActivity.setOnResponse(null); + PatternRequestActivity.setOnResponse(null); /* * Connect error and success listeners * */ - /*if(onResponsePattern != null){ + if(onResponsePattern != null){ PatternRequestActivity.setOnResponse(onResponsePattern); - }*/ + } } if (intent != null) { intent.putExtra("ACTIVITY_TYPE", "PASSWORD_REQUEST"); @@ -220,7 +220,4 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall public void onActivityDestroyed(Activity activity) { // } - - - -} +} \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java index 66732c1..9fa4865 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java @@ -30,7 +30,7 @@ import butterknife.OnTextChanged; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; import cy.agorise.crystalwallet.dialogs.material.CrystalDialog; -//import cy.agorise.crystalwallet.interfaces.OnResponse; +import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests; import cy.agorise.crystalwallet.util.ChildViewPager; @@ -52,8 +52,8 @@ public class PatternSecurityFragment extends Fragment { TextView tvPatternText; /* - * Contains the ChildViewPager to block the viewpager when the user is using the pattern control - * */ + * Contains the ChildViewPager to block the viewpager when the user is using the pattern control + * */ private ChildViewPager childViewPager; private PatternLockViewListener actualPatternListener; @@ -174,8 +174,8 @@ public class PatternSecurityFragment extends Fragment { private void resetPattern(){ /* - * Show error - * */ + * Show error + * */ tvPatternText.setText(getActivity().getResources().getString(R.string.Incorrect_pattern)); tvPatternText.setTextColor(Color.RED); final Timer t = new Timer(); @@ -227,20 +227,20 @@ public class PatternSecurityFragment extends Fragment { final Timer t_ = new Timer(); t_.scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { + @Override + public void run() { - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { - t_.cancel(); - showNewPatternUI(); - } - }); - } + t_.cancel(); + showNewPatternUI(); + } + }); + } - }, + }, //Set how long before to start calling the TimerTask (in milliseconds) 1000, //Set the amount of time between each execution (in milliseconds) diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/ReceiveTransactionFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/ReceiveTransactionFragment.java index 747d89f..acc1872 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/ReceiveTransactionFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/ReceiveTransactionFragment.java @@ -152,6 +152,16 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali } List cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds); + /* + * Test + * */ + CryptoCurrency crypto1 = new CryptoCurrency(); + crypto1.setId(1); + crypto1.setName("BITCOIN"); + crypto1.setPrecision(1); + cryptoCurrencyList.add(crypto1); + + CryptoCurrencyAdapter assetAdapter = new CryptoCurrencyAdapter(getContext(), android.R.layout.simple_spinner_item, cryptoCurrencyList); spAsset.setAdapter(assetAdapter); } diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java index bc97df5..767c87f 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java @@ -61,7 +61,7 @@ import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; import cy.agorise.crystalwallet.dialogs.material.CrystalDialog; import cy.agorise.crystalwallet.dialogs.material.ToastIt; -//import cy.agorise.crystalwallet.interfaces.OnResponse; +import cy.agorise.crystalwallet.interfaces.OnResponse; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener; import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests; import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest; @@ -134,8 +134,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat View viewCamera; /* - * Flag to control when the camera is visible and when is hide - * */ + * Flag to control when the camera is visible and when is hide + * */ private boolean cameraVisible = true; Button btnScanQrCode; @@ -196,9 +196,9 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat this.cryptoNetAccount = db.cryptoNetAccountDao().getById(this.cryptoNetAccountId); /* - * this is only for graphene accounts. - * - **/ + * this is only for graphene accounts. + * + **/ this.grapheneAccount = new GrapheneAccount(this.cryptoNetAccount); this.grapheneAccount.loadInfo(db.grapheneAccountInfoDao().getByAccountId(this.cryptoNetAccountId)); @@ -213,8 +213,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat List cryptoCurrencyList = db.cryptoCurrencyDao().getByIds(assetIds); /* - * Test - * */ + * Test + * */ /*CryptoCurrency crypto1 = new CryptoCurrency(); crypto1.setId(1); crypto1.setName("BITCOIN"); @@ -234,8 +234,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat CryptoNetAccountAdapter fromSpinnerAdapter = new CryptoNetAccountAdapter(this.getContext(), android.R.layout.simple_spinner_item, cryptoNetAccounts); /* - * If only one account block the control - * */ + * If only one account block the control + * */ if(cryptoNetAccounts.size()==1){ spFrom.setEnabled(false); } @@ -244,8 +244,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat //spFrom.setSelection(0); /* - * Custom material spinner implementation - * */ + * Custom material spinner implementation + * */ spFrom.setItems(cryptoNetAccounts); //spFrom.setSelectedIndex(0); spFrom.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener() { @@ -275,8 +275,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat // Your Permission granted already .Do next code /* - * Init the camera - * */ + * Init the camera + * */ try { beginScanQrCode(); }catch(Exception e){ @@ -312,8 +312,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat Toast.makeText(getActivity(), getActivity().getString(R.string.permission_denied_camera), Toast.LENGTH_LONG).show(); /* - * Disable the button of the camera visibility - * */ + * Disable the button of the camera visibility + * */ disableVisibilityCamera(); } else { @@ -458,8 +458,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat mScannerView.stopCamera(); /* - * Hide the camera or show it - * */ + * Hide the camera or show it + * */ if(cameraVisible){ hideCamera(); } @@ -490,31 +490,31 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat cameraVisible = true; /* - * Star the camera again - * */ + * Star the camera again + * */ beginScanQrCode(); } /* - * Hide the camera and show the black background - * */ + * Hide the camera and show the black background + * */ private void hideCamera(){ /* - * Change visibilities of views - * */ + * Change visibilities of views + * */ viewCamera.setVisibility(View.VISIBLE); mScannerView.setVisibility(View.INVISIBLE); /* - * Change icon - * */ + * Change icon + * */ btnCloseCamera.setImageDrawable(getResources().getDrawable(R.drawable.ok)); /* - * Reset variable - * */ + * Reset variable + * */ cameraVisible = false; } @@ -595,12 +595,12 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat Long amount = (long)Math.floor(amountFromEditText*Math.round(Math.pow(10,((CryptoCurrency)spAsset.getSelectedItem()).getPrecision()))); final ValidateBitsharesSendRequest sendRequest = new ValidateBitsharesSendRequest( - this.getContext(), - grapheneAccountSelected, - this.etTo.getText().toString(), - amount, - ((CryptoCurrency)spAsset.getSelectedItem()).getName(), - etMemo.getText().toString() + this.getContext(), + grapheneAccountSelected, + this.etTo.getText().toString(), + amount, + ((CryptoCurrency)spAsset.getSelectedItem()).getName(), + etMemo.getText().toString() ); sendRequest.setListener(new CryptoNetInfoRequestListener() { @@ -621,16 +621,16 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat }); /* - * If exists mode scurity show it and valide events in case of success or fail - * */ - /*CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity(), new OnResponse() { + * If exists mode scurity show it and valide events in case of success or fail + * */ + CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity(), new OnResponse() { @Override public void onSuccess() { /* * Show loading dialog * */ -/* crystalDialog = new CrystalDialog((Activity) getContext()); + crystalDialog = new CrystalDialog((Activity) getContext()); crystalDialog.setText("Sending"); crystalDialog.progress(); crystalDialog.show(); @@ -642,7 +642,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat public void onFailed() { } - });*/ + }); } } @@ -743,4 +743,4 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat e.printStackTrace(); } } -} +} \ No newline at end of file From 7ae875e208225bbc3d28941795c2fc7544b14452 Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 25 Oct 2018 11:01:05 -0500 Subject: [PATCH 17/17] Fixes from henrry code --- .../cy/agorise/crystalwallet/interfaces/OnResponse.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 app/src/main/java/cy/agorise/crystalwallet/interfaces/OnResponse.java diff --git a/app/src/main/java/cy/agorise/crystalwallet/interfaces/OnResponse.java b/app/src/main/java/cy/agorise/crystalwallet/interfaces/OnResponse.java new file mode 100644 index 0000000..ad6cac6 --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/interfaces/OnResponse.java @@ -0,0 +1,6 @@ +package cy.agorise.crystalwallet.interfaces; + +public interface OnResponse { + void onSuccess(); + void onFailed(); +}