diff options
author | Torsten Grote <t@grobox.de> | 2023-01-03 11:22:42 -0300 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2023-01-03 11:22:42 -0300 |
commit | 9bb3505277b8132c3fd0be52d9bbbc6078723ff2 (patch) | |
tree | 60688f65d464ee02834c4ae1d89b715f4e8f5640 /wallet | |
parent | 3cf3abb25adf040ad8e4e30d0fc8f311b2b1f4ee (diff) | |
download | taler-android-9bb3505277b8132c3fd0be52d9bbbc6078723ff2.tar.gz taler-android-9bb3505277b8132c3fd0be52d9bbbc6078723ff2.tar.bz2 taler-android-9bb3505277b8132c3fd0be52d9bbbc6078723ff2.zip |
[wallet] Don't allow entering invalid amounts
#0007350
Diffstat (limited to 'wallet')
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt | 4 | ||||
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt b/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt index 647512c..8ae96ad 100644 --- a/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt @@ -55,6 +55,7 @@ import androidx.fragment.app.activityViewModels import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.findNavController import net.taler.common.Amount +import net.taler.common.Amount.Companion.isValidAmountStr import net.taler.wallet.exchanges.ExchangeItem class ReceiveFundsFragment : Fragment() { @@ -136,7 +137,8 @@ private fun ReceiveFundsIntro( keyboardOptions = KeyboardOptions.Default.copy(keyboardType = Decimal), onValueChange = { input -> isError = false - text = input.filter { it.isDigit() || it == '.' } + val filtered = input.filter { it.isDigit() || it == '.' } + if (filtered.endsWith('.') || isValidAmountStr(filtered)) text = filtered }, isError = isError, label = { diff --git a/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt b/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt index 640fbf7..c5348a3 100644 --- a/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt @@ -52,6 +52,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController import net.taler.common.Amount +import net.taler.common.Amount.Companion.isValidAmountStr class SendFundsFragment : Fragment() { private val model: MainViewModel by activityViewModels() @@ -126,7 +127,8 @@ private fun SendFundsIntro( onValueChange = { input -> isError = false insufficientBalance = false - text = input.filter { it.isDigit() || it == '.' } + val filtered = input.filter { it.isDigit() || it == '.' } + if (filtered.endsWith('.') || isValidAmountStr(filtered)) text = filtered }, isError = isError || insufficientBalance, label = { |