force US locale for amount / bid values sent with sdk requests

This commit is contained in:
Akinwale Ariwodola 2020-05-22 15:40:06 +01:00
parent aa1b9972a8
commit 729d7fe2a1
5 changed files with 16 additions and 5 deletions

View file

@ -9,7 +9,9 @@ import org.json.JSONObject;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException;
@ -47,7 +49,7 @@ public class ChannelCreateUpdateTask extends AsyncTask<Void, Void, Claim> {
} else {
options.put("claim_id", claim.getClaimId());
}
options.put("bid", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT).format(deposit.doubleValue()));
options.put("bid", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).format(deposit.doubleValue()));
if (!Helper.isNullOrEmpty(claim.getTitle())) {
options.put("title", claim.getTitle());
}

View file

@ -9,8 +9,10 @@ import org.json.JSONObject;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException;
@ -38,7 +40,7 @@ public class PublishClaimTask extends AsyncTask<Void, Void, Claim> {
}
protected Claim doInBackground(Void... params) {
Claim.StreamMetadata metadata = (Claim.StreamMetadata) claim.getValue();
DecimalFormat amountFormat = new DecimalFormat(Helper.SDK_AMOUNT_FORMAT);
DecimalFormat amountFormat = new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US));
Map<String, Object> options = new HashMap<>();
options.put("blocking", true);

View file

@ -9,7 +9,9 @@ import org.json.JSONObject;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException;
@ -40,7 +42,7 @@ public class StreamRepostTask extends AsyncTask<Void, Void, Claim> {
try {
Map<String, Object> options = new HashMap<>();
options.put("name", name);
options.put("bid", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT).format(bid.doubleValue()));
options.put("bid", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).format(bid.doubleValue()));
options.put("claim_id", claimId);
options.put("channel_id", channelId);

View file

@ -5,7 +5,9 @@ import android.view.View;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException;
@ -39,7 +41,7 @@ public class SupportCreateTask extends AsyncTask<Void, Void, Boolean> {
try {
Map<String, Object> options = new HashMap<>();
options.put("claim_id", claimId);
options.put("amount", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT).format(amount.doubleValue()));
options.put("amount", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).format(amount.doubleValue()));
options.put("tip", tip);
Lbry.genericApiCall(Lbry.METHOD_SUPPORT_CREATE, options);
} catch (ApiCallException ex) {

View file

@ -30,7 +30,9 @@ import com.google.android.material.textfield.TextInputEditText;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.List;
import java.util.Locale;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
@ -381,7 +383,8 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
// wallet_send task
String recipientAddress = Helper.getValue(inputSendAddress.getText());
String amountString = Helper.getValue(inputSendAmount.getText());
String amount = new DecimalFormat(Helper.SDK_AMOUNT_FORMAT).format(new BigDecimal(amountString).doubleValue());
String amount = new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).
format(new BigDecimal(amountString).doubleValue());
disableSendControls();
WalletSendTask task = new WalletSendTask(recipientAddress, amount, walletSendProgress, new WalletSendTask.WalletSendHandler() {