- Adjusting send and receive fragment to work with multiaccounts

This commit is contained in:
Javier Varona 2018-06-27 22:29:30 -04:00
parent 594bd4b816
commit 5b21c0719e
4 changed files with 34 additions and 3 deletions

View file

@ -16,6 +16,7 @@ import android.os.FileObserver;
import android.os.Parcelable; import android.os.Parcelable;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.widget.TextView; import android.widget.TextView;
@ -60,6 +61,9 @@ public class AccountsActivity extends AppCompatActivity {
@BindView(R.id.user_img) @BindView(R.id.user_img)
CircleImageView userImg; CircleImageView userImg;
@BindView(R.id.fabAddAccount)
FloatingActionButton fabAddAccount;
static final int NEW_PICTURE_REQUEST_CODE = 1; static final int NEW_PICTURE_REQUEST_CODE = 1;
FileObserver fileObserver; FileObserver fileObserver;
@ -125,6 +129,12 @@ public class AccountsActivity extends AppCompatActivity {
.start(); .start();
} }
@OnClick(R.id.fabAddAccount)
public void goToAddAccount(){
Intent intent = new Intent(this, CreateSeedActivity.class);
startActivity(intent);
}
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (ImagePicker.shouldHandle(requestCode, resultCode, data)) { if (ImagePicker.shouldHandle(requestCode, resultCode, data)) {

View file

@ -302,6 +302,15 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
Log.e("ReceiveFragment","Amount casting error."); 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.clear();
this.invoiceItems.add( this.invoiceItems.add(
@ -311,7 +320,7 @@ public class ReceiveTransactionFragment extends DialogFragment implements UIVali
LineItem items[] = new LineItem[this.invoiceItems.size()]; LineItem items[] = new LineItem[this.invoiceItems.size()];
items = this.invoiceItems.toArray(items); items = this.invoiceItems.toArray(items);
this.invoice.setLineItems(items); this.invoice.setLineItems(items);
this.invoice.setTo(this.grapheneAccount.getName()); this.invoice.setTo(grapheneAccountSelected.getName());
this.invoice.setCurrency(this.cryptoCurrency.getName()); this.invoice.setCurrency(this.cryptoCurrency.getName());
try { try {

View file

@ -311,13 +311,25 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
@OnClick(R.id.btnSend) @OnClick(R.id.btnSend)
public void sendTransaction(){ public void sendTransaction(){
if (this.sendTransactionValidator.isValid()) { 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 //TODO convert the amount to long type using the precision of the currency
Long amountFromEditText = Long.parseLong(this.etAmount.getText().toString()); Long amountFromEditText = Long.parseLong(this.etAmount.getText().toString());
Long amount = amountFromEditText*Math.round(Math.pow(10,((CryptoCurrency)spAsset.getSelectedItem()).getPrecision())); Long amount = amountFromEditText*Math.round(Math.pow(10,((CryptoCurrency)spAsset.getSelectedItem()).getPrecision()));
final ValidateBitsharesSendRequest sendRequest = new ValidateBitsharesSendRequest( final ValidateBitsharesSendRequest sendRequest = new ValidateBitsharesSendRequest(
this.getContext(), this.getContext(),
this.grapheneAccount, grapheneAccountSelected,
this.etTo.getText().toString(), this.etTo.getText().toString(),
amount, amount,
((CryptoCurrency)spAsset.getSelectedItem()).getName(), ((CryptoCurrency)spAsset.getSelectedItem()).getName(),

View file

@ -84,7 +84,7 @@
android:layout_height="55dp" android:layout_height="55dp"
android:layout_marginEnd="32dp" android:layout_marginEnd="32dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:visibility="gone" android:visibility="visible"
app:backgroundTint="@color/colorPrimary" app:backgroundTint="@color/colorPrimary"
app:fabSize="normal" app:fabSize="normal"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"