From eecc28bb06fa669b399d54bf048707a8d317ee99 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Wed, 25 Sep 2019 22:23:22 -0500 Subject: [PATCH] Fix comma issue in SendTransactionFragment. - The amount field in the SendTransactionsFragment wasn't prepared to deal with Locales where the decimal separator is a comma. In order to deal with that internally, the commas in the amount are first converted to points before trying to convert the amount string to a double. --- .../fragments/SendTransactionFragment.kt | 5 +++-- app/src/main/res/layout/fragment_send_transaction.xml | 1 + 2 files changed, 4 insertions(+), 2 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 acaf8d9..6214504 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt @@ -457,7 +457,7 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand } private fun validateAmount() { - val txtAmount = tietAmount.text.toString() + val txtAmount = tietAmount.text.toString().replace(",", ".") if (mBalancesDetailsAdapter?.isEmpty != false) return val balance = mBalancesDetailsAdapter?.getItem(spAsset.selectedItemPosition) ?: return @@ -543,7 +543,8 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand // Create TransferOperation if (mNetworkService?.isConnected == true) { val balance = mBalancesDetailsAdapter!!.getItem(spAsset.selectedItemPosition)!! - val amount = (tietAmount.text.toString().toDouble() * Math.pow(10.0, balance.precision.toDouble())).toLong() + val amount = (tietAmount.text.toString().replace(",", ".").toDouble() + * Math.pow(10.0, balance.precision.toDouble())).toLong() val transferAmount = AssetAmount(UnsignedLong.valueOf(amount), Asset(balance.id)) diff --git a/app/src/main/res/layout/fragment_send_transaction.xml b/app/src/main/res/layout/fragment_send_transaction.xml index ece7a05..dc03729 100644 --- a/app/src/main/res/layout/fragment_send_transaction.xml +++ b/app/src/main/res/layout/fragment_send_transaction.xml @@ -70,6 +70,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:maxLines="1" + android:digits="0123456789.," android:inputType="numberDecimal"/>