From 5b21c0719ebc4985842c92c665247592560ce546 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Wed, 27 Jun 2018 22:29:30 -0400 Subject: [PATCH] - Adjusting send and receive fragment to work with multiaccounts --- .../crystalwallet/activities/AccountsActivity.java | 10 ++++++++++ .../fragments/ReceiveTransactionFragment.java | 11 ++++++++++- .../fragments/SendTransactionFragment.java | 14 +++++++++++++- app/src/main/res/layout/activity_accounts.xml | 2 +- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/AccountsActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/AccountsActivity.java index 730877c..855cd3d 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/AccountsActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/AccountsActivity.java @@ -16,6 +16,7 @@ import android.os.FileObserver; import android.os.Parcelable; import android.provider.MediaStore; import android.support.annotation.Nullable; +import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; @@ -60,6 +61,9 @@ public class AccountsActivity extends AppCompatActivity { @BindView(R.id.user_img) CircleImageView userImg; + @BindView(R.id.fabAddAccount) + FloatingActionButton fabAddAccount; + static final int NEW_PICTURE_REQUEST_CODE = 1; FileObserver fileObserver; @@ -125,6 +129,12 @@ public class AccountsActivity extends AppCompatActivity { .start(); } + @OnClick(R.id.fabAddAccount) + public void goToAddAccount(){ + Intent intent = new Intent(this, CreateSeedActivity.class); + startActivity(intent); + } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (ImagePicker.shouldHandle(requestCode, resultCode, data)) { 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 b4c6455..7967e3c 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/ReceiveTransactionFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/ReceiveTransactionFragment.java @@ -302,6 +302,15 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali Log.e("ReceiveFragment","Amount casting error."); } + CryptoNetAccount toAccountSelected = (CryptoNetAccount) spTo.getSelectedItem(); + + /* + * this is only for graphene accounts. + * + **/ + GrapheneAccount grapheneAccountSelected = new GrapheneAccount(toAccountSelected); + grapheneAccountSelected.loadInfo(db.grapheneAccountInfoDao().getByAccountId(toAccountSelected.getId())); + this.invoiceItems.clear(); this.invoiceItems.add( @@ -311,7 +320,7 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali LineItem items[] = new LineItem[this.invoiceItems.size()]; items = this.invoiceItems.toArray(items); this.invoice.setLineItems(items); - this.invoice.setTo(this.grapheneAccount.getName()); + this.invoice.setTo(grapheneAccountSelected.getName()); this.invoice.setCurrency(this.cryptoCurrency.getName()); try { 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 e47eca9..e6d96e1 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SendTransactionFragment.java @@ -311,13 +311,25 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat @OnClick(R.id.btnSend) public void sendTransaction(){ if (this.sendTransactionValidator.isValid()) { + CryptoNetAccount fromAccountSelected = (CryptoNetAccount) spFrom.getSelectedItem(); + + + /* + * this is only for graphene accounts. + * + **/ + GrapheneAccount grapheneAccountSelected = new GrapheneAccount(fromAccountSelected); + grapheneAccountSelected.loadInfo(db.grapheneAccountInfoDao().getByAccountId(fromAccountSelected.getId())); + + + //TODO convert the amount to long type using the precision of the currency Long amountFromEditText = Long.parseLong(this.etAmount.getText().toString()); Long amount = amountFromEditText*Math.round(Math.pow(10,((CryptoCurrency)spAsset.getSelectedItem()).getPrecision())); final ValidateBitsharesSendRequest sendRequest = new ValidateBitsharesSendRequest( this.getContext(), - this.grapheneAccount, + grapheneAccountSelected, this.etTo.getText().toString(), amount, ((CryptoCurrency)spAsset.getSelectedItem()).getName(), diff --git a/app/src/main/res/layout/activity_accounts.xml b/app/src/main/res/layout/activity_accounts.xml index 7aac477..53177e6 100644 --- a/app/src/main/res/layout/activity_accounts.xml +++ b/app/src/main/res/layout/activity_accounts.xml @@ -84,7 +84,7 @@ android:layout_height="55dp" android:layout_marginEnd="32dp" android:layout_marginTop="12dp" - android:visibility="gone" + android:visibility="visible" app:backgroundTint="@color/colorPrimary" app:fabSize="normal" app:layout_constraintEnd_toEndOf="parent"