From 42428b79b950b731f3e9c3b759c598e6140a96e0 Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Tue, 6 Apr 2021 08:23:00 -0500 Subject: [PATCH] CashByMail show terms and conditions upon taking an offer --- .../resources/i18n/displayStrings.properties | 7 ++ .../paymentmethods/CashByMailForm.java | 2 +- .../main/offer/takeoffer/TakeOfferView.java | 22 ++++++- .../windows/GenericMessageWindow.java | 64 +++++++++++++++++++ 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 desktop/src/main/java/bisq/desktop/main/overlays/windows/GenericMessageWindow.java diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 940e84b5829..9b457aa3081 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -3419,6 +3419,13 @@ payment.f2f.city.prompt=The city will be displayed with the offer payment.shared.optionalExtra=Optional additional information payment.shared.extraInfo=Additional information payment.shared.extraInfo.prompt=Define any special terms, conditions, or details you would like to be displayed with your offers for this payment account (users will see this info before accepting offers). +payment.cashByMail.extraInfo.prompt=Please state on your offers: \n\n\ +Country you are located (eg France); \n\ +Countries / regions you would accept trades from (eg France, EU, or any European country); \n\ +Any special terms/conditions; \n\ +Any other details. +payment.cashByMail.tradingRestrictions=Please review the maker's terms and conditions.\n\ + If you do not meet the requirements do not take this trade. payment.f2f.info='Face to Face' trades have different rules and come with different risks than online transactions.\n\n\ The main differences are:\n\ ● The trading peers need to exchange information about the meeting location and time by using their provided contact details.\n\ diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CashByMailForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CashByMailForm.java index 4d7eb0d8425..37a8be1edca 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CashByMailForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CashByMailForm.java @@ -96,7 +96,7 @@ public void addFormForAddAccount() { }); TextArea extraTextArea = addTopLabelTextArea(gridPane, ++gridRow, - Res.get("payment.shared.optionalExtra"), Res.get("payment.shared.extraInfo.prompt")).second; + Res.get("payment.shared.optionalExtra"), Res.get("payment.cashByMail.extraInfo.prompt")).second; extraTextArea.setMinHeight(70); ((JFXTextArea) extraTextArea).setLabelFloat(false); extraTextArea.textProperty().addListener((ov, oldValue, newValue) -> { diff --git a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java index 016f0824c4c..5f6bed73cbc 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java @@ -40,6 +40,7 @@ import bisq.desktop.main.offer.OfferViewUtil; import bisq.desktop.main.overlays.notifications.Notification; import bisq.desktop.main.overlays.popups.Popup; +import bisq.desktop.main.overlays.windows.GenericMessageWindow; import bisq.desktop.main.overlays.windows.OfferDetailsWindow; import bisq.desktop.main.overlays.windows.QRCodeWindow; import bisq.desktop.main.portfolio.PortfolioView; @@ -161,7 +162,8 @@ public class TakeOfferView extends ActivatableViewAndModel amountFocusedListener, getShowWalletFundedNotificationListener; @@ -307,6 +309,7 @@ protected void activate() { maybeShowTakeOfferFromUnsignedAccountWarning(model.dataModel.getOffer()); maybeShowClearXchangeWarning(lastPaymentAccount); maybeShowFasterPaymentsWarning(lastPaymentAccount); + maybeShowCashByMailWarning(lastPaymentAccount, model.dataModel.getOffer()); if (!DevEnv.isDaoActivated() && !model.isRange()) { nextButton.setVisible(false); @@ -1269,6 +1272,23 @@ private void maybeShowFasterPaymentsWarning(PaymentAccount paymentAccount) { } } + private void maybeShowCashByMailWarning(PaymentAccount paymentAccount, Offer offer) { + if (paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.CASH_BY_MAIL_ID) && + !cashByMailWarningDisplayed && !offer.getExtraInfo().isEmpty()) { + cashByMailWarningDisplayed = true; + UserThread.runAfter(() -> { + new GenericMessageWindow() + .preamble(Res.get("payment.cashByMail.tradingRestrictions")) + .instruction(offer.getExtraInfo()) + .actionButtonText(Res.get("shared.iConfirm")) + .closeButtonText(Res.get("shared.close")) + .width(Layout.INITIAL_WINDOW_WIDTH) + .onClose(() -> close(false)) + .show(); + }, 500, TimeUnit.MILLISECONDS); + } + } + private Tuple2 getTradeInputBox(HBox amountValueBox, String promptText) { Label descriptionLabel = new AutoTooltipLabel(promptText); descriptionLabel.setId("input-description-label"); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/GenericMessageWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/GenericMessageWindow.java new file mode 100644 index 00000000000..c3b6d34cc2b --- /dev/null +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/GenericMessageWindow.java @@ -0,0 +1,64 @@ +/* + * 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 . + */ + +package bisq.desktop.main.overlays.windows; + +import bisq.desktop.main.overlays.Overlay; +import bisq.desktop.util.Layout; + +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; + +import static bisq.desktop.util.FormBuilder.addMultilineLabel; +import static bisq.desktop.util.FormBuilder.addTextArea; +import static com.google.common.base.Preconditions.checkNotNull; + +public class GenericMessageWindow extends Overlay { + private String preamble; + + public GenericMessageWindow() { + super(); + } + + public void show() { + createGridPane(); + addHeadLine(); + addContent(); + addButtons(); + applyStyles(); + display(); + } + + public GenericMessageWindow preamble(String preamble) { + this.preamble = preamble; + return this; + } + + private void addContent() { + if (preamble != null) { + Label label = addMultilineLabel(gridPane, ++rowIndex, preamble, 10); + label.setPrefSize(Layout.INITIAL_WINDOW_WIDTH, Layout.INITIAL_WINDOW_HEIGHT * 0.1); + } + checkNotNull(message, "message must not be null"); + TextArea textArea = addTextArea(gridPane, ++rowIndex, "", 10); + textArea.setText(message); + textArea.setEditable(false); + textArea.setWrapText(true); + // sizes the textArea to fit within its parent container + textArea.setPrefSize(Layout.INITIAL_WINDOW_WIDTH, Layout.INITIAL_WINDOW_HEIGHT * 0.9); + } +}