kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix error when trying to create payment in languages which use , instead of .
rodzic
0d4e109c72
commit
18cf55b156
|
@ -5,6 +5,7 @@ import androidx.annotation.NonNull;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.Currency;
|
import java.util.Currency;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class FiatMoney {
|
public class FiatMoney {
|
||||||
private final BigDecimal amount;
|
private final BigDecimal amount;
|
||||||
|
@ -37,7 +38,14 @@ public class FiatMoney {
|
||||||
* @return amount, rounded to the default fractional amount.
|
* @return amount, rounded to the default fractional amount.
|
||||||
*/
|
*/
|
||||||
public @NonNull String getDefaultPrecisionString() {
|
public @NonNull String getDefaultPrecisionString() {
|
||||||
NumberFormat formatter = NumberFormat.getInstance();
|
return getDefaultPrecisionString(Locale.getDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return amount, rounded to the default fractional amount.
|
||||||
|
*/
|
||||||
|
public @NonNull String getDefaultPrecisionString(@NonNull Locale locale) {
|
||||||
|
NumberFormat formatter = NumberFormat.getInstance(locale);
|
||||||
formatter.setMinimumFractionDigits(currency.getDefaultFractionDigits());
|
formatter.setMinimumFractionDigits(currency.getDefaultFractionDigits());
|
||||||
formatter.setGroupingUsed(false);
|
formatter.setGroupingUsed(false);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.signal.core.util.logging.Log
|
import org.signal.core.util.logging.Log
|
||||||
import org.signal.core.util.money.FiatMoney
|
import org.signal.core.util.money.FiatMoney
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entrypoint for Google Pay APIs
|
* Entrypoint for Google Pay APIs
|
||||||
|
@ -124,7 +125,7 @@ class GooglePayApi(
|
||||||
put("currencyCode", price.currency.currencyCode)
|
put("currencyCode", price.currency.currencyCode)
|
||||||
put("countryCode", "US")
|
put("countryCode", "US")
|
||||||
put("totalPriceStatus", "FINAL")
|
put("totalPriceStatus", "FINAL")
|
||||||
put("totalPrice", price.defaultPrecisionString)
|
put("totalPrice", price.getDefaultPrecisionString(Locale.US))
|
||||||
put("totalPriceLabel", label)
|
put("totalPriceLabel", label)
|
||||||
put("checkoutOption", "COMPLETE_IMMEDIATE_PURCHASE")
|
put("checkoutOption", "COMPLETE_IMMEDIATE_PURCHASE")
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue