Use Utilities when accessing the default currency

This commit is contained in:
Manfred Karrer 2014-11-19 20:50:33 +01:00
parent c57aba7992
commit a23277a527
5 changed files with 12 additions and 18 deletions

View file

@ -46,8 +46,8 @@ public class FeePolicy {
switch (bitcoinNetwork) { switch (bitcoinNetwork) {
case TESTNET: case TESTNET:
createOfferFeeAddress = "mmm8BdTcHoc5wi75RmiQYsJ2Tr1NoZmM84"; createOfferFeeAddress = "mopJDiHncoveyy7S7FZTUNVbrCxazxvGrE";
takeOfferFeeAddress = "mmm8BdTcHoc5wi75RmiQYsJ2Tr1NoZmM84"; takeOfferFeeAddress = "mopJDiHncoveyy7S7FZTUNVbrCxazxvGrE";
break; break;
case MAINNET: case MAINNET:
// bitsquare donation address used for the moment... // bitsquare donation address used for the moment...

View file

@ -20,6 +20,7 @@ package io.bitsquare.gui.util;
import io.bitsquare.arbitrator.Arbitrator; import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import io.bitsquare.locale.CurrencyUtil;
import io.bitsquare.offer.Direction; import io.bitsquare.offer.Direction;
import io.bitsquare.offer.Offer; import io.bitsquare.offer.Offer;
import io.bitsquare.user.User; import io.bitsquare.user.User;
@ -33,7 +34,6 @@ import java.math.BigDecimal;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Currency;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -68,7 +68,7 @@ public class BSFormatter {
// no way to remove grouping separator). It seems to be not optimal for user input formatting. // no way to remove grouping separator). It seems to be not optimal for user input formatting.
private MonetaryFormat coinFormat = MonetaryFormat.BTC.repeatOptionalDecimals(2, 2); private MonetaryFormat coinFormat = MonetaryFormat.BTC.repeatOptionalDecimals(2, 2);
private String currencyCode = Currency.getInstance(Locale.getDefault()).getCurrencyCode(); private String currencyCode = CurrencyUtil.getDefaultCurrency().getCurrencyCode();
// format is like: 1,00 never more then 2 decimals // format is like: 1,00 never more then 2 decimals
private final MonetaryFormat fiatFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0).code(0, currencyCode); private final MonetaryFormat fiatFormat = MonetaryFormat.FIAT.repeatOptionalDecimals(0, 0).code(0, currencyCode);
@ -77,7 +77,7 @@ public class BSFormatter {
@Inject @Inject
public BSFormatter(User user) { public BSFormatter(User user) {
if (user.currentBankAccountProperty().get() == null) if (user.currentBankAccountProperty().get() == null)
setFiatCurrencyCode(Currency.getInstance(Locale.getDefault()).getCurrencyCode()); setFiatCurrencyCode(CurrencyUtil.getDefaultCurrency().getCurrencyCode());
else if (user.currentBankAccountProperty().get() != null) else if (user.currentBankAccountProperty().get() != null)
setFiatCurrencyCode(user.currentBankAccountProperty().get().getCurrency().getCurrencyCode()); setFiatCurrencyCode(user.currentBankAccountProperty().get().getCurrency().getCurrencyCode());

View file

@ -18,11 +18,9 @@
package io.bitsquare.gui.util.validation; package io.bitsquare.gui.util.validation;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
import io.bitsquare.locale.CurrencyUtil;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import java.util.Currency;
import java.util.Locale;
import javax.inject.Inject; import javax.inject.Inject;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -46,7 +44,7 @@ public final class FiatValidator extends NumberValidator {
public FiatValidator(User user) { public FiatValidator(User user) {
if (user != null) { if (user != null) {
if (user.currentBankAccountProperty().get() == null) if (user.currentBankAccountProperty().get() == null)
setFiatCurrencyCode(Currency.getInstance(Locale.getDefault()).getCurrencyCode()); setFiatCurrencyCode(CurrencyUtil.getDefaultCurrency().getCurrencyCode());
else if (user.currentBankAccountProperty().get() != null) else if (user.currentBankAccountProperty().get() != null)
setFiatCurrencyCode(user.currentBankAccountProperty().get().getCurrency().getCurrencyCode()); setFiatCurrencyCode(user.currentBankAccountProperty().get().getCurrency().getCurrencyCode());

View file

@ -18,11 +18,9 @@
package io.bitsquare.gui.util.validation; package io.bitsquare.gui.util.validation;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
import io.bitsquare.locale.CurrencyUtil;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import java.util.Currency;
import java.util.Locale;
import javax.inject.Inject; import javax.inject.Inject;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -46,7 +44,7 @@ public final class OptionalFiatValidator extends NumberValidator {
public OptionalFiatValidator(User user) { public OptionalFiatValidator(User user) {
if (user != null) { if (user != null) {
if (user.currentBankAccountProperty().get() == null) if (user.currentBankAccountProperty().get() == null)
setFiatCurrencyCode(Currency.getInstance(Locale.getDefault()).getCurrencyCode()); setFiatCurrencyCode(CurrencyUtil.getDefaultCurrency().getCurrencyCode());
else if (user.currentBankAccountProperty().get() != null) else if (user.currentBankAccountProperty().get() != null)
setFiatCurrencyCode(user.currentBankAccountProperty().get().getCurrency().getCurrencyCode()); setFiatCurrencyCode(user.currentBankAccountProperty().get().getCurrency().getCurrencyCode());

View file

@ -20,7 +20,6 @@ package io.bitsquare.locale;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Currency; import java.util.Currency;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Set; import java.util.Set;
public class CurrencyUtil { public class CurrencyUtil {
@ -47,9 +46,8 @@ public class CurrencyUtil {
final List<Currency> resultList = new ArrayList<>(mainCurrencies); final List<Currency> resultList = new ArrayList<>(mainCurrencies);
resultList.addAll(allCurrenciesList); resultList.addAll(allCurrenciesList);
Currency defaultCurrency = Currency.getInstance(Locale.getDefault()); resultList.remove(getDefaultCurrency());
resultList.remove(defaultCurrency); resultList.add(0, getDefaultCurrency());
resultList.add(0, defaultCurrency);
return resultList; return resultList;
} }
@ -57,6 +55,6 @@ public class CurrencyUtil {
public static Currency getDefaultCurrency() { public static Currency getDefaultCurrency() {
// TODO Only display EUR for the moment // TODO Only display EUR for the moment
return Currency.getInstance("EUR"); return Currency.getInstance("EUR");
// NumberFormat.getNumberInstance(Locale.getDefault()).getCurrency(); // return Currency.getInstance(Locale.getDefault());
} }
} }