Skip to content

Commit

Permalink
Merge branch 'add-toggle-for-hiding-not-takable-offers' into add-new-…
Browse files Browse the repository at this point in the history
…filter-entries
  • Loading branch information
chimp1984 committed Jan 4, 2021
2 parents 4bbc394 + f588b22 commit cfabf79
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 33 deletions.
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 @@ -772,6 +772,11 @@ public void setIgnoreDustThreshold(int value) {
requestPersistence();
}

public void setShowOffersMatchingMyAccounts(boolean value) {
prefPayload.setShowOffersMatchingMyAccounts(value);
requestPersistence();
}


///////////////////////////////////////////////////////////////////////////////////////////
// Getter
Expand Down Expand Up @@ -1081,5 +1086,7 @@ private interface ExcludesDelegateMethods {
void setAutoConfirmSettings(AutoConfirmSettings autoConfirmSettings);

void setHideNonAccountPaymentMethods(boolean hideNonAccountPaymentMethods);

void setShowOffersMatchingMyAccounts(boolean value);
}
}
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 @@ -131,6 +131,8 @@ public final class PreferencesPayload implements PersistableEnvelope {

// Added in 1.5.5
private boolean hideNonAccountPaymentMethods;
private boolean showOffersMatchingMyAccounts;


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

Optional.ofNullable(backupDirectory).ifPresent(builder::setBackupDirectory);
Optional.ofNullable(preferredTradeCurrency).ifPresent(e -> builder.setPreferredTradeCurrency((protobuf.TradeCurrency) e.toProtoMessage()));
Expand Down Expand Up @@ -290,7 +293,8 @@ public static PreferencesPayload fromProto(protobuf.PreferencesPayload proto, Co
new ArrayList<>(proto.getAutoConfirmSettingsList().stream()
.map(AutoConfirmSettings::fromProto)
.collect(Collectors.toList())),
proto.getHideNonAccountPaymentMethods()
proto.getHideNonAccountPaymentMethods(),
proto.getShowOffersMatchingMyAccounts()
);
}
}
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 @@ -342,6 +342,7 @@ offerbook.offerersAcceptedBankSeats=Accepted seat of bank countries (taker):\n {
offerbook.availableOffers=Available offers
offerbook.filterByCurrency=Filter by currency
offerbook.filterByPaymentMethod=Filter by payment method
offerbook.matchingOffers=Offers matching my accounts
offerbook.timeSinceSigning=Account info
offerbook.timeSinceSigning.info=This account was verified and {0}
offerbook.timeSinceSigning.info.arbitrator=signed by an arbitrator and can sign peer accounts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import bisq.desktop.common.view.FxmlView;
import bisq.desktop.components.AutoTooltipButton;
import bisq.desktop.components.AutoTooltipLabel;
import bisq.desktop.components.AutoTooltipSlideToggleButton;
import bisq.desktop.components.AutoTooltipTableColumn;
import bisq.desktop.components.AutocompleteComboBox;
import bisq.desktop.components.ColoredDecimalPlacesWithZerosText;
Expand Down Expand Up @@ -126,6 +127,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
private AutocompleteComboBox<TradeCurrency> currencyComboBox;
private AutocompleteComboBox<PaymentMethod> paymentMethodComboBox;
private AutoTooltipButton createOfferButton;
private AutoTooltipSlideToggleButton matchingOffersToggle;
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> amountColumn, volumeColumn, marketColumn,
priceColumn, paymentMethodColumn, depositColumn, signingStateColumn, avatarColumn;
private TableView<OfferBookListItem> tableView;
Expand Down Expand Up @@ -174,22 +176,32 @@ public void initialize() {
hBox.setSpacing(35);
hBox.setPadding(new Insets(10, 0, 0, 0));

final Tuple3<VBox, Label, AutocompleteComboBox<TradeCurrency>> currencyBoxTuple = FormBuilder.addTopLabelAutocompleteComboBox(
Tuple3<VBox, Label, AutocompleteComboBox<TradeCurrency>> currencyBoxTuple = FormBuilder.addTopLabelAutocompleteComboBox(
Res.get("offerbook.filterByCurrency"));
final Tuple3<VBox, Label, AutocompleteComboBox<PaymentMethod>> paymentBoxTuple = FormBuilder.addTopLabelAutocompleteComboBox(
currencyComboBox = currencyBoxTuple.third;
currencyComboBox.setPrefWidth(270);

Tuple3<VBox, Label, AutocompleteComboBox<PaymentMethod>> paymentBoxTuple = FormBuilder.addTopLabelAutocompleteComboBox(
Res.get("offerbook.filterByPaymentMethod"));
paymentMethodComboBox = paymentBoxTuple.third;
paymentMethodComboBox.setCellFactory(GUIUtil.getPaymentMethodCellFactory());
paymentMethodComboBox.setPrefWidth(270);

matchingOffersToggle = new AutoTooltipSlideToggleButton();
matchingOffersToggle.setText(Res.get("offerbook.matchingOffers"));
HBox.setMargin(matchingOffersToggle, new Insets(7, 0, -9, -15));

hBox.getChildren().addAll(currencyBoxTuple.first, paymentBoxTuple.first, matchingOffersToggle);
AnchorPane.setLeftAnchor(hBox, 0d);
AnchorPane.setTopAnchor(hBox, 0d);
AnchorPane.setBottomAnchor(hBox, 0d);

createOfferButton = new AutoTooltipButton();
createOfferButton.setMinHeight(40);
createOfferButton.setGraphicTextGap(10);
AnchorPane.setRightAnchor(createOfferButton, 0d);
AnchorPane.setBottomAnchor(createOfferButton, 0d);

hBox.getChildren().addAll(currencyBoxTuple.first, paymentBoxTuple.first, createOfferButton);
AnchorPane.setLeftAnchor(hBox, 0d);
AnchorPane.setTopAnchor(hBox, 0d);
AnchorPane.setBottomAnchor(hBox, 0d);

AnchorPane anchorPane = new AnchorPane();
anchorPane.getChildren().addAll(hBox, createOfferButton);

Expand All @@ -199,11 +211,6 @@ public void initialize() {
GridPane.setMargin(anchorPane, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0));
root.getChildren().add(anchorPane);

currencyComboBox = currencyBoxTuple.third;

paymentMethodComboBox = paymentBoxTuple.third;
paymentMethodComboBox.setCellFactory(GUIUtil.getPaymentMethodCellFactory());

tableView = new TableView<>();

GridPane.setRowIndex(tableView, ++gridRow);
Expand Down Expand Up @@ -328,6 +335,10 @@ protected void activate() {

currencyComboBox.getEditor().setText(new CurrencyStringConverter(currencyComboBox).toString(currencyComboBox.getSelectionModel().getSelectedItem()));

matchingOffersToggle.setSelected(model.useOffersMatchingMyAccountsFilter);
matchingOffersToggle.disableProperty().bind(model.disableMatchToggle);
matchingOffersToggle.setOnAction(e -> model.onShowOffersMatchingMyAccounts(matchingOffersToggle.isSelected()));

volumeColumn.sortableProperty().bind(model.showAllTradeCurrenciesProperty.not());
model.getOfferList().comparatorProperty().bind(tableView.comparatorProperty());

Expand Down Expand Up @@ -424,6 +435,8 @@ private void updateSigningStateColumn() {
@Override
protected void deactivate() {
createOfferButton.setOnAction(null);
matchingOffersToggle.setOnAction(null);
matchingOffersToggle.disableProperty().unbind();
model.getOfferList().comparatorProperty().unbind();

volumeColumn.sortableProperty().unbind();
Expand Down Expand Up @@ -1024,6 +1037,10 @@ public void updateItem(final OfferBookListItem item, boolean empty) {
final Offer offer = item.getOffer();
boolean myOffer = model.isMyOffer(offer);
if (tableRow != null) {
// this code is duplicated in model.getOffersMatchingMyAccountsPredicate but as
// we want to pass the results for displaying relevant info in popups we
// cannot simply replace it with the predicate. If there are any changes we
// need to maintain both.
isPaymentAccountValidForOffer = model.isAnyPaymentAccountValidForOffer(offer);
isInsufficientCounterpartyTradeLimit = model.isInsufficientCounterpartyTradeLimit(offer);
hasSameProtocolVersion = model.hasSameProtocolVersion(offer);
Expand Down
Loading

0 comments on commit cfabf79

Please sign in to comment.