Make sure to use the asset precision to correctly format the asset amount when reading QRs in SendTransactionActivity.

master
Severiano Jaramillo 2019-02-11 20:10:21 -06:00
parent 1e67fdf065
commit dd8a52451a
1 changed files with 4 additions and 1 deletions

View File

@ -372,6 +372,8 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
tietTo.setText(invoice.to)
var balanceDetail: BalanceDetail? = null
// Try to select the invoice's Asset in the Assets spinner
for (i in 0 until (mBalancesDetailsAdapter?.count ?: 0)) {
if (mBalancesDetailsAdapter?.getItem(i)?.symbol == invoice.currency.toUpperCase() ||
@ -379,6 +381,7 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
invoice.currency.replaceFirst("bit", "").toUpperCase() ==
mBalancesDetailsAdapter?.getItem(i)?.symbol)) {
spAsset.setSelection(i)
balanceDetail = mBalancesDetailsAdapter?.getItem(i)
break
}
}
@ -394,7 +397,7 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
amount += nextItem.quantity * nextItem.price
}
// TODO Improve pattern to account for different asset precisions
val df = DecimalFormat("####.########")
val df = DecimalFormat("####." + "#".repeat(balanceDetail?.precision ?: 5))
df.roundingMode = RoundingMode.CEILING
df.decimalFormatSymbols = DecimalFormatSymbols(Locale.getDefault())
tietAmount.setText(df.format(amount))