Skip to content

Commit

Permalink
Merge pull request #4863 from jmacxx/account_usability
Browse files Browse the repository at this point in the history
Account management usability improvements
  • Loading branch information
ripcurlx committed Dec 1, 2020
2 parents 740071d + 0af139c commit 0967715
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import javafx.collections.SetChangeListener;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -88,7 +89,7 @@ private void fillAndSortPaymentAccounts() {
paymentAccounts.setAll(user.getPaymentAccounts().stream()
.filter(paymentAccount -> paymentAccount.getPaymentMethod().isAsset())
.collect(Collectors.toList()));
paymentAccounts.sort((o1, o2) -> o1.getCreationDate().compareTo(o2.getCreationDate()));
paymentAccounts.sort(Comparator.comparing(PaymentAccount::getAccountName));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void fillAndSortPaymentAccounts() {
.filter(paymentAccount -> !paymentAccount.getPaymentMethod().isAsset())
.collect(Collectors.toList());
paymentAccounts.setAll(list);
paymentAccounts.sort(Comparator.comparing(PaymentAccount::getCreationDate));
paymentAccounts.sort(Comparator.comparing(PaymentAccount::getAccountName));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
import javax.annotation.Nullable;

import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Comparator.comparing;

public abstract class MutableOfferDataModel extends OfferDataModel implements BsqBalanceListener {
private final CreateOfferService createOfferService;
Expand Down Expand Up @@ -330,7 +331,7 @@ void onPaymentAccountSelected(PaymentAccount paymentAccount) {
setTradeCurrencyFromPaymentAccount(paymentAccount);
setSuggestedSecurityDeposit(getPaymentAccount());

if (amount.get() != null)
if (amount.get() != null && this.allowAmountUpdate)
this.amount.set(Coin.valueOf(Math.min(amount.get().value, getMaxTradeLimit())));
}
}
Expand Down Expand Up @@ -612,6 +613,7 @@ void swapTradeToSavings() {
private void fillPaymentAccounts() {
if (user.getPaymentAccounts() != null)
paymentAccounts.setAll(new HashSet<>(user.getPaymentAccounts()));
paymentAccounts.sort(comparing(PaymentAccount::getAccountName));
}

protected void setAmount(Coin amount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ private void onShowPayFundsScreen() {
}

private void updateOfferElementsStyle() {
GridPane.setColumnSpan(firstRowHBox, 1);
GridPane.setColumnSpan(firstRowHBox, 2);

final String activeInputStyle = "input-with-border";
final String readOnlyInputStyle = "input-with-border-readonly";
Expand Down Expand Up @@ -991,7 +991,7 @@ private void addPaymentGroup() {

paymentGroupBox = new HBox();
paymentGroupBox.setAlignment(Pos.CENTER_LEFT);
paymentGroupBox.setSpacing(62);
paymentGroupBox.setSpacing(12);
paymentGroupBox.setPadding(new Insets(10, 0, 18, 0));

final Tuple3<VBox, Label, ComboBox<PaymentAccount>> tradingAccountBoxTuple = addTopLabelComboBox(
Expand All @@ -1007,12 +1007,15 @@ private void addPaymentGroup() {
GridPane.setMargin(paymentGroupBox, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0));
gridPane.getChildren().add(paymentGroupBox);

tradingAccountBoxTuple.first.setMinWidth(800);
paymentAccountsComboBox = tradingAccountBoxTuple.third;
paymentAccountsComboBox.setMinWidth(300);
paymentAccountsComboBox.setMinWidth(tradingAccountBoxTuple.first.getMinWidth());
paymentAccountsComboBox.setPrefWidth(tradingAccountBoxTuple.first.getMinWidth());
editOfferElements.add(tradingAccountBoxTuple.first);

// we display either currencyComboBox (multi currency account) or currencyTextField (single)
currencyComboBox = currencyBoxTuple.third;
currencyComboBox.setMaxWidth(tradingAccountBoxTuple.first.getMinWidth() / 2);
editOfferElements.add(currencySelection);
currencyComboBox.setConverter(new StringConverter<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ public void testUseTradeCurrencySetInOfferViewWhenInPaymentAccountAvailable() {
final HashSet<PaymentAccount> paymentAccounts = new HashSet<>();
final ClearXchangeAccount zelleAccount = new ClearXchangeAccount();
zelleAccount.setId("234");
zelleAccount.setAccountName("zelleAccount");
paymentAccounts.add(zelleAccount);
final RevolutAccount revolutAccount = new RevolutAccount();
revolutAccount.setId("123");
revolutAccount.setAccountName("revolutAccount");
revolutAccount.setSingleTradeCurrency(new FiatCurrency("EUR"));
revolutAccount.addCurrency(new FiatCurrency("USD"));
paymentAccounts.add(revolutAccount);
Expand All @@ -104,9 +106,11 @@ public void testUseTradeAccountThatMatchesTradeCurrencySetInOffer() {
final HashSet<PaymentAccount> paymentAccounts = new HashSet<>();
final ClearXchangeAccount zelleAccount = new ClearXchangeAccount();
zelleAccount.setId("234");
zelleAccount.setAccountName("zelleAccount");
paymentAccounts.add(zelleAccount);
final RevolutAccount revolutAccount = new RevolutAccount();
revolutAccount.setId("123");
revolutAccount.setAccountName("revolutAccount");
revolutAccount.setSingleTradeCurrency(new FiatCurrency("EUR"));
paymentAccounts.add(revolutAccount);

Expand Down

0 comments on commit 0967715

Please sign in to comment.