refactor buy/sell tab functionality #1351

This commit is contained in:
woodser 2024-11-03 10:16:21 -05:00
parent f470112cae
commit 0c76c48c65
24 changed files with 363 additions and 351 deletions

View file

@ -73,14 +73,6 @@ public class CurrencyUtil {
private static String baseCurrencyCode = "XMR"; private static String baseCurrencyCode = "XMR";
private static List<TraditionalCurrency> getTraditionalNonFiatCurrencies() {
return Arrays.asList(
new TraditionalCurrency("XAG", "Silver"),
new TraditionalCurrency("XAU", "Gold"),
new TraditionalCurrency("XGB", "Goldback")
);
}
// Calls to isTraditionalCurrency and isCryptoCurrency are very frequent so we use a cache of the results. // Calls to isTraditionalCurrency and isCryptoCurrency are very frequent so we use a cache of the results.
// The main improvement was already achieved with using memoize for the source maps, but // The main improvement was already achieved with using memoize for the source maps, but
// the caching still reduces performance costs by about 20% for isCryptoCurrency (1752 ms vs 2121 ms) and about 50% // the caching still reduces performance costs by about 20% for isCryptoCurrency (1752 ms vs 2121 ms) and about 50%
@ -124,6 +116,14 @@ public class CurrencyUtil {
return new ArrayList<>(traditionalCurrencyMapSupplier.get().values()); return new ArrayList<>(traditionalCurrencyMapSupplier.get().values());
} }
public static List<TraditionalCurrency> getTraditionalNonFiatCurrencies() {
return Arrays.asList(
new TraditionalCurrency("XAG", "Silver"),
new TraditionalCurrency("XAU", "Gold"),
new TraditionalCurrency("XGB", "Goldback")
);
}
public static Collection<TraditionalCurrency> getAllSortedTraditionalCurrencies(Comparator comparator) { public static Collection<TraditionalCurrency> getAllSortedTraditionalCurrencies(Comparator comparator) {
return (List<TraditionalCurrency>) getAllSortedTraditionalCurrencies().stream() return (List<TraditionalCurrency>) getAllSortedTraditionalCurrencies().stream()
.sorted(comparator) .sorted(comparator)

View file

@ -139,6 +139,10 @@ public abstract class PaymentAccount implements PersistablePayload {
return getSingleTradeCurrency() == null || CurrencyUtil.isFiatCurrency(getSingleTradeCurrency().getCode()); // TODO: check if trade currencies contain fiat return getSingleTradeCurrency() == null || CurrencyUtil.isFiatCurrency(getSingleTradeCurrency().getCode()); // TODO: check if trade currencies contain fiat
} }
public boolean isCryptoCurrency() {
return getSingleTradeCurrency() != null && CurrencyUtil.isCryptoCurrency(getSingleTradeCurrency().getCode());
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER // PROTO BUFFER

View file

@ -566,6 +566,16 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
requestPersistence(); requestPersistence();
} }
public void setBuyScreenOtherCurrencyCode(String buyScreenCurrencyCode) {
prefPayload.setBuyScreenOtherCurrencyCode(buyScreenCurrencyCode);
requestPersistence();
}
public void setSellScreenOtherCurrencyCode(String sellScreenCurrencyCode) {
prefPayload.setSellScreenOtherCurrencyCode(sellScreenCurrencyCode);
requestPersistence();
}
public void setIgnoreTradersList(List<String> ignoreTradersList) { public void setIgnoreTradersList(List<String> ignoreTradersList) {
prefPayload.setIgnoreTradersList(ignoreTradersList); prefPayload.setIgnoreTradersList(ignoreTradersList);
requestPersistence(); requestPersistence();

View file

@ -77,6 +77,10 @@ public final class PreferencesPayload implements PersistableEnvelope {
private String buyScreenCryptoCurrencyCode; private String buyScreenCryptoCurrencyCode;
@Nullable @Nullable
private String sellScreenCryptoCurrencyCode; private String sellScreenCryptoCurrencyCode;
@Nullable
private String buyScreenOtherCurrencyCode;
@Nullable
private String sellScreenOtherCurrencyCode;
private int tradeStatisticsTickUnitIndex = 3; private int tradeStatisticsTickUnitIndex = 3;
private boolean resyncSpvRequested; private boolean resyncSpvRequested;
private boolean sortMarketCurrenciesNumerically = true; private boolean sortMarketCurrenciesNumerically = true;
@ -212,6 +216,8 @@ public final class PreferencesPayload implements PersistableEnvelope {
Optional.ofNullable(sellScreenCurrencyCode).ifPresent(builder::setSellScreenCurrencyCode); Optional.ofNullable(sellScreenCurrencyCode).ifPresent(builder::setSellScreenCurrencyCode);
Optional.ofNullable(buyScreenCryptoCurrencyCode).ifPresent(builder::setBuyScreenCryptoCurrencyCode); Optional.ofNullable(buyScreenCryptoCurrencyCode).ifPresent(builder::setBuyScreenCryptoCurrencyCode);
Optional.ofNullable(sellScreenCryptoCurrencyCode).ifPresent(builder::setSellScreenCryptoCurrencyCode); Optional.ofNullable(sellScreenCryptoCurrencyCode).ifPresent(builder::setSellScreenCryptoCurrencyCode);
Optional.ofNullable(buyScreenOtherCurrencyCode).ifPresent(builder::setBuyScreenOtherCurrencyCode);
Optional.ofNullable(sellScreenOtherCurrencyCode).ifPresent(builder::setSellScreenOtherCurrencyCode);
Optional.ofNullable(selectedPaymentAccountForCreateOffer).ifPresent( Optional.ofNullable(selectedPaymentAccountForCreateOffer).ifPresent(
account -> builder.setSelectedPaymentAccountForCreateOffer(selectedPaymentAccountForCreateOffer.toProtoMessage())); account -> builder.setSelectedPaymentAccountForCreateOffer(selectedPaymentAccountForCreateOffer.toProtoMessage()));
Optional.ofNullable(bridgeAddresses).ifPresent(builder::addAllBridgeAddresses); Optional.ofNullable(bridgeAddresses).ifPresent(builder::addAllBridgeAddresses);
@ -260,6 +266,8 @@ public final class PreferencesPayload implements PersistableEnvelope {
ProtoUtil.stringOrNullFromProto(proto.getSellScreenCurrencyCode()), ProtoUtil.stringOrNullFromProto(proto.getSellScreenCurrencyCode()),
ProtoUtil.stringOrNullFromProto(proto.getBuyScreenCryptoCurrencyCode()), ProtoUtil.stringOrNullFromProto(proto.getBuyScreenCryptoCurrencyCode()),
ProtoUtil.stringOrNullFromProto(proto.getSellScreenCryptoCurrencyCode()), ProtoUtil.stringOrNullFromProto(proto.getSellScreenCryptoCurrencyCode()),
ProtoUtil.stringOrNullFromProto(proto.getBuyScreenOtherCurrencyCode()),
ProtoUtil.stringOrNullFromProto(proto.getSellScreenOtherCurrencyCode()),
proto.getTradeStatisticsTickUnitIndex(), proto.getTradeStatisticsTickUnitIndex(),
proto.getResyncSpvRequested(), proto.getResyncSpvRequested(),
proto.getSortMarketCurrenciesNumerically(), proto.getSortMarketCurrenciesNumerically(),

View file

@ -207,6 +207,7 @@ shared.crypto=Crypto
shared.traditional=Traditional shared.traditional=Traditional
shared.otherAssets=other assets shared.otherAssets=other assets
shared.other=Other shared.other=Other
shared.preciousMetals=Precious Metals
shared.all=All shared.all=All
shared.edit=Edit shared.edit=Edit
shared.advancedOptions=Advanced options shared.advancedOptions=Advanced options
@ -245,8 +246,8 @@ shared.taker=Taker
#################################################################### ####################################################################
mainView.menu.market=Market mainView.menu.market=Market
mainView.menu.buy=Buy mainView.menu.buyXmr=Buy XMR
mainView.menu.sell=Sell mainView.menu.sellXmr=Sell XMR
mainView.menu.portfolio=Portfolio mainView.menu.portfolio=Portfolio
mainView.menu.funds=Funds mainView.menu.funds=Funds
mainView.menu.support=Support mainView.menu.support=Support

View file

@ -245,8 +245,8 @@ shared.taker=Alıcı
#################################################################### ####################################################################
mainView.menu.market=Piyasa mainView.menu.market=Piyasa
mainView.menu.buy=Satın Al mainView.menu.buyXmr=XMR Satın Al
mainView.menu.sell=Sat mainView.menu.sellXmr=XMR Sat
mainView.menu.portfolio=Portföy mainView.menu.portfolio=Portföy
mainView.menu.funds=Fonlar mainView.menu.funds=Fonlar
mainView.menu.support=Destek mainView.menu.support=Destek

View file

@ -165,8 +165,8 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
MainView.rootContainer.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT); MainView.rootContainer.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
ToggleButton marketButton = new NavButton(MarketView.class, Res.get("mainView.menu.market").toUpperCase()); ToggleButton marketButton = new NavButton(MarketView.class, Res.get("mainView.menu.market").toUpperCase());
ToggleButton buyButton = new NavButton(BuyOfferView.class, Res.get("mainView.menu.buy").toUpperCase()); ToggleButton buyButton = new NavButton(BuyOfferView.class, Res.get("mainView.menu.buyXmr").toUpperCase());
ToggleButton sellButton = new NavButton(SellOfferView.class, Res.get("mainView.menu.sell").toUpperCase()); ToggleButton sellButton = new NavButton(SellOfferView.class, Res.get("mainView.menu.sellXmr").toUpperCase());
ToggleButton portfolioButton = new NavButton(PortfolioView.class, Res.get("mainView.menu.portfolio").toUpperCase()); ToggleButton portfolioButton = new NavButton(PortfolioView.class, Res.get("mainView.menu.portfolio").toUpperCase());
ToggleButton fundsButton = new NavButton(FundsView.class, Res.get("mainView.menu.funds").toUpperCase()); ToggleButton fundsButton = new NavButton(FundsView.class, Res.get("mainView.menu.funds").toUpperCase());

View file

@ -425,14 +425,10 @@ class OfferBookChartViewModel extends ActivatableViewModel {
if (isSellOffer(direction)) { if (isSellOffer(direction)) {
if (CurrencyUtil.isTraditionalCurrency(getCurrencyCode())) { if (CurrencyUtil.isTraditionalCurrency(getCurrencyCode())) {
preferences.setBuyScreenCurrencyCode(getCurrencyCode()); preferences.setBuyScreenCurrencyCode(getCurrencyCode());
} else if (!getCurrencyCode().equals(GUIUtil.TOP_CRYPTO.getCode())) {
preferences.setBuyScreenCryptoCurrencyCode(getCurrencyCode());
} }
} else { } else {
if (CurrencyUtil.isTraditionalCurrency(getCurrencyCode())) { if (CurrencyUtil.isTraditionalCurrency(getCurrencyCode())) {
preferences.setSellScreenCurrencyCode(getCurrencyCode()); preferences.setSellScreenCurrencyCode(getCurrencyCode());
} else if (!getCurrencyCode().equals(GUIUtil.TOP_CRYPTO.getCode())) {
preferences.setSellScreenCryptoCurrencyCode(getCurrencyCode());
} }
} }
} }

View file

@ -57,7 +57,6 @@ import java.util.Comparator;
import static java.util.Comparator.comparing; import static java.util.Comparator.comparing;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
@ -257,10 +256,10 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
private Optional<PaymentAccount> getAnyPaymentAccount() { private Optional<PaymentAccount> getAnyPaymentAccount() {
if (CurrencyUtil.isFiatCurrency(tradeCurrency.getCode())) { if (CurrencyUtil.isFiatCurrency(tradeCurrency.getCode())) {
return paymentAccounts.stream().filter(paymentAccount1 -> paymentAccount1.isFiat()).findAny(); return paymentAccounts.stream().filter(paymentAccount1 -> paymentAccount1.isFiat()).findAny();
} else if (CurrencyUtil.isCryptoCurrency(tradeCurrency.getCode())) {
return paymentAccounts.stream().filter(paymentAccount1 -> paymentAccount1.isCryptoCurrency()).findAny();
} else { } else {
return paymentAccounts.stream().filter(paymentAccount1 -> !paymentAccount1.isFiat() && return paymentAccounts.stream().filter(paymentAccount1 -> paymentAccount1.getTradeCurrency().isPresent()).findAny();
paymentAccount1.getTradeCurrency().isPresent() &&
!Objects.equals(paymentAccount1.getTradeCurrency().get().getCode(), GUIUtil.TOP_CRYPTO.getCode())).findAny();
} }
} }

View file

@ -33,10 +33,10 @@ import haveno.desktop.common.view.View;
import haveno.desktop.common.view.ViewLoader; import haveno.desktop.common.view.ViewLoader;
import haveno.desktop.main.MainView; import haveno.desktop.main.MainView;
import haveno.desktop.main.offer.createoffer.CreateOfferView; import haveno.desktop.main.offer.createoffer.CreateOfferView;
import haveno.desktop.main.offer.offerbook.XmrOfferBookView; import haveno.desktop.main.offer.offerbook.FiatOfferBookView;
import haveno.desktop.main.offer.offerbook.OfferBookView; import haveno.desktop.main.offer.offerbook.OfferBookView;
import haveno.desktop.main.offer.offerbook.CryptoOfferBookView;
import haveno.desktop.main.offer.offerbook.OtherOfferBookView; import haveno.desktop.main.offer.offerbook.OtherOfferBookView;
import haveno.desktop.main.offer.offerbook.TopCryptoOfferBookView;
import haveno.desktop.main.offer.takeoffer.TakeOfferView; import haveno.desktop.main.offer.takeoffer.TakeOfferView;
import haveno.desktop.util.GUIUtil; import haveno.desktop.util.GUIUtil;
import haveno.network.p2p.P2PService; import haveno.network.p2p.P2PService;
@ -50,9 +50,9 @@ import java.util.Optional;
public abstract class OfferView extends ActivatableView<TabPane, Void> { public abstract class OfferView extends ActivatableView<TabPane, Void> {
private OfferBookView<?, ?> xmrOfferBookView, topCryptoOfferBookView, otherOfferBookView; private OfferBookView<?, ?> fiatOfferBookView, cryptoOfferBookView, otherOfferBookView;
private Tab xmrOfferBookTab, topCryptoOfferBookTab, otherOfferBookTab; private Tab fiatOfferBookTab, cryptoOfferBookTab, otherOfferBookTab;
private final ViewLoader viewLoader; private final ViewLoader viewLoader;
private final Navigation navigation; private final Navigation navigation;
@ -95,17 +95,17 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
tabChangeListener = (observableValue, oldValue, newValue) -> { tabChangeListener = (observableValue, oldValue, newValue) -> {
UserThread.execute(() -> { UserThread.execute(() -> {
if (newValue != null) { if (newValue != null) {
if (newValue.equals(xmrOfferBookTab)) { if (newValue.equals(fiatOfferBookTab)) {
if (xmrOfferBookView != null) { if (fiatOfferBookView != null) {
xmrOfferBookView.onTabSelected(true); fiatOfferBookView.onTabSelected(true);
} else { } else {
loadView(XmrOfferBookView.class, null, null); loadView(FiatOfferBookView.class, null, null);
} }
} else if (newValue.equals(topCryptoOfferBookTab)) { } else if (newValue.equals(cryptoOfferBookTab)) {
if (topCryptoOfferBookView != null) { if (cryptoOfferBookView != null) {
topCryptoOfferBookView.onTabSelected(true); cryptoOfferBookView.onTabSelected(true);
} else { } else {
loadView(TopCryptoOfferBookView.class, null, null); loadView(CryptoOfferBookView.class, null, null);
} }
} else if (newValue.equals(otherOfferBookTab)) { } else if (newValue.equals(otherOfferBookTab)) {
if (otherOfferBookView != null) { if (otherOfferBookView != null) {
@ -116,10 +116,10 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
} }
} }
if (oldValue != null) { if (oldValue != null) {
if (oldValue.equals(xmrOfferBookTab) && xmrOfferBookView != null) { if (oldValue.equals(fiatOfferBookTab) && fiatOfferBookView != null) {
xmrOfferBookView.onTabSelected(false); fiatOfferBookView.onTabSelected(false);
} else if (oldValue.equals(topCryptoOfferBookTab) && topCryptoOfferBookView != null) { } else if (oldValue.equals(cryptoOfferBookTab) && cryptoOfferBookView != null) {
topCryptoOfferBookView.onTabSelected(false); cryptoOfferBookView.onTabSelected(false);
} else if (oldValue.equals(otherOfferBookTab) && otherOfferBookView != null) { } else if (oldValue.equals(otherOfferBookTab) && otherOfferBookView != null) {
otherOfferBookView.onTabSelected(false); otherOfferBookView.onTabSelected(false);
} }
@ -154,14 +154,8 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener); root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
navigation.addListener(navigationListener); navigation.addListener(navigationListener);
if (xmrOfferBookView == null) { if (fiatOfferBookView == null) {
navigation.navigateTo(MainView.class, this.getClass(), XmrOfferBookView.class); navigation.navigateTo(MainView.class, this.getClass(), FiatOfferBookView.class);
}
GUIUtil.updateTopCrypto(preferences);
if (topCryptoOfferBookTab != null) {
topCryptoOfferBookTab.setText(GUIUtil.TOP_CRYPTO.getName().toUpperCase());
} }
} }
@ -179,66 +173,65 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
if (OfferBookView.class.isAssignableFrom(viewClass)) { if (OfferBookView.class.isAssignableFrom(viewClass)) {
if (viewClass == XmrOfferBookView.class && xmrOfferBookTab != null && xmrOfferBookView != null) { if (viewClass == FiatOfferBookView.class && fiatOfferBookTab != null && fiatOfferBookView != null) {
if (childViewClass == null) { if (childViewClass == null) {
xmrOfferBookTab.setContent(xmrOfferBookView.getRoot()); fiatOfferBookTab.setContent(fiatOfferBookView.getRoot());
} else if (childViewClass == TakeOfferView.class) { } else if (childViewClass == TakeOfferView.class) {
loadTakeViewClass(viewClass, childViewClass, xmrOfferBookTab); loadTakeViewClass(viewClass, childViewClass, fiatOfferBookTab);
} else { } else {
loadCreateViewClass(xmrOfferBookView, viewClass, childViewClass, xmrOfferBookTab, (PaymentMethod) data); loadCreateViewClass(fiatOfferBookView, viewClass, childViewClass, fiatOfferBookTab, (PaymentMethod) data);
} }
tabPane.getSelectionModel().select(xmrOfferBookTab); tabPane.getSelectionModel().select(fiatOfferBookTab);
} else if (viewClass == TopCryptoOfferBookView.class && topCryptoOfferBookTab != null && topCryptoOfferBookView != null) { } else if (viewClass == CryptoOfferBookView.class && cryptoOfferBookTab != null && cryptoOfferBookView != null) {
if (childViewClass == null) { if (childViewClass == null) {
topCryptoOfferBookTab.setContent(topCryptoOfferBookView.getRoot()); cryptoOfferBookTab.setContent(cryptoOfferBookView.getRoot());
} else if (childViewClass == TakeOfferView.class) { } else if (childViewClass == TakeOfferView.class) {
loadTakeViewClass(viewClass, childViewClass, topCryptoOfferBookTab); loadTakeViewClass(viewClass, childViewClass, cryptoOfferBookTab);
} else { } else {
tradeCurrency = GUIUtil.TOP_CRYPTO; // add sanity check in case of app restart
loadCreateViewClass(topCryptoOfferBookView, viewClass, childViewClass, topCryptoOfferBookTab, (PaymentMethod) data);
}
tabPane.getSelectionModel().select(topCryptoOfferBookTab);
} else if (viewClass == OtherOfferBookView.class && otherOfferBookTab != null && otherOfferBookView != null) {
if (childViewClass == null) {
otherOfferBookTab.setContent(otherOfferBookView.getRoot());
} else if (childViewClass == TakeOfferView.class) {
loadTakeViewClass(viewClass, childViewClass, otherOfferBookTab);
} else {
//add sanity check in case of app restart
if (CurrencyUtil.isTraditionalCurrency(tradeCurrency.getCode())) { if (CurrencyUtil.isTraditionalCurrency(tradeCurrency.getCode())) {
Optional<TradeCurrency> tradeCurrencyOptional = (this.direction == OfferDirection.SELL) ? Optional<TradeCurrency> tradeCurrencyOptional = (this.direction == OfferDirection.SELL) ?
CurrencyUtil.getTradeCurrency(preferences.getSellScreenCryptoCurrencyCode()) : CurrencyUtil.getTradeCurrency(preferences.getSellScreenCryptoCurrencyCode()) :
CurrencyUtil.getTradeCurrency(preferences.getBuyScreenCryptoCurrencyCode()); CurrencyUtil.getTradeCurrency(preferences.getBuyScreenCryptoCurrencyCode());
tradeCurrency = tradeCurrencyOptional.isEmpty() ? OfferViewUtil.getAnyOfMainCryptoCurrencies() : tradeCurrencyOptional.get(); tradeCurrency = tradeCurrencyOptional.isEmpty() ? OfferViewUtil.getAnyOfMainCryptoCurrencies() : tradeCurrencyOptional.get();
} }
loadCreateViewClass(cryptoOfferBookView, viewClass, childViewClass, cryptoOfferBookTab, (PaymentMethod) data);
}
tabPane.getSelectionModel().select(cryptoOfferBookTab);
} else if (viewClass == OtherOfferBookView.class && otherOfferBookTab != null && otherOfferBookView != null) {
if (childViewClass == null) {
otherOfferBookTab.setContent(otherOfferBookView.getRoot());
} else if (childViewClass == TakeOfferView.class) {
loadTakeViewClass(viewClass, childViewClass, otherOfferBookTab);
} else {
loadCreateViewClass(otherOfferBookView, viewClass, childViewClass, otherOfferBookTab, (PaymentMethod) data); loadCreateViewClass(otherOfferBookView, viewClass, childViewClass, otherOfferBookTab, (PaymentMethod) data);
} }
tabPane.getSelectionModel().select(otherOfferBookTab); tabPane.getSelectionModel().select(otherOfferBookTab);
} else { } else {
if (xmrOfferBookTab == null) { if (fiatOfferBookTab == null) {
xmrOfferBookTab = new Tab(Res.getBaseCurrencyName().toUpperCase()); fiatOfferBookTab = new Tab(Res.get("shared.fiat").toUpperCase());
xmrOfferBookTab.setClosable(false); fiatOfferBookTab.setClosable(false);
topCryptoOfferBookTab = new Tab(GUIUtil.TOP_CRYPTO.getName().toUpperCase()); cryptoOfferBookTab = new Tab(Res.get("shared.crypto").toUpperCase());
topCryptoOfferBookTab.setClosable(false); cryptoOfferBookTab.setClosable(false);
otherOfferBookTab = new Tab(Res.get("shared.other").toUpperCase()); otherOfferBookTab = new Tab(Res.get("shared.preciousMetals").toUpperCase());
otherOfferBookTab.setClosable(false); otherOfferBookTab.setClosable(false);
tabPane.getTabs().addAll(xmrOfferBookTab, topCryptoOfferBookTab, otherOfferBookTab); tabPane.getTabs().addAll(fiatOfferBookTab, cryptoOfferBookTab, otherOfferBookTab);
} }
if (viewClass == XmrOfferBookView.class) { if (viewClass == FiatOfferBookView.class) {
xmrOfferBookView = (XmrOfferBookView) viewLoader.load(XmrOfferBookView.class); fiatOfferBookView = (FiatOfferBookView) viewLoader.load(FiatOfferBookView.class);
xmrOfferBookView.setOfferActionHandler(offerActionHandler); fiatOfferBookView.setOfferActionHandler(offerActionHandler);
xmrOfferBookView.setDirection(direction); fiatOfferBookView.setDirection(direction);
xmrOfferBookView.onTabSelected(true); fiatOfferBookView.onTabSelected(true);
tabPane.getSelectionModel().select(xmrOfferBookTab); tabPane.getSelectionModel().select(fiatOfferBookTab);
xmrOfferBookTab.setContent(xmrOfferBookView.getRoot()); fiatOfferBookTab.setContent(fiatOfferBookView.getRoot());
} else if (viewClass == TopCryptoOfferBookView.class) { } else if (viewClass == CryptoOfferBookView.class) {
topCryptoOfferBookView = (TopCryptoOfferBookView) viewLoader.load(TopCryptoOfferBookView.class); cryptoOfferBookView = (CryptoOfferBookView) viewLoader.load(CryptoOfferBookView.class);
topCryptoOfferBookView.setOfferActionHandler(offerActionHandler); cryptoOfferBookView.setOfferActionHandler(offerActionHandler);
topCryptoOfferBookView.setDirection(direction); cryptoOfferBookView.setDirection(direction);
topCryptoOfferBookView.onTabSelected(true); cryptoOfferBookView.onTabSelected(true);
tabPane.getSelectionModel().select(topCryptoOfferBookTab); tabPane.getSelectionModel().select(cryptoOfferBookTab);
topCryptoOfferBookTab.setContent(topCryptoOfferBookView.getRoot()); cryptoOfferBookTab.setContent(cryptoOfferBookView.getRoot());
} else if (viewClass == OtherOfferBookView.class) { } else if (viewClass == OtherOfferBookView.class) {
otherOfferBookView = (OtherOfferBookView) viewLoader.load(OtherOfferBookView.class); otherOfferBookView = (OtherOfferBookView) viewLoader.load(OtherOfferBookView.class);
otherOfferBookView.setOfferActionHandler(offerActionHandler); otherOfferBookView.setOfferActionHandler(offerActionHandler);
@ -265,11 +258,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
// in different graphs // in different graphs
view = viewLoader.load(childViewClass); view = viewLoader.load(childViewClass);
// Invert direction for non-Fiat trade currencies -> BUY BCH is to SELL Monero ((CreateOfferView) view).initWithData(direction, tradeCurrency, offerActionHandler);
OfferDirection offerDirection = CurrencyUtil.isFiatCurrency(tradeCurrency.getCode()) ? direction :
direction == OfferDirection.BUY ? OfferDirection.SELL : OfferDirection.BUY;
((CreateOfferView) view).initWithData(offerDirection, tradeCurrency, offerActionHandler);
((SelectableView) view).onTabSelected(true); ((SelectableView) view).onTabSelected(true);
@ -329,9 +318,9 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
private Class<? extends OfferBookView<?, ?>> getOfferBookViewClassFor(String currencyCode) { private Class<? extends OfferBookView<?, ?>> getOfferBookViewClassFor(String currencyCode) {
Class<? extends OfferBookView<?, ?>> offerBookViewClass; Class<? extends OfferBookView<?, ?>> offerBookViewClass;
if (CurrencyUtil.isFiatCurrency(currencyCode)) { if (CurrencyUtil.isFiatCurrency(currencyCode)) {
offerBookViewClass = XmrOfferBookView.class; offerBookViewClass = FiatOfferBookView.class;
} else if (currencyCode.equals(GUIUtil.TOP_CRYPTO.getCode())) { } else if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
offerBookViewClass = TopCryptoOfferBookView.class; offerBookViewClass = CryptoOfferBookView.class;
} else { } else {
offerBookViewClass = OtherOfferBookView.class; offerBookViewClass = OtherOfferBookView.class;
} }

View file

@ -22,16 +22,16 @@ import haveno.core.locale.CryptoCurrency;
import haveno.core.locale.CurrencyUtil; import haveno.core.locale.CurrencyUtil;
import haveno.core.locale.Res; import haveno.core.locale.Res;
import haveno.core.locale.TradeCurrency; import haveno.core.locale.TradeCurrency;
import haveno.core.locale.TraditionalCurrency;
import haveno.core.offer.Offer; import haveno.core.offer.Offer;
import haveno.core.offer.OfferDirection; import haveno.core.offer.OfferDirection;
import haveno.core.xmr.wallet.XmrWalletService; import haveno.core.xmr.wallet.XmrWalletService;
import haveno.desktop.components.AutoTooltipLabel; import haveno.desktop.components.AutoTooltipLabel;
import haveno.desktop.main.offer.offerbook.XmrOfferBookView; import haveno.desktop.main.offer.offerbook.FiatOfferBookView;
import haveno.desktop.main.offer.offerbook.OfferBookView; import haveno.desktop.main.offer.offerbook.OfferBookView;
import haveno.desktop.main.offer.offerbook.CryptoOfferBookView;
import haveno.desktop.main.offer.offerbook.OtherOfferBookView; import haveno.desktop.main.offer.offerbook.OtherOfferBookView;
import haveno.desktop.main.offer.offerbook.TopCryptoOfferBookView;
import haveno.desktop.main.overlays.popups.Popup; import haveno.desktop.main.overlays.popups.Popup;
import haveno.desktop.util.GUIUtil;
import javafx.geometry.HPos; import javafx.geometry.HPos;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.VPos; import javafx.geometry.VPos;
@ -44,7 +44,6 @@ import monero.daemon.model.MoneroSubmitTxResult;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.HashMap; import java.util.HashMap;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -90,10 +89,10 @@ public class OfferViewUtil {
public static Class<? extends OfferBookView<?, ?>> getOfferBookViewClass(String currencyCode) { public static Class<? extends OfferBookView<?, ?>> getOfferBookViewClass(String currencyCode) {
Class<? extends OfferBookView<?, ?>> offerBookViewClazz; Class<? extends OfferBookView<?, ?>> offerBookViewClazz;
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) { if (CurrencyUtil.isFiatCurrency(currencyCode)) {
offerBookViewClazz = XmrOfferBookView.class; offerBookViewClazz = FiatOfferBookView.class;
} else if (currencyCode.equals(GUIUtil.TOP_CRYPTO.getCode())) { } else if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
offerBookViewClazz = TopCryptoOfferBookView.class; offerBookViewClazz = CryptoOfferBookView.class;
} else { } else {
offerBookViewClazz = OtherOfferBookView.class; offerBookViewClazz = OtherOfferBookView.class;
} }
@ -109,7 +108,7 @@ public class OfferViewUtil {
} }
public static boolean isShownAsSellOffer(String currencyCode, OfferDirection direction) { public static boolean isShownAsSellOffer(String currencyCode, OfferDirection direction) {
return CurrencyUtil.isFiatCurrency(currencyCode) == (direction == OfferDirection.SELL); return direction == OfferDirection.SELL;
} }
public static boolean isShownAsBuyOffer(Offer offer) { public static boolean isShownAsBuyOffer(Offer offer) {
@ -124,10 +123,18 @@ public class OfferViewUtil {
return getMainCryptoCurrencies().findAny().get(); return getMainCryptoCurrencies().findAny().get();
} }
public static TradeCurrency getAnyOfOtherCurrencies() {
return getOtherCurrencies().findAny().get();
}
@NotNull @NotNull
public static Stream<CryptoCurrency> getMainCryptoCurrencies() { public static Stream<CryptoCurrency> getMainCryptoCurrencies() {
return CurrencyUtil.getMainCryptoCurrencies().stream().filter(cryptoCurrency -> return CurrencyUtil.getMainCryptoCurrencies().stream();
!Objects.equals(cryptoCurrency.getCode(), GUIUtil.TOP_CRYPTO.getCode())); }
@NotNull
public static Stream<TraditionalCurrency> getOtherCurrencies() {
return CurrencyUtil.getTraditionalNonFiatCurrencies().stream();
} }
public static void submitTransactionHex(XmrWalletService xmrWalletService, public static void submitTransactionHex(XmrWalletService xmrWalletService,

View file

@ -31,8 +31,6 @@ import haveno.desktop.common.view.FxmlView;
import haveno.desktop.main.offer.MutableOfferView; import haveno.desktop.main.offer.MutableOfferView;
import haveno.desktop.main.offer.OfferView; import haveno.desktop.main.offer.OfferView;
import haveno.desktop.main.overlays.windows.OfferDetailsWindow; import haveno.desktop.main.overlays.windows.OfferDetailsWindow;
import haveno.desktop.util.GUIUtil;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
@ -60,12 +58,12 @@ public class CreateOfferView extends MutableOfferView<CreateOfferViewModel> {
protected ObservableList<PaymentAccount> filterPaymentAccounts(ObservableList<PaymentAccount> paymentAccounts) { protected ObservableList<PaymentAccount> filterPaymentAccounts(ObservableList<PaymentAccount> paymentAccounts) {
return FXCollections.observableArrayList( return FXCollections.observableArrayList(
paymentAccounts.stream().filter(paymentAccount -> { paymentAccounts.stream().filter(paymentAccount -> {
if (model.getTradeCurrency().equals(GUIUtil.TOP_CRYPTO)) { if (CurrencyUtil.isFiatCurrency(model.getTradeCurrency().getCode())) {
return Objects.equals(paymentAccount.getSingleTradeCurrency(), GUIUtil.TOP_CRYPTO);
} else if (CurrencyUtil.isFiatCurrency(model.getTradeCurrency().getCode())) {
return paymentAccount.isFiat(); return paymentAccount.isFiat();
} else if (CurrencyUtil.isCryptoCurrency(model.getTradeCurrency().getCode())) {
return paymentAccount.isCryptoCurrency();
} else { } else {
return !paymentAccount.isFiat() && !Objects.equals(paymentAccount.getSingleTradeCurrency(), GUIUtil.TOP_CRYPTO); return !paymentAccount.isFiat() && !paymentAccount.isCryptoCurrency();
} }
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
} }

View file

@ -19,7 +19,7 @@
<?import javafx.scene.layout.ColumnConstraints?> <?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.GridPane?>
<GridPane fx:id="root" fx:controller="haveno.desktop.main.offer.offerbook.TopCryptoOfferBookView" <GridPane fx:id="root" fx:controller="haveno.desktop.main.offer.offerbook.CryptoOfferBookView"
hgap="5.0" vgap="5" hgap="5.0" vgap="5"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">

View file

@ -33,39 +33,29 @@ import haveno.desktop.main.overlays.windows.OfferDetailsWindow;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
@FxmlView @FxmlView
public class TopCryptoOfferBookView extends OfferBookView<GridPane, TopCryptoOfferBookViewModel> { public class CryptoOfferBookView extends OfferBookView<GridPane, CryptoOfferBookViewModel> {
@Inject @Inject
TopCryptoOfferBookView(TopCryptoOfferBookViewModel model, CryptoOfferBookView(CryptoOfferBookViewModel model,
Navigation navigation, Navigation navigation,
OfferDetailsWindow offerDetailsWindow, OfferDetailsWindow offerDetailsWindow,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
PrivateNotificationManager privateNotificationManager, PrivateNotificationManager privateNotificationManager,
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys, @Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
AccountAgeWitnessService accountAgeWitnessService, AccountAgeWitnessService accountAgeWitnessService,
SignedWitnessService signedWitnessService) { SignedWitnessService signedWitnessService) {
super(model, navigation, offerDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService); super(model, navigation, offerDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService);
} }
@Override @Override
protected String getMarketTitle() { protected String getMarketTitle() {
return model.getDirection().equals(OfferDirection.BUY) ? return model.getDirection().equals(OfferDirection.BUY) ?
Res.get("offerbook.availableOffersToBuy", TopCryptoOfferBookViewModel.TOP_CRYPTO.getCode(), Res.getBaseCurrencyCode()) : Res.get("offerbook.availableOffersToBuy", Res.getBaseCurrencyCode(), Res.get("shared.crypto")) :
Res.get("offerbook.availableOffersToSell", TopCryptoOfferBookViewModel.TOP_CRYPTO.getCode(), Res.getBaseCurrencyCode()); Res.get("offerbook.availableOffersToSell", Res.getBaseCurrencyCode(), Res.get("shared.crypto"));
}
@Override
protected void activate() {
model.onSetTradeCurrency(TopCryptoOfferBookViewModel.TOP_CRYPTO);
super.activate();
currencyComboBoxContainer.setVisible(false);
currencyComboBoxContainer.setManaged(false);
} }
@Override @Override
String getTradeCurrencyCode() { String getTradeCurrencyCode() {
return TopCryptoOfferBookViewModel.TOP_CRYPTO.getCode(); return Res.getBaseCurrencyCode();
} }
} }

View file

@ -0,0 +1,148 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/
package haveno.desktop.main.offer.offerbook;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import haveno.core.account.witness.AccountAgeWitnessService;
import haveno.core.api.CoreApi;
import haveno.core.locale.CryptoCurrency;
import haveno.core.locale.CurrencyUtil;
import haveno.core.locale.GlobalSettings;
import haveno.core.locale.TradeCurrency;
import haveno.core.offer.Offer;
import haveno.core.offer.OfferDirection;
import haveno.core.offer.OfferFilterService;
import haveno.core.offer.OpenOfferManager;
import haveno.core.payment.payload.PaymentMethod;
import haveno.core.provider.price.PriceFeedService;
import haveno.core.trade.ClosedTradableManager;
import haveno.core.user.Preferences;
import haveno.core.user.User;
import haveno.core.util.FormattingUtils;
import haveno.core.util.PriceUtil;
import haveno.core.util.coin.CoinFormatter;
import haveno.core.xmr.setup.WalletsSetup;
import haveno.desktop.Navigation;
import haveno.desktop.main.offer.OfferViewUtil;
import haveno.desktop.util.GUIUtil;
import haveno.network.p2p.P2PService;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
public class CryptoOfferBookViewModel extends OfferBookViewModel {
@Inject
public CryptoOfferBookViewModel(User user,
OpenOfferManager openOfferManager,
OfferBook offerBook,
Preferences preferences,
WalletsSetup walletsSetup,
P2PService p2PService,
PriceFeedService priceFeedService,
ClosedTradableManager closedTradableManager,
AccountAgeWitnessService accountAgeWitnessService,
Navigation navigation,
PriceUtil priceUtil,
OfferFilterService offerFilterService,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
CoreApi coreApi) {
super(user, openOfferManager, offerBook, preferences, walletsSetup, p2PService, priceFeedService, closedTradableManager, accountAgeWitnessService, navigation, priceUtil, offerFilterService, btcFormatter, coreApi);
}
@Override
void saveSelectedCurrencyCodeInPreferences(OfferDirection direction, String code) {
if (direction == OfferDirection.BUY) {
preferences.setBuyScreenCryptoCurrencyCode(code);
} else {
preferences.setSellScreenCryptoCurrencyCode(code);
}
}
@Override
protected ObservableList<PaymentMethod> filterPaymentMethods(ObservableList<PaymentMethod> list,
TradeCurrency selectedTradeCurrency) {
return FXCollections.observableArrayList(list.stream().filter(paymentMethod -> {
return paymentMethod.isBlockchain();
}).collect(Collectors.toList()));
}
@Override
void fillCurrencies(ObservableList<TradeCurrency> tradeCurrencies,
ObservableList<TradeCurrency> allCurrencies) {
tradeCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
tradeCurrencies.addAll(preferences.getCryptoCurrenciesAsObservable().stream()
.collect(Collectors.toList()));
tradeCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
allCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
allCurrencies.addAll(CurrencyUtil.getAllSortedCryptoCurrencies().stream()
.collect(Collectors.toList()));
allCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
}
@Override
Predicate<OfferBookListItem> getCurrencyAndMethodPredicate(OfferDirection direction,
TradeCurrency selectedTradeCurrency) {
return offerBookListItem -> {
Offer offer = offerBookListItem.getOffer();
boolean directionResult = offer.getDirection() != direction; // offer to buy xmr appears as offer to sell in peer's offer book and vice versa
boolean currencyResult = CurrencyUtil.isCryptoCurrency(offer.getCurrencyCode()) &&
(showAllTradeCurrenciesProperty.get() ||
offer.getCurrencyCode().equals(selectedTradeCurrency.getCode()));
boolean paymentMethodResult = showAllPaymentMethods ||
offer.getPaymentMethod().equals(selectedPaymentMethod);
boolean notMyOfferOrShowMyOffersActivated = !isMyOffer(offerBookListItem.getOffer()) || preferences.isShowOwnOffersInOfferBook();
return directionResult && currencyResult && paymentMethodResult && notMyOfferOrShowMyOffersActivated;
};
}
@Override
TradeCurrency getDefaultTradeCurrency() {
TradeCurrency defaultTradeCurrency = GlobalSettings.getDefaultTradeCurrency();
if (CurrencyUtil.isCryptoCurrency(defaultTradeCurrency.getCode()) &&
hasPaymentAccountForCurrency(defaultTradeCurrency)) {
return defaultTradeCurrency;
}
ObservableList<TradeCurrency> tradeCurrencies = FXCollections.observableArrayList(getTradeCurrencies());
if (!tradeCurrencies.isEmpty()) {
// drop show all entry and select first currency with payment account available
tradeCurrencies.remove(0);
List<TradeCurrency> sortedList = tradeCurrencies.stream().sorted((o1, o2) ->
Boolean.compare(!hasPaymentAccountForCurrency(o1),
!hasPaymentAccountForCurrency(o2))).collect(Collectors.toList());
return sortedList.get(0);
} else {
return OfferViewUtil.getMainCryptoCurrencies().sorted((o1, o2) ->
Boolean.compare(!hasPaymentAccountForCurrency(o1),
!hasPaymentAccountForCurrency(o2))).collect(Collectors.toList()).get(0);
}
}
@Override
String getCurrencyCodeFromPreferences(OfferDirection direction) {
return direction == OfferDirection.BUY ? preferences.getBuyScreenCryptoCurrencyCode() :
preferences.getSellScreenCryptoCurrencyCode();
}
}

View file

@ -19,7 +19,7 @@
<?import javafx.scene.layout.ColumnConstraints?> <?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.GridPane?>
<GridPane fx:id="root" fx:controller="haveno.desktop.main.offer.offerbook.XmrOfferBookView" <GridPane fx:id="root" fx:controller="haveno.desktop.main.offer.offerbook.FiatOfferBookView"
hgap="5.0" vgap="5" hgap="5.0" vgap="5"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">

View file

@ -33,17 +33,17 @@ import haveno.desktop.main.overlays.windows.OfferDetailsWindow;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
@FxmlView @FxmlView
public class XmrOfferBookView extends OfferBookView<GridPane, XmrOfferBookViewModel> { public class FiatOfferBookView extends OfferBookView<GridPane, FiatOfferBookViewModel> {
@Inject @Inject
XmrOfferBookView(XmrOfferBookViewModel model, FiatOfferBookView(FiatOfferBookViewModel model,
Navigation navigation, Navigation navigation,
OfferDetailsWindow offerDetailsWindow, OfferDetailsWindow offerDetailsWindow,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
PrivateNotificationManager privateNotificationManager, PrivateNotificationManager privateNotificationManager,
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys, @Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
AccountAgeWitnessService accountAgeWitnessService, AccountAgeWitnessService accountAgeWitnessService,
SignedWitnessService signedWitnessService) { SignedWitnessService signedWitnessService) {
super(model, navigation, offerDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService); super(model, navigation, offerDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService);
} }

View file

@ -49,23 +49,23 @@ import java.util.stream.Collectors;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
public class XmrOfferBookViewModel extends OfferBookViewModel { public class FiatOfferBookViewModel extends OfferBookViewModel {
@Inject @Inject
public XmrOfferBookViewModel(User user, public FiatOfferBookViewModel(User user,
OpenOfferManager openOfferManager, OpenOfferManager openOfferManager,
OfferBook offerBook, OfferBook offerBook,
Preferences preferences, Preferences preferences,
WalletsSetup walletsSetup, WalletsSetup walletsSetup,
P2PService p2PService, P2PService p2PService,
PriceFeedService priceFeedService, PriceFeedService priceFeedService,
ClosedTradableManager closedTradableManager, ClosedTradableManager closedTradableManager,
AccountAgeWitnessService accountAgeWitnessService, AccountAgeWitnessService accountAgeWitnessService,
Navigation navigation, Navigation navigation,
PriceUtil priceUtil, PriceUtil priceUtil,
OfferFilterService offerFilterService, OfferFilterService offerFilterService,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
CoreApi coreApi) { CoreApi coreApi) {
super(user, openOfferManager, offerBook, preferences, walletsSetup, p2PService, priceFeedService, closedTradableManager, accountAgeWitnessService, navigation, priceUtil, offerFilterService, btcFormatter, coreApi); super(user, openOfferManager, offerBook, preferences, walletsSetup, p2PService, priceFeedService, closedTradableManager, accountAgeWitnessService, navigation, priceUtil, offerFilterService, btcFormatter, coreApi);
} }
@ -141,9 +141,10 @@ public class XmrOfferBookViewModel extends OfferBookViewModel {
!hasPaymentAccountForCurrency(o2))).collect(Collectors.toList()); !hasPaymentAccountForCurrency(o2))).collect(Collectors.toList());
return sortedList.get(0); return sortedList.get(0);
} else { } else {
return CurrencyUtil.getMainTraditionalCurrencies().stream().sorted((o1, o2) -> return CurrencyUtil.getMainTraditionalCurrencies().stream()
Boolean.compare(!hasPaymentAccountForCurrency(o1), .filter(withFiatCurrency())
!hasPaymentAccountForCurrency(o2))).collect(Collectors.toList()).get(0); .sorted((o1, o2) -> Boolean.compare(!hasPaymentAccountForCurrency(o1), !hasPaymentAccountForCurrency(o2)))
.collect(Collectors.toList()).get(0);
} }
} }

View file

@ -37,25 +37,25 @@ public class OtherOfferBookView extends OfferBookView<GridPane, OtherOfferBookVi
@Inject @Inject
OtherOfferBookView(OtherOfferBookViewModel model, OtherOfferBookView(OtherOfferBookViewModel model,
Navigation navigation, Navigation navigation,
OfferDetailsWindow offerDetailsWindow, OfferDetailsWindow offerDetailsWindow,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
PrivateNotificationManager privateNotificationManager, PrivateNotificationManager privateNotificationManager,
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys, @Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
AccountAgeWitnessService accountAgeWitnessService, AccountAgeWitnessService accountAgeWitnessService,
SignedWitnessService signedWitnessService) { SignedWitnessService signedWitnessService) {
super(model, navigation, offerDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService); super(model, navigation, offerDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService);
} }
@Override @Override
protected String getMarketTitle() { protected String getMarketTitle() {
return model.getDirection().equals(OfferDirection.BUY) ? return model.getDirection().equals(OfferDirection.BUY) ?
Res.get("offerbook.availableOffersToBuy", Res.get("shared.otherAssets"), Res.getBaseCurrencyCode()) : Res.get("offerbook.availableOffersToBuy", Res.getBaseCurrencyCode(), Res.get("shared.otherAssets")) :
Res.get("offerbook.availableOffersToSell", Res.get("shared.otherAssets"), Res.getBaseCurrencyCode()); Res.get("offerbook.availableOffersToSell", Res.getBaseCurrencyCode(), Res.get("shared.otherAssets"));
} }
@Override @Override
String getTradeCurrencyCode() { String getTradeCurrencyCode() {
return model.showAllTradeCurrenciesProperty.get() ? "" : model.getSelectedTradeCurrency().getCode(); return Res.getBaseCurrencyCode();
} }
} }

View file

@ -40,7 +40,6 @@ import haveno.core.util.PriceUtil;
import haveno.core.util.coin.CoinFormatter; import haveno.core.util.coin.CoinFormatter;
import haveno.core.xmr.setup.WalletsSetup; import haveno.core.xmr.setup.WalletsSetup;
import haveno.desktop.Navigation; import haveno.desktop.Navigation;
import haveno.desktop.main.offer.OfferViewUtil;
import haveno.desktop.util.GUIUtil; import haveno.desktop.util.GUIUtil;
import haveno.network.p2p.P2PService; import haveno.network.p2p.P2PService;
import java.util.List; import java.util.List;
@ -54,28 +53,28 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
@Inject @Inject
public OtherOfferBookViewModel(User user, public OtherOfferBookViewModel(User user,
OpenOfferManager openOfferManager, OpenOfferManager openOfferManager,
OfferBook offerBook, OfferBook offerBook,
Preferences preferences, Preferences preferences,
WalletsSetup walletsSetup, WalletsSetup walletsSetup,
P2PService p2PService, P2PService p2PService,
PriceFeedService priceFeedService, PriceFeedService priceFeedService,
ClosedTradableManager closedTradableManager, ClosedTradableManager closedTradableManager,
AccountAgeWitnessService accountAgeWitnessService, AccountAgeWitnessService accountAgeWitnessService,
Navigation navigation, Navigation navigation,
PriceUtil priceUtil, PriceUtil priceUtil,
OfferFilterService offerFilterService, OfferFilterService offerFilterService,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
CoreApi coreApi) { CoreApi coreApi) {
super(user, openOfferManager, offerBook, preferences, walletsSetup, p2PService, priceFeedService, closedTradableManager, accountAgeWitnessService, navigation, priceUtil, offerFilterService, btcFormatter, coreApi); super(user, openOfferManager, offerBook, preferences, walletsSetup, p2PService, priceFeedService, closedTradableManager, accountAgeWitnessService, navigation, priceUtil, offerFilterService, btcFormatter, coreApi);
} }
@Override @Override
void saveSelectedCurrencyCodeInPreferences(OfferDirection direction, String code) { void saveSelectedCurrencyCodeInPreferences(OfferDirection direction, String code) {
if (direction == OfferDirection.BUY) { if (direction == OfferDirection.BUY) {
preferences.setBuyScreenCryptoCurrencyCode(code); preferences.setBuyScreenOtherCurrencyCode(code);
} else { } else {
preferences.setSellScreenCryptoCurrencyCode(code); preferences.setBuyScreenOtherCurrencyCode(code);
} }
} }
@ -83,7 +82,6 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
protected ObservableList<PaymentMethod> filterPaymentMethods(ObservableList<PaymentMethod> list, protected ObservableList<PaymentMethod> filterPaymentMethods(ObservableList<PaymentMethod> list,
TradeCurrency selectedTradeCurrency) { TradeCurrency selectedTradeCurrency) {
return FXCollections.observableArrayList(list.stream().filter(paymentMethod -> { return FXCollections.observableArrayList(list.stream().filter(paymentMethod -> {
if (paymentMethod.isBlockchain()) return true;
if (paymentMethod.getSupportedAssetCodes() == null) return true; if (paymentMethod.getSupportedAssetCodes() == null) return true;
for (String assetCode : paymentMethod.getSupportedAssetCodes()) { for (String assetCode : paymentMethod.getSupportedAssetCodes()) {
if (!CurrencyUtil.isFiatCurrency(assetCode)) return true; if (!CurrencyUtil.isFiatCurrency(assetCode)) return true;
@ -95,20 +93,13 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
@Override @Override
void fillCurrencies(ObservableList<TradeCurrency> tradeCurrencies, void fillCurrencies(ObservableList<TradeCurrency> tradeCurrencies,
ObservableList<TradeCurrency> allCurrencies) { ObservableList<TradeCurrency> allCurrencies) {
tradeCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, "")); tradeCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
tradeCurrencies.addAll(preferences.getCryptoCurrenciesAsObservable().stream()
.filter(withoutTopCrypto())
.collect(Collectors.toList()));
tradeCurrencies.addAll(CurrencyUtil.getMainTraditionalCurrencies().stream() tradeCurrencies.addAll(CurrencyUtil.getMainTraditionalCurrencies().stream()
.filter(withoutFiatCurrency()) .filter(withoutFiatCurrency())
.collect(Collectors.toList())); .collect(Collectors.toList()));
tradeCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, "")); tradeCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
allCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, "")); allCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
allCurrencies.addAll(CurrencyUtil.getAllSortedCryptoCurrencies().stream()
.filter(withoutTopCrypto())
.collect(Collectors.toList()));
allCurrencies.addAll(CurrencyUtil.getMainTraditionalCurrencies().stream() allCurrencies.addAll(CurrencyUtil.getMainTraditionalCurrencies().stream()
.filter(withoutFiatCurrency()) .filter(withoutFiatCurrency())
.collect(Collectors.toList())); .collect(Collectors.toList()));
@ -120,12 +111,9 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
TradeCurrency selectedTradeCurrency) { TradeCurrency selectedTradeCurrency) {
return offerBookListItem -> { return offerBookListItem -> {
Offer offer = offerBookListItem.getOffer(); Offer offer = offerBookListItem.getOffer();
// BUY Crypto is actually SELL Monero boolean directionResult = offer.getDirection() != direction;
boolean directionResult = offer.getDirection() == direction; boolean currencyResult = CurrencyUtil.isTraditionalCurrency(offer.getCurrencyCode()) && !CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) &&
boolean currencyResult = !CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) && (showAllTradeCurrenciesProperty.get() || offer.getCurrencyCode().equals(selectedTradeCurrency.getCode()));
((showAllTradeCurrenciesProperty.get() &&
!offer.getCurrencyCode().equals(GUIUtil.TOP_CRYPTO.getCode())) ||
offer.getCurrencyCode().equals(selectedTradeCurrency.getCode()));
boolean paymentMethodResult = showAllPaymentMethods || boolean paymentMethodResult = showAllPaymentMethods ||
offer.getPaymentMethod().equals(selectedPaymentMethod); offer.getPaymentMethod().equals(selectedPaymentMethod);
boolean notMyOfferOrShowMyOffersActivated = !isMyOffer(offerBookListItem.getOffer()) || preferences.isShowOwnOffersInOfferBook(); boolean notMyOfferOrShowMyOffersActivated = !isMyOffer(offerBookListItem.getOffer()) || preferences.isShowOwnOffersInOfferBook();
@ -137,8 +125,8 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
TradeCurrency getDefaultTradeCurrency() { TradeCurrency getDefaultTradeCurrency() {
TradeCurrency defaultTradeCurrency = GlobalSettings.getDefaultTradeCurrency(); TradeCurrency defaultTradeCurrency = GlobalSettings.getDefaultTradeCurrency();
if (!CurrencyUtil.isTraditionalCurrency(defaultTradeCurrency.getCode()) && if (CurrencyUtil.isTraditionalCurrency(defaultTradeCurrency.getCode()) &&
!defaultTradeCurrency.equals(GUIUtil.TOP_CRYPTO) && !CurrencyUtil.isFiatCurrency(defaultTradeCurrency.getCode()) &&
hasPaymentAccountForCurrency(defaultTradeCurrency)) { hasPaymentAccountForCurrency(defaultTradeCurrency)) {
return defaultTradeCurrency; return defaultTradeCurrency;
} }
@ -152,22 +140,19 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
!hasPaymentAccountForCurrency(o2))).collect(Collectors.toList()); !hasPaymentAccountForCurrency(o2))).collect(Collectors.toList());
return sortedList.get(0); return sortedList.get(0);
} else { } else {
return OfferViewUtil.getMainCryptoCurrencies().sorted((o1, o2) -> return CurrencyUtil.getMainTraditionalCurrencies().stream()
Boolean.compare(!hasPaymentAccountForCurrency(o1), .filter(withoutFiatCurrency())
!hasPaymentAccountForCurrency(o2))).collect(Collectors.toList()).get(0); .sorted((o1, o2) -> Boolean.compare(!hasPaymentAccountForCurrency(o1), !hasPaymentAccountForCurrency(o2)))
.collect(Collectors.toList()).get(0);
} }
} }
@Override @Override
String getCurrencyCodeFromPreferences(OfferDirection direction) { String getCurrencyCodeFromPreferences(OfferDirection direction) {
return direction == OfferDirection.BUY ? preferences.getBuyScreenCryptoCurrencyCode() : // validate if previous stored currencies are Traditional ones
preferences.getSellScreenCryptoCurrencyCode(); String currencyCode = direction == OfferDirection.BUY ? preferences.getBuyScreenOtherCurrencyCode() : preferences.getSellScreenOtherCurrencyCode();
}
@NotNull return CurrencyUtil.isTraditionalCurrency(currencyCode) ? currencyCode : null;
private Predicate<CryptoCurrency> withoutTopCrypto() {
return cryptoCurrency ->
!cryptoCurrency.equals(GUIUtil.TOP_CRYPTO);
} }
@NotNull @NotNull

View file

@ -1,116 +0,0 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/
package haveno.desktop.main.offer.offerbook;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import haveno.core.account.witness.AccountAgeWitnessService;
import haveno.core.api.CoreApi;
import haveno.core.locale.TradeCurrency;
import haveno.core.offer.Offer;
import haveno.core.offer.OfferDirection;
import haveno.core.offer.OfferFilterService;
import haveno.core.offer.OpenOfferManager;
import haveno.core.payment.payload.PaymentMethod;
import haveno.core.provider.price.PriceFeedService;
import haveno.core.trade.ClosedTradableManager;
import haveno.core.user.Preferences;
import haveno.core.user.User;
import haveno.core.util.FormattingUtils;
import haveno.core.util.PriceUtil;
import haveno.core.util.coin.CoinFormatter;
import haveno.core.xmr.setup.WalletsSetup;
import haveno.desktop.Navigation;
import haveno.desktop.util.GUIUtil;
import haveno.network.p2p.P2PService;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
public class TopCryptoOfferBookViewModel extends OfferBookViewModel {
public static TradeCurrency TOP_CRYPTO = GUIUtil.TOP_CRYPTO;
@Inject
public TopCryptoOfferBookViewModel(User user,
OpenOfferManager openOfferManager,
OfferBook offerBook,
Preferences preferences,
WalletsSetup walletsSetup,
P2PService p2PService,
PriceFeedService priceFeedService,
ClosedTradableManager closedTradableManager,
AccountAgeWitnessService accountAgeWitnessService,
Navigation navigation,
PriceUtil priceUtil,
OfferFilterService offerFilterService,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
CoreApi coreApi) {
super(user, openOfferManager, offerBook, preferences, walletsSetup, p2PService, priceFeedService, closedTradableManager, accountAgeWitnessService, navigation, priceUtil, offerFilterService, btcFormatter, coreApi);
}
@Override
protected void activate() {
super.activate();
TOP_CRYPTO = GUIUtil.TOP_CRYPTO;
}
@Override
void saveSelectedCurrencyCodeInPreferences(OfferDirection direction, String code) {
// No need to store anything as it is just one Crypto offers anyway
}
@Override
protected ObservableList<PaymentMethod> filterPaymentMethods(ObservableList<PaymentMethod> list,
TradeCurrency selectedTradeCurrency) {
return FXCollections.observableArrayList(list.stream().filter(PaymentMethod::isBlockchain).collect(Collectors.toList()));
}
@Override
void fillCurrencies(ObservableList<TradeCurrency> tradeCurrencies,
ObservableList<TradeCurrency> allCurrencies) {
tradeCurrencies.add(TOP_CRYPTO);
allCurrencies.add(TOP_CRYPTO);
}
@Override
Predicate<OfferBookListItem> getCurrencyAndMethodPredicate(OfferDirection direction,
TradeCurrency selectedTradeCurrency) {
return offerBookListItem -> {
Offer offer = offerBookListItem.getOffer();
// BUY Crypto is actually SELL Bitcoin
boolean directionResult = offer.getDirection() == direction;
boolean currencyResult = offer.getCurrencyCode().equals(TOP_CRYPTO.getCode());
boolean paymentMethodResult = showAllPaymentMethods ||
offer.getPaymentMethod().equals(selectedPaymentMethod);
boolean notMyOfferOrShowMyOffersActivated = !isMyOffer(offerBookListItem.getOffer()) || preferences.isShowOwnOffersInOfferBook();
return directionResult && currencyResult && paymentMethodResult && notMyOfferOrShowMyOffersActivated;
};
}
@Override
TradeCurrency getDefaultTradeCurrency() {
return TOP_CRYPTO;
}
@Override
String getCurrencyCodeFromPreferences(OfferDirection direction) {
return TOP_CRYPTO.getCode();
}
}

View file

@ -134,8 +134,6 @@ public class GUIUtil {
private static Preferences preferences; private static Preferences preferences;
public static TradeCurrency TOP_CRYPTO = CurrencyUtil.getTradeCurrency("BTC").get();
public static void setPreferences(Preferences preferences) { public static void setPreferences(Preferences preferences) {
GUIUtil.preferences = preferences; GUIUtil.preferences = preferences;
} }
@ -1033,12 +1031,4 @@ public class GUIUtil {
columnConstraints2.setHgrow(Priority.ALWAYS); columnConstraints2.setHgrow(Priority.ALWAYS);
gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2); gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
} }
public static void updateTopCrypto(Preferences preferences) {
TradeCurrency tradeCurrency = preferences.getPreferredTradeCurrency();
if (CurrencyUtil.isTraditionalCurrency(tradeCurrency.getCode())) {
return;
}
TOP_CRYPTO = tradeCurrency;
}
} }

View file

@ -241,7 +241,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new XmrOfferBookViewModel(null, null, offerBook, empty, null, null, null, final OfferBookViewModel model = new FiatOfferBookViewModel(null, null, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null); null, null, null, getPriceUtil(), null, coinFormatter, null);
assertEquals(0, model.maxPlacesForAmount.intValue()); assertEquals(0, model.maxPlacesForAmount.intValue());
} }
@ -255,7 +255,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null, final OfferBookViewModel model = new FiatOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null); null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate(); model.activate();
@ -273,7 +273,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null, final OfferBookViewModel model = new FiatOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null); null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate(); model.activate();
@ -292,7 +292,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new XmrOfferBookViewModel(null, null, offerBook, empty, null, null, null, final OfferBookViewModel model = new FiatOfferBookViewModel(null, null, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null); null, null, null, getPriceUtil(), null, coinFormatter, null);
assertEquals(0, model.maxPlacesForVolume.intValue()); assertEquals(0, model.maxPlacesForVolume.intValue());
} }
@ -306,7 +306,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null, final OfferBookViewModel model = new FiatOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null); null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate(); model.activate();
@ -324,7 +324,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null, final OfferBookViewModel model = new FiatOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null); null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate(); model.activate();
@ -342,7 +342,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new XmrOfferBookViewModel(null, null, offerBook, empty, null, null, null, final OfferBookViewModel model = new FiatOfferBookViewModel(null, null, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null); null, null, null, getPriceUtil(), null, coinFormatter, null);
assertEquals(0, model.maxPlacesForPrice.intValue()); assertEquals(0, model.maxPlacesForPrice.intValue());
} }
@ -356,7 +356,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null, final OfferBookViewModel model = new FiatOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null); null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate(); model.activate();
@ -374,7 +374,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new XmrOfferBookViewModel(null, null, offerBook, empty, null, null, null, final OfferBookViewModel model = new FiatOfferBookViewModel(null, null, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null); null, null, null, getPriceUtil(), null, coinFormatter, null);
assertEquals(0, model.maxPlacesForMarketPriceMargin.intValue()); assertEquals(0, model.maxPlacesForMarketPriceMargin.intValue());
} }
@ -409,7 +409,7 @@ public class OfferBookViewModelTest {
item4.getOffer().setPriceFeedService(priceFeedService); item4.getOffer().setPriceFeedService(priceFeedService);
offerBookListItems.addAll(item1, item2); offerBookListItems.addAll(item1, item2);
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, priceFeedService, final OfferBookViewModel model = new FiatOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, priceFeedService,
null, null, null, getPriceUtil(), null, coinFormatter, null); null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate(); model.activate();
@ -430,7 +430,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems); when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
when(priceFeedService.getMarketPrice(anyString())).thenReturn(new MarketPrice("USD", 12684.0450, Instant.now().getEpochSecond(), true)); when(priceFeedService.getMarketPrice(anyString())).thenReturn(new MarketPrice("USD", 12684.0450, Instant.now().getEpochSecond(), true));
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null, final OfferBookViewModel model = new FiatOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null); null, null, null, getPriceUtil(), null, coinFormatter, null);
final OfferBookListItem item = make(xmrBuyItem.but( final OfferBookListItem item = make(xmrBuyItem.but(

View file

@ -1742,6 +1742,8 @@ message PreferencesPayload {
bool split_offer_output = 62; bool split_offer_output = 62;
bool use_sound_for_notifications = 63; bool use_sound_for_notifications = 63;
bool use_sound_for_notifications_initialized = 64; bool use_sound_for_notifications_initialized = 64;
string buy_screen_other_currency_code = 65;
string sell_screen_other_currency_code = 66;
} }
message AutoConfirmSettings { message AutoConfirmSettings {