Merge pull request #4362 from jmacxx/fix_altcoins_instant_acc

Fix altcoin instant account creation / deletion issues
This commit is contained in:
Christoph Atteneder 2020-07-23 16:10:19 +02:00 committed by GitHub
commit 9ab39c2a8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 9 deletions

View file

@ -110,6 +110,7 @@ public class AssetsForm extends PaymentMethodForm {
tradeInstant = tradeInstantCheckBox.isSelected();
if (tradeInstant)
new Popup().information(Res.get("payment.altcoin.tradeInstant.popup")).show();
paymentLimitationsTextField.setText(getLimitationsText());
});
gridPane.getChildren().remove(tradeInstantCheckBox);

View file

@ -53,6 +53,7 @@ import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleButton;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.FlowPane;
@ -86,6 +87,7 @@ public abstract class PaymentMethodForm {
protected int gridRowFrom;
InputTextField accountNameTextField;
protected TextField paymentLimitationsTextField;
ToggleButton useCustomAccountNameToggleButton;
protected ComboBox<TradeCurrency> currencyComboBox;
@ -164,22 +166,20 @@ public abstract class PaymentMethodForm {
return time;
}
protected void addLimitations(boolean isDisplayForm) {
protected String getLimitationsText() {
final PaymentAccount paymentAccount = getPaymentAccount();
long hours = paymentAccount.getMaxTradePeriod() / 3600_000;
final TradeCurrency tradeCurrency;
if (paymentAccount.getSingleTradeCurrency() != null)
tradeCurrency = paymentAccount.getSingleTradeCurrency();
else if (paymentAccount.getSelectedTradeCurrency() != null)
tradeCurrency = paymentAccount.getSelectedTradeCurrency();
else if (!paymentAccount.getTradeCurrencies().isEmpty())
else if (!paymentAccount.getTradeCurrencies().isEmpty() && paymentAccount.getTradeCurrencies().get(0) != null)
tradeCurrency = paymentAccount.getTradeCurrencies().get(0);
else
tradeCurrency = paymentAccount instanceof AssetAccount ?
CurrencyUtil.getAllSortedCryptoCurrencies().iterator().next() :
CurrencyUtil.getDefaultTradeCurrency();
final boolean isAddAccountScreen = paymentAccount.getAccountName() == null;
final long accountAge = !isAddAccountScreen ? accountAgeWitnessService.getMyAccountAge(paymentAccount.getPaymentAccountPayload()) : 0L;
@ -196,9 +196,14 @@ public abstract class PaymentMethodForm {
formatter.formatCoinWithCode(Coin.valueOf(accountAgeWitnessService.getMyTradeLimit(
paymentAccount, tradeCurrency.getCode(), OfferPayload.Direction.SELL))),
DisplayUtils.formatAccountAge(accountAge));
return limitationsText;
}
protected void addLimitations(boolean isDisplayForm) {
final boolean isAddAccountScreen = paymentAccount.getAccountName() == null;
if (isDisplayForm) {
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.limitations"), limitationsText);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.limitations"), getLimitationsText());
String accountSigningStateText;
MaterialDesignIcon icon;
@ -233,8 +238,9 @@ public abstract class PaymentMethodForm {
accountSigningField.setContent(icon, accountSigningStateText, "", 0.4);
}
} else
addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.limitations"), limitationsText);
} else {
paymentLimitationsTextField = addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.limitations"), getLimitationsText()).second;
}
if (!(paymentAccount instanceof AssetAccount)) {
if (isAddAccountScreen) {

View file

@ -221,7 +221,7 @@ public class AltCoinAccountsView extends PaymentAccountsView<GridPane, AltCoinAc
gridRow = paymentMethodForm.getGridRow();
Tuple2<Button, Button> tuple = add2ButtonsAfterGroup(root, ++gridRow, Res.get("shared.deleteAccount"), Res.get("shared.cancel"));
Button deleteAccountButton = tuple.first;
deleteAccountButton.setOnAction(event -> onDeleteAccount(paymentMethodForm.getPaymentAccount()));
deleteAccountButton.setOnAction(event -> onDeleteAccount(paymentAccount));
Button cancelButton = tuple.second;
cancelButton.setOnAction(event -> removeSelectAccountForm());
GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan());