From 0de1c6a6c2e95faefb251bd3ac4c7546a4f7d77b Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Mon, 27 Nov 2017 11:31:37 -0500 Subject: [PATCH] Improve UI --- common/src/main/java/io/bisq/common/app/DevEnv.java | 6 +++--- .../java/io/bisq/common/locale/CurrencyUtil.java | 7 +++++-- .../main/resources/i18n/displayStrings.properties | 8 ++++---- .../bisq/gui/main/dao/wallet/send/BsqSendView.java | 12 ++++++++++-- .../gui/main/funds/withdrawal/WithdrawalView.java | 3 ++- .../io/bisq/gui/util/validation/BsqValidator.java | 2 +- .../io/bisq/gui/util/validation/BtcValidator.java | 2 +- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/common/src/main/java/io/bisq/common/app/DevEnv.java b/common/src/main/java/io/bisq/common/app/DevEnv.java index 9878dc6314..679ef03109 100644 --- a/common/src/main/java/io/bisq/common/app/DevEnv.java +++ b/common/src/main/java/io/bisq/common/app/DevEnv.java @@ -10,7 +10,7 @@ public class DevEnv { // peer (click user icon and alt+r), filter/block offers by various data like offer ID (cmd + f). // The user can set a program argument to ignore all of those privileged network_messages. They are intended for // emergency cases only (beside update message and arbitrator registration). - public static final boolean USE_DEV_PRIVILEGE_KEYS = false; + public static final boolean USE_DEV_PRIVILEGE_KEYS = true; public static final String DEV_PRIVILEGE_PUB_KEY = "027a381b5333a56e1cc3d90d3a7d07f26509adf7029ed06fc997c656621f8da1ee"; public static final String DEV_PRIVILEGE_PRIV_KEY = "6ac43ea1df2a290c1c8391736aa42e4339c5cb4f110ff0257a13b63211977b7a"; @@ -18,7 +18,7 @@ public class DevEnv { // If set to true we ignore several UI behavior like confirmation popups as well dummy accounts are created and // offers are filled with default values. Intended to make dev testing faster. @SuppressWarnings("PointlessBooleanExpression") - public static final boolean DEV_MODE = STRESS_TEST_MODE || false; + public static final boolean DEV_MODE = STRESS_TEST_MODE || true; - public static final boolean DAO_PHASE2_ACTIVATED = false; + public static final boolean DAO_PHASE2_ACTIVATED = true; } diff --git a/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java b/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java index d0996c6999..e3aec48000 100644 --- a/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java +++ b/common/src/main/java/io/bisq/common/locale/CurrencyUtil.java @@ -18,6 +18,7 @@ package io.bisq.common.locale; import io.bisq.common.GlobalSettings; +import io.bisq.common.app.DevEnv; import lombok.extern.slf4j.Slf4j; import java.util.*; @@ -86,7 +87,8 @@ public class CurrencyUtil { public static List createAllSortedCryptoCurrenciesList() { final List result = new ArrayList<>(); - // result.add(new CryptoCurrency("BSQ", "Bisq Token")); + if (DevEnv.DAO_PHASE2_ACTIVATED) + result.add(new CryptoCurrency("BSQ", "Bisq Token")); if (!baseCurrencyCode.equals("BTC")) result.add(new CryptoCurrency("BTC", "Bitcoin")); @@ -162,7 +164,8 @@ public class CurrencyUtil { public static List getMainCryptoCurrencies() { final List result = new ArrayList<>(); - // result.add(new CryptoCurrency("BSQ", "Bisq Token")); + if (DevEnv.DAO_PHASE2_ACTIVATED) + result.add(new CryptoCurrency("BSQ", "Bisq Token")); if (!baseCurrencyCode.equals("BTC")) result.add(new CryptoCurrency("BTC", "Bitcoin")); if (!baseCurrencyCode.equals("DASH")) diff --git a/common/src/main/resources/i18n/displayStrings.properties b/common/src/main/resources/i18n/displayStrings.properties index 6b87b6cd7a..a669b64d95 100644 --- a/common/src/main/resources/i18n/displayStrings.properties +++ b/common/src/main/resources/i18n/displayStrings.properties @@ -1298,11 +1298,11 @@ popup.warning.tooLargePercentageValue=You cannot set a percentage of 100% or lar popup.warning.examplePercentageValue=Please enter a percentage number like \"5.4\" for 5.4% popup.warning.noPriceFeedAvailable=There is no price feed available for that currency. You cannot use a percent based price.\nPlease select the fixed price. popup.warning.sendMsgFailed=Sending message to your trading partner failed.\nPlease try again and if it continue to fail report a bug. -popup.warning.insufficientBtcFundsForBsqTx=You don''t have sufficient BTC funds for paying the tx fee for that BSQ transaction.\n\ +popup.warning.insufficientBtcFundsForBsqTx=You don''t have sufficient BTC funds for paying the miner fee for that BSQ transaction.\n\ Please fund your BTC wallet to be able to transfer BSQ.\nMissing funds: {0} -popup.warning.insufficientBsqFundsForBtcFeePayment=You don''t have sufficient BSQ funds for paying the tx fee in BSQ.\n\ +popup.warning.insufficientBsqFundsForBtcFeePayment=You don''t have sufficient BSQ funds for paying the mining fee in BSQ.\n\ You can pay the fee in BTC or you need to fund your BSQ wallet.\nMissing BSQ funds: {0} -popup.warning.noBsqFundsForBtcFeePayment=Your BSQ wallet does not have sufficient funds for paying the tx fee in BSQ. +popup.warning.noBsqFundsForBtcFeePayment=Your BSQ wallet does not have sufficient funds for paying the mining fee in BSQ. popup.warning.messageTooLong=Your message exceeds the max. allowed size. Please send it in several parts or upload it to a service like https://pastebin.com. popup.warning.lockedUpFunds=You have locked up funds from a failed trade.\n\ Locked up balance: {0} \n\ @@ -1726,7 +1726,7 @@ validation.bankIdNumber={0} must consist of {1} numbers. validation.accountNr=Account number must consist of {0} numbers. validation.accountNrChars=Account number must consist of {0} characters. validation.btc.invalidAddress=The address is not correct. Please check the address format. -validation.btc.amountBelowDust=The amount you would like to send is below the dust limit\nand would be rejected by the bitcoin network.\nPlease use a higher amount. +validation.btc.amountBelowDust=The amount you would like to send is below the dust limit of {0} \nand would be rejected by the bitcoin network.\nPlease use a higher amount. validation.integerOnly=Please enter integer numbers only. validation.inputError=Your input caused an error:\n{0} validation.bsq.insufficientBalance=Amount exceeds the available balance of {0}. diff --git a/gui/src/main/java/io/bisq/gui/main/dao/wallet/send/BsqSendView.java b/gui/src/main/java/io/bisq/gui/main/dao/wallet/send/BsqSendView.java index 8bb3b3b303..86712cd112 100644 --- a/gui/src/main/java/io/bisq/gui/main/dao/wallet/send/BsqSendView.java +++ b/gui/src/main/java/io/bisq/gui/main/dao/wallet/send/BsqSendView.java @@ -20,6 +20,7 @@ package io.bisq.gui.main.dao.wallet.send; import com.google.common.util.concurrent.FutureCallback; import io.bisq.common.locale.Res; import io.bisq.core.btc.Restrictions; +import io.bisq.core.btc.wallet.BsqBalanceListener; import io.bisq.core.btc.wallet.BsqWalletService; import io.bisq.core.btc.wallet.BtcWalletService; import io.bisq.core.util.CoinUtil; @@ -66,6 +67,7 @@ public class BsqSendView extends ActivatableView { private Button sendButton; private InputTextField receiversAddressInputTextField; private ChangeListener focusOutListener; + private BsqBalanceListener balanceListener; /////////////////////////////////////////////////////////////////////////////////////////// @@ -102,7 +104,6 @@ public class BsqSendView extends ActivatableView { amountInputTextField.setPromptText(Res.get("dao.wallet.send.setAmount", Restrictions.getMinNonDustOutput().value)); amountInputTextField.setValidator(bsqValidator); - focusOutListener = (observable, oldValue, newValue) -> { if (!newValue) verifyInputs(); @@ -137,7 +138,7 @@ public class BsqSendView extends ActivatableView { @Override public void onSuccess(@Nullable Transaction transaction) { if (transaction != null) { - log.error("Successfully sent tx with id " + transaction.getHashAsString()); + log.debug("Successfully sent tx with id " + transaction.getHashAsString()); } } @@ -147,6 +148,9 @@ public class BsqSendView extends ActivatableView { new Popup<>().warning(t.toString()); } }); + + receiversAddressInputTextField.setText(""); + amountInputTextField.setText(""); }) .closeButtonText(Res.get("shared.cancel")) .show(); @@ -166,6 +170,8 @@ public class BsqSendView extends ActivatableView { } } }); + + balanceListener = (availableBalance, unverifiedBalance) -> verifyInputs(); } @Override @@ -173,6 +179,7 @@ public class BsqSendView extends ActivatableView { bsqBalanceUtil.activate(); receiversAddressInputTextField.focusedProperty().addListener(focusOutListener); amountInputTextField.focusedProperty().addListener(focusOutListener); + bsqWalletService.addBsqBalanceListener(balanceListener); verifyInputs(); } @@ -181,6 +188,7 @@ public class BsqSendView extends ActivatableView { bsqBalanceUtil.deactivate(); receiversAddressInputTextField.focusedProperty().removeListener(focusOutListener); amountInputTextField.focusedProperty().removeListener(focusOutListener); + bsqWalletService.removeBsqBalanceListener(balanceListener); } private void verifyInputs() { diff --git a/gui/src/main/java/io/bisq/gui/main/funds/withdrawal/WithdrawalView.java b/gui/src/main/java/io/bisq/gui/main/funds/withdrawal/WithdrawalView.java index 1460f4ed54..53c8591e50 100644 --- a/gui/src/main/java/io/bisq/gui/main/funds/withdrawal/WithdrawalView.java +++ b/gui/src/main/java/io/bisq/gui/main/funds/withdrawal/WithdrawalView.java @@ -25,6 +25,7 @@ import io.bisq.common.locale.Res; import io.bisq.core.btc.AddressEntry; import io.bisq.core.btc.AddressEntryException; import io.bisq.core.btc.InsufficientFundsException; +import io.bisq.core.btc.Restrictions; import io.bisq.core.btc.listeners.BalanceListener; import io.bisq.core.btc.wallet.BtcWalletService; import io.bisq.core.trade.Tradable; @@ -360,7 +361,7 @@ public class WithdrawalView extends ActivatableView { } catch (AddressFormatException e) { new Popup<>().warning(Res.get("validation.btc.invalidAddress")).show(); } catch (Wallet.DustySendRequested e) { - new Popup<>().warning(Res.get("validation.btc.amountBelowDust")).show(); + new Popup<>().warning(Res.get("validation.btc.amountBelowDust", formatter.formatCoinWithCode(Restrictions.getMinNonDustOutput()))).show(); } catch (AddressEntryException e) { new Popup<>().error(e.getMessage()).show(); } catch (InsufficientMoneyException e) { diff --git a/gui/src/main/java/io/bisq/gui/util/validation/BsqValidator.java b/gui/src/main/java/io/bisq/gui/util/validation/BsqValidator.java index 6725b512b6..1c812c0e86 100644 --- a/gui/src/main/java/io/bisq/gui/util/validation/BsqValidator.java +++ b/gui/src/main/java/io/bisq/gui/util/validation/BsqValidator.java @@ -82,7 +82,7 @@ public class BsqValidator extends AltcoinValidator { if (Restrictions.isAboveDust(coin)) return new ValidationResult(true); else - return new ValidationResult(false, Res.get("validation.btc.amountBelowDust")); + return new ValidationResult(false, Res.get("validation.btc.amountBelowDust", bsqFormatter.formatCoinWithCode(Restrictions.getMinNonDustOutput()))); } protected ValidationResult validateIfNotFractionalBtcValue(String input) { diff --git a/gui/src/main/java/io/bisq/gui/util/validation/BtcValidator.java b/gui/src/main/java/io/bisq/gui/util/validation/BtcValidator.java index 943e7bcf03..f3417b1f2d 100644 --- a/gui/src/main/java/io/bisq/gui/util/validation/BtcValidator.java +++ b/gui/src/main/java/io/bisq/gui/util/validation/BtcValidator.java @@ -76,7 +76,7 @@ public class BtcValidator extends NumberValidator { if (Restrictions.isAboveDust(coin)) return new ValidationResult(true); else - return new ValidationResult(false, Res.get("validation.btc.amountBelowDust")); + return new ValidationResult(false, Res.get("validation.btc.amountBelowDust", formatter.formatCoinWithCode(Restrictions.getMinNonDustOutput()))); } catch (Throwable t) { return new ValidationResult(false, Res.get("validation.invalidInput", t.getMessage())); }