Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CashByMail show terms and conditions upon taking an offer #5399

Merged
merged 1 commit into from Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -161,7 +162,8 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
isOfferAvailableSubscription;

private int gridRow = 0;
private boolean offerDetailsWindowDisplayed, clearXchangeWarningDisplayed, fasterPaymentsWarningDisplayed, takeOfferFromUnsignedAccountWarningDisplayed;
private boolean offerDetailsWindowDisplayed, clearXchangeWarningDisplayed, fasterPaymentsWarningDisplayed,
takeOfferFromUnsignedAccountWarningDisplayed, cashByMailWarningDisplayed;
private SimpleBooleanProperty errorPopupDisplayed;
private ChangeListener<Boolean> amountFocusedListener, getShowWalletFundedNotificationListener;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<Label, VBox> getTradeInputBox(HBox amountValueBox, String promptText) {
Label descriptionLabel = new AutoTooltipLabel(promptText);
descriptionLabel.setId("input-description-label");
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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<GenericMessageWindow> {
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);
}
}