kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix custom amount parsing for languages that utilize , separator.
rodzic
ec7e73bb7c
commit
8b23a409ef
|
@ -23,6 +23,7 @@ import org.thoughtcrime.securesms.util.InternetConnectionObserver
|
||||||
import org.thoughtcrime.securesms.util.PlatformCurrencyUtil
|
import org.thoughtcrime.securesms.util.PlatformCurrencyUtil
|
||||||
import org.thoughtcrime.securesms.util.livedata.Store
|
import org.thoughtcrime.securesms.util.livedata.Store
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
|
import java.text.DecimalFormat
|
||||||
import java.text.DecimalFormatSymbols
|
import java.text.DecimalFormatSymbols
|
||||||
import java.util.Currency
|
import java.util.Currency
|
||||||
|
|
||||||
|
@ -192,10 +193,12 @@ class BoostViewModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setCustomAmount(amount: String) {
|
fun setCustomAmount(amount: String) {
|
||||||
val bigDecimalAmount = if (amount.isEmpty() || amount == DecimalFormatSymbols.getInstance().decimalSeparator.toString()) {
|
val bigDecimalAmount: BigDecimal = if (amount.isEmpty() || amount == DecimalFormatSymbols.getInstance().decimalSeparator.toString()) {
|
||||||
BigDecimal.ZERO
|
BigDecimal.ZERO
|
||||||
} else {
|
} else {
|
||||||
BigDecimal(amount)
|
val decimalFormat = DecimalFormat.getInstance() as DecimalFormat
|
||||||
|
decimalFormat.isParseBigDecimal = true
|
||||||
|
decimalFormat.parse(amount) as BigDecimal
|
||||||
}
|
}
|
||||||
|
|
||||||
store.update { it.copy(customAmount = FiatMoney(bigDecimalAmount, it.customAmount.currency)) }
|
store.update { it.copy(customAmount = FiatMoney(bigDecimalAmount, it.customAmount.currency)) }
|
||||||
|
|
Ładowanie…
Reference in New Issue