Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
b1e8e4dfe7
5 changed files with 56 additions and 13 deletions
|
@ -36,6 +36,7 @@ import android.widget.ImageView;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.Result;
|
import com.google.zxing.Result;
|
||||||
|
@ -56,6 +57,7 @@ import butterknife.OnClick;
|
||||||
import butterknife.OnItemSelected;
|
import butterknife.OnItemSelected;
|
||||||
import butterknife.OnTextChanged;
|
import butterknife.OnTextChanged;
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
|
import cy.agorise.crystalwallet.dialogs.material.CrystalDialog;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequestListener;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
import cy.agorise.crystalwallet.requestmanagers.CryptoNetInfoRequests;
|
||||||
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest;
|
import cy.agorise.crystalwallet.requestmanagers.ValidateBitsharesSendRequest;
|
||||||
|
@ -131,7 +133,10 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
||||||
private FloatingActionButton fabSend;
|
private FloatingActionButton fabSend;
|
||||||
private AlertDialog.Builder builder;
|
private AlertDialog.Builder builder;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Dialog for loading
|
||||||
|
*/
|
||||||
|
private CrystalDialog crystalDialog;
|
||||||
|
|
||||||
public static SendTransactionFragment newInstance(long cryptoNetAccountId) {
|
public static SendTransactionFragment newInstance(long cryptoNetAccountId) {
|
||||||
SendTransactionFragment f = new SendTransactionFragment();
|
SendTransactionFragment f = new SendTransactionFragment();
|
||||||
|
@ -408,6 +413,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
||||||
|
|
||||||
@OnClick(R.id.btnSend)
|
@OnClick(R.id.btnSend)
|
||||||
public void sendTransaction(){
|
public void sendTransaction(){
|
||||||
|
final SendTransactionFragment thisFragment = this;
|
||||||
|
|
||||||
if (this.sendTransactionValidator.isValid()) {
|
if (this.sendTransactionValidator.isValid()) {
|
||||||
CryptoNetAccount fromAccountSelected = (CryptoNetAccount) spFrom.getItems().get(spFrom.getSelectedIndex());
|
CryptoNetAccount fromAccountSelected = (CryptoNetAccount) spFrom.getItems().get(spFrom.getSelectedIndex());
|
||||||
|
|
||||||
|
@ -439,13 +446,26 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
|
||||||
public void onCarryOut() {
|
public void onCarryOut() {
|
||||||
if (sendRequest.getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)){
|
if (sendRequest.getStatus().equals(ValidateBitsharesSendRequest.StatusCode.SUCCEEDED)){
|
||||||
try {
|
try {
|
||||||
this.finalize();
|
crystalDialog.dismiss();
|
||||||
|
thisFragment.dismiss();
|
||||||
|
//thisFragment.finalize();
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(getContext(), getContext().getString(R.string.unable_to_send_amount), Toast.LENGTH_LONG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Show loading dialog
|
||||||
|
* */
|
||||||
|
crystalDialog = new CrystalDialog((Activity) getContext());
|
||||||
|
crystalDialog.setText("Sending");
|
||||||
|
crystalDialog.progress();
|
||||||
|
crystalDialog.show();
|
||||||
|
|
||||||
CryptoNetInfoRequests.getInstance().addRequest(sendRequest);
|
CryptoNetInfoRequests.getInstance().addRequest(sendRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cy.agorise.crystalwallet.manager;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.common.primitives.UnsignedLong;
|
import com.google.common.primitives.UnsignedLong;
|
||||||
|
|
||||||
|
@ -127,7 +128,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
long[] idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount);
|
long[] idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount);
|
||||||
grapheneAccount.setId(idAccount[0]);
|
grapheneAccount.setId(idAccount[0]);
|
||||||
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
||||||
subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
//subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -145,7 +146,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
|
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
|
||||||
db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount);
|
db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount);
|
||||||
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
||||||
subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
//subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,7 +158,7 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
|
||||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
|
CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
|
||||||
db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount);
|
db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount);
|
||||||
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
|
||||||
subscribeBitsharesAccount(grapheneAccount.getId(), grapheneAccount.getAccountId(), context);
|
//subscribeBitsharesAccount(grapheneAccount.getId(), grapheneAccount.getAccountId(), context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,12 +105,19 @@ public class CryptoCoinBalanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
public void onChanged(@Nullable CryptoCurrencyEquivalence cryptoCurrencyEquivalence) {
|
public void onChanged(@Nullable CryptoCurrencyEquivalence cryptoCurrencyEquivalence) {
|
||||||
if (cryptoCurrencyEquivalence != null) {
|
if (cryptoCurrencyEquivalence != null) {
|
||||||
CryptoCurrency toCurrency = CrystalDatabase.getAppDatabase(context).cryptoCurrencyDao().getById(cryptoCurrencyEquivalence.getFromCurrencyId());
|
CryptoCurrency toCurrency = CrystalDatabase.getAppDatabase(context).cryptoCurrencyDao().getById(cryptoCurrencyEquivalence.getFromCurrencyId());
|
||||||
double equivalentValue = (balance.getBalance() / Math.pow(10, currencyFrom.getPrecision())) /
|
double equivalentValue = 0;
|
||||||
(cryptoCurrencyEquivalence.getValue() / Math.pow(10, toCurrency.getPrecision()));
|
String equivalenceString = "";
|
||||||
String equivalenceString = String.format(
|
if (cryptoCurrencyEquivalence.getValue() > 0) {
|
||||||
"%.2f",
|
equivalentValue = (balance.getBalance() / Math.pow(10, currencyFrom.getPrecision())) /
|
||||||
equivalentValue
|
(cryptoCurrencyEquivalence.getValue() / Math.pow(10, toCurrency.getPrecision()));
|
||||||
);
|
equivalenceString = String.format(
|
||||||
|
"%.2f",
|
||||||
|
equivalentValue
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
equivalentValue = 0;
|
||||||
|
equivalenceString = "0";
|
||||||
|
}
|
||||||
|
|
||||||
cryptoNetBalanceViewHolder.setEquivalentBalance(balance,equivalentValue);
|
cryptoNetBalanceViewHolder.setEquivalentBalance(balance,equivalentValue);
|
||||||
cryptoCoinBalanceEquivalence.setText(
|
cryptoCoinBalanceEquivalence.setText(
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cy.agorise.crystalwallet.views;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.arch.lifecycle.LifecycleOwner;
|
import android.arch.lifecycle.LifecycleOwner;
|
||||||
import android.arch.lifecycle.LiveData;
|
import android.arch.lifecycle.LiveData;
|
||||||
|
@ -24,12 +25,14 @@ import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.activities.SendTransactionActivity;
|
import cy.agorise.crystalwallet.activities.SendTransactionActivity;
|
||||||
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
import cy.agorise.crystalwallet.fragments.ReceiveTransactionFragment;
|
import cy.agorise.crystalwallet.fragments.ReceiveTransactionFragment;
|
||||||
import cy.agorise.crystalwallet.fragments.SendTransactionFragment;
|
import cy.agorise.crystalwallet.fragments.SendTransactionFragment;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCurrencyEquivalence;
|
import cy.agorise.crystalwallet.models.CryptoCurrencyEquivalence;
|
||||||
import cy.agorise.crystalwallet.models.CryptoNetBalance;
|
import cy.agorise.crystalwallet.models.CryptoNetBalance;
|
||||||
|
import cy.agorise.crystalwallet.models.GeneralSetting;
|
||||||
import cy.agorise.crystalwallet.viewmodels.CryptoCoinBalanceListViewModel;
|
import cy.agorise.crystalwallet.viewmodels.CryptoCoinBalanceListViewModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,6 +89,8 @@ public class CryptoNetBalanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
*/
|
*/
|
||||||
private Fragment fragment;
|
private Fragment fragment;
|
||||||
|
|
||||||
|
String preferredCurrency = "";
|
||||||
|
|
||||||
public CryptoNetBalanceViewHolder(View itemView, Fragment fragment) {
|
public CryptoNetBalanceViewHolder(View itemView, Fragment fragment) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
//-1 represents a crypto net account not loaded yet
|
//-1 represents a crypto net account not loaded yet
|
||||||
|
@ -114,6 +119,16 @@ public class CryptoNetBalanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
});
|
});
|
||||||
this.fragment = fragment;
|
this.fragment = fragment;
|
||||||
this.context = itemView.getContext();
|
this.context = itemView.getContext();
|
||||||
|
|
||||||
|
LiveData<GeneralSetting> preferedCurrencySetting = CrystalDatabase.getAppDatabase(this.context).generalSettingDao().getByName(GeneralSetting.SETTING_NAME_PREFERRED_CURRENCY);
|
||||||
|
|
||||||
|
preferedCurrencySetting.observe((LifecycleOwner)this.itemView.getContext(), new Observer<GeneralSetting>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(@Nullable GeneralSetting generalSetting) {
|
||||||
|
preferredCurrency = generalSetting.getValue();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear(){
|
public void clear(){
|
||||||
|
@ -179,7 +194,7 @@ public class CryptoNetBalanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
totalEquivalent += nextEquivalent;
|
totalEquivalent += nextEquivalent;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cryptoNetEquivalentTotal.setText(""+totalEquivalent);
|
this.cryptoNetEquivalentTotal.setText(""+totalEquivalent+" "+preferredCurrency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvMemoError" />
|
app:layout_constraintTop_toBottomOf="@id/tvMemoError" />
|
||||||
|
|
||||||
<ImageView
|
<me.dm7.barcodescanner.zxing.ZXingScannerView
|
||||||
android:id="@+id/ivCamera"
|
android:id="@+id/ivCamera"
|
||||||
android:layout_width="180dp"
|
android:layout_width="180dp"
|
||||||
android:layout_height="180dp"
|
android:layout_height="180dp"
|
||||||
|
|
Loading…
Reference in a new issue