diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java index dc9a93ec49..dc86d0aaff 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java @@ -26,6 +26,7 @@ import bisq.desktop.main.portfolio.pendingtrades.TradeStepInfo; import bisq.desktop.main.portfolio.pendingtrades.TradeSubView; import bisq.desktop.util.Layout; +import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; import bisq.core.support.dispute.Dispute; import bisq.core.support.dispute.DisputeResult; @@ -607,6 +608,18 @@ public abstract class TradeStepView extends AnchorPane { protected void deactivatePaymentButtons(boolean isDisabled) { } + protected String getCurrencyName(Trade trade) { + return CurrencyUtil.getNameByCode(getCurrencyCode(trade)); + } + + protected String getCurrencyCode(Trade trade) { + return checkNotNull(trade.getOffer()).getCurrencyCode(); + } + + protected boolean isXmrTrade() { + return getCurrencyCode(trade).equals("XMR"); + } + private void updateTradePeriodState(Trade.TradePeriodState tradePeriodState) { if (trade.getDisputeState() == Trade.DisputeState.NO_DISPUTE) { switch (tradePeriodState) { diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java index 562c716ebe..c1588140d0 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java @@ -55,7 +55,6 @@ import bisq.desktop.util.DisplayUtils; import bisq.desktop.util.Layout; import bisq.desktop.util.Transitions; -import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; import bisq.core.network.MessageState; import bisq.core.offer.Offer; @@ -313,8 +312,7 @@ public class BuyerStep2View extends TradeStepView { break; case PaymentMethod.BLOCK_CHAINS_ID: case PaymentMethod.BLOCK_CHAINS_INSTANT_ID: - String labelTitle = Res.get("portfolio.pending.step2_buyer.sellersAddress", - CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode())); + String labelTitle = Res.get("portfolio.pending.step2_buyer.sellersAddress", getCurrencyName(trade)); gridRow = AssetsForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload, labelTitle); break; case PaymentMethod.PROMPT_PAY_ID: @@ -365,7 +363,7 @@ public class BuyerStep2View extends TradeStepView { @Override protected String getFirstHalfOverWarnText() { return Res.get("portfolio.pending.step2_buyer.warn", - model.dataModel.getCurrencyCode(), + getCurrencyCode(trade), model.getDateForOpenDispute()); } @@ -456,8 +454,7 @@ public class BuyerStep2View extends TradeStepView { } else { showConfirmPaymentStartedPopup(); } - } else if (sellersPaymentAccountPayload instanceof AssetsAccountPayload && - checkNotNull(trade.getOffer()).getCurrencyCode().equals("XMR")) { + } else if (sellersPaymentAccountPayload instanceof AssetsAccountPayload && isXmrTrade()) { SetXmrTxKeyWindow setXmrTxKeyWindow = new SetXmrTxKeyWindow(); setXmrTxKeyWindow .actionButtonText(Res.get("portfolio.pending.step2_buyer.confirmStart.headline")) @@ -498,8 +495,7 @@ public class BuyerStep2View extends TradeStepView { if (!DevEnv.isDevMode() && DontShowAgainLookup.showAgain(key)) { Popup popup = new Popup(); popup.headLine(Res.get("portfolio.pending.step2_buyer.confirmStart.headline")) - .confirmation(Res.get("portfolio.pending.step2_buyer.confirmStart.msg", - CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode()))) + .confirmation(Res.get("portfolio.pending.step2_buyer.confirmStart.msg", getCurrencyName(trade))) .width(700) .actionButtonText(Res.get("portfolio.pending.step2_buyer.confirmStart.yes")) .onAction(this::confirmPaymentStarted) @@ -548,7 +544,7 @@ public class BuyerStep2View extends TradeStepView { String amount = DisplayUtils.formatVolumeWithCode(trade.getTradeVolume()); if (paymentAccountPayload instanceof AssetsAccountPayload) { message += Res.get("portfolio.pending.step2_buyer.altcoin", - CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode()), + getCurrencyName(trade), amount) + accountDetails + paymentDetailsForTradePopup + "\n\n" + diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep3View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep3View.java index 372a7d4480..f04305aefe 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep3View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep3View.java @@ -87,7 +87,7 @@ public class BuyerStep3View extends TradeStepView { @Override protected String getInfoText() { - return Res.get("portfolio.pending.step3_buyer.wait.info", model.dataModel.getCurrencyCode()); + return Res.get("portfolio.pending.step3_buyer.wait.info", getCurrencyCode(trade)); } private void updateMessageStateInfo() { @@ -130,7 +130,7 @@ public class BuyerStep3View extends TradeStepView { @Override protected String getFirstHalfOverWarnText() { String substitute = model.isBlockChainMethod() ? - Res.get("portfolio.pending.step3_buyer.warn.part1a", model.dataModel.getCurrencyCode()) : + Res.get("portfolio.pending.step3_buyer.warn.part1a", getCurrencyCode(trade)) : Res.get("portfolio.pending.step3_buyer.warn.part1b"); return Res.get("portfolio.pending.step3_buyer.warn.part2", substitute); } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep2View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep2View.java index 5fb7130267..425634d2fb 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep2View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep2View.java @@ -134,7 +134,7 @@ public class SellerStep2View extends TradeStepView { @Override protected String getInfoText() { - return Res.get("portfolio.pending.step2_seller.waitPayment.msg", model.dataModel.getCurrencyCode()); + return Res.get("portfolio.pending.step2_seller.waitPayment.msg", getCurrencyCode(trade)); } @@ -145,7 +145,7 @@ public class SellerStep2View extends TradeStepView { @Override protected String getFirstHalfOverWarnText() { return Res.get("portfolio.pending.step2_seller.warn", - model.dataModel.getCurrencyCode(), + getCurrencyCode(trade), model.getDateForOpenDispute()); } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java index 5e45038ada..938470c3cf 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java @@ -29,7 +29,6 @@ import bisq.desktop.util.DisplayUtils; import bisq.desktop.util.GUIUtil; import bisq.desktop.util.Layout; -import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; import bisq.core.payment.PaymentAccount; import bisq.core.payment.PaymentAccountUtil; @@ -91,7 +90,6 @@ public class SellerStep3View extends TradeStepView { private TxConfidenceIndicator assetTxConfidenceIndicator; @Nullable private ChangeListener proofResultListener; - private boolean useXmrTxProof; /////////////////////////////////////////////////////////////////////////////////////////// @@ -160,8 +158,7 @@ public class SellerStep3View extends TradeStepView { } }); - useXmrTxProof = getCurrencyCode(trade).equals("XMR"); - if (useXmrTxProof) { + if (isXmrTrade()) { proofResultListener = (observable, oldValue, newValue) -> { applyAssetTxProofResult(trade.getAssetTxProofResult()); }; @@ -186,7 +183,7 @@ public class SellerStep3View extends TradeStepView { timeoutTimer.stop(); } - if (useXmrTxProof) { + if (isXmrTrade()) { trade.getAssetTxProofResultUpdateProperty().removeListener(proofResultListener); } } @@ -215,7 +212,7 @@ public class SellerStep3View extends TradeStepView { String myTitle = ""; String peersTitle = ""; boolean isBlockChain = false; - String nameByCode = CurrencyUtil.getNameByCode(getCurrencyCode(trade)); + String currencyName = getCurrencyName(trade); Contract contract = trade.getContract(); if (contract != null) { PaymentAccountPayload myPaymentAccountPayload = contract.getSellerPaymentAccountPayload(); @@ -231,8 +228,8 @@ public class SellerStep3View extends TradeStepView { myPaymentDetails = ((AssetsAccountPayload) myPaymentAccountPayload).getAddress(); } peersPaymentDetails = ((AssetsAccountPayload) peersPaymentAccountPayload).getAddress(); - myTitle = Res.get("portfolio.pending.step3_seller.yourAddress", nameByCode); - peersTitle = Res.get("portfolio.pending.step3_seller.buyersAddress", nameByCode); + myTitle = Res.get("portfolio.pending.step3_seller.yourAddress", currencyName); + peersTitle = Res.get("portfolio.pending.step3_seller.buyersAddress", currencyName); isBlockChain = true; } else { if (myPaymentDetails.isEmpty()) { @@ -252,7 +249,7 @@ public class SellerStep3View extends TradeStepView { GridPane.setRowSpan(titledGroupBg, 4); } - if (useXmrTxProof) { + if (isXmrTrade()) { assetTxProofResultField = new InfoTextField(); Tuple2 topLabelWithVBox = getTopLabelWithVBox(Res.get("portfolio.pending.step3_seller.autoConf.status.label"), assetTxProofResultField); @@ -324,11 +321,11 @@ public class SellerStep3View extends TradeStepView { @Override protected String getInfoText() { - String currencyCode = getCurrencyCode(trade); + String currencyName = getCurrencyName(trade); if (model.isBlockChainMethod()) { - return Res.get("portfolio.pending.step3_seller.buyerStartedPayment", Res.get("portfolio.pending.step3_seller.buyerStartedPayment.altcoin", currencyCode)); + return Res.get("portfolio.pending.step3_seller.buyerStartedPayment", Res.get("portfolio.pending.step3_seller.buyerStartedPayment.altcoin", currencyName)); } else { - return Res.get("portfolio.pending.step3_seller.buyerStartedPayment", Res.get("portfolio.pending.step3_seller.buyerStartedPayment.fiat", currencyCode)); + return Res.get("portfolio.pending.step3_seller.buyerStartedPayment", Res.get("portfolio.pending.step3_seller.buyerStartedPayment.fiat", currencyName)); } } @@ -339,7 +336,7 @@ public class SellerStep3View extends TradeStepView { @Override protected String getFirstHalfOverWarnText() { String substitute = model.isBlockChainMethod() ? - Res.get("portfolio.pending.step3_seller.warn.part1a", getCurrencyCode(trade)) : + Res.get("portfolio.pending.step3_seller.warn.part1a", getCurrencyName(trade)) : Res.get("portfolio.pending.step3_seller.warn.part1b"); return Res.get("portfolio.pending.step3_seller.warn.part2", substitute); @@ -370,7 +367,7 @@ public class SellerStep3View extends TradeStepView { String key = "confirmPaymentReceived"; if (!DevEnv.isDevMode() && DontShowAgainLookup.showAgain(key)) { PaymentAccountPayload paymentAccountPayload = model.dataModel.getSellersPaymentAccountPayload(); - String message = Res.get("portfolio.pending.step3_seller.onPaymentReceived.part1", CurrencyUtil.getNameByCode(getCurrencyCode(trade))); + String message = Res.get("portfolio.pending.step3_seller.onPaymentReceived.part1", getCurrencyName(trade)); if (!(paymentAccountPayload instanceof AssetsAccountPayload)) { if (!(paymentAccountPayload instanceof WesternUnionAccountPayload) && !(paymentAccountPayload instanceof HalCashAccountPayload) && @@ -406,12 +403,12 @@ public class SellerStep3View extends TradeStepView { String key = "confirmPayment" + trade.getId(); String message = ""; String tradeVolumeWithCode = DisplayUtils.formatVolumeWithCode(trade.getTradeVolume()); - String currencyName = CurrencyUtil.getNameByCode(getCurrencyCode(trade)); + String currencyName = getCurrencyName(trade); String part1 = Res.get("portfolio.pending.step3_seller.part", currencyName); String id = trade.getShortId(); if (paymentAccountPayload instanceof AssetsAccountPayload) { String address = ((AssetsAccountPayload) paymentAccountPayload).getAddress(); - String explorerOrWalletString = getCurrencyCode(trade).equals("XMR") ? + String explorerOrWalletString = isXmrTrade() ? Res.get("portfolio.pending.step3_seller.altcoin.wallet", currencyName) : Res.get("portfolio.pending.step3_seller.altcoin.explorer", currencyName); message = Res.get("portfolio.pending.step3_seller.altcoin", part1, explorerOrWalletString, address, tradeVolumeWithCode, currencyName); @@ -533,8 +530,4 @@ public class SellerStep3View extends TradeStepView { label.setPadding(new Insets(10)); return label; } - - private String getCurrencyCode(Trade trade) { - return CurrencyUtil.getNameByCode(checkNotNull(trade.getOffer()).getCurrencyCode()); - } }