diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 1e556868a0..15824a99a9 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -198,6 +198,7 @@ shared.openURL=Open {0} shared.fiat=Fiat shared.crypto=Crypto shared.otherAssets=other assets +shared.other=Other shared.all=All shared.edit=Edit shared.advancedOptions=Advanced options @@ -383,7 +384,6 @@ offerbook.createNewOffer=Create new offer to {0} {1} offerbook.createOfferDisabled.tooltip=You can only create one offer at a time offerbook.takeOfferButton.tooltip=Take offer for {0} -offerbook.yesCreateOffer=Yes, create offer offerbook.setupNewAccount=Set up a new trading account offerbook.removeOffer.success=Remove offer was successful. offerbook.removeOffer.failed=Remove offer failed:\n{0} diff --git a/desktop/src/main/java/bisq/desktop/main/offer/BuyOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/BuyOfferView.java index e72e44b4a7..247420183d 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/BuyOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/BuyOfferView.java @@ -22,7 +22,6 @@ import bisq.desktop.common.view.FxmlView; import bisq.desktop.common.view.ViewLoader; import bisq.core.offer.OfferDirection; -import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager; import bisq.core.user.Preferences; import bisq.core.user.User; @@ -37,7 +36,6 @@ public class BuyOfferView extends OfferView { public BuyOfferView(ViewLoader viewLoader, Navigation navigation, Preferences preferences, - ArbitratorManager arbitratorManager, User user, P2PService p2PService) { super(viewLoader, diff --git a/desktop/src/main/java/bisq/desktop/main/offer/OfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/OfferView.java index 46e2f91290..95ef6b9d67 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/OfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/OfferView.java @@ -22,6 +22,7 @@ import bisq.desktop.common.view.ActivatableView; import bisq.desktop.common.view.View; import bisq.desktop.common.view.ViewLoader; import bisq.desktop.main.MainView; +import bisq.desktop.main.offer.bisq_v1.OfferViewUtil; import bisq.desktop.main.offer.bisq_v1.createoffer.CreateOfferView; import bisq.desktop.main.offer.bisq_v1.takeoffer.TakeOfferView; import bisq.desktop.main.offer.bsq_swap.create_offer.BsqSwapCreateOfferView; @@ -31,13 +32,13 @@ import bisq.desktop.main.offer.offerbook.BsqOfferBookViewModel; import bisq.desktop.main.offer.offerbook.BtcOfferBookView; import bisq.desktop.main.offer.offerbook.OfferBookView; import bisq.desktop.main.offer.offerbook.OtherOfferBookView; -import bisq.desktop.main.offer.offerbook.OtherOfferBookViewModel; import bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookView; import bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookViewModel; import bisq.desktop.util.GUIUtil; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.GlobalSettings; +import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; import bisq.core.offer.Offer; import bisq.core.offer.OfferDirection; @@ -205,6 +206,7 @@ public abstract class OfferView extends ActivatableView { } else if (data instanceof BsqSwapOfferPayload) { loadCreateViewClass(bsqOfferBookView, viewClass, childViewClass, bsqOfferBookTab, PaymentMethod.BSQ_SWAP, (BsqSwapOfferPayload) data); } else { + tradeCurrency = BsqOfferBookViewModel.BSQ; loadCreateViewClass(bsqOfferBookView, viewClass, childViewClass, bsqOfferBookTab, (PaymentMethod) data, null); } tabPane.getSelectionModel().select(bsqOfferBookTab); @@ -214,6 +216,7 @@ public abstract class OfferView extends ActivatableView { } else if (childViewClass == TakeOfferView.class) { loadTakeViewClass(viewClass, childViewClass, topAltcoinOfferBookTab); } else { + tradeCurrency = TopAltcoinOfferBookViewModel.TOP_ALTCOIN; loadCreateViewClass(topAltcoinOfferBookView, viewClass, childViewClass, topAltcoinOfferBookTab, (PaymentMethod) data, null); } tabPane.getSelectionModel().select(topAltcoinOfferBookTab); @@ -228,21 +231,20 @@ public abstract class OfferView extends ActivatableView { Optional tradeCurrencyOptional = (this.direction == OfferDirection.SELL) ? CurrencyUtil.getTradeCurrency(preferences.getSellScreenCryptoCurrencyCode()) : CurrencyUtil.getTradeCurrency(preferences.getBuyScreenCryptoCurrencyCode()); - tradeCurrency = tradeCurrencyOptional.isEmpty() ? OtherOfferBookViewModel.DEFAULT_ALTCOIN : tradeCurrencyOptional.get(); + tradeCurrency = tradeCurrencyOptional.isEmpty() ? OfferViewUtil.getAnyOfMainCryptoCurrencies() : tradeCurrencyOptional.get(); } loadCreateViewClass(otherOfferBookView, viewClass, childViewClass, otherOfferBookTab, (PaymentMethod) data, null); } tabPane.getSelectionModel().select(otherOfferBookTab); } else { if (btcOfferBookTab == null) { - //TODO: use naming from currencies or from translations - btcOfferBookTab = new Tab("BITCOIN"); + btcOfferBookTab = new Tab(Res.getBaseCurrencyName().toUpperCase()); btcOfferBookTab.setClosable(false); - bsqOfferBookTab = new Tab("BSQ"); + bsqOfferBookTab = new Tab(BsqOfferBookViewModel.BSQ.getCode()); bsqOfferBookTab.setClosable(false); - topAltcoinOfferBookTab = new Tab("MONERO"); + topAltcoinOfferBookTab = new Tab(TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode()); topAltcoinOfferBookTab.setClosable(false); - otherOfferBookTab = new Tab("OTHER"); + otherOfferBookTab = new Tab(Res.get("shared.other").toUpperCase()); otherOfferBookTab.setClosable(false); tabPane.getTabs().addAll(btcOfferBookTab, bsqOfferBookTab, topAltcoinOfferBookTab, otherOfferBookTab); diff --git a/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/MutableOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/MutableOfferView.java index 1a50040424..6d4b591168 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/MutableOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/MutableOfferView.java @@ -337,7 +337,7 @@ public abstract class MutableOfferView> exten if (CurrencyUtil.isFiatCurrency(tradeCurrency.getCode())) { placeOfferButtonLabel = Res.get("createOffer.placeOfferButton", Res.get("shared.buy")); } else { - placeOfferButtonLabel = Res.get("createOffer.placeOfferButtonAltcoin", Res.get("shared.buy"), tradeCurrency.getName()); + placeOfferButtonLabel = Res.get("createOffer.placeOfferButtonAltcoin", Res.get("shared.buy"), tradeCurrency.getCode()); } placeOfferButton.updateText(placeOfferButtonLabel); nextButton.setId("buy-button"); @@ -347,7 +347,7 @@ public abstract class MutableOfferView> exten if (CurrencyUtil.isFiatCurrency(tradeCurrency.getCode())) { placeOfferButtonLabel = Res.get("createOffer.placeOfferButton", Res.get("shared.sell")); } else { - placeOfferButtonLabel = Res.get("createOffer.placeOfferButtonAltcoin", Res.get("shared.sell"), tradeCurrency.getName()); + placeOfferButtonLabel = Res.get("createOffer.placeOfferButtonAltcoin", Res.get("shared.sell"), tradeCurrency.getCode()); } nextButton.setId("sell-button"); fundFromSavingsWalletButton.setId("sell-button"); @@ -793,10 +793,10 @@ public abstract class MutableOfferView> exten if (!CurrencyUtil.isFiatCurrency(newValue)) { if (model.isShownAsBuyOffer()) { placeOfferButton.updateText(Res.get("createOffer.placeOfferButtonAltcoin", Res.get("shared.buy"), - model.getTradeCurrency().getName())); + model.getTradeCurrency().getCode())); } else { placeOfferButton.updateText(Res.get("createOffer.placeOfferButtonAltcoin", Res.get("shared.sell"), - model.getTradeCurrency().getName())); + model.getTradeCurrency().getCode())); } } }; diff --git a/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/OfferViewUtil.java b/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/OfferViewUtil.java index 2d7b37fae9..773d799fe3 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/OfferViewUtil.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/OfferViewUtil.java @@ -24,6 +24,8 @@ import bisq.desktop.components.HyperlinkWithIcon; import bisq.desktop.main.MainView; import bisq.desktop.main.offer.SellOfferView; import bisq.desktop.main.offer.offerbook.BsqOfferBookView; +import bisq.desktop.main.offer.offerbook.BsqOfferBookViewModel; +import bisq.desktop.main.offer.offerbook.TopAltcoinOfferBookViewModel; import bisq.desktop.main.overlays.popups.Popup; import bisq.core.locale.CurrencyUtil; @@ -46,6 +48,7 @@ import javafx.geometry.Pos; import javafx.geometry.VPos; import java.util.HashMap; +import java.util.Objects; import java.util.concurrent.TimeUnit; // Shared utils for Views @@ -133,4 +136,10 @@ public class OfferViewUtil { public static boolean isShownAsBuyOffer(OfferDirection direction, TradeCurrency tradeCurrency) { return !isShownAsSellOffer(tradeCurrency.getCode(), direction); } + + public static TradeCurrency getAnyOfMainCryptoCurrencies() { + return CurrencyUtil.getMainCryptoCurrencies().stream().filter(cryptoCurrency -> + !Objects.equals(cryptoCurrency.getCode(), TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode()) && + !Objects.equals(cryptoCurrency.getCode(), BsqOfferBookViewModel.BSQ.getCode())).findAny().get(); + } } diff --git a/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/takeoffer/TakeOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/takeoffer/TakeOfferView.java index a507c073d8..12dfeb7a44 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/takeoffer/TakeOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/bisq_v1/takeoffer/TakeOfferView.java @@ -1351,7 +1351,7 @@ public class TakeOfferView extends ActivatableViewAndModel BUY BSQ is to SELL Bitcoin + OfferDirection offerDirection = direction == OfferDirection.BUY ? OfferDirection.SELL : OfferDirection.BUY; - if (model.dataModel.isBuyOffer()) { + model.initWithData(offerPayload != null ? offerPayload.getDirection() : offerDirection, offerPayload); + + if (OfferViewUtil.isShownAsBuyOffer(offerDirection, BsqOfferBookViewModel.BSQ)) { actionButton.setId("buy-button-big"); - actionButton.updateText(Res.get("createOffer.placeOfferButton", Res.get("shared.buy"))); - volumeDescriptionLabel.setText(Res.get("createOffer.amountPriceBox.buy.volumeDescription", BSQ)); + actionButton.updateText(Res.get("createOffer.placeOfferButtonAltcoin", Res.get("shared.buy"), BSQ)); + nextButton.setId("buy-button"); + volumeDescriptionLabel.setText(Res.get("createOffer.amountPriceBox.sell.volumeDescription", BSQ)); } else { actionButton.setId("sell-button-big"); - actionButton.updateText(Res.get("createOffer.placeOfferButton", Res.get("shared.sell"))); - volumeDescriptionLabel.setText(Res.get("createOffer.amountPriceBox.sell.volumeDescription", BSQ)); + actionButton.updateText(Res.get("createOffer.placeOfferButtonAltcoin", Res.get("shared.sell"), BSQ)); + nextButton.setId("sell-button"); + volumeDescriptionLabel.setText(Res.get("createOffer.amountPriceBox.buy.volumeDescription", BSQ)); } String amountDescription = Res.get("createOffer.amountPriceBox.amountDescription", diff --git a/desktop/src/main/java/bisq/desktop/main/offer/bsq_swap/take_offer/BsqSwapTakeOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/bsq_swap/take_offer/BsqSwapTakeOfferView.java index d7d0c16f24..a440317cde 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/bsq_swap/take_offer/BsqSwapTakeOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/bsq_swap/take_offer/BsqSwapTakeOfferView.java @@ -163,8 +163,8 @@ public class BsqSwapTakeOfferView extends BsqSwapOfferView { private void addConfirmAndCancelButtons(boolean isPlaceOffer) { boolean isBuyOffer = OfferViewUtil.isShownAsBuyOffer(offer); boolean isBuyerRole = isPlaceOffer == isBuyOffer; - String tradeCurrencyByName = CurrencyUtil.getNameByCode(offer.getCurrencyCode()); + String tradeCurrencyByCode = offer.getCurrencyCode(); String placeOfferButtonText = isBuyerRole ? CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) ? Res.get("offerDetailsWindow.confirm.maker", Res.get("shared.buy")) : Res.get("offerDetailsWindow.confirm.makerAltcoin", Res.get("shared.buy"), - tradeCurrencyByName) : + tradeCurrencyByCode) : CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) ? Res.get("offerDetailsWindow.confirm.maker", Res.get("shared.sell")) : Res.get("offerDetailsWindow.confirm.makerAltcoin", Res.get("shared.sell"), - tradeCurrencyByName); + tradeCurrencyByCode); String takeOfferButtonText = isBuyerRole ? CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) ? Res.get("offerDetailsWindow.confirm.taker", Res.get("shared.buy")) : Res.get("offerDetailsWindow.confirm.takerAltcoin", Res.get("shared.buy"), - tradeCurrencyByName) : + tradeCurrencyByCode) : CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) ? Res.get("offerDetailsWindow.confirm.taker", Res.get("shared.sell")) : Res.get("offerDetailsWindow.confirm.takerAltcoin", Res.get("shared.sell"), - tradeCurrencyByName); + tradeCurrencyByCode); ImageView iconView = new ImageView(); iconView.setId(isBuyerRole ? "image-buy-white" : "image-sell-white");