From 2a1f2895d4e3f1f32938d5c2a8e1e0d96a18e216 Mon Sep 17 00:00:00 2001 From: dtvv Date: Wed, 5 Sep 2018 12:25:31 -0500 Subject: [PATCH 01/13] Set the loading dialog when connecting to server to progress() loading icon --- .../validationFields/BitsharesAccountNameValidation.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/customImpl/validationFields/BitsharesAccountNameValidation.kt b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/customImpl/validationFields/BitsharesAccountNameValidation.kt index 9c56bfe..9074fcc 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/customImpl/validationFields/BitsharesAccountNameValidation.kt +++ b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/customImpl/validationFields/BitsharesAccountNameValidation.kt @@ -166,7 +166,7 @@ class BitsharesAccountNameValidation : CustomValidationField, UIValidator { * */ val creatingAccountMaterialDialog = CrystalDialog(activity) creatingAccountMaterialDialog.setText(activity.resources.getString(R.string.window_create_seed_Server_validation)) - creatingAccountMaterialDialog.build() + creatingAccountMaterialDialog.progress() creatingAccountMaterialDialog.show() val request = ValidateExistBitsharesAccountRequest(newValue) From 8a6e8ce24069b5312f27b209849df0eb4acd6679 Mon Sep 17 00:00:00 2001 From: dtvv Date: Wed, 5 Sep 2018 13:20:17 -0500 Subject: [PATCH 02/13] In the create seed screen, when all the Fields are complete filled and delete one character in pin field for example, the loading connection server existing account validation was fired --- .../activities/CreateSeedActivity.kt | 67 ++++++++++++++++--- .../BitsharesAccountNameValidation.kt | 48 +++---------- 2 files changed, 69 insertions(+), 46 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt b/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt index b1b86ba..5eb9400 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/CreateSeedActivity.kt @@ -13,6 +13,7 @@ import cy.agorise.crystalwallet.R import cy.agorise.crystalwallet.dialogs.material.CrystalDialog import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests import cy.agorise.crystalwallet.requestmanagers.ValidateCreateBitsharesAccountRequest +import cy.agorise.crystalwallet.requestmanagers.ValidateExistBitsharesAccountRequest import cy.agorise.crystalwallet.viewmodels.validators.customImpl.interfaces.UIValidatorListener import cy.agorise.crystalwallet.viewmodels.validators.customImpl.validationFields.BitsharesAccountNameValidation import cy.agorise.crystalwallet.viewmodels.validators.customImpl.validationFields.BitsharesAccountNameValidation.OnAccountExist @@ -62,16 +63,12 @@ class CreateSeedActivity : CustomActivity() { runOnUiThread { val customTextInputEditText = customValidationField.currentView as CustomTextInputEditText customTextInputEditText.error = null + customTextInputEditText.fieldValidatorModel.setValid() } } catch (e: Exception) { e.printStackTrace() } - - /* - * Validate if can continue - * */ - validateFieldsToContinue() } override fun onValidationFailed(customValidationField: CustomValidationField) { @@ -82,6 +79,7 @@ class CreateSeedActivity : CustomActivity() { runOnUiThread { val customTextInputEditText = customValidationField.currentView as CustomTextInputEditText customTextInputEditText.error = customTextInputEditText.fieldValidatorModel.message + customTextInputEditText.fieldValidatorModel.setInvalid() } } } @@ -131,6 +129,8 @@ class CreateSeedActivity : CustomActivity() { * Validate continue to create account * */ validateFieldsToContinue() + + } @OnTextChanged(value = R.id.tietPinConfirmation, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) @@ -148,9 +148,9 @@ class CreateSeedActivity : CustomActivity() { this.fieldsValidator.validate() /* - * Always disable till the server response comes + * Validate continue to create account * */ - disableCreate() + validateFieldsToContinue() } @OnClick(R.id.btnCancel) @@ -221,8 +221,59 @@ class CreateSeedActivity : CustomActivity() { * If the result is true so the user can continue to the creation of the account * */ if (result) { - enableCreate() + + /* + * Show the dialog for connection with the server + * */ + val creatingAccountMaterialDialog = CrystalDialog(globalActivity) + creatingAccountMaterialDialog.setText(globalActivity.resources.getString(R.string.window_create_seed_Server_validation)) + creatingAccountMaterialDialog.progress() + creatingAccountMaterialDialog.show() + + /* + * Validate the account does not exists + * */ + val request = ValidateExistBitsharesAccountRequest(tietAccountName?.text.toString()) + request.setListener { + + /* + * Dismiss the dialog of loading + * */ + creatingAccountMaterialDialog.dismiss() + + if (request.accountExists) { + + /* + * The account exists and is not valid + * */ + tietAccountName.fieldValidatorModel.setInvalid() + tietAccountName.fieldValidatorModel.message = tietAccountName.resources.getString(R.string.account_name_already_exist) + + /* + * Disaible button create + * */ + disableCreate() + + } else { + + /* + * Passed all validations + * */ + tietAccountName.fieldValidatorModel.setValid() + + /* + * Enable button create + * */ + enableCreate() + } + } + CryptoNetInfoRequests.getInstance().addRequest(request) + } else { + + /* + * Disaible button create + * */ disableCreate() } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/customImpl/validationFields/BitsharesAccountNameValidation.kt b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/customImpl/validationFields/BitsharesAccountNameValidation.kt index 9074fcc..2f6f002 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/customImpl/validationFields/BitsharesAccountNameValidation.kt +++ b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/customImpl/validationFields/BitsharesAccountNameValidation.kt @@ -69,6 +69,7 @@ class BitsharesAccountNameValidation : CustomValidationField, UIValidator { * Remove error * */ accountNameField.error = null + accountNameField.fieldValidatorModel.setValid() /* Validate at least min length @@ -87,6 +88,7 @@ class BitsharesAccountNameValidation : CustomValidationField, UIValidator { * Remove error * */ accountNameField.error = null + accountNameField.fieldValidatorModel.setValid() /* Validate at least one character @@ -105,6 +107,7 @@ class BitsharesAccountNameValidation : CustomValidationField, UIValidator { * Remove error * */ accountNameField.error = null + accountNameField.fieldValidatorModel.setValid() /* Validate at least one number for the account string @@ -117,12 +120,14 @@ class BitsharesAccountNameValidation : CustomValidationField, UIValidator { result = false accountNameField.fieldValidatorModel.setInvalid() accountNameField.fieldValidatorModel.message = this.accountNameField.resources.getString(R.string.create_account_window_err_at_least_one_number) + } else { /* * Remove error * */ accountNameField.error = null + accountNameField.fieldValidatorModel.setValid() /* @@ -136,12 +141,14 @@ class BitsharesAccountNameValidation : CustomValidationField, UIValidator { result = false accountNameField.fieldValidatorModel.setInvalid() accountNameField.fieldValidatorModel.message = this.accountNameField.resources.getString(R.string.create_account_window_err_at_least_one_script) + } else { /* * Remove error * */ accountNameField.error = null + accountNameField.fieldValidatorModel.setValid() } } } @@ -162,46 +169,11 @@ class BitsharesAccountNameValidation : CustomValidationField, UIValidator { } else { /* - * Show the dialog for connection with the server + * Deliver result * */ - val creatingAccountMaterialDialog = CrystalDialog(activity) - creatingAccountMaterialDialog.setText(activity.resources.getString(R.string.window_create_seed_Server_validation)) - creatingAccountMaterialDialog.progress() - creatingAccountMaterialDialog.show() - - val request = ValidateExistBitsharesAccountRequest(newValue) - request.setListener { - - /* - * Dismiss the dialog of loading - * */ - creatingAccountMaterialDialog.dismiss() - - if (request.accountExists) { - - /* - * The account exists and is not valid - * */ - accountNameField.fieldValidatorModel.setInvalid() - accountNameField.fieldValidatorModel.message = accountNameField.resources.getString(R.string.account_name_already_exist) - - } else { - - /* - * Passed all validations - * */ - accountNameField.fieldValidatorModel.setValid() - - /* - * Deliver the response - * */ - if (uiValidatorListener != null) { - uiValidatorListener.onValidationSucceeded(globalCustomValidationField) - } - } + if (uiValidatorListener != null) { + uiValidatorListener.onValidationSucceeded(this) } - CryptoNetInfoRequests.getInstance().addRequest(request) - } /* * Passed initial validations, next final validations From 018cced971841350ba36037535dd249d9f1bd786 Mon Sep 17 00:00:00 2001 From: dtvv Date: Wed, 5 Sep 2018 13:52:27 -0500 Subject: [PATCH 03/13] In the loading dialog when you Press back button it lets to close it --- .../cy/agorise/crystalwallet/dialogs/material/DialogMaterial.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/DialogMaterial.kt b/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/DialogMaterial.kt index 973081c..9f43713 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/DialogMaterial.kt +++ b/app/src/main/java/cy/agorise/crystalwallet/dialogs/material/DialogMaterial.kt @@ -43,6 +43,7 @@ open abstract class DialogMaterial{ * Init the builder * */ builder = MaterialDialog.Builder(activity) + builder.cancelable(false) } /* From 72dc7abf8b220bc64917b8383f954b5c55dd419f Mon Sep 17 00:00:00 2001 From: dtvv Date: Wed, 5 Sep 2018 14:49:35 -0500 Subject: [PATCH 04/13] =?UTF-8?q?Change=20the=20=E2=80=9Ccancel=E2=80=9D?= =?UTF-8?q?=20button=20in=20the=20send=20assets=20screen=20to=20a=20cross?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/send_transaction.xml | 30 +++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/app/src/main/res/layout/send_transaction.xml b/app/src/main/res/layout/send_transaction.xml index 34116a5..b691589 100644 --- a/app/src/main/res/layout/send_transaction.xml +++ b/app/src/main/res/layout/send_transaction.xml @@ -2,6 +2,7 @@ @@ -13,12 +14,10 @@ @@ -228,16 +227,27 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="@+id/viewSend" /> - + app:layout_constraintEnd_toEndOf="parent" + android:padding="5dp"> + + + + + From e0903c0a2697ae4bcc1e4fe56095b6b429aaf9a0 Mon Sep 17 00:00:00 2001 From: dtvv Date: Wed, 5 Sep 2018 14:51:07 -0500 Subject: [PATCH 05/13] Remove AppTheme.NoActionBar from LicenceActivity.java --- app/src/main/AndroidManifest.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0258a50..b1b4b47 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,7 +18,7 @@ android:configChanges="locale" android:theme="@style/AppTheme"> @@ -30,8 +30,7 @@ android:theme="@style/AppTheme.NoActionBar"> - + From 5fb847ba1c9ec2bda450b538174ca46f2c461b57 Mon Sep 17 00:00:00 2001 From: dtvv Date: Wed, 5 Sep 2018 19:36:27 -0500 Subject: [PATCH 06/13] Revert network changes --- .../apigenerator/GrapheneApiGenerator.java | 274 +++++++++--------- .../network/BitsharesCryptoNetVerifier.java | 28 +- .../network/CryptoNetVerifier.java | 18 +- .../network/WebSocketThread.java | 62 +--- 4 files changed, 155 insertions(+), 227 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 575a75c..de1a19e 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/apigenerator/GrapheneApiGenerator.java @@ -8,6 +8,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; +import cy.agorise.crystalwallet.application.constant.BitsharesConstant; import cy.agorise.crystalwallet.dao.BitsharesAssetDao; import cy.agorise.crystalwallet.dao.CryptoCoinBalanceDao; import cy.agorise.crystalwallet.dao.CryptoCurrencyDao; @@ -78,17 +79,15 @@ public abstract class GrapheneApiGenerator { /** * This is used for manager each listener in the subscription thread */ - private static HashMap currentBitsharesListener = new HashMap<>(); - - + private static HashMap currentBitsharesListener = new HashMap<>(); /** * Retrieves the data of an account searching by it's id * * @param accountId The accountId to retrieve - * @param request The Api request object, to answer this petition + * @param request The Api request object, to answer this petition */ - public static void getAccountById(String accountId, final ApiRequest request) { + public static void getAccountById(String accountId, final ApiRequest request){ WebSocketThread thread = new WebSocketThread(new GetAccounts(accountId, new WitnessResponseListener() { @Override @@ -97,7 +96,7 @@ public abstract class GrapheneApiGenerator { List list = (List) response.result; if (list.size() > 0) { if (list.get(0).getClass() == AccountProperties.class) { - request.getListener().success(list.get(0), request.getId()); + request.getListener().success(list.get(0),request.getId()); return; } } @@ -109,7 +108,7 @@ public abstract class GrapheneApiGenerator { public void onError(BaseResponse.Error error) { request.getListener().fail(request.getId()); } - }), CryptoNetManager.getURL(CryptoNet.BITSHARES)); + }),CryptoNetManager.getURL(CryptoNet.BITSHARES)); thread.start(); } @@ -119,20 +118,17 @@ public abstract class GrapheneApiGenerator { * @param address The address to retrieve * @param request The Api request object, to answer this petition */ - public static void getAccountByOwnerOrActiveAddress(Address address, final ApiRequest request) { + public static void getAccountByOwnerOrActiveAddress(Address address, final ApiRequest request){ WebSocketThread thread = new WebSocketThread(new GetKeyReferences(address, true, new WitnessResponseListener() { @Override public void onSuccess(WitnessResponse response) { final List> resp = (List>) response.result; - if (resp.size() > 0) { + if(resp.size() > 0){ List accounts = resp.get(0); - if (accounts.size() > 0) { - for (UserAccount account : accounts) { - request.getListener().success(account, request.getId()); - } - } - } + if(accounts.size() > 0){ + for(UserAccount account : accounts) { + request.getListener().success(account,request.getId());}}} request.getListener().fail(request.getId()); } @@ -140,7 +136,7 @@ public abstract class GrapheneApiGenerator { public void onError(BaseResponse.Error error) { request.getListener().fail(request.getId()); } - }), CryptoNetManager.getURL(CryptoNet.BITSHARES)); + }),CryptoNetManager.getURL(CryptoNet.BITSHARES)); thread.start(); } @@ -149,25 +145,25 @@ public abstract class GrapheneApiGenerator { * Gets the Transaction for an Account * * @param accountGrapheneId The account id to search - * @param start The start index of the transaction list - * @param stop The stop index of the transaction list - * @param limit the maximun transactions to retrieve - * @param request The Api request object, to answer this petition + * @param start The start index of the transaction list + * @param stop The stop index of the transaction list + * @param limit the maximun transactions to retrieve + * @param request The Api request object, to answer this petition */ public static void getAccountTransaction(String accountGrapheneId, int start, int stop, - int limit, final ApiRequest request) { + int limit, final ApiRequest request){ WebSocketThread thread = new WebSocketThread(new GetRelativeAccountHistory(new UserAccount(accountGrapheneId), start, limit, stop, new WitnessResponseListener() { @Override public void onSuccess(WitnessResponse response) { - request.getListener().success(response.result, request.getId()); + request.getListener().success(response.result,request.getId()); } @Override public void onError(BaseResponse.Error error) { request.getListener().fail(request.getId()); } - }), CryptoNetManager.getURL(CryptoNet.BITSHARES)); + }),CryptoNetManager.getURL(CryptoNet.BITSHARES)); thread.start(); } @@ -175,18 +171,18 @@ public abstract class GrapheneApiGenerator { * Retrieves the account id by the name of the account * * @param accountName The account Name to find - * @param request The Api request object, to answer this petition + * @param request The Api request object, to answer this petition */ - public static void getAccountByName(String accountName, final ApiRequest request) { + public static void getAccountByName(String accountName, final ApiRequest request){ WebSocketThread thread = new WebSocketThread(new GetAccountByName(accountName, new WitnessResponseListener() { @Override public void onSuccess(WitnessResponse response) { - AccountProperties accountProperties = (AccountProperties) response.result; - if (accountProperties == null) { + AccountProperties accountProperties = (AccountProperties)response.result; + if(accountProperties == null){ request.getListener().fail(request.getId()); - } else { - request.getListener().success(accountProperties, request.getId()); + }else{ + request.getListener().success(accountProperties,request.getId()); } } @@ -194,7 +190,7 @@ public abstract class GrapheneApiGenerator { public void onError(BaseResponse.Error error) { request.getListener().fail(request.getId()); } - }), CryptoNetManager.getURL(CryptoNet.BITSHARES)); + }),CryptoNetManager.getURL(CryptoNet.BITSHARES)); thread.start(); } @@ -202,18 +198,18 @@ public abstract class GrapheneApiGenerator { * Retrieves the account id by the name of the account * * @param accountName The account Name to find - * @param request The Api request object, to answer this petition + * @param request The Api request object, to answer this petition */ - public static void getAccountIdByName(String accountName, final ApiRequest request) { + public static void getAccountIdByName(String accountName, final ApiRequest request){ WebSocketThread thread = new WebSocketThread(new GetAccountByName(accountName, new WitnessResponseListener() { @Override public void onSuccess(WitnessResponse response) { - AccountProperties accountProperties = (AccountProperties) response.result; - if (accountProperties == null) { - request.getListener().success(null, request.getId()); - } else { - request.getListener().success(accountProperties.id, request.getId()); + AccountProperties accountProperties = (AccountProperties)response.result; + if(accountProperties == null){ + request.getListener().success(null,request.getId()); + }else{ + request.getListener().success(accountProperties.id,request.getId()); } } @@ -221,7 +217,7 @@ public abstract class GrapheneApiGenerator { public void onError(BaseResponse.Error error) { request.getListener().fail(request.getId()); } - }), CryptoNetManager.getURL(CryptoNet.BITSHARES)); + }),CryptoNetManager.getURL(CryptoNet.BITSHARES)); thread.start(); } @@ -229,23 +225,23 @@ public abstract class GrapheneApiGenerator { * Broadcast a transaction, this is use for sending funds * * @param transaction The graphene transaction - * @param feeAsset The feeAseet, this needs only the id of the asset - * @param request the api request object, to answer this petition + * @param feeAsset The feeAseet, this needs only the id of the asset + * @param request the api request object, to answer this petition */ public static void broadcastTransaction(Transaction transaction, Asset feeAsset, - final ApiRequest request) { + final ApiRequest request){ WebSocketThread thread = new WebSocketThread(new TransactionBroadcastSequence(transaction, feeAsset, new WitnessResponseListener() { @Override public void onSuccess(WitnessResponse response) { - request.getListener().success(true, request.getId()); + request.getListener().success(true,request.getId()); } @Override public void onError(BaseResponse.Error error) { request.getListener().fail(request.getId()); } - }), CryptoNetManager.getURL(CryptoNet.BITSHARES)); + }),CryptoNetManager.getURL(CryptoNet.BITSHARES)); thread.start(); } @@ -253,20 +249,20 @@ public abstract class GrapheneApiGenerator { * This gets the asset information using only the asset name * * @param assetNames The list of the names of the assets to be retrieve - * @param request the api request object, to answer this petition + * @param request the api request object, to answer this petition */ - public static void getAssetByName(ArrayList assetNames, final ApiRequest request) { + public static void getAssetByName(ArrayList assetNames, final ApiRequest request){ - WebSocketThread thread = new WebSocketThread(new LookupAssetSymbols(assetNames, true, + WebSocketThread thread = new WebSocketThread(new LookupAssetSymbols(assetNames,true, new WitnessResponseListener() { @Override public void onSuccess(WitnessResponse response) { List assets = (List) response.result; - if (assets.size() <= 0) { + if(assets.size() <= 0){ request.getListener().fail(request.getId()); - } else { + }else{ ArrayList responseAssets = new ArrayList<>(); - for (Asset asset : assets) { + for(Asset asset: assets){ //TODO asset type BitsharesAsset.Type assetType = BitsharesAsset.Type.UIA; /*if(asset.getAssetType().equals(Asset.AssetType.CORE_ASSET)){ @@ -279,10 +275,10 @@ public abstract class GrapheneApiGenerator { assetType = BitsharesAsset.Type.PREDICTION_MARKET; }*/ BitsharesAsset responseAsset = new BitsharesAsset(asset.getSymbol(), - asset.getPrecision(), asset.getObjectId(), assetType); + asset.getPrecision(),asset.getObjectId(),assetType); responseAssets.add(responseAsset); } - request.getListener().success(responseAssets, request.getId()); + request.getListener().success(responseAssets,request.getId()); } } @@ -290,32 +286,31 @@ public abstract class GrapheneApiGenerator { public void onError(BaseResponse.Error error) { request.getListener().fail(request.getId()); } - }), CryptoNetManager.getURL(CryptoNet.BITSHARES)); + }),CryptoNetManager.getURL(CryptoNet.BITSHARES)); thread.start(); } /** * Gets the asset ifnormation using the id of the net - * * @param assetIds The list of the ids to retrieve - * @param request the api request object, to answer this petition + * @param request the api request object, to answer this petition */ - public static void getAssetById(ArrayList assetIds, final ApiRequest request) { + public static void getAssetById(ArrayList assetIds, final ApiRequest request){ ArrayList assets = new ArrayList<>(); - for (String assetId : assetIds) { + for(String assetId : assetIds){ Asset asset = new Asset(assetId); assets.add(asset); } - WebSocketThread thread = new WebSocketThread(new LookupAssetSymbols(assets, true, new WitnessResponseListener() { + WebSocketThread thread = new WebSocketThread(new LookupAssetSymbols(assets,true, new WitnessResponseListener() { @Override public void onSuccess(WitnessResponse response) { List assets = (List) response.result; - if (assets.size() <= 0) { + if(assets.size() <= 0){ request.getListener().fail(request.getId()); - } else { + }else{ ArrayList responseAssets = new ArrayList<>(); - for (Asset asset : assets) { + for(Asset asset: assets){ //TODO asset type BitsharesAsset.Type assetType = BitsharesAsset.Type.UIA; /*if(asset.getAssetType().equals(Asset.AssetType.CORE_ASSET)){ @@ -328,10 +323,10 @@ public abstract class GrapheneApiGenerator { assetType = BitsharesAsset.Type.PREDICTION_MARKET; }*/ BitsharesAsset responseAsset = new BitsharesAsset(asset.getSymbol(), - asset.getPrecision(), asset.getObjectId(), assetType); + asset.getPrecision(),asset.getObjectId(),assetType); responseAssets.add(responseAsset); } - request.getListener().success(responseAssets, request.getId()); + request.getListener().success(responseAssets,request.getId()); } } @@ -339,20 +334,20 @@ public abstract class GrapheneApiGenerator { public void onError(BaseResponse.Error error) { request.getListener().fail(request.getId()); } - }), CryptoNetManager.getURL(CryptoNet.BITSHARES)); + }),CryptoNetManager.getURL(CryptoNet.BITSHARES)); thread.start(); } /** * Subscribe a bitshares account to receive real time updates * - * @param accountId The id opf the database of the account - * @param accountBitsharesId The bitshares id of the account - * @param context The android context of this application + * @param accountId The id opf the database of the account + * @param accountBitsharesId The bitshares id of the account + * @param context The android context of this application */ public static void subscribeBitsharesAccount(final long accountId, final String accountBitsharesId, - final Context context) { - if (!currentBitsharesListener.containsKey(accountId)) { + final Context context){ + if(!currentBitsharesListener.containsKey(accountId)){ CrystalDatabase db = CrystalDatabase.getAppDatabase(context); final BitsharesAssetDao bitsharesAssetDao = db.bitsharesAssetDao(); final CryptoCurrencyDao cryptoCurrencyDao = db.cryptoCurrencyDao(); @@ -365,15 +360,15 @@ public abstract class GrapheneApiGenerator { @Override public void onSubscriptionUpdate(SubscriptionResponse response) { List updatedObjects = (List) response.params.get(1); - if (updatedObjects.size() > 0) { - for (Serializable update : updatedObjects) { - if (update instanceof BroadcastedTransaction) { + if(updatedObjects.size() > 0){ + for(Serializable update : updatedObjects){ + if(update instanceof BroadcastedTransaction){ BroadcastedTransaction transactionUpdate = (BroadcastedTransaction) update; - for (BaseOperation operation : transactionUpdate.getTransaction().getOperations()) { - if (operation instanceof TransferOperation) { + for(BaseOperation operation : transactionUpdate.getTransaction().getOperations()){ + if(operation instanceof TransferOperation){ final TransferOperation tOperation = (TransferOperation) operation; - if (tOperation.getFrom().getObjectId().equals(accountBitsharesId) || tOperation.getTo().getObjectId().equals(accountBitsharesId)) { - GrapheneApiGenerator.getAccountBalance(accountId, accountBitsharesId, context); + if(tOperation.getFrom().getObjectId().equals(accountBitsharesId) || tOperation.getTo().getObjectId().equals(accountBitsharesId)){ + GrapheneApiGenerator.getAccountBalance(accountId,accountBitsharesId,context); final CryptoCoinTransaction transaction = new CryptoCoinTransaction(); transaction.setAccountId(accountId); transaction.setAmount(tOperation.getAssetAmount().getAmount().longValue()); @@ -384,13 +379,13 @@ public abstract class GrapheneApiGenerator { @Override public void success(Object answer, int idPetition) { ArrayList assets = (ArrayList) answer; - for (BitsharesAsset asset : assets) { + for(BitsharesAsset asset : assets){ long idCryptoCurrency = cryptoCurrencyDao.insertCryptoCurrency(asset)[0]; BitsharesAssetInfo info = new BitsharesAssetInfo(asset); info.setCryptoCurrencyId(idCryptoCurrency); - asset.setId((int) idCryptoCurrency); + asset.setId((int)idCryptoCurrency); bitsharesAssetDao.insertBitsharesAssetInfo(info); - saveTransaction(transaction, cryptoCurrencyDao.getById(info.getCryptoCurrencyId()), accountBitsharesId, tOperation, context); + saveTransaction(transaction,cryptoCurrencyDao.getById(info.getCryptoCurrencyId()),accountBitsharesId,tOperation,context); } } @@ -401,9 +396,9 @@ public abstract class GrapheneApiGenerator { }); ArrayList assets = new ArrayList<>(); assets.add(tOperation.getAssetAmount().getAsset().getObjectId()); - GrapheneApiGenerator.getAssetById(assets, assetRequest); - } else { - saveTransaction(transaction, cryptoCurrencyDao.getById(info.getCryptoCurrencyId()), accountBitsharesId, tOperation, context); + GrapheneApiGenerator.getAssetById(assets,assetRequest); + }else{ + saveTransaction(transaction,cryptoCurrencyDao.getById(info.getCryptoCurrencyId()),accountBitsharesId,tOperation,context); } } } @@ -415,62 +410,56 @@ public abstract class GrapheneApiGenerator { } }; - currentBitsharesListener.put(accountId, balanceListener); + currentBitsharesListener.put(accountId,balanceListener); bitsharesSubscriptionHub.addSubscriptionListener(balanceListener); - try { - if (!subscriptionThread.isConnected() && !subscriptionThread.isAlive()) { - subscriptionThread.start(); - - } else if (bitsharesSubscriptionHub != null && !bitsharesSubscriptionHub.isSubscribed()) { - bitsharesSubscriptionHub.resubscribe(); - } - } catch (Exception e) { - e.printStackTrace(); + if(!subscriptionThread.isConnected()){ + subscriptionThread.start(); + }else if(!bitsharesSubscriptionHub.isSubscribed()){ + bitsharesSubscriptionHub.resubscribe(); } } } /** * Function to save a transaction retrieved from the update - * - * @param transaction The transaction db object - * @param currency The currency of the transaccion + * @param transaction The transaction db object + * @param currency The currency of the transaccion * @param accountBitsharesId The id of the account in the bitshares network - * @param tOperation The transfer operation fetched from the update - * @param context The context of this app + * @param tOperation The transfer operation fetched from the update + * @param context The context of this app */ private static void saveTransaction(CryptoCoinTransaction transaction, CryptoCurrency currency, - String accountBitsharesId, TransferOperation tOperation, - Context context) { - transaction.setIdCurrency((int) currency.getId()); + String accountBitsharesId, TransferOperation tOperation , + Context context){ + transaction.setIdCurrency((int)currency.getId()); transaction.setConfirmed(true); //graphene transaction are always confirmed transaction.setFrom(tOperation.getFrom().getObjectId()); transaction.setInput(!tOperation.getFrom().getObjectId().equals(accountBitsharesId)); transaction.setTo(tOperation.getTo().getObjectId()); transaction.setDate(new Date()); CrystalDatabase.getAppDatabase(context).transactionDao().insertTransaction(transaction); - if (transaction.getInput()) { - CryptoNetEvents.getInstance().fireEvent(new ReceivedFundsCryptoNetEvent(transaction.getAccount(), currency, transaction.getAmount())); + if(transaction.getInput()){ + CryptoNetEvents.getInstance().fireEvent(new ReceivedFundsCryptoNetEvent(transaction.getAccount(),currency,transaction.getAmount())); } } /** * Cancels all bitshares account subscriptions */ - public static void cancelBitsharesAccountSubscriptions() { + public static void cancelBitsharesAccountSubscriptions(){ bitsharesSubscriptionHub.cancelSubscriptions(); } /** * Retrieve the account balance of an account * - * @param accountId The dataabase id of the account + * @param accountId The dataabase id of the account * @param accountGrapheneId The bitshares id of the account - * @param context The android context of this application + * @param context The android context of this application */ public static void getAccountBalance(final long accountId, final String accountGrapheneId, - final Context context) { + final Context context){ CrystalDatabase db = CrystalDatabase.getAppDatabase(context); final CryptoCoinBalanceDao balanceDao = db.cryptoCoinBalanceDao(); @@ -481,19 +470,19 @@ public abstract class GrapheneApiGenerator { @Override public void onSuccess(WitnessResponse response) { List balances = (List) response.result; - for (final AssetAmount balance : balances) { + for(final AssetAmount balance : balances){ final CryptoCoinBalance ccBalance = new CryptoCoinBalance(); ccBalance.setAccountId(accountId); ccBalance.setBalance(balance.getAmount().longValue()); BitsharesAssetInfo assetInfo = bitsharesAssetDao.getBitsharesAssetInfoById(balance.getAsset().getObjectId()); - if (assetInfo == null) { + if(assetInfo == null ){ ArrayList idAssets = new ArrayList<>(); idAssets.add(balance.getAsset().getObjectId()); ApiRequest getAssetRequest = new ApiRequest(1, new ApiRequestListener() { @Override public void success(Object answer, int idPetition) { List assets = (List) answer; - for (BitsharesAsset asset : assets) { + for(BitsharesAsset asset : assets) { BitsharesAssetInfo info = new BitsharesAssetInfo(asset); long[] cryptoCurrencyId = cryptoCurrencyDao.insertCryptoCurrency((CryptoCurrency) asset); info.setCryptoCurrencyId(cryptoCurrencyId[0]); @@ -507,9 +496,9 @@ public abstract class GrapheneApiGenerator { public void fail(int idPetition) { } }); - getAssetById(idAssets, getAssetRequest); + getAssetById(idAssets,getAssetRequest); - } else { + }else { ccBalance.setCryptoCurrencyId(assetInfo.getCryptoCurrencyId()); balanceDao.insertCryptoCoinBalance(ccBalance); @@ -521,7 +510,7 @@ public abstract class GrapheneApiGenerator { public void onError(BaseResponse.Error error) { } - }), CryptoNetManager.getURL(CryptoNet.BITSHARES)); + }),CryptoNetManager.getURL(CryptoNet.BITSHARES)); thread.start(); @@ -531,15 +520,15 @@ public abstract class GrapheneApiGenerator { * Gets the date time of a block header * * @param blockHeader The block header to retrieve the date time - * @param request the api request object, to answer this petition + * @param request the api request object, to answer this petition */ - public static void getBlockHeaderTime(long blockHeader, final ApiRequest request) { + public static void getBlockHeaderTime(long blockHeader, final ApiRequest request){ WebSocketThread thread = new WebSocketThread(new GetBlockHeader(blockHeader, new WitnessResponseListener() { @Override public void onSuccess(WitnessResponse response) { - if (response == null) { + if(response == null){ request.getListener().fail(request.getId()); - } else { + }else { request.getListener().success(response.result, request.getId()); } } @@ -548,7 +537,7 @@ public abstract class GrapheneApiGenerator { public void onError(BaseResponse.Error error) { request.getListener().fail(request.getId()); } - }), CryptoNetManager.getURL(CryptoNet.BITSHARES)); + }),CryptoNetManager.getURL(CryptoNet.BITSHARES)); thread.start(); } @@ -556,21 +545,21 @@ public abstract class GrapheneApiGenerator { /** * Gets a single equivalent value * - * @param baseId The base asset bistshares id + * @param baseId The base asset bistshares id * @param quoteId the quote asset bitshares id * @param request the api request object, to answer this petition */ - public static void getEquivalentValue(final String baseId, String quoteId, final ApiRequest request) { + public static void getEquivalentValue(final String baseId, String quoteId, final ApiRequest request){ WebSocketThread thread = new WebSocketThread(new GetLimitOrders(baseId, quoteId, 10, new WitnessResponseListener() { @Override public void onSuccess(WitnessResponse response) { List orders = (List) response.result; - if (orders.size() <= 0) { + if(orders.size()<= 0){ //TODO indirect equivalent value } - for (LimitOrder order : orders) { - if (order.getSellPrice().base.getAsset().getBitassetId().equals(baseId)) { + for(LimitOrder order : orders){ + if(order.getSellPrice().base.getAsset().getBitassetId().equals(baseId)) { Converter converter = new Converter(); double equiValue = converter.getConversionRate(order.getSellPrice(), Converter.BASE_TO_QUOTE); @@ -584,23 +573,23 @@ public abstract class GrapheneApiGenerator { public void onError(BaseResponse.Error error) { request.getListener().fail(request.getId()); } - }), CryptoNetManager.getURL(CryptoNet.BITSHARES)); //todo change equivalent url for current server url + }), BitsharesConstant.EQUIVALENT_URL); //todo change equivalent url for current server url thread.start(); } /** * Gets equivalent value and store it on the database * - * @param baseAsset The baset asset as a bitshares asset, it needs the CryptoCurrency and thge BitsharesInfo + * @param baseAsset The baset asset as a bitshares asset, it needs the CryptoCurrency and thge BitsharesInfo * @param quoteAssets The list of the qutoe assets as a full bitshares asset object - * @param context The android context of this application + * @param context The android context of this application */ public static void getEquivalentValue(BitsharesAsset baseAsset, - final List quoteAssets, final Context context) { - for (BitsharesAsset quoteAsset : quoteAssets) { + final List quoteAssets, final Context context){ + for(BitsharesAsset quoteAsset : quoteAssets){ WebSocketThread thread = new WebSocketThread(new GetLimitOrders(baseAsset.getBitsharesId(), quoteAsset.getBitsharesId(), 10, new EquivalentValueListener(baseAsset, - quoteAsset, context)), CryptoNetManager.getURL(CryptoNet.BITSHARES)); //todo change equivalent url for current server url + quoteAsset,context)), BitsharesConstant.EQUIVALENT_URL); //todo change equivalent url for current server url thread.start(); } } @@ -609,25 +598,25 @@ public abstract class GrapheneApiGenerator { * Retrieves the equivalent value from a list of assets to a base asset * * @param baseAssetName The base asset to use - * @param quoteAssets The list of quotes assets to query - * @param context The Context of this Application + * @param quoteAssets The list of quotes assets to query + * @param context The Context of this Application */ - public static void getEquivalentValue(String baseAssetName, final List quoteAssets, final Context context) { + public static void getEquivalentValue(String baseAssetName, final List quoteAssets, final Context context){ CrystalDatabase db = CrystalDatabase.getAppDatabase(context); final CryptoCurrencyDao cryptoCurrencyDao = db.cryptoCurrencyDao(); final BitsharesAssetDao bitsharesAssetDao = db.bitsharesAssetDao(); CryptoCurrency baseCurrency = cryptoCurrencyDao.getByName(baseAssetName); BitsharesAssetInfo info = null; - if (baseCurrency != null) { + if(baseCurrency != null){ info = db.bitsharesAssetDao().getBitsharesAssetInfo(baseCurrency.getId()); } - if (baseCurrency == null || info == null) { + if(baseCurrency == null || info == null){ ApiRequest getAssetRequest = new ApiRequest(1, new ApiRequestListener() { @Override public void success(Object answer, int idPetition) { - if (answer instanceof BitsharesAsset) { + if(answer instanceof BitsharesAsset){ BitsharesAssetInfo info = new BitsharesAssetInfo((BitsharesAsset) answer); - long cryptoCurrencyId = cryptoCurrencyDao.insertCryptoCurrency((CryptoCurrency) answer)[0]; + long cryptoCurrencyId = cryptoCurrencyDao.insertCryptoCurrency((CryptoCurrency)answer )[0]; info.setCryptoCurrencyId(cryptoCurrencyId); bitsharesAssetDao.insertBitsharesAssetInfo(info); GrapheneApiGenerator.getEquivalentValue((BitsharesAsset) answer, quoteAssets, context); @@ -641,12 +630,12 @@ public abstract class GrapheneApiGenerator { }); ArrayList names = new ArrayList<>(); names.add(baseAssetName); - GrapheneApiGenerator.getAssetByName(names, getAssetRequest); + GrapheneApiGenerator.getAssetByName(names,getAssetRequest); - } else { + }else { BitsharesAsset baseAsset = new BitsharesAsset(baseCurrency); baseAsset.loadInfo(info); - getEquivalentValue(baseAsset, quoteAssets, context); + getEquivalentValue(baseAsset,quoteAssets,context); } @@ -655,7 +644,7 @@ public abstract class GrapheneApiGenerator { /** * Listener of the equivalent value the answer is stored in the database, for use in conjuntion with LiveData */ - private static class EquivalentValueListener implements WitnessResponseListener { + private static class EquivalentValueListener implements WitnessResponseListener{ /** * The base asset */ @@ -678,10 +667,10 @@ public abstract class GrapheneApiGenerator { @Override public void onSuccess(WitnessResponse response) { List orders = (List) response.result; - if (orders.size() <= 0) { + if(orders.size()<= 0){ //TODO indirect equivalent value } - for (LimitOrder order : orders) { + for(LimitOrder order : orders){ try { //if (order.getSellPrice().base.getAsset().getBitassetId().equals(baseAsset.getBitsharesId())) { Converter converter = new Converter(); @@ -692,7 +681,7 @@ public abstract class GrapheneApiGenerator { CrystalDatabase.getAppDatabase(context).cryptoCurrencyEquivalenceDao().insertCryptoCurrencyEquivalence(equivalence); break; //} - } catch (Exception e) { + }catch(Exception e){ e.printStackTrace(); } } @@ -703,4 +692,5 @@ public abstract class GrapheneApiGenerator { } } -} + +} \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/crystalwallet/network/BitsharesCryptoNetVerifier.java b/app/src/main/java/cy/agorise/crystalwallet/network/BitsharesCryptoNetVerifier.java index e90758f..c382cc5 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/network/BitsharesCryptoNetVerifier.java +++ b/app/src/main/java/cy/agorise/crystalwallet/network/BitsharesCryptoNetVerifier.java @@ -1,6 +1,5 @@ package cy.agorise.crystalwallet.network; -import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator; import cy.agorise.crystalwallet.enums.CryptoNet; import cy.agorise.graphenej.interfaces.WitnessResponseListener; import cy.agorise.graphenej.models.BaseResponse; @@ -24,21 +23,15 @@ public class BitsharesCryptoNetVerifier extends CryptoNetVerifier { private final String CHAIN_ID = "9cf6f255a208100d2bb275a3c52f4b1589b7ec9c9bfc2cb2a5fe6411295106d8";//testnet //private final String CHAIN_ID = "4018d7844c78f6a6c41c6a552b898022310fc5dec06da467ee7905a8dad512c8";//mainnet - - - - - - public BitsharesCryptoNetVerifier(){ - - /**/ + @Override + public void checkURL(final String url) { final long startTime = System.currentTimeMillis(); - thread = new WebSocketThread(new GetChainId(new WitnessResponseListener() { + WebSocketThread thread = new WebSocketThread(new GetChainId(new WitnessResponseListener() { @Override public void onSuccess(WitnessResponse response) { if(response.result instanceof String) { if(response.result.equals(CHAIN_ID)) { - CryptoNetManager.verifiedCryptoNetURL(cryptoNet, null, System.currentTimeMillis() - startTime); + CryptoNetManager.verifiedCryptoNetURL(cryptoNet, url, System.currentTimeMillis() - startTime); }else{ System.out.println(" BitsharesCryptoNetVerifier Error we are not in the net current chain id " + response.result + " excepted " + CHAIN_ID); //TODO handle error bad chain @@ -50,19 +43,12 @@ public class BitsharesCryptoNetVerifier extends CryptoNetVerifier { public void onError(BaseResponse.Error error) { //TODO handle error } - }),null); - - } - - - @Override - public void checkURL(final String url) { - thread.setmUrl(url); //Set the url - thread.start(); //Run the thread connection + }),url); + thread.start(); } @Override public String getChainId() { return CHAIN_ID; } -} +} \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java b/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java index 832d2f0..046a3d7 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java +++ b/app/src/main/java/cy/agorise/crystalwallet/network/CryptoNetVerifier.java @@ -1,8 +1,5 @@ package cy.agorise.crystalwallet.network; -import android.app.Activity; - -import cy.agorise.crystalwallet.apigenerator.GrapheneApiGenerator; import cy.agorise.crystalwallet.enums.CryptoNet; /** @@ -15,14 +12,6 @@ import cy.agorise.crystalwallet.enums.CryptoNet; public abstract class CryptoNetVerifier { - /* - * Contains the worker connection thread - */ - protected WebSocketThread thread; - - - - static CryptoNetVerifier getNetworkVerify(CryptoNet cryptoNet){ if(cryptoNet.getLabel().equals(CryptoNet.BITSHARES.getLabel())){ return new BitsharesCryptoNetVerifier(); @@ -33,9 +22,4 @@ public abstract class CryptoNetVerifier { public abstract void checkURL(final String url); public abstract String getChainId(); - - - public WebSocketThread getThread() { - return thread; - } -} +} \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/crystalwallet/network/WebSocketThread.java b/app/src/main/java/cy/agorise/crystalwallet/network/WebSocketThread.java index 58f4dad..d3c9504 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/network/WebSocketThread.java +++ b/app/src/main/java/cy/agorise/crystalwallet/network/WebSocketThread.java @@ -3,6 +3,7 @@ package cy.agorise.crystalwallet.network; import android.util.Log; import com.neovisionaries.ws.client.WebSocket; +import com.neovisionaries.ws.client.WebSocketException; import com.neovisionaries.ws.client.WebSocketFactory; import com.neovisionaries.ws.client.WebSocketListener; @@ -33,11 +34,6 @@ public class WebSocketThread extends Thread { private boolean canChange = true; - /* - * Object needed for socket connection - * */ - private WebSocketFactory factory; - /** * Basic constructor, * @@ -47,27 +43,16 @@ public class WebSocketThread extends Thread { * @param url The url to connect */ public WebSocketThread(WebSocketListener webSocketListener, String url) { - - /* - * The listener always can be setted - * */ - this.mWebSocketListener = webSocketListener; - - /* - * - * If at this point the url is not defined, this will be set after - * */ - if(url!=null){ - try { - factory = new WebSocketFactory().setConnectionTimeout(5000); - this.mUrl = url; - this.mWebSocket = factory.createSocket(this.mUrl); - this.mWebSocket.addListener(this.mWebSocketListener); - } catch (IOException e) { - Log.e(TAG, "IOException. Msg: "+e.getMessage()); - } catch(NullPointerException e){ - Log.e(TAG, "NullPointerException at WebsocketWorkerThreas. Msg: "+e.getMessage()); - } + try { + WebSocketFactory factory = new WebSocketFactory().setConnectionTimeout(5000); + this.mUrl = url; + this.mWebSocketListener = webSocketListener; + this.mWebSocket = factory.createSocket(this.mUrl); + this.mWebSocket.addListener(this.mWebSocketListener); + } catch (IOException e) { + Log.e(TAG, "IOException. Msg: "+e.getMessage()); + } catch(NullPointerException e){ + Log.e(TAG, "NullPointerException at WebsocketWorkerThreas. Msg: "+e.getMessage()); } } @@ -125,28 +110,16 @@ public class WebSocketThread extends Thread { @Override public void run() { - canChange = false; - // Moves the current Thread into the background android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND); - try { - - /* - * If the initialization of the socket comes after - * */ - if(factory==null){ - factory = new WebSocketFactory().setConnectionTimeout(5000); - this.mWebSocket = factory.createSocket(this.mUrl); - this.mWebSocket.addListener(this.mWebSocketListener); - } - WebSocketThread.currentThreads.put(this.getId(),this); mWebSocket.connect(); - - } catch (final Exception e) { + } catch (WebSocketException e) { Log.e(TAG, "WebSocketException. Msg: "+e.getMessage()); + } catch(NullPointerException e){ + Log.e(TAG, "NullPointerException. Msg: "+e.getMessage()); } WebSocketThread.currentThreads.remove(this.getId()); } @@ -154,9 +127,4 @@ public class WebSocketThread extends Thread { public boolean isConnected(){ return mWebSocket.isOpen(); } - - - public void setmUrl(String mUrl) { - this.mUrl = mUrl; - } -} +} \ No newline at end of file From 508e30fc1510556e1a01345e5eb772801a50b627 Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 6 Sep 2018 00:02:06 -0500 Subject: [PATCH 07/13] Correct manifest --- app/src/main/AndroidManifest.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b1b4b47..b185b0d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -18,8 +18,7 @@ android:configChanges="locale" android:theme="@style/AppTheme"> + android:name=".activities.LicenseActivity"> @@ -30,7 +29,8 @@ android:theme="@style/AppTheme.NoActionBar"> - + From 65669e155cee646e5ce2d9d673bed4419f35fac2 Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 6 Sep 2018 11:31:29 -0500 Subject: [PATCH 08/13] Integration of animated layout Library severiano --- app/src/main/res/layout/board.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/board.xml b/app/src/main/res/layout/board.xml index 2cfab65..274f075 100644 --- a/app/src/main/res/layout/board.xml +++ b/app/src/main/res/layout/board.xml @@ -98,7 +98,7 @@ - Date: Thu, 6 Sep 2018 11:44:05 -0500 Subject: [PATCH 09/13] Complete layout view for backup with brainkey --- app/src/main/res/layout/fragment_backups_settings.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/res/layout/fragment_backups_settings.xml b/app/src/main/res/layout/fragment_backups_settings.xml index 4a52a27..b27873f 100644 --- a/app/src/main/res/layout/fragment_backups_settings.xml +++ b/app/src/main/res/layout/fragment_backups_settings.xml @@ -38,7 +38,6 @@ android:layout_marginTop="24dp" android:text="@string/brainkey_description" android:textSize="15sp" - android:visibility="invisible" app:layout_constraintEnd_toEndOf="@id/tvBinFile" app:layout_constraintStart_toStartOf="@id/tvBinFile" app:layout_constraintTop_toBottomOf="@id/btnBinFile" /> @@ -53,7 +52,6 @@ android:text="@string/view_and_copy" android:textColor="@color/white" android:textStyle="bold" - android:visibility="invisible" app:layout_constraintStart_toStartOf="@id/btnBinFile" app:layout_constraintTop_toBottomOf="@id/tvBrainkey" /> From a1876733f5e99122861f1fad25ccdf9811688e7b Mon Sep 17 00:00:00 2001 From: dtvv Date: Thu, 6 Sep 2018 14:22:42 -0500 Subject: [PATCH 10/13] In the backup seed screen there is not option for brainkey backup --- .../activities/BackupSeedActivity.java | 9 +- .../fragments/BackupsSettingsFragment.java | 15 +++ app/src/main/res/anim/cycle_7.xml | 2 + app/src/main/res/anim/shake.xml | 4 + app/src/main/res/drawable/square.xml | 12 ++ app/src/main/res/layout/backup_seed.xml | 113 +++++++++--------- 6 files changed, 93 insertions(+), 62 deletions(-) create mode 100644 app/src/main/res/anim/cycle_7.xml create mode 100644 app/src/main/res/anim/shake.xml create mode 100644 app/src/main/res/drawable/square.xml diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/BackupSeedActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/BackupSeedActivity.java index 15b7d6b..1e4ebbc 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/BackupSeedActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/BackupSeedActivity.java @@ -18,6 +18,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.fragments.BackupsSettingsFragment; import cy.agorise.crystalwallet.models.AccountSeed; import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel; @@ -28,7 +29,7 @@ public class BackupSeedActivity extends AppCompatActivity { @BindView(R.id.tvBrainKey) TextView textfieldBrainkey; - @BindView(R.id.btnOk) + @BindView(R.id.btnCancel) Button btnOk; @BindView(R.id.btnCopy) Button btnCopy; @@ -60,14 +61,14 @@ public class BackupSeedActivity extends AppCompatActivity { accountSeedViewModel.loadSeed(seedId); } else { + finish(); } } - @OnClick(R.id.btnOk) + @OnClick(R.id.btnCancel) public void btnOkClick(){ - Intent intent = new Intent(this, IntroActivity.class); - startActivity(intent); + finish(); } /* diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/BackupsSettingsFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/BackupsSettingsFragment.java index f20f11e..66dd34e 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/BackupsSettingsFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/BackupsSettingsFragment.java @@ -2,6 +2,7 @@ package cy.agorise.crystalwallet.fragments; import android.arch.lifecycle.LiveData; import android.arch.lifecycle.Observer; +import android.content.Intent; import android.os.Bundle; import android.os.Environment; import android.support.annotation.Nullable; @@ -24,6 +25,8 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.activities.BackupSeedActivity; +import cy.agorise.crystalwallet.activities.IntroActivity; import cy.agorise.crystalwallet.dao.CrystalDatabase; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.requestmanagers.CreateBackupRequest; @@ -47,6 +50,9 @@ public class BackupsSettingsFragment extends Fragment{ return fragment; } + @BindView(R.id.btnBrainkey) + public Button btnBrainkey; + @BindView(R.id.tvBinFile) public TextView tvBinFile; @@ -81,6 +87,15 @@ public class BackupsSettingsFragment extends Fragment{ return ssb; } + + @OnClick(R.id.btnBrainkey) + public void btnBrainOnClick(){ + + Intent intent = new Intent(getContext(), BackupSeedActivity.class); + startActivity(intent); + } + + @OnClick(R.id.btnBinFile) public void makeBackupFile(){ if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { diff --git a/app/src/main/res/anim/cycle_7.xml b/app/src/main/res/anim/cycle_7.xml new file mode 100644 index 0000000..c396f74 --- /dev/null +++ b/app/src/main/res/anim/cycle_7.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/app/src/main/res/anim/shake.xml b/app/src/main/res/anim/shake.xml new file mode 100644 index 0000000..c79b244 --- /dev/null +++ b/app/src/main/res/anim/shake.xml @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/app/src/main/res/drawable/square.xml b/app/src/main/res/drawable/square.xml new file mode 100644 index 0000000..efde959 --- /dev/null +++ b/app/src/main/res/drawable/square.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/backup_seed.xml b/app/src/main/res/layout/backup_seed.xml index 0a50ef8..d892d28 100644 --- a/app/src/main/res/layout/backup_seed.xml +++ b/app/src/main/res/layout/backup_seed.xml @@ -3,88 +3,85 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:background="@color/white" android:paddingBottom="0dp" - android:paddingLeft="0dp" - android:paddingRight="0dp" + android:paddingLeft="25dp" + android:paddingRight="25dp" android:paddingTop="@dimen/activity_vertical_margin"> + android:layout_height="370dp" + android:background="@color/white" + android:padding="20dp" + android:layout_alignParentStart="true" + android:layout_centerVertical="true"> - + android:layout_marginTop="35dp" + android:background="@drawable/square" + android:padding="10dp"> - + + + + +