Avoid 0 in Send screen when reading a QR.

- Changed the logic that populates the fields in SendTransactionFragment when a QR code is read, when the amount is zero then just leave the amount field empty so that the user does not have to erase the 0 before typing in the desired amount.
This commit is contained in:
Severiano Jaramillo 2019-12-26 09:19:46 -06:00
parent 3b5d04abd4
commit 46af454259

View file

@ -317,7 +317,7 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
transaction!!.blockData = BlockData(headBlockNumber, headBlockId, expirationTime)
var feeAsset = Asset(Constants.CORE_ASSET)
val feeAsset = Asset(Constants.CORE_ASSET)
val id = mNetworkService?.sendMessage(GetRequiredFees(transaction!!, feeAsset), GetRequiredFees.REQUIRED_API)
if (id != null) responseMap.append(id, RESPONSE_GET_REQUIRED_FEES)
@ -451,10 +451,15 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
amount += nextItem.quantity * nextItem.price
}
// Populate the amount field only if amount is not zero.
if (amount > 0.0) {
val df = DecimalFormat("####." + "#".repeat(balanceDetail.precision))
df.roundingMode = RoundingMode.CEILING
df.decimalFormatSymbols = DecimalFormatSymbols(Locale.getDefault())
tietAmount.setText(df.format(amount))
} else {
tietAmount.setText("")
}
}catch (e: Exception) {
Log.d(TAG, "Invoice error: " + e.message)