Add sticky market price checkbox to settings: If sticky market price is selected market price does not change with currency selection, otherwise it is context sensitive.

This commit is contained in:
Manfred Karrer 2016-04-13 15:54:26 +02:00
parent 1c51efa704
commit b4fdb2e059
10 changed files with 113 additions and 41 deletions

View file

@ -114,7 +114,7 @@ public class CurrencyUtil {
// result.add(new CryptoCurrency("BCN", "Bytecoin"));
return result;
}
/**
* @return Sorted list of SEPA currencies with EUR as first item
@ -156,6 +156,10 @@ public class CurrencyUtil {
return !(isCryptoCurrency(currencyCode)) && Currency.getInstance(currencyCode) != null;
}
public static Optional<FiatCurrency> getFiatCurrency(String currencyCode) {
return allSortedFiatCurrencies.stream().filter(e -> e.getCode().equals(currencyCode)).findAny();
}
@SuppressWarnings("WeakerAccess")
public static boolean isCryptoCurrency(String currencyCode) {
return getAllSortedCryptoCurrencies().stream().filter(e -> e.getCode().equals(currencyCode)).findAny().isPresent();

View file

@ -108,6 +108,7 @@ public final class Preferences implements Persistable {
private long nonTradeTxFeePerKB = FeePolicy.getNonTradeFeePerKb().value;
private double maxPriceDistanceInPercent;
private boolean useInvertedMarketPrice;
private boolean useStickyMarketPrice = false;
// Observable wrappers
transient private final StringProperty btcDenominationProperty = new SimpleStringProperty(btcDenomination);
@ -158,6 +159,7 @@ public final class Preferences implements Persistable {
preferredTradeCurrency = persisted.getPreferredTradeCurrency();
defaultTradeCurrency = preferredTradeCurrency;
useTorForBitcoinJ = persisted.getUseTorForBitcoinJ();
useStickyMarketPrice = persisted.getUseStickyMarketPrice();
showOwnOffersInOfferBook = persisted.getShowOwnOffersInOfferBook();
maxPriceDistanceInPercent = persisted.getMaxPriceDistanceInPercent();
// Backward compatible to version 0.3.6. Can be removed after a while
@ -358,7 +360,11 @@ public final class Preferences implements Persistable {
setUseInvertedMarketPrice(!getUseInvertedMarketPrice());
return getUseInvertedMarketPrice();
}
public void setUseStickyMarketPrice(boolean useStickyMarketPrice) {
this.useStickyMarketPrice = useStickyMarketPrice;
storage.queueUpForSave();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getter
@ -476,6 +482,10 @@ public final class Preferences implements Persistable {
return maxPriceDistanceInPercent;
}
public boolean getUseStickyMarketPrice() {
return useStickyMarketPrice;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private