hide xmr auto confirmation settings

This commit is contained in:
woodser 2023-05-24 09:29:07 -04:00
parent 8b735d17b7
commit 79247e87fa

View File

@ -41,7 +41,6 @@ import haveno.core.user.Preferences;
import haveno.core.user.User; import haveno.core.user.User;
import haveno.core.util.FormattingUtils; import haveno.core.util.FormattingUtils;
import haveno.core.util.ParsingUtils; import haveno.core.util.ParsingUtils;
import haveno.core.util.coin.CoinFormatter;
import haveno.core.util.validation.IntegerValidator; import haveno.core.util.validation.IntegerValidator;
import haveno.core.util.validation.RegexValidator; import haveno.core.util.validation.RegexValidator;
import haveno.core.util.validation.RegexValidatorFactory; import haveno.core.util.validation.RegexValidatorFactory;
@ -81,7 +80,6 @@ import javafx.scene.layout.VBox;
import javafx.util.Callback; import javafx.util.Callback;
import javafx.util.StringConverter; import javafx.util.StringConverter;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.bitcoinj.core.Coin;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -106,7 +104,6 @@ import static haveno.desktop.util.FormBuilder.addTopLabelListView;
@FxmlView @FxmlView
public class PreferencesView extends ActivatableViewAndModel<GridPane, PreferencesViewModel> { public class PreferencesView extends ActivatableViewAndModel<GridPane, PreferencesViewModel> {
private final User user; private final User user;
private final CoinFormatter formatter;
private TextField btcExplorerTextField; private TextField btcExplorerTextField;
private ComboBox<String> userLanguageComboBox; private ComboBox<String> userLanguageComboBox;
private ComboBox<Country> userCountryComboBox; private ComboBox<Country> userCountryComboBox;
@ -148,6 +145,8 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
private final boolean displayStandbyModeFeature; private final boolean displayStandbyModeFeature;
private ChangeListener<Filter> filterChangeListener; private ChangeListener<Filter> filterChangeListener;
private boolean hideXmrAutoConf = true; // TODO: remove xmr auto conf or use as a model for other blockchains
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, initialisation // Constructor, initialisation
@ -159,11 +158,9 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
FilterManager filterManager, FilterManager filterManager,
Config config, Config config,
User user, User user,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
@Named(Config.STORAGE_DIR) File storageDir) { @Named(Config.STORAGE_DIR) File storageDir) {
super(model); super(model);
this.user = user; this.user = user;
this.formatter = formatter;
this.preferences = preferences; this.preferences = preferences;
this.filterManager = filterManager; this.filterManager = filterManager;
this.storageDir = storageDir; this.storageDir = storageDir;
@ -305,13 +302,13 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
private void initializeDisplayCurrencies() { private void initializeDisplayCurrencies() {
TitledGroupBg titledGroupBg = addTitledGroupBg(root, displayCurrenciesGridRowIndex, 8, TitledGroupBg titledGroupBg = addTitledGroupBg(root, displayCurrenciesGridRowIndex, 8,
Res.get("setting.preferences.currenciesInList"), Layout.GROUP_DISTANCE); Res.get("setting.preferences.currenciesInList"), hideXmrAutoConf ? 0.0 :Layout.GROUP_DISTANCE);
GridPane.setColumnIndex(titledGroupBg, 2); GridPane.setColumnIndex(titledGroupBg, 2);
GridPane.setColumnSpan(titledGroupBg, 2); GridPane.setColumnSpan(titledGroupBg, 2);
preferredTradeCurrencyComboBox = addComboBox(root, displayCurrenciesGridRowIndex++, preferredTradeCurrencyComboBox = addComboBox(root, displayCurrenciesGridRowIndex++,
Res.get("setting.preferences.prefCurrency"), Res.get("setting.preferences.prefCurrency"),
Layout.FIRST_ROW_AND_GROUP_DISTANCE); Layout.FIRST_ROW_DISTANCE);
GridPane.setColumnIndex(preferredTradeCurrencyComboBox, 2); GridPane.setColumnIndex(preferredTradeCurrencyComboBox, 2);
preferredTradeCurrencyComboBox.setConverter(new StringConverter<>() { preferredTradeCurrencyComboBox.setConverter(new StringConverter<>() {
@ -526,7 +523,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
private void initializeAutoConfirmOptions() { private void initializeAutoConfirmOptions() {
GridPane autoConfirmGridPane = new GridPane(); GridPane autoConfirmGridPane = new GridPane();
GridPane.setHgrow(autoConfirmGridPane, Priority.ALWAYS); GridPane.setHgrow(autoConfirmGridPane, Priority.ALWAYS);
root.add(autoConfirmGridPane, 2, displayCurrenciesGridRowIndex, 2, 10); if (!hideXmrAutoConf) root.add(autoConfirmGridPane, 2, displayCurrenciesGridRowIndex, 2, 10);
addTitledGroupBg(autoConfirmGridPane, 0, 4, Res.get("setting.preferences.autoConfirmXMR"), 0); addTitledGroupBg(autoConfirmGridPane, 0, 4, Res.get("setting.preferences.autoConfirmXMR"), 0);
int localRowIndex = 0; int localRowIndex = 0;
autoConfirmXmrToggle = addSlideToggleButton(autoConfirmGridPane, localRowIndex, Res.get("setting.preferences.autoConfirmEnabled"), Layout.FIRST_ROW_DISTANCE); autoConfirmXmrToggle = addSlideToggleButton(autoConfirmGridPane, localRowIndex, Res.get("setting.preferences.autoConfirmEnabled"), Layout.FIRST_ROW_DISTANCE);
@ -539,7 +536,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
autoConfServiceAddressTf = addInputTextField(autoConfirmGridPane, ++localRowIndex, Res.get("setting.preferences.autoConfirmServiceAddresses")); autoConfServiceAddressTf = addInputTextField(autoConfirmGridPane, ++localRowIndex, Res.get("setting.preferences.autoConfirmServiceAddresses"));
GridPane.setHgrow(autoConfServiceAddressTf, Priority.ALWAYS); GridPane.setHgrow(autoConfServiceAddressTf, Priority.ALWAYS);
displayCurrenciesGridRowIndex += 4; if (!hideXmrAutoConf) displayCurrenciesGridRowIndex += 4;
autoConfServiceAddressListener = (observable, oldValue, newValue) -> { autoConfServiceAddressListener = (observable, oldValue, newValue) -> {
if (!newValue.equals(oldValue)) { if (!newValue.equals(oldValue)) {
@ -801,7 +798,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
preferences.findAutoConfirmSettings("XMR").ifPresent(autoConfirmSettings -> { preferences.findAutoConfirmSettings("XMR").ifPresent(autoConfirmSettings -> {
autoConfirmXmrToggle.setSelected(autoConfirmSettings.isEnabled()); autoConfirmXmrToggle.setSelected(autoConfirmSettings.isEnabled());
autoConfRequiredConfirmationsTf.setText(String.valueOf(autoConfirmSettings.getRequiredConfirmations())); autoConfRequiredConfirmationsTf.setText(String.valueOf(autoConfirmSettings.getRequiredConfirmations()));
autoConfTradeLimitTf.setText(formatter.formatCoin(Coin.valueOf(autoConfirmSettings.getTradeLimit()))); autoConfTradeLimitTf.setText(HavenoUtils.formatXmr(autoConfirmSettings.getTradeLimit()));
autoConfServiceAddressTf.setText(String.join(", ", autoConfirmSettings.getServiceAddresses())); autoConfServiceAddressTf.setText(String.join(", ", autoConfirmSettings.getServiceAddresses()));
autoConfRequiredConfirmationsTf.focusedProperty().addListener(autoConfRequiredConfirmationsFocusOutListener); autoConfRequiredConfirmationsTf.focusedProperty().addListener(autoConfRequiredConfirmationsFocusOutListener);
autoConfTradeLimitTf.textProperty().addListener(autoConfTradeLimitListener); autoConfTradeLimitTf.textProperty().addListener(autoConfTradeLimitListener);