diff --git a/core/src/main/java/bisq/core/user/Preferences.java b/core/src/main/java/bisq/core/user/Preferences.java index 4dd43b85d2a..c07a912cb5b 100644 --- a/core/src/main/java/bisq/core/user/Preferences.java +++ b/core/src/main/java/bisq/core/user/Preferences.java @@ -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(); @@ -1074,5 +1079,7 @@ private interface ExcludesDelegateMethods { void setBsqAverageTrimThreshold(double bsqAverageTrimThreshold); void setAutoConfirmSettings(AutoConfirmSettings autoConfirmSettings); + + void setHideNonAccountPaymentMethods(boolean hideNonAccountPaymentMethods); } } diff --git a/core/src/main/java/bisq/core/user/PreferencesPayload.java b/core/src/main/java/bisq/core/user/PreferencesPayload.java index 0a7aede7e36..82b800f13eb 100644 --- a/core/src/main/java/bisq/core/user/PreferencesPayload.java +++ b/core/src/main/java/bisq/core/user/PreferencesPayload.java @@ -129,6 +129,8 @@ public final class PreferencesPayload implements PersistableEnvelope { // Added at 1.3.8 private List autoConfirmSettingsList = new ArrayList<>(); + // Added in 1.5.5 + private boolean hideNonAccountPaymentMethods; /////////////////////////////////////////////////////////////////////////////////////////// // Constructor @@ -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())); @@ -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() ); } } diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 4a3f82283c4..71044b09ab1 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -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}. diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java index e1133a16b24..417fe20730d 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java @@ -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()); @@ -359,6 +356,7 @@ protected void activate() { if (paymentMethodComboBox.getEditor().getText().isEmpty()) paymentMethodComboBox.getSelectionModel().select(SHOW_ALL); model.onSetPaymentMethod(paymentMethodComboBox.getSelectionModel().getSelectedItem()); + updateCurrencyComboBoxFromModel(); updateSigningStateColumn(); }); @@ -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)) { diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java index 98737f4036c..92b97e1e29b 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java @@ -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; @@ -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(); } @@ -331,6 +339,14 @@ TradeCurrency getSelectedTradeCurrency() { ObservableList getPaymentMethods() { ObservableList list = FXCollections.observableArrayList(PaymentMethod.getPaymentMethods()); + if (preferences.isHideNonAccountPaymentMethods() && user.getPaymentAccounts() != null) { + Set 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; diff --git a/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java b/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java index 8d000b3139b..79870291161 100644 --- a/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java +++ b/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java @@ -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; @@ -100,13 +103,16 @@ 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 { + private final User user; private final CoinFormatter formatter; private TextField btcExplorerTextField, bsqExplorerTextField; private ComboBox userLanguageComboBox; @@ -114,7 +120,7 @@ public class PreferencesView extends ActivatableViewAndModel 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, @@ -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; @@ -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); @@ -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 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 -> { @@ -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) { diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index 66af295531f..06e431a0967 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -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 {