From 46af45425981620fd541b4fccb072df9f39c63a1 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 26 Dec 2019 09:19:46 -0600 Subject: [PATCH] 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. --- .../fragments/SendTransactionFragment.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt index 3ac55bf..36016fe 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt @@ -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 } - val df = DecimalFormat("####." + "#".repeat(balanceDetail.precision)) - df.roundingMode = RoundingMode.CEILING - df.decimalFormatSymbols = DecimalFormatSymbols(Locale.getDefault()) - tietAmount.setText(df.format(amount)) + // 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)