From fb39babbac9c2378bc6f6d1a989af95643ef5aba Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Fri, 27 Dec 2024 17:52:55 +0000 Subject: [PATCH] Show ARS Blue Rate popup during payment account creation At the moment, we show the ARS Blue Rate popup when the user saves a single currency payment account (PR #7122). This misses many payment accounts that support ARS. The new behaviour is to show the ARS Blue Rate popup when ARS is selected during account generation (either pre-selected or later selected by the user). Payment accounts supporting ARS: - CashByMail - CashDeposit - F2F - MoneyGram - National bank - OKPayAccount (deprecated) - Same bank - Specific bank - Transferwise - Uphold - Western Union --- .../paymentmethods/PaymentMethodForm.java | 46 +++++++++++++++++-- .../fiataccounts/FiatAccountsDataModel.java | 13 ------ .../main/java/bisq/desktop/util/GUIUtil.java | 11 ++++- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java index a6b52cd7021..c033964ffc7 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java @@ -37,6 +37,7 @@ import bisq.core.payment.AssetAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.PaymentMethod; +import bisq.core.user.DontShowAgainLookup; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; @@ -67,6 +68,7 @@ import javafx.util.StringConverter; import java.util.Date; +import java.util.List; import java.util.concurrent.TimeUnit; import lombok.extern.slf4j.Slf4j; @@ -118,8 +120,13 @@ public TradeCurrency fromString(String s) { } }); currencyComboBox.setOnAction(e -> { - paymentAccount.setSingleTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem()); + TradeCurrency selectedCurrency = currencyComboBox.getSelectionModel().getSelectedItem(); + paymentAccount.setSingleTradeCurrency(selectedCurrency); updateFromInputs(); + + if (isArgentinePesos(selectedCurrency)) { + maybeShowArgentinePesosBlueRatePopup(); + } }); } @@ -299,19 +306,32 @@ void fillUpFlowPaneWithCurrencies(boolean isEditable, FlowPane flowPane, TradeCurrency e, PaymentAccount paymentAccount) { CheckBox checkBox = new AutoTooltipCheckBox(e.getCode()); checkBox.setMouseTransparent(!isEditable); - checkBox.setSelected(paymentAccount.getTradeCurrencies().contains(e)); + + boolean isCurrencySelected = paymentAccount.getTradeCurrencies().contains(e); + checkBox.setSelected(isCurrencySelected); + checkBox.setMinWidth(60); checkBox.setMaxWidth(checkBox.getMinWidth()); checkBox.setTooltip(new Tooltip(e.getName())); checkBox.setOnAction(event -> { - if (checkBox.isSelected()) + if (checkBox.isSelected()) { paymentAccount.addCurrency(e); - else + + if (isArgentinePesos(e)) { + maybeShowArgentinePesosBlueRatePopup(); + } + + } else { paymentAccount.removeCurrency(e); + } updateAllInputsValid(); }); flowPane.getChildren().add(checkBox); + + if (isCurrencySelected && isArgentinePesos(e)) { + maybeShowArgentinePesosBlueRatePopup(); + } } protected abstract void autoFillNameTextField(); @@ -352,4 +372,22 @@ void removeAcceptedCountry(String countryCode) { void addAcceptedCountry(String countryCode) { } + + public static boolean isArgentinePesos(TradeCurrency tradeCurrency) { + FiatCurrency arsCurrency = new FiatCurrency("ARS"); + return tradeCurrency.equals(arsCurrency); + } + + public static void maybeShowArgentinePesosBlueRatePopup() { + String key = "arsBlueMarketNotificationPopup"; + if (DontShowAgainLookup.showAgain(key)) { + new Popup() + .headLine(Res.get("popup.arsBlueMarket.title")) + .information(Res.get("popup.arsBlueMarket.info")) + .actionButtonText(Res.get("shared.iUnderstand")) + .hideCloseButton() + .dontShowAgainId(key) + .show(); + } + } } diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java index 8d212fac609..3c3a784b6d9 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java @@ -126,19 +126,6 @@ public void onSaveNewAccount(PaymentAccount paymentAccount) { accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload()); accountAgeWitnessService.signAndPublishSameNameAccounts(); - - if (paymentAccount.getSingleTradeCurrency().getCode().equals("ARS")) { - String key = "arsBlueMarketNotificationPopup"; - if (DontShowAgainLookup.showAgain(key)) { - new Popup() - .headLine(Res.get("popup.arsBlueMarket.title")) - .information(Res.get("popup.arsBlueMarket.info")) - .actionButtonText(Res.get("shared.iUnderstand")) - .hideCloseButton() - .dontShowAgainId(key) - .show(); - } - } } public void onUpdateAccount(PaymentAccount paymentAccount) { diff --git a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java index e921faa1fcc..c6f39bd7a1c 100644 --- a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java @@ -24,6 +24,7 @@ import bisq.desktop.components.BisqTextArea; import bisq.desktop.components.InfoAutoTooltipLabel; import bisq.desktop.components.indicator.TxConfidenceIndicator; +import bisq.desktop.components.paymentmethods.PaymentMethodForm; import bisq.desktop.main.MainView; import bisq.desktop.main.account.AccountView; import bisq.desktop.main.account.content.fiataccounts.FiatAccountsView; @@ -1103,8 +1104,14 @@ public TradeCurrency fromString(String string) { }); currencyComboBox.setDisable(true); - currencyComboBox.setOnAction(e -> - onTradeCurrencySelectedHandler.accept(currencyComboBox.getSelectionModel().getSelectedItem())); + currencyComboBox.setOnAction(e -> { + TradeCurrency selectedCurrency = currencyComboBox.getSelectionModel().getSelectedItem(); + onTradeCurrencySelectedHandler.accept(selectedCurrency); + + if (PaymentMethodForm.isArgentinePesos(selectedCurrency)) { + PaymentMethodForm.maybeShowArgentinePesosBlueRatePopup(); + } + }); return new Tuple2<>(currencyComboBox, gridRow); }