mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-11-16 15:58:08 +00:00
refactor buy/sell tab functionality #1351
This commit is contained in:
parent
f470112cae
commit
0c76c48c65
24 changed files with 363 additions and 351 deletions
|
@ -73,14 +73,6 @@ public class CurrencyUtil {
|
|||
|
||||
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.
|
||||
// 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%
|
||||
|
@ -124,6 +116,14 @@ public class CurrencyUtil {
|
|||
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) {
|
||||
return (List<TraditionalCurrency>) getAllSortedTraditionalCurrencies().stream()
|
||||
.sorted(comparator)
|
||||
|
|
|
@ -139,6 +139,10 @@ public abstract class PaymentAccount implements PersistablePayload {
|
|||
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
|
||||
|
|
|
@ -566,6 +566,16 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
|
|||
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) {
|
||||
prefPayload.setIgnoreTradersList(ignoreTradersList);
|
||||
requestPersistence();
|
||||
|
|
|
@ -77,6 +77,10 @@ public final class PreferencesPayload implements PersistableEnvelope {
|
|||
private String buyScreenCryptoCurrencyCode;
|
||||
@Nullable
|
||||
private String sellScreenCryptoCurrencyCode;
|
||||
@Nullable
|
||||
private String buyScreenOtherCurrencyCode;
|
||||
@Nullable
|
||||
private String sellScreenOtherCurrencyCode;
|
||||
private int tradeStatisticsTickUnitIndex = 3;
|
||||
private boolean resyncSpvRequested;
|
||||
private boolean sortMarketCurrenciesNumerically = true;
|
||||
|
@ -212,6 +216,8 @@ public final class PreferencesPayload implements PersistableEnvelope {
|
|||
Optional.ofNullable(sellScreenCurrencyCode).ifPresent(builder::setSellScreenCurrencyCode);
|
||||
Optional.ofNullable(buyScreenCryptoCurrencyCode).ifPresent(builder::setBuyScreenCryptoCurrencyCode);
|
||||
Optional.ofNullable(sellScreenCryptoCurrencyCode).ifPresent(builder::setSellScreenCryptoCurrencyCode);
|
||||
Optional.ofNullable(buyScreenOtherCurrencyCode).ifPresent(builder::setBuyScreenOtherCurrencyCode);
|
||||
Optional.ofNullable(sellScreenOtherCurrencyCode).ifPresent(builder::setSellScreenOtherCurrencyCode);
|
||||
Optional.ofNullable(selectedPaymentAccountForCreateOffer).ifPresent(
|
||||
account -> builder.setSelectedPaymentAccountForCreateOffer(selectedPaymentAccountForCreateOffer.toProtoMessage()));
|
||||
Optional.ofNullable(bridgeAddresses).ifPresent(builder::addAllBridgeAddresses);
|
||||
|
@ -260,6 +266,8 @@ public final class PreferencesPayload implements PersistableEnvelope {
|
|||
ProtoUtil.stringOrNullFromProto(proto.getSellScreenCurrencyCode()),
|
||||
ProtoUtil.stringOrNullFromProto(proto.getBuyScreenCryptoCurrencyCode()),
|
||||
ProtoUtil.stringOrNullFromProto(proto.getSellScreenCryptoCurrencyCode()),
|
||||
ProtoUtil.stringOrNullFromProto(proto.getBuyScreenOtherCurrencyCode()),
|
||||
ProtoUtil.stringOrNullFromProto(proto.getSellScreenOtherCurrencyCode()),
|
||||
proto.getTradeStatisticsTickUnitIndex(),
|
||||
proto.getResyncSpvRequested(),
|
||||
proto.getSortMarketCurrenciesNumerically(),
|
||||
|
|
|
@ -207,6 +207,7 @@ shared.crypto=Crypto
|
|||
shared.traditional=Traditional
|
||||
shared.otherAssets=other assets
|
||||
shared.other=Other
|
||||
shared.preciousMetals=Precious Metals
|
||||
shared.all=All
|
||||
shared.edit=Edit
|
||||
shared.advancedOptions=Advanced options
|
||||
|
@ -245,8 +246,8 @@ shared.taker=Taker
|
|||
####################################################################
|
||||
|
||||
mainView.menu.market=Market
|
||||
mainView.menu.buy=Buy
|
||||
mainView.menu.sell=Sell
|
||||
mainView.menu.buyXmr=Buy XMR
|
||||
mainView.menu.sellXmr=Sell XMR
|
||||
mainView.menu.portfolio=Portfolio
|
||||
mainView.menu.funds=Funds
|
||||
mainView.menu.support=Support
|
||||
|
|
|
@ -245,8 +245,8 @@ shared.taker=Alıcı
|
|||
####################################################################
|
||||
|
||||
mainView.menu.market=Piyasa
|
||||
mainView.menu.buy=Satın Al
|
||||
mainView.menu.sell=Sat
|
||||
mainView.menu.buyXmr=XMR Satın Al
|
||||
mainView.menu.sellXmr=XMR Sat
|
||||
mainView.menu.portfolio=Portföy
|
||||
mainView.menu.funds=Fonlar
|
||||
mainView.menu.support=Destek
|
||||
|
|
|
@ -165,8 +165,8 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
|
|||
MainView.rootContainer.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
|
||||
|
||||
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 sellButton = new NavButton(SellOfferView.class, Res.get("mainView.menu.sell").toUpperCase());
|
||||
ToggleButton buyButton = new NavButton(BuyOfferView.class, Res.get("mainView.menu.buyXmr").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 fundsButton = new NavButton(FundsView.class, Res.get("mainView.menu.funds").toUpperCase());
|
||||
|
||||
|
|
|
@ -425,14 +425,10 @@ class OfferBookChartViewModel extends ActivatableViewModel {
|
|||
if (isSellOffer(direction)) {
|
||||
if (CurrencyUtil.isTraditionalCurrency(getCurrencyCode())) {
|
||||
preferences.setBuyScreenCurrencyCode(getCurrencyCode());
|
||||
} else if (!getCurrencyCode().equals(GUIUtil.TOP_CRYPTO.getCode())) {
|
||||
preferences.setBuyScreenCryptoCurrencyCode(getCurrencyCode());
|
||||
}
|
||||
} else {
|
||||
if (CurrencyUtil.isTraditionalCurrency(getCurrencyCode())) {
|
||||
preferences.setSellScreenCurrencyCode(getCurrencyCode());
|
||||
} else if (!getCurrencyCode().equals(GUIUtil.TOP_CRYPTO.getCode())) {
|
||||
preferences.setSellScreenCryptoCurrencyCode(getCurrencyCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ import java.util.Comparator;
|
|||
import static java.util.Comparator.comparing;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
@ -257,10 +256,10 @@ public abstract class MutableOfferDataModel extends OfferDataModel {
|
|||
private Optional<PaymentAccount> getAnyPaymentAccount() {
|
||||
if (CurrencyUtil.isFiatCurrency(tradeCurrency.getCode())) {
|
||||
return paymentAccounts.stream().filter(paymentAccount1 -> paymentAccount1.isFiat()).findAny();
|
||||
} else if (CurrencyUtil.isCryptoCurrency(tradeCurrency.getCode())) {
|
||||
return paymentAccounts.stream().filter(paymentAccount1 -> paymentAccount1.isCryptoCurrency()).findAny();
|
||||
} else {
|
||||
return paymentAccounts.stream().filter(paymentAccount1 -> !paymentAccount1.isFiat() &&
|
||||
paymentAccount1.getTradeCurrency().isPresent() &&
|
||||
!Objects.equals(paymentAccount1.getTradeCurrency().get().getCode(), GUIUtil.TOP_CRYPTO.getCode())).findAny();
|
||||
return paymentAccounts.stream().filter(paymentAccount1 -> paymentAccount1.getTradeCurrency().isPresent()).findAny();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,10 @@ import haveno.desktop.common.view.View;
|
|||
import haveno.desktop.common.view.ViewLoader;
|
||||
import haveno.desktop.main.MainView;
|
||||
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.CryptoOfferBookView;
|
||||
import haveno.desktop.main.offer.offerbook.OtherOfferBookView;
|
||||
import haveno.desktop.main.offer.offerbook.TopCryptoOfferBookView;
|
||||
import haveno.desktop.main.offer.takeoffer.TakeOfferView;
|
||||
import haveno.desktop.util.GUIUtil;
|
||||
import haveno.network.p2p.P2PService;
|
||||
|
@ -50,9 +50,9 @@ import java.util.Optional;
|
|||
|
||||
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 Navigation navigation;
|
||||
|
@ -95,17 +95,17 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
|||
tabChangeListener = (observableValue, oldValue, newValue) -> {
|
||||
UserThread.execute(() -> {
|
||||
if (newValue != null) {
|
||||
if (newValue.equals(xmrOfferBookTab)) {
|
||||
if (xmrOfferBookView != null) {
|
||||
xmrOfferBookView.onTabSelected(true);
|
||||
if (newValue.equals(fiatOfferBookTab)) {
|
||||
if (fiatOfferBookView != null) {
|
||||
fiatOfferBookView.onTabSelected(true);
|
||||
} else {
|
||||
loadView(XmrOfferBookView.class, null, null);
|
||||
loadView(FiatOfferBookView.class, null, null);
|
||||
}
|
||||
} else if (newValue.equals(topCryptoOfferBookTab)) {
|
||||
if (topCryptoOfferBookView != null) {
|
||||
topCryptoOfferBookView.onTabSelected(true);
|
||||
} else if (newValue.equals(cryptoOfferBookTab)) {
|
||||
if (cryptoOfferBookView != null) {
|
||||
cryptoOfferBookView.onTabSelected(true);
|
||||
} else {
|
||||
loadView(TopCryptoOfferBookView.class, null, null);
|
||||
loadView(CryptoOfferBookView.class, null, null);
|
||||
}
|
||||
} else if (newValue.equals(otherOfferBookTab)) {
|
||||
if (otherOfferBookView != null) {
|
||||
|
@ -116,10 +116,10 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
|||
}
|
||||
}
|
||||
if (oldValue != null) {
|
||||
if (oldValue.equals(xmrOfferBookTab) && xmrOfferBookView != null) {
|
||||
xmrOfferBookView.onTabSelected(false);
|
||||
} else if (oldValue.equals(topCryptoOfferBookTab) && topCryptoOfferBookView != null) {
|
||||
topCryptoOfferBookView.onTabSelected(false);
|
||||
if (oldValue.equals(fiatOfferBookTab) && fiatOfferBookView != null) {
|
||||
fiatOfferBookView.onTabSelected(false);
|
||||
} else if (oldValue.equals(cryptoOfferBookTab) && cryptoOfferBookView != null) {
|
||||
cryptoOfferBookView.onTabSelected(false);
|
||||
} else if (oldValue.equals(otherOfferBookTab) && otherOfferBookView != null) {
|
||||
otherOfferBookView.onTabSelected(false);
|
||||
}
|
||||
|
@ -154,14 +154,8 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
|||
|
||||
root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
|
||||
navigation.addListener(navigationListener);
|
||||
if (xmrOfferBookView == null) {
|
||||
navigation.navigateTo(MainView.class, this.getClass(), XmrOfferBookView.class);
|
||||
}
|
||||
|
||||
GUIUtil.updateTopCrypto(preferences);
|
||||
|
||||
if (topCryptoOfferBookTab != null) {
|
||||
topCryptoOfferBookTab.setText(GUIUtil.TOP_CRYPTO.getName().toUpperCase());
|
||||
if (fiatOfferBookView == null) {
|
||||
navigation.navigateTo(MainView.class, this.getClass(), FiatOfferBookView.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,66 +173,65 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
|||
|
||||
if (OfferBookView.class.isAssignableFrom(viewClass)) {
|
||||
|
||||
if (viewClass == XmrOfferBookView.class && xmrOfferBookTab != null && xmrOfferBookView != null) {
|
||||
if (viewClass == FiatOfferBookView.class && fiatOfferBookTab != null && fiatOfferBookView != null) {
|
||||
if (childViewClass == null) {
|
||||
xmrOfferBookTab.setContent(xmrOfferBookView.getRoot());
|
||||
fiatOfferBookTab.setContent(fiatOfferBookView.getRoot());
|
||||
} else if (childViewClass == TakeOfferView.class) {
|
||||
loadTakeViewClass(viewClass, childViewClass, xmrOfferBookTab);
|
||||
loadTakeViewClass(viewClass, childViewClass, fiatOfferBookTab);
|
||||
} else {
|
||||
loadCreateViewClass(xmrOfferBookView, viewClass, childViewClass, xmrOfferBookTab, (PaymentMethod) data);
|
||||
loadCreateViewClass(fiatOfferBookView, viewClass, childViewClass, fiatOfferBookTab, (PaymentMethod) data);
|
||||
}
|
||||
tabPane.getSelectionModel().select(xmrOfferBookTab);
|
||||
} else if (viewClass == TopCryptoOfferBookView.class && topCryptoOfferBookTab != null && topCryptoOfferBookView != null) {
|
||||
tabPane.getSelectionModel().select(fiatOfferBookTab);
|
||||
} else if (viewClass == CryptoOfferBookView.class && cryptoOfferBookTab != null && cryptoOfferBookView != null) {
|
||||
if (childViewClass == null) {
|
||||
topCryptoOfferBookTab.setContent(topCryptoOfferBookView.getRoot());
|
||||
cryptoOfferBookTab.setContent(cryptoOfferBookView.getRoot());
|
||||
} else if (childViewClass == TakeOfferView.class) {
|
||||
loadTakeViewClass(viewClass, childViewClass, topCryptoOfferBookTab);
|
||||
loadTakeViewClass(viewClass, childViewClass, cryptoOfferBookTab);
|
||||
} else {
|
||||
tradeCurrency = GUIUtil.TOP_CRYPTO;
|
||||
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
|
||||
// add sanity check in case of app restart
|
||||
if (CurrencyUtil.isTraditionalCurrency(tradeCurrency.getCode())) {
|
||||
Optional<TradeCurrency> tradeCurrencyOptional = (this.direction == OfferDirection.SELL) ?
|
||||
CurrencyUtil.getTradeCurrency(preferences.getSellScreenCryptoCurrencyCode()) :
|
||||
CurrencyUtil.getTradeCurrency(preferences.getBuyScreenCryptoCurrencyCode());
|
||||
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);
|
||||
}
|
||||
tabPane.getSelectionModel().select(otherOfferBookTab);
|
||||
} else {
|
||||
if (xmrOfferBookTab == null) {
|
||||
xmrOfferBookTab = new Tab(Res.getBaseCurrencyName().toUpperCase());
|
||||
xmrOfferBookTab.setClosable(false);
|
||||
topCryptoOfferBookTab = new Tab(GUIUtil.TOP_CRYPTO.getName().toUpperCase());
|
||||
topCryptoOfferBookTab.setClosable(false);
|
||||
otherOfferBookTab = new Tab(Res.get("shared.other").toUpperCase());
|
||||
if (fiatOfferBookTab == null) {
|
||||
fiatOfferBookTab = new Tab(Res.get("shared.fiat").toUpperCase());
|
||||
fiatOfferBookTab.setClosable(false);
|
||||
cryptoOfferBookTab = new Tab(Res.get("shared.crypto").toUpperCase());
|
||||
cryptoOfferBookTab.setClosable(false);
|
||||
otherOfferBookTab = new Tab(Res.get("shared.preciousMetals").toUpperCase());
|
||||
otherOfferBookTab.setClosable(false);
|
||||
|
||||
tabPane.getTabs().addAll(xmrOfferBookTab, topCryptoOfferBookTab, otherOfferBookTab);
|
||||
tabPane.getTabs().addAll(fiatOfferBookTab, cryptoOfferBookTab, otherOfferBookTab);
|
||||
}
|
||||
if (viewClass == XmrOfferBookView.class) {
|
||||
xmrOfferBookView = (XmrOfferBookView) viewLoader.load(XmrOfferBookView.class);
|
||||
xmrOfferBookView.setOfferActionHandler(offerActionHandler);
|
||||
xmrOfferBookView.setDirection(direction);
|
||||
xmrOfferBookView.onTabSelected(true);
|
||||
tabPane.getSelectionModel().select(xmrOfferBookTab);
|
||||
xmrOfferBookTab.setContent(xmrOfferBookView.getRoot());
|
||||
} else if (viewClass == TopCryptoOfferBookView.class) {
|
||||
topCryptoOfferBookView = (TopCryptoOfferBookView) viewLoader.load(TopCryptoOfferBookView.class);
|
||||
topCryptoOfferBookView.setOfferActionHandler(offerActionHandler);
|
||||
topCryptoOfferBookView.setDirection(direction);
|
||||
topCryptoOfferBookView.onTabSelected(true);
|
||||
tabPane.getSelectionModel().select(topCryptoOfferBookTab);
|
||||
topCryptoOfferBookTab.setContent(topCryptoOfferBookView.getRoot());
|
||||
if (viewClass == FiatOfferBookView.class) {
|
||||
fiatOfferBookView = (FiatOfferBookView) viewLoader.load(FiatOfferBookView.class);
|
||||
fiatOfferBookView.setOfferActionHandler(offerActionHandler);
|
||||
fiatOfferBookView.setDirection(direction);
|
||||
fiatOfferBookView.onTabSelected(true);
|
||||
tabPane.getSelectionModel().select(fiatOfferBookTab);
|
||||
fiatOfferBookTab.setContent(fiatOfferBookView.getRoot());
|
||||
} else if (viewClass == CryptoOfferBookView.class) {
|
||||
cryptoOfferBookView = (CryptoOfferBookView) viewLoader.load(CryptoOfferBookView.class);
|
||||
cryptoOfferBookView.setOfferActionHandler(offerActionHandler);
|
||||
cryptoOfferBookView.setDirection(direction);
|
||||
cryptoOfferBookView.onTabSelected(true);
|
||||
tabPane.getSelectionModel().select(cryptoOfferBookTab);
|
||||
cryptoOfferBookTab.setContent(cryptoOfferBookView.getRoot());
|
||||
} else if (viewClass == OtherOfferBookView.class) {
|
||||
otherOfferBookView = (OtherOfferBookView) viewLoader.load(OtherOfferBookView.class);
|
||||
otherOfferBookView.setOfferActionHandler(offerActionHandler);
|
||||
|
@ -265,11 +258,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
|||
// in different graphs
|
||||
view = viewLoader.load(childViewClass);
|
||||
|
||||
// Invert direction for non-Fiat trade currencies -> BUY BCH is to SELL Monero
|
||||
OfferDirection offerDirection = CurrencyUtil.isFiatCurrency(tradeCurrency.getCode()) ? direction :
|
||||
direction == OfferDirection.BUY ? OfferDirection.SELL : OfferDirection.BUY;
|
||||
|
||||
((CreateOfferView) view).initWithData(offerDirection, tradeCurrency, offerActionHandler);
|
||||
((CreateOfferView) view).initWithData(direction, tradeCurrency, offerActionHandler);
|
||||
|
||||
((SelectableView) view).onTabSelected(true);
|
||||
|
||||
|
@ -329,9 +318,9 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
|
|||
private Class<? extends OfferBookView<?, ?>> getOfferBookViewClassFor(String currencyCode) {
|
||||
Class<? extends OfferBookView<?, ?>> offerBookViewClass;
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
offerBookViewClass = XmrOfferBookView.class;
|
||||
} else if (currencyCode.equals(GUIUtil.TOP_CRYPTO.getCode())) {
|
||||
offerBookViewClass = TopCryptoOfferBookView.class;
|
||||
offerBookViewClass = FiatOfferBookView.class;
|
||||
} else if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
|
||||
offerBookViewClass = CryptoOfferBookView.class;
|
||||
} else {
|
||||
offerBookViewClass = OtherOfferBookView.class;
|
||||
}
|
||||
|
|
|
@ -22,16 +22,16 @@ import haveno.core.locale.CryptoCurrency;
|
|||
import haveno.core.locale.CurrencyUtil;
|
||||
import haveno.core.locale.Res;
|
||||
import haveno.core.locale.TradeCurrency;
|
||||
import haveno.core.locale.TraditionalCurrency;
|
||||
import haveno.core.offer.Offer;
|
||||
import haveno.core.offer.OfferDirection;
|
||||
import haveno.core.xmr.wallet.XmrWalletService;
|
||||
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.CryptoOfferBookView;
|
||||
import haveno.desktop.main.offer.offerbook.OtherOfferBookView;
|
||||
import haveno.desktop.main.offer.offerbook.TopCryptoOfferBookView;
|
||||
import haveno.desktop.main.overlays.popups.Popup;
|
||||
import haveno.desktop.util.GUIUtil;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.VPos;
|
||||
|
@ -44,7 +44,6 @@ import monero.daemon.model.MoneroSubmitTxResult;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
@ -90,10 +89,10 @@ public class OfferViewUtil {
|
|||
|
||||
public static Class<? extends OfferBookView<?, ?>> getOfferBookViewClass(String currencyCode) {
|
||||
Class<? extends OfferBookView<?, ?>> offerBookViewClazz;
|
||||
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) {
|
||||
offerBookViewClazz = XmrOfferBookView.class;
|
||||
} else if (currencyCode.equals(GUIUtil.TOP_CRYPTO.getCode())) {
|
||||
offerBookViewClazz = TopCryptoOfferBookView.class;
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
offerBookViewClazz = FiatOfferBookView.class;
|
||||
} else if (CurrencyUtil.isCryptoCurrency(currencyCode)) {
|
||||
offerBookViewClazz = CryptoOfferBookView.class;
|
||||
} else {
|
||||
offerBookViewClazz = OtherOfferBookView.class;
|
||||
}
|
||||
|
@ -109,7 +108,7 @@ public class OfferViewUtil {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -124,10 +123,18 @@ public class OfferViewUtil {
|
|||
return getMainCryptoCurrencies().findAny().get();
|
||||
}
|
||||
|
||||
public static TradeCurrency getAnyOfOtherCurrencies() {
|
||||
return getOtherCurrencies().findAny().get();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Stream<CryptoCurrency> getMainCryptoCurrencies() {
|
||||
return CurrencyUtil.getMainCryptoCurrencies().stream().filter(cryptoCurrency ->
|
||||
!Objects.equals(cryptoCurrency.getCode(), GUIUtil.TOP_CRYPTO.getCode()));
|
||||
return CurrencyUtil.getMainCryptoCurrencies().stream();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Stream<TraditionalCurrency> getOtherCurrencies() {
|
||||
return CurrencyUtil.getTraditionalNonFiatCurrencies().stream();
|
||||
}
|
||||
|
||||
public static void submitTransactionHex(XmrWalletService xmrWalletService,
|
||||
|
|
|
@ -31,8 +31,6 @@ import haveno.desktop.common.view.FxmlView;
|
|||
import haveno.desktop.main.offer.MutableOfferView;
|
||||
import haveno.desktop.main.offer.OfferView;
|
||||
import haveno.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||
import haveno.desktop.util.GUIUtil;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
@ -60,12 +58,12 @@ public class CreateOfferView extends MutableOfferView<CreateOfferViewModel> {
|
|||
protected ObservableList<PaymentAccount> filterPaymentAccounts(ObservableList<PaymentAccount> paymentAccounts) {
|
||||
return FXCollections.observableArrayList(
|
||||
paymentAccounts.stream().filter(paymentAccount -> {
|
||||
if (model.getTradeCurrency().equals(GUIUtil.TOP_CRYPTO)) {
|
||||
return Objects.equals(paymentAccount.getSingleTradeCurrency(), GUIUtil.TOP_CRYPTO);
|
||||
} else if (CurrencyUtil.isFiatCurrency(model.getTradeCurrency().getCode())) {
|
||||
if (CurrencyUtil.isFiatCurrency(model.getTradeCurrency().getCode())) {
|
||||
return paymentAccount.isFiat();
|
||||
} else if (CurrencyUtil.isCryptoCurrency(model.getTradeCurrency().getCode())) {
|
||||
return paymentAccount.isCryptoCurrency();
|
||||
} else {
|
||||
return !paymentAccount.isFiat() && !Objects.equals(paymentAccount.getSingleTradeCurrency(), GUIUtil.TOP_CRYPTO);
|
||||
return !paymentAccount.isFiat() && !paymentAccount.isCryptoCurrency();
|
||||
}
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?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"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
|
|
@ -33,39 +33,29 @@ import haveno.desktop.main.overlays.windows.OfferDetailsWindow;
|
|||
import javafx.scene.layout.GridPane;
|
||||
|
||||
@FxmlView
|
||||
public class TopCryptoOfferBookView extends OfferBookView<GridPane, TopCryptoOfferBookViewModel> {
|
||||
public class CryptoOfferBookView extends OfferBookView<GridPane, CryptoOfferBookViewModel> {
|
||||
|
||||
@Inject
|
||||
TopCryptoOfferBookView(TopCryptoOfferBookViewModel model,
|
||||
Navigation navigation,
|
||||
OfferDetailsWindow offerDetailsWindow,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||
PrivateNotificationManager privateNotificationManager,
|
||||
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
SignedWitnessService signedWitnessService) {
|
||||
CryptoOfferBookView(CryptoOfferBookViewModel model,
|
||||
Navigation navigation,
|
||||
OfferDetailsWindow offerDetailsWindow,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||
PrivateNotificationManager privateNotificationManager,
|
||||
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
SignedWitnessService signedWitnessService) {
|
||||
super(model, navigation, offerDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMarketTitle() {
|
||||
return model.getDirection().equals(OfferDirection.BUY) ?
|
||||
Res.get("offerbook.availableOffersToBuy", TopCryptoOfferBookViewModel.TOP_CRYPTO.getCode(), Res.getBaseCurrencyCode()) :
|
||||
Res.get("offerbook.availableOffersToSell", TopCryptoOfferBookViewModel.TOP_CRYPTO.getCode(), Res.getBaseCurrencyCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
model.onSetTradeCurrency(TopCryptoOfferBookViewModel.TOP_CRYPTO);
|
||||
|
||||
super.activate();
|
||||
|
||||
currencyComboBoxContainer.setVisible(false);
|
||||
currencyComboBoxContainer.setManaged(false);
|
||||
Res.get("offerbook.availableOffersToBuy", Res.getBaseCurrencyCode(), Res.get("shared.crypto")) :
|
||||
Res.get("offerbook.availableOffersToSell", Res.getBaseCurrencyCode(), Res.get("shared.crypto"));
|
||||
}
|
||||
|
||||
@Override
|
||||
String getTradeCurrencyCode() {
|
||||
return TopCryptoOfferBookViewModel.TOP_CRYPTO.getCode();
|
||||
return Res.getBaseCurrencyCode();
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?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"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
|
|
@ -33,17 +33,17 @@ import haveno.desktop.main.overlays.windows.OfferDetailsWindow;
|
|||
import javafx.scene.layout.GridPane;
|
||||
|
||||
@FxmlView
|
||||
public class XmrOfferBookView extends OfferBookView<GridPane, XmrOfferBookViewModel> {
|
||||
public class FiatOfferBookView extends OfferBookView<GridPane, FiatOfferBookViewModel> {
|
||||
|
||||
@Inject
|
||||
XmrOfferBookView(XmrOfferBookViewModel model,
|
||||
Navigation navigation,
|
||||
OfferDetailsWindow offerDetailsWindow,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||
PrivateNotificationManager privateNotificationManager,
|
||||
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
SignedWitnessService signedWitnessService) {
|
||||
FiatOfferBookView(FiatOfferBookViewModel model,
|
||||
Navigation navigation,
|
||||
OfferDetailsWindow offerDetailsWindow,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||
PrivateNotificationManager privateNotificationManager,
|
||||
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
SignedWitnessService signedWitnessService) {
|
||||
super(model, navigation, offerDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService);
|
||||
}
|
||||
|
|
@ -49,23 +49,23 @@ import java.util.stream.Collectors;
|
|||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
public class XmrOfferBookViewModel extends OfferBookViewModel {
|
||||
public class FiatOfferBookViewModel extends OfferBookViewModel {
|
||||
|
||||
@Inject
|
||||
public XmrOfferBookViewModel(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) {
|
||||
public FiatOfferBookViewModel(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);
|
||||
}
|
||||
|
||||
|
@ -141,9 +141,10 @@ public class XmrOfferBookViewModel extends OfferBookViewModel {
|
|||
!hasPaymentAccountForCurrency(o2))).collect(Collectors.toList());
|
||||
return sortedList.get(0);
|
||||
} else {
|
||||
return CurrencyUtil.getMainTraditionalCurrencies().stream().sorted((o1, o2) ->
|
||||
Boolean.compare(!hasPaymentAccountForCurrency(o1),
|
||||
!hasPaymentAccountForCurrency(o2))).collect(Collectors.toList()).get(0);
|
||||
return CurrencyUtil.getMainTraditionalCurrencies().stream()
|
||||
.filter(withFiatCurrency())
|
||||
.sorted((o1, o2) -> Boolean.compare(!hasPaymentAccountForCurrency(o1), !hasPaymentAccountForCurrency(o2)))
|
||||
.collect(Collectors.toList()).get(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -37,25 +37,25 @@ public class OtherOfferBookView extends OfferBookView<GridPane, OtherOfferBookVi
|
|||
|
||||
@Inject
|
||||
OtherOfferBookView(OtherOfferBookViewModel model,
|
||||
Navigation navigation,
|
||||
OfferDetailsWindow offerDetailsWindow,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||
PrivateNotificationManager privateNotificationManager,
|
||||
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
SignedWitnessService signedWitnessService) {
|
||||
Navigation navigation,
|
||||
OfferDetailsWindow offerDetailsWindow,
|
||||
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
|
||||
PrivateNotificationManager privateNotificationManager,
|
||||
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
SignedWitnessService signedWitnessService) {
|
||||
super(model, navigation, offerDetailsWindow, formatter, privateNotificationManager, useDevPrivilegeKeys, accountAgeWitnessService, signedWitnessService);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMarketTitle() {
|
||||
return model.getDirection().equals(OfferDirection.BUY) ?
|
||||
Res.get("offerbook.availableOffersToBuy", Res.get("shared.otherAssets"), Res.getBaseCurrencyCode()) :
|
||||
Res.get("offerbook.availableOffersToSell", Res.get("shared.otherAssets"), Res.getBaseCurrencyCode());
|
||||
Res.get("offerbook.availableOffersToBuy", Res.getBaseCurrencyCode(), Res.get("shared.otherAssets")) :
|
||||
Res.get("offerbook.availableOffersToSell", Res.getBaseCurrencyCode(), Res.get("shared.otherAssets"));
|
||||
}
|
||||
|
||||
@Override
|
||||
String getTradeCurrencyCode() {
|
||||
return model.showAllTradeCurrenciesProperty.get() ? "" : model.getSelectedTradeCurrency().getCode();
|
||||
return Res.getBaseCurrencyCode();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ 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;
|
||||
|
@ -54,28 +53,28 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
|
|||
|
||||
@Inject
|
||||
public OtherOfferBookViewModel(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) {
|
||||
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);
|
||||
preferences.setBuyScreenOtherCurrencyCode(code);
|
||||
} else {
|
||||
preferences.setSellScreenCryptoCurrencyCode(code);
|
||||
preferences.setBuyScreenOtherCurrencyCode(code);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +82,6 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
|
|||
protected ObservableList<PaymentMethod> filterPaymentMethods(ObservableList<PaymentMethod> list,
|
||||
TradeCurrency selectedTradeCurrency) {
|
||||
return FXCollections.observableArrayList(list.stream().filter(paymentMethod -> {
|
||||
if (paymentMethod.isBlockchain()) return true;
|
||||
if (paymentMethod.getSupportedAssetCodes() == null) return true;
|
||||
for (String assetCode : paymentMethod.getSupportedAssetCodes()) {
|
||||
if (!CurrencyUtil.isFiatCurrency(assetCode)) return true;
|
||||
|
@ -95,20 +93,13 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
|
|||
@Override
|
||||
void fillCurrencies(ObservableList<TradeCurrency> tradeCurrencies,
|
||||
ObservableList<TradeCurrency> allCurrencies) {
|
||||
|
||||
tradeCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
|
||||
tradeCurrencies.addAll(preferences.getCryptoCurrenciesAsObservable().stream()
|
||||
.filter(withoutTopCrypto())
|
||||
.collect(Collectors.toList()));
|
||||
tradeCurrencies.addAll(CurrencyUtil.getMainTraditionalCurrencies().stream()
|
||||
.filter(withoutFiatCurrency())
|
||||
.collect(Collectors.toList()));
|
||||
tradeCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
|
||||
|
||||
allCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
|
||||
allCurrencies.addAll(CurrencyUtil.getAllSortedCryptoCurrencies().stream()
|
||||
.filter(withoutTopCrypto())
|
||||
.collect(Collectors.toList()));
|
||||
allCurrencies.addAll(CurrencyUtil.getMainTraditionalCurrencies().stream()
|
||||
.filter(withoutFiatCurrency())
|
||||
.collect(Collectors.toList()));
|
||||
|
@ -120,12 +111,9 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
|
|||
TradeCurrency selectedTradeCurrency) {
|
||||
return offerBookListItem -> {
|
||||
Offer offer = offerBookListItem.getOffer();
|
||||
// BUY Crypto is actually SELL Monero
|
||||
boolean directionResult = offer.getDirection() == direction;
|
||||
boolean currencyResult = !CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) &&
|
||||
((showAllTradeCurrenciesProperty.get() &&
|
||||
!offer.getCurrencyCode().equals(GUIUtil.TOP_CRYPTO.getCode())) ||
|
||||
offer.getCurrencyCode().equals(selectedTradeCurrency.getCode()));
|
||||
boolean directionResult = offer.getDirection() != direction;
|
||||
boolean currencyResult = CurrencyUtil.isTraditionalCurrency(offer.getCurrencyCode()) && !CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) &&
|
||||
(showAllTradeCurrenciesProperty.get() || offer.getCurrencyCode().equals(selectedTradeCurrency.getCode()));
|
||||
boolean paymentMethodResult = showAllPaymentMethods ||
|
||||
offer.getPaymentMethod().equals(selectedPaymentMethod);
|
||||
boolean notMyOfferOrShowMyOffersActivated = !isMyOffer(offerBookListItem.getOffer()) || preferences.isShowOwnOffersInOfferBook();
|
||||
|
@ -137,8 +125,8 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
|
|||
TradeCurrency getDefaultTradeCurrency() {
|
||||
TradeCurrency defaultTradeCurrency = GlobalSettings.getDefaultTradeCurrency();
|
||||
|
||||
if (!CurrencyUtil.isTraditionalCurrency(defaultTradeCurrency.getCode()) &&
|
||||
!defaultTradeCurrency.equals(GUIUtil.TOP_CRYPTO) &&
|
||||
if (CurrencyUtil.isTraditionalCurrency(defaultTradeCurrency.getCode()) &&
|
||||
!CurrencyUtil.isFiatCurrency(defaultTradeCurrency.getCode()) &&
|
||||
hasPaymentAccountForCurrency(defaultTradeCurrency)) {
|
||||
return defaultTradeCurrency;
|
||||
}
|
||||
|
@ -152,22 +140,19 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
|
|||
!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);
|
||||
return CurrencyUtil.getMainTraditionalCurrencies().stream()
|
||||
.filter(withoutFiatCurrency())
|
||||
.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();
|
||||
}
|
||||
// validate if previous stored currencies are Traditional ones
|
||||
String currencyCode = direction == OfferDirection.BUY ? preferences.getBuyScreenOtherCurrencyCode() : preferences.getSellScreenOtherCurrencyCode();
|
||||
|
||||
@NotNull
|
||||
private Predicate<CryptoCurrency> withoutTopCrypto() {
|
||||
return cryptoCurrency ->
|
||||
!cryptoCurrency.equals(GUIUtil.TOP_CRYPTO);
|
||||
return CurrencyUtil.isTraditionalCurrency(currencyCode) ? currencyCode : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -134,8 +134,6 @@ public class GUIUtil {
|
|||
|
||||
private static Preferences preferences;
|
||||
|
||||
public static TradeCurrency TOP_CRYPTO = CurrencyUtil.getTradeCurrency("BTC").get();
|
||||
|
||||
public static void setPreferences(Preferences preferences) {
|
||||
GUIUtil.preferences = preferences;
|
||||
}
|
||||
|
@ -1033,12 +1031,4 @@ public class GUIUtil {
|
|||
columnConstraints2.setHgrow(Priority.ALWAYS);
|
||||
gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
|
||||
}
|
||||
|
||||
public static void updateTopCrypto(Preferences preferences) {
|
||||
TradeCurrency tradeCurrency = preferences.getPreferredTradeCurrency();
|
||||
if (CurrencyUtil.isTraditionalCurrency(tradeCurrency.getCode())) {
|
||||
return;
|
||||
}
|
||||
TOP_CRYPTO = tradeCurrency;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ public class OfferBookViewModelTest {
|
|||
|
||||
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);
|
||||
assertEquals(0, model.maxPlacesForAmount.intValue());
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ public class OfferBookViewModelTest {
|
|||
|
||||
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);
|
||||
model.activate();
|
||||
|
||||
|
@ -273,7 +273,7 @@ public class OfferBookViewModelTest {
|
|||
|
||||
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);
|
||||
model.activate();
|
||||
|
||||
|
@ -292,7 +292,7 @@ public class OfferBookViewModelTest {
|
|||
|
||||
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);
|
||||
assertEquals(0, model.maxPlacesForVolume.intValue());
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ public class OfferBookViewModelTest {
|
|||
|
||||
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);
|
||||
model.activate();
|
||||
|
||||
|
@ -324,7 +324,7 @@ public class OfferBookViewModelTest {
|
|||
|
||||
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);
|
||||
model.activate();
|
||||
|
||||
|
@ -342,7 +342,7 @@ public class OfferBookViewModelTest {
|
|||
|
||||
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);
|
||||
assertEquals(0, model.maxPlacesForPrice.intValue());
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ public class OfferBookViewModelTest {
|
|||
|
||||
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);
|
||||
model.activate();
|
||||
|
||||
|
@ -374,7 +374,7 @@ public class OfferBookViewModelTest {
|
|||
|
||||
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);
|
||||
assertEquals(0, model.maxPlacesForMarketPriceMargin.intValue());
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ public class OfferBookViewModelTest {
|
|||
item4.getOffer().setPriceFeedService(priceFeedService);
|
||||
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);
|
||||
model.activate();
|
||||
|
||||
|
@ -430,7 +430,7 @@ public class OfferBookViewModelTest {
|
|||
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
|
||||
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);
|
||||
|
||||
final OfferBookListItem item = make(xmrBuyItem.but(
|
||||
|
|
|
@ -1742,6 +1742,8 @@ message PreferencesPayload {
|
|||
bool split_offer_output = 62;
|
||||
bool use_sound_for_notifications = 63;
|
||||
bool use_sound_for_notifications_initialized = 64;
|
||||
string buy_screen_other_currency_code = 65;
|
||||
string sell_screen_other_currency_code = 66;
|
||||
}
|
||||
|
||||
message AutoConfirmSettings {
|
||||
|
|
Loading…
Reference in a new issue