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

Add option to hide non supported payment methods #5045

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/java/bisq/core/user/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ public void setAutoConfTradeLimit(String currencyCode, long tradeLimit) {
});
}

public void setHideNonAccountPaymentMethods(boolean hideNonAccountPaymentMethods) {
prefPayload.setHideNonAccountPaymentMethods(hideNonAccountPaymentMethods);
requestPersistence();
}

private void requestPersistence() {
if (initialReadDone)
persistenceManager.requestPersistence();
Expand Down Expand Up @@ -1074,5 +1079,7 @@ private interface ExcludesDelegateMethods {
void setBsqAverageTrimThreshold(double bsqAverageTrimThreshold);

void setAutoConfirmSettings(AutoConfirmSettings autoConfirmSettings);

void setHideNonAccountPaymentMethods(boolean hideNonAccountPaymentMethods);
}
}
8 changes: 6 additions & 2 deletions core/src/main/java/bisq/core/user/PreferencesPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public final class PreferencesPayload implements PersistableEnvelope {
// Added at 1.3.8
private List<AutoConfirmSettings> autoConfirmSettingsList = new ArrayList<>();

// Added in 1.5.5
private boolean hideNonAccountPaymentMethods;

///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
Expand Down Expand Up @@ -192,7 +194,8 @@ public Message toProtoMessage() {
.setBsqAverageTrimThreshold(bsqAverageTrimThreshold)
.addAllAutoConfirmSettings(autoConfirmSettingsList.stream()
.map(autoConfirmSettings -> ((protobuf.AutoConfirmSettings) autoConfirmSettings.toProtoMessage()))
.collect(Collectors.toList()));
.collect(Collectors.toList()))
.setHideNonAccountPaymentMethods(hideNonAccountPaymentMethods);

Optional.ofNullable(backupDirectory).ifPresent(builder::setBackupDirectory);
Optional.ofNullable(preferredTradeCurrency).ifPresent(e -> builder.setPreferredTradeCurrency((protobuf.TradeCurrency) e.toProtoMessage()));
Expand Down Expand Up @@ -286,7 +289,8 @@ public static PreferencesPayload fromProto(protobuf.PreferencesPayload proto, Co
proto.getAutoConfirmSettingsList().isEmpty() ? new ArrayList<>() :
new ArrayList<>(proto.getAutoConfirmSettingsList().stream()
.map(AutoConfirmSettings::fromProto)
.collect(Collectors.toList()))
.collect(Collectors.toList())),
proto.getHideNonAccountPaymentMethods()
);
}
}
1 change: 1 addition & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,7 @@ setting.preferences.showOwnOffers=Show my own offers in offer book
setting.preferences.useAnimations=Use animations
setting.preferences.useDarkMode=Use dark mode
setting.preferences.sortWithNumOffers=Sort market lists with no. of offers/trades
setting.preferences.onlyShowPaymentMethodsFromAccount=Hide non-supported payment methods
setting.preferences.resetAllFlags=Reset all \"Don't show again\" flags
settings.preferences.languageChange=To apply the language change to all screens requires a restart.
settings.preferences.supportLanguageWarning=In case of a dispute, please note that mediation is handled in {0} and arbitration in {1}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,8 @@ protected void activate() {
currencyComboBox.getSelectionModel().select(SHOW_ALL);
model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
});
updateCurrencyComboBoxFromModel();

if (model.showAllTradeCurrenciesProperty.get())
currencyComboBox.getSelectionModel().select(SHOW_ALL);
else
currencyComboBox.getSelectionModel().select(model.getSelectedTradeCurrency());
currencyComboBox.getEditor().setText(new CurrencyStringConverter(currencyComboBox).toString(currencyComboBox.getSelectionModel().getSelectedItem()));

volumeColumn.sortableProperty().bind(model.showAllTradeCurrenciesProperty.not());
Expand Down Expand Up @@ -359,6 +356,7 @@ protected void activate() {
if (paymentMethodComboBox.getEditor().getText().isEmpty())
paymentMethodComboBox.getSelectionModel().select(SHOW_ALL);
model.onSetPaymentMethod(paymentMethodComboBox.getSelectionModel().getSelectedItem());
updateCurrencyComboBoxFromModel();
updateSigningStateColumn();
});

Expand Down Expand Up @@ -405,6 +403,14 @@ protected void activate() {
model.priceFeedService.updateCounterProperty().addListener(priceFeedUpdateCounterListener);
}

private void updateCurrencyComboBoxFromModel() {
if (model.showAllTradeCurrenciesProperty.get()) {
currencyComboBox.getSelectionModel().select(SHOW_ALL);
} else {
currencyComboBox.getSelectionModel().select(model.getSelectedTradeCurrency());
}
}

private void updateSigningStateColumn() {
if (model.hasSelectionAccountSigning()) {
if (!tableView.getColumns().contains(signingStateColumn)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -281,10 +282,17 @@ void onSetPaymentMethod(PaymentMethod paymentMethod) {
return;

showAllPaymentMethods = isShowAllEntry(paymentMethod.getId());
if (!showAllPaymentMethods)
if (!showAllPaymentMethods) {
this.selectedPaymentMethod = paymentMethod;
else

// If we select TransferWise we switch to show all currencies as TransferWise supports
// sending to most currencies.
if (paymentMethod.getId().equals(PaymentMethod.TRANSFERWISE_ID)) {
onSetTradeCurrency(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
}
} else {
this.selectedPaymentMethod = PaymentMethod.getDummyPaymentMethod(GUIUtil.SHOW_ALL_FLAG);
}

applyFilterPredicate();
}
Expand Down Expand Up @@ -331,6 +339,14 @@ TradeCurrency getSelectedTradeCurrency() {

ObservableList<PaymentMethod> getPaymentMethods() {
ObservableList<PaymentMethod> list = FXCollections.observableArrayList(PaymentMethod.getPaymentMethods());
if (preferences.isHideNonAccountPaymentMethods() && user.getPaymentAccounts() != null) {
Set<PaymentMethod> supportedPaymentMethods = user.getPaymentAccounts().stream()
.map(PaymentAccount::getPaymentMethod).collect(Collectors.toSet());
if (!supportedPaymentMethods.isEmpty()) {
list = FXCollections.observableArrayList(supportedPaymentMethods);
}
}

list.sort(Comparator.naturalOrder());
list.add(0, PaymentMethod.getDummyPaymentMethod(GUIUtil.SHOW_ALL_FLAG));
return list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@
import bisq.core.locale.LanguageUtil;
import bisq.core.locale.Res;
import bisq.core.locale.TradeCurrency;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.provider.fee.FeeService;
import bisq.core.user.Preferences;
import bisq.core.user.User;
import bisq.core.util.FormattingUtils;
import bisq.core.util.ParsingUtils;
import bisq.core.util.coin.CoinFormatter;
Expand Down Expand Up @@ -100,21 +103,24 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import static bisq.desktop.util.FormBuilder.*;
import static com.google.common.base.Preconditions.checkArgument;

@FxmlView
public class PreferencesView extends ActivatableViewAndModel<GridPane, PreferencesViewModel> {
private final User user;
private final CoinFormatter formatter;
private TextField btcExplorerTextField, bsqExplorerTextField;
private ComboBox<String> userLanguageComboBox;
private ComboBox<Country> userCountryComboBox;
private ComboBox<TradeCurrency> preferredTradeCurrencyComboBox;

private ToggleButton showOwnOffersInOfferBook, useAnimations, useDarkMode, sortMarketCurrenciesNumerically,
avoidStandbyMode, useCustomFee, autoConfirmXmrToggle;
avoidStandbyMode, useCustomFee, autoConfirmXmrToggle, hideNonAccountPaymentMethodsToggle;
private int gridRow = 0;
private int displayCurrenciesGridRowIndex = 0;
private InputTextField transactionFeeInputTextField, ignoreTradersListInputTextField, ignoreDustThresholdInputTextField,
Expand Down Expand Up @@ -171,12 +177,14 @@ public PreferencesView(PreferencesViewModel model,
FilterManager filterManager,
DaoFacade daoFacade,
Config config,
User user,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
@Named(Config.RPC_USER) String rpcUser,
@Named(Config.RPC_PASSWORD) String rpcPassword,
@Named(Config.RPC_BLOCK_NOTIFICATION_PORT) int rpcBlockNotificationPort,
@Named(Config.STORAGE_DIR) File storageDir) {
super(model);
this.user = user;
this.formatter = formatter;
this.preferences = preferences;
this.feeService = feeService;
Expand Down Expand Up @@ -595,14 +603,14 @@ public CryptoCurrency fromString(String s) {
}

private void initializeDisplayOptions() {
TitledGroupBg titledGroupBg = addTitledGroupBg(root, ++gridRow, 5, Res.get("setting.preferences.displayOptions"), Layout.GROUP_DISTANCE);
TitledGroupBg titledGroupBg = addTitledGroupBg(root, ++gridRow, 6, Res.get("setting.preferences.displayOptions"), Layout.GROUP_DISTANCE);
GridPane.setColumnSpan(titledGroupBg, 1);

showOwnOffersInOfferBook = addSlideToggleButton(root, gridRow, Res.get("setting.preferences.showOwnOffers"), Layout.FIRST_ROW_AND_GROUP_DISTANCE);
useAnimations = addSlideToggleButton(root, ++gridRow, Res.get("setting.preferences.useAnimations"));
useDarkMode = addSlideToggleButton(root, ++gridRow, Res.get("setting.preferences.useDarkMode"));
// useStickyMarketPriceCheckBox = addLabelCheckBox(root, ++gridRow, "Use sticky market price:", "").second;
sortMarketCurrenciesNumerically = addSlideToggleButton(root, ++gridRow, Res.get("setting.preferences.sortWithNumOffers"));
hideNonAccountPaymentMethodsToggle = addSlideToggleButton(root, ++gridRow, Res.get("setting.preferences.onlyShowPaymentMethodsFromAccount"));
resetDontShowAgainButton = addButton(root, ++gridRow, Res.get("setting.preferences.resetAllFlags"), 0);
resetDontShowAgainButton.getStyleClass().add("compact-button");
resetDontShowAgainButton.setMaxWidth(Double.MAX_VALUE);
Expand Down Expand Up @@ -932,6 +940,16 @@ private void activateDisplayPreferences() {
sortMarketCurrenciesNumerically.setSelected(preferences.isSortMarketCurrenciesNumerically());
sortMarketCurrenciesNumerically.setOnAction(e -> preferences.setSortMarketCurrenciesNumerically(sortMarketCurrenciesNumerically.isSelected()));

boolean disableToggle = false;
if (user.getPaymentAccounts() != null) {
Set<PaymentMethod> supportedPaymentMethods = user.getPaymentAccounts().stream()
.map(PaymentAccount::getPaymentMethod).collect(Collectors.toSet());
disableToggle = supportedPaymentMethods.isEmpty();
}
hideNonAccountPaymentMethodsToggle.setSelected(preferences.isHideNonAccountPaymentMethods() && !disableToggle);
hideNonAccountPaymentMethodsToggle.setOnAction(e -> preferences.setHideNonAccountPaymentMethods(hideNonAccountPaymentMethodsToggle.isSelected()));
hideNonAccountPaymentMethodsToggle.setDisable(disableToggle);

resetDontShowAgainButton.setOnAction(e -> preferences.resetDontShowAgain());

editCustomBtcExplorer.setOnAction(e -> {
Expand Down Expand Up @@ -1108,8 +1126,8 @@ private void deactivateDisplayCurrencies() {
private void deactivateDisplayPreferences() {
useAnimations.setOnAction(null);
useDarkMode.setOnAction(null);
// useStickyMarketPriceCheckBox.setOnAction(null);
sortMarketCurrenciesNumerically.setOnAction(null);
hideNonAccountPaymentMethodsToggle.setOnAction(null);
showOwnOffersInOfferBook.setOnAction(null);
resetDontShowAgainButton.setOnAction(null);
if (displayStandbyModeFeature) {
Expand Down
1 change: 1 addition & 0 deletions proto/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,7 @@ message PreferencesPayload {
bool tac_accepted_v120 = 55;
repeated AutoConfirmSettings auto_confirm_settings = 56;
double bsq_average_trim_threshold = 57;
bool hide_non_account_payment_methods = 58;
}

message AutoConfirmSettings {
Expand Down