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.
This commit is contained in:
Severiano Jaramillo 2019-09-25 22:23:22 -05:00
parent f6d00053db
commit eecc28bb06
2 changed files with 4 additions and 2 deletions

View file

@ -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))

View file

@ -70,6 +70,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:digits="0123456789.,"
android:inputType="numberDecimal"/>
</com.google.android.material.textfield.TextInputLayout>