Adapt navigation labels back to currency code

and fix lots of minor issues
This commit is contained in:
Christoph Atteneder 2022-04-08 17:49:33 +02:00
parent 497158ad13
commit 33725c2b4e
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B
16 changed files with 69 additions and 55 deletions

View file

@ -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}

View file

@ -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,

View file

@ -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<TabPane, Void> {
} 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<TabPane, Void> {
} 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<TabPane, Void> {
Optional<TradeCurrency> 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);

View file

@ -337,7 +337,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> 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<M extends MutableOfferViewModel<?>> 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<M extends MutableOfferViewModel<?>> 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()));
}
}
};

View file

@ -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();
}
}

View file

@ -1351,7 +1351,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
Res.get("takeOffer.takeOfferButton", direction) :
Res.get("takeOffer.takeOfferButtonAltcoin",
direction,
CurrencyUtil.getNameByCode(offer.getCurrencyCode()));
offer.getCurrencyCode());
}
}

View file

@ -27,7 +27,9 @@ import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.main.MainView;
import bisq.desktop.main.offer.OfferView;
import bisq.desktop.main.offer.SelectableView;
import bisq.desktop.main.offer.bisq_v1.OfferViewUtil;
import bisq.desktop.main.offer.bsq_swap.BsqSwapOfferView;
import bisq.desktop.main.offer.offerbook.BsqOfferBookViewModel;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.BsqSwapOfferDetailsWindow;
import bisq.desktop.main.portfolio.PortfolioView;
@ -168,16 +170,21 @@ public class BsqSwapCreateOfferView extends BsqSwapOfferView<BsqSwapCreateOfferV
@Nullable BsqSwapOfferPayload offerPayload) {
this.offerActionHandler = offerActionHandler;
model.initWithData(offerPayload != null ? offerPayload.getDirection() : direction, offerPayload);
// Invert direction for non-Fiat trade currencies -> 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",

View file

@ -163,8 +163,8 @@ public class BsqSwapTakeOfferView extends BsqSwapOfferView<BsqSwapTakeOfferViewM
amountDescriptionLabel.setText(Res.get("takeOffer.amountPriceBox.sell.amountDescription"));
} else {
actionButton.setId("sell-button-big");
nextButton.setId("sell-button");
actionButton.updateText(Res.get("takeOffer.takeOfferButtonAltcoin", Res.get("shared.sell"), BSQ));
nextButton.setId("sell-button");
volumeDescriptionLabel.setText(Res.get("createOffer.amountPriceBox.sell.volumeDescription", BSQ));
amountDescriptionLabel.setText(Res.get("takeOffer.amountPriceBox.buy.amountDescription"));
}

View file

@ -58,8 +58,8 @@ public class BsqOfferBookView extends OfferBookView<GridPane, BsqOfferBookViewMo
@Override
protected String getMarketTitle() {
return model.getDirection().equals(OfferDirection.BUY) ?
Res.get("offerbook.availableOffersToBuy", BsqOfferBookViewModel.BSQ.getCode(), Res.getBaseCurrencyName()) :
Res.get("offerbook.availableOffersToSell", BsqOfferBookViewModel.BSQ.getCode(), Res.getBaseCurrencyName());
Res.get("offerbook.availableOffersToBuy", BsqOfferBookViewModel.BSQ.getCode(), Res.getBaseCurrencyCode()) :
Res.get("offerbook.availableOffersToSell", BsqOfferBookViewModel.BSQ.getCode(), Res.getBaseCurrencyCode());
}
@Override
@ -73,7 +73,7 @@ public class BsqOfferBookView extends OfferBookView<GridPane, BsqOfferBookViewMo
}
@Override
String getCreateOfferButtonLabel() {
String getTradeCurrencyCode() {
return BsqOfferBookViewModel.BSQ.getCode();
}
}

View file

@ -56,14 +56,14 @@ public class BtcOfferBookView extends OfferBookView<GridPane, BtcOfferBookViewMo
@Override
protected String getMarketTitle() {
return model.getDirection().equals(OfferDirection.BUY) ?
Res.get("offerbook.availableOffersToBuy", Res.getBaseCurrencyName(), Res.get("shared.fiat")) :
Res.get("offerbook.availableOffersToSell", Res.getBaseCurrencyName(), Res.get("shared.fiat"));
Res.get("offerbook.availableOffersToBuy", Res.getBaseCurrencyCode(), Res.get("shared.fiat")) :
Res.get("offerbook.availableOffersToSell", Res.getBaseCurrencyCode(), Res.get("shared.fiat"));
}
@Override
String getCreateOfferButtonLabel() {
return Res.getBaseCurrencyName().toUpperCase();
String getTradeCurrencyCode() {
return Res.getBaseCurrencyCode();
}
}

View file

@ -289,7 +289,7 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
if (price2 == null || price1 == null) {
return 0;
}
if (model.getDirection() == OfferDirection.SELL) {
if (OfferViewUtil.isShownAsSellOffer(model.getSelectedTradeCurrency().getCode(), model.getDirection())) {
return price1.compareTo(price2);
} else {
return price2.compareTo(price1);
@ -1292,8 +1292,8 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
private void updateCreateOfferButton() {
createOfferButton.setText(Res.get("offerbook.createNewOffer",
model.getDirection() == OfferDirection.BUY ? Res.get("shared.buy") : Res.get("shared.sell"),
getCreateOfferButtonLabel()).toUpperCase());
getTradeCurrencyCode()).toUpperCase());
}
abstract String getCreateOfferButtonLabel();
abstract String getTradeCurrencyCode();
}

View file

@ -56,12 +56,12 @@ public class OtherOfferBookView extends OfferBookView<GridPane, OtherOfferBookVi
@Override
protected String getMarketTitle() {
return model.getDirection().equals(OfferDirection.BUY) ?
Res.get("offerbook.availableOffersToBuy", Res.get("shared.otherAssets"), Res.getBaseCurrencyName()) :
Res.get("offerbook.availableOffersToSell", Res.get("shared.otherAssets"), Res.getBaseCurrencyName());
Res.get("offerbook.availableOffersToBuy", Res.get("shared.otherAssets"), Res.getBaseCurrencyCode()) :
Res.get("offerbook.availableOffersToSell", Res.get("shared.otherAssets"), Res.getBaseCurrencyCode());
}
@Override
String getCreateOfferButtonLabel() {
return model.showAllTradeCurrenciesProperty.get() ? "" : model.getSelectedTradeCurrency().getName();
String getTradeCurrencyCode() {
return model.showAllTradeCurrenciesProperty.get() ? "" : model.getSelectedTradeCurrency().getCode();
}
}

View file

@ -18,6 +18,7 @@
package bisq.desktop.main.offer.offerbook;
import bisq.desktop.Navigation;
import bisq.desktop.main.offer.bisq_v1.OfferViewUtil;
import bisq.desktop.util.GUIUtil;
import bisq.core.account.witness.AccountAgeWitnessService;
@ -58,8 +59,6 @@ import org.jetbrains.annotations.NotNull;
public class OtherOfferBookViewModel extends OfferBookViewModel {
public static final TradeCurrency DEFAULT_ALTCOIN = CurrencyUtil.getTradeCurrency("ETH").get();
@Inject
public OtherOfferBookViewModel(User user,
OpenOfferManager openOfferManager,
@ -133,9 +132,9 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
@Override
TradeCurrency getDefaultTradeCurrency() {
// select first currency in list, otherwise if view is not initialized add Ether as default one
// select first currency in list, otherwise if view is not initialized any of the main crypto currencies
return !getTradeCurrencies().isEmpty() ? getTradeCurrencies().get(1) :
DEFAULT_ALTCOIN;
OfferViewUtil.getAnyOfMainCryptoCurrencies();
}
@Override

View file

@ -56,8 +56,8 @@ public class TopAltcoinOfferBookView extends OfferBookView<GridPane, TopAltcoinO
@Override
protected String getMarketTitle() {
return model.getDirection().equals(OfferDirection.BUY) ?
Res.get("offerbook.availableOffersToBuy", TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getName(), Res.getBaseCurrencyName()) :
Res.get("offerbook.availableOffersToSell", TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getName(), Res.getBaseCurrencyName());
Res.get("offerbook.availableOffersToBuy", TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode(), Res.getBaseCurrencyCode()) :
Res.get("offerbook.availableOffersToSell", TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode(), Res.getBaseCurrencyCode());
}
@Override
@ -71,7 +71,7 @@ public class TopAltcoinOfferBookView extends OfferBookView<GridPane, TopAltcoinO
}
@Override
String getCreateOfferButtonLabel() {
return TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getName();
String getTradeCurrencyCode() {
return TopAltcoinOfferBookViewModel.TOP_ALTCOIN.getCode();
}
}

View file

@ -24,7 +24,6 @@ import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.util.DisplayUtils;
import bisq.desktop.util.Layout;
import bisq.core.locale.CurrencyUtil;
import bisq.core.locale.Res;
import bisq.core.monetary.Price;
import bisq.core.monetary.Volume;
@ -268,13 +267,13 @@ public class BsqSwapOfferDetailsWindow extends Overlay<BsqSwapOfferDetailsWindow
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 ?
Res.get("offerDetailsWindow.confirm.makerAltcoin", Res.get("shared.buy"), tradeCurrencyByName) :
Res.get("offerDetailsWindow.confirm.makerAltcoin", Res.get("shared.sell"), tradeCurrencyByName);
Res.get("offerDetailsWindow.confirm.makerAltcoin", Res.get("shared.buy"), tradeCurrencyByCode) :
Res.get("offerDetailsWindow.confirm.makerAltcoin", Res.get("shared.sell"), tradeCurrencyByCode);
String takeOfferButtonText = isBuyerRole ?
Res.get("offerDetailsWindow.confirm.takerAltcoin", Res.get("shared.buy"), tradeCurrencyByName) :
Res.get("offerDetailsWindow.confirm.takerAltcoin", Res.get("shared.sell"), tradeCurrencyByName);
Res.get("offerDetailsWindow.confirm.takerAltcoin", Res.get("shared.buy"), tradeCurrencyByCode) :
Res.get("offerDetailsWindow.confirm.takerAltcoin", Res.get("shared.sell"), tradeCurrencyByCode);
ImageView iconView = new ImageView();
iconView.setId(isBuyerRole ? "image-buy-white" : "image-sell-white");

View file

@ -390,25 +390,25 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
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");