From 0488ef46686a0f06d69327acaaeaca4e642b8d88 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Wed, 25 May 2016 12:58:36 +0200 Subject: [PATCH] Move dev flags to core class --- common/src/main/java/io/bitsquare/app/DevFlags.java | 13 +++++++++++++ .../main/java/io/bitsquare/app/BitsquareApp.java | 7 ++----- .../java/io/bitsquare/gui/main/MainViewModel.java | 3 ++- .../io/bitsquare/gui/main/account/AccountView.java | 4 ++-- .../altcoinaccounts/AltCoinAccountsView.java | 2 +- .../bitsquare/gui/main/disputes/DisputesView.java | 4 ++-- .../gui/main/funds/deposit/DepositView.java | 4 ++-- .../gui/main/funds/withdrawal/WithdrawalView.java | 6 +++--- .../gui/main/offer/createoffer/CreateOfferView.java | 6 +++--- .../offer/createoffer/CreateOfferViewModel.java | 4 ++-- .../main/offer/takeoffer/TakeOfferDataModel.java | 4 ++-- .../gui/main/offer/takeoffer/TakeOfferView.java | 6 +++--- .../main/overlays/windows/EmptyWalletWindow.java | 4 ++-- .../gui/main/overlays/windows/TacWindow.java | 3 ++- .../pendingtrades/steps/buyer/BuyerStep2View.java | 6 +++--- .../pendingtrades/steps/buyer/BuyerStep5View.java | 12 ++++++------ .../pendingtrades/steps/seller/SellerStep3View.java | 6 +++--- 17 files changed, 53 insertions(+), 41 deletions(-) create mode 100644 common/src/main/java/io/bitsquare/app/DevFlags.java diff --git a/common/src/main/java/io/bitsquare/app/DevFlags.java b/common/src/main/java/io/bitsquare/app/DevFlags.java new file mode 100644 index 0000000000..b7349c9311 --- /dev/null +++ b/common/src/main/java/io/bitsquare/app/DevFlags.java @@ -0,0 +1,13 @@ +package io.bitsquare.app; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DevFlags { + private static final Logger log = LoggerFactory.getLogger(DevFlags.class); + + public static final boolean STRESS_TEST_MODE = true; + public static final boolean DEV_MODE = STRESS_TEST_MODE || false; + public static final boolean IS_RELEASE_VERSION = !DEV_MODE && true; + +} diff --git a/gui/src/main/java/io/bitsquare/app/BitsquareApp.java b/gui/src/main/java/io/bitsquare/app/BitsquareApp.java index 034867677d..da27c02a8e 100644 --- a/gui/src/main/java/io/bitsquare/app/BitsquareApp.java +++ b/gui/src/main/java/io/bitsquare/app/BitsquareApp.java @@ -75,9 +75,6 @@ import static io.bitsquare.app.BitsquareEnvironment.APP_NAME_KEY; public class BitsquareApp extends Application { private static final Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(BitsquareApp.class); - public static final boolean DEV_MODE = false; - public static final boolean IS_RELEASE_VERSION = !DEV_MODE && true; - private static Environment env; private BitsquareAppModule bitsquareAppModule; @@ -104,7 +101,7 @@ public class BitsquareApp extends Application { log.info("Log files under: " + logPath); Version.printVersion(); Utilities.printSysInfo(); - Log.setLevel(!IS_RELEASE_VERSION); + Log.setLevel(!DevFlags.IS_RELEASE_VERSION); UserThread.setExecutor(Platform::runLater); UserThread.setTimerClass(UITimer.class); @@ -184,7 +181,7 @@ public class BitsquareApp extends Application { showSendAlertMessagePopup(); } else if (new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) showFPSWindow(); - else if (BitsquareApp.DEV_MODE) { + else if (DevFlags.DEV_MODE) { if (new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) showDebugWindow(); } diff --git a/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java b/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java index 578f532305..cda3c1c983 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java +++ b/gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java @@ -21,6 +21,7 @@ import com.google.inject.Inject; import io.bitsquare.alert.Alert; import io.bitsquare.alert.AlertManager; import io.bitsquare.app.BitsquareApp; +import io.bitsquare.app.DevFlags; import io.bitsquare.app.Log; import io.bitsquare.app.Version; import io.bitsquare.arbitration.ArbitratorManager; @@ -502,7 +503,7 @@ public class MainViewModel implements ViewModel { setupBtcNumPeersWatcher(); setupP2PNumPeersWatcher(); updateBalance(); - if (BitsquareApp.DEV_MODE) { + if (DevFlags.DEV_MODE) { preferences.setShowOwnOffersInOfferBook(true); if (user.getPaymentAccounts().isEmpty()) setupDevDummyPaymentAccounts(); diff --git a/gui/src/main/java/io/bitsquare/gui/main/account/AccountView.java b/gui/src/main/java/io/bitsquare/gui/main/account/AccountView.java index aeff73c5b0..30d7facf51 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/account/AccountView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/account/AccountView.java @@ -17,7 +17,7 @@ package io.bitsquare.gui.main.account; -import io.bitsquare.app.BitsquareApp; +import io.bitsquare.app.DevFlags; import io.bitsquare.gui.Navigation; import io.bitsquare.gui.common.view.*; import io.bitsquare.gui.main.MainView; @@ -120,7 +120,7 @@ public class AccountView extends ActivatableView { } String key = "accountPrivacyInfo"; - if (!BitsquareApp.DEV_MODE) + if (!DevFlags.DEV_MODE) new Popup().backgroundInfo("In the account screen you can setup your payment accounts for national currencies " + "as well as for crypto currencies.\n\n" + "Please note that this data is stored locally on your computer only. Bitsquare does not operate servers " + diff --git a/gui/src/main/java/io/bitsquare/gui/main/account/content/altcoinaccounts/AltCoinAccountsView.java b/gui/src/main/java/io/bitsquare/gui/main/account/content/altcoinaccounts/AltCoinAccountsView.java index 29f9e874b9..b97955b767 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/account/content/altcoinaccounts/AltCoinAccountsView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/account/content/altcoinaccounts/AltCoinAccountsView.java @@ -154,7 +154,7 @@ public class AltCoinAccountsView extends ActivatableViewAndModel navigation.navigateTo(MainView.class, DisputesView.class, TraderDisputeView.class); String key = "supportInfo"; - if (!BitsquareApp.DEV_MODE) + if (!DevFlags.DEV_MODE) new Popup().backgroundInfo("Bitsquare is not a company and not operating any kind of customer support.\n\n" + "If there are disputes in the trade process (e.g. one trader does not follow the trade protocol) " + "the application will display a \"Open dispute\" button after the trade period is over " + diff --git a/gui/src/main/java/io/bitsquare/gui/main/funds/deposit/DepositView.java b/gui/src/main/java/io/bitsquare/gui/main/funds/deposit/DepositView.java index e4547dedce..8385953128 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/funds/deposit/DepositView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/funds/deposit/DepositView.java @@ -18,7 +18,7 @@ package io.bitsquare.gui.main.funds.deposit; import de.jensd.fx.fontawesome.AwesomeIcon; -import io.bitsquare.app.BitsquareApp; +import io.bitsquare.app.DevFlags; import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.Restrictions; import io.bitsquare.btc.WalletService; @@ -165,7 +165,7 @@ public class DepositView extends ActivatableView { Tuple2 amountTuple = addLabelInputTextField(gridPane, ++gridRow, "Amount in BTC (optional):"); amountLabel = amountTuple.first; amountTextField = amountTuple.second; - if (BitsquareApp.DEV_MODE) + if (DevFlags.DEV_MODE) amountTextField.setText("10"); titledGroupBg.setVisible(false); diff --git a/gui/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalView.java b/gui/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalView.java index 164429cba8..dd65097d52 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalView.java @@ -19,7 +19,7 @@ package io.bitsquare.gui.main.funds.withdrawal; import com.google.common.util.concurrent.FutureCallback; import de.jensd.fx.fontawesome.AwesomeIcon; -import io.bitsquare.app.BitsquareApp; +import io.bitsquare.app.DevFlags; import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntryException; import io.bitsquare.btc.WalletService; @@ -212,7 +212,7 @@ public class WithdrawalView extends ActivatableView { withdrawToTextField.getText(), amountOfSelectedItems); Coin receiverAmount = senderAmountAsCoinProperty.get().subtract(requiredFee); if (receiverAmount.isPositive()) { - if (BitsquareApp.DEV_MODE) { + if (DevFlags.DEV_MODE) { doWithdraw(receiverAmount, callback); } else { new Popup().headLine("Confirm withdrawal request") @@ -356,7 +356,7 @@ public class WithdrawalView extends ActivatableView { withdrawToTextField.setText(""); withdrawToTextField.setPromptText("Fill in your destination address"); - if (BitsquareApp.DEV_MODE) + if (DevFlags.DEV_MODE) withdrawToTextField.setText("mjYhQYSbET2bXJDyCdNqYhqSye5QX2WHPz"); } diff --git a/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferView.java b/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferView.java index 7e2b9b2744..7c17ef7dcf 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferView.java @@ -19,7 +19,7 @@ package io.bitsquare.gui.main.offer.createoffer; import de.jensd.fx.fontawesome.AwesomeDude; import de.jensd.fx.fontawesome.AwesomeIcon; -import io.bitsquare.app.BitsquareApp; +import io.bitsquare.app.DevFlags; import io.bitsquare.common.UserThread; import io.bitsquare.common.util.Tuple2; import io.bitsquare.common.util.Tuple3; @@ -293,7 +293,7 @@ public class CreateOfferView extends ActivatableViewAndModel { - if (BitsquareApp.DEV_MODE) { + if (DevFlags.DEV_MODE) { close(); navigation.navigateTo(MainView.class, PortfolioView.class, OpenOffersView.class); } else if (newValue) { diff --git a/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferViewModel.java b/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferViewModel.java index 7077e549ae..b5d70963f5 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferViewModel.java +++ b/gui/src/main/java/io/bitsquare/gui/main/offer/createoffer/CreateOfferViewModel.java @@ -17,7 +17,7 @@ package io.bitsquare.gui.main.offer.createoffer; -import io.bitsquare.app.BitsquareApp; +import io.bitsquare.app.DevFlags; import io.bitsquare.btc.pricefeed.MarketPrice; import io.bitsquare.btc.pricefeed.PriceFeed; import io.bitsquare.common.Timer; @@ -149,7 +149,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel { - if (newValue && BitsquareApp.DEV_MODE) { + if (newValue && DevFlags.DEV_MODE) { close(); navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class); } else if (newValue && model.getTrade() != null && model.getTrade().errorMessageProperty().get() == null) { diff --git a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/EmptyWalletWindow.java b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/EmptyWalletWindow.java index f5446426bb..e3f192274f 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/EmptyWalletWindow.java +++ b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/EmptyWalletWindow.java @@ -17,7 +17,7 @@ package io.bitsquare.gui.main.overlays.windows; -import io.bitsquare.app.BitsquareApp; +import io.bitsquare.app.DevFlags; import io.bitsquare.btc.Restrictions; import io.bitsquare.btc.WalletService; import io.bitsquare.common.UserThread; @@ -118,7 +118,7 @@ public class EmptyWalletWindow extends Overlay { Tuple2 tuple = addLabelInputTextField(gridPane, ++rowIndex, "Your destination address:"); addressInputTextField = tuple.second; - if (BitsquareApp.DEV_MODE) + if (DevFlags.DEV_MODE) addressInputTextField.setText("mjYhQYSbET2bXJDyCdNqYhqSye5QX2WHPz"); emptyWalletButton = new Button("Empty wallet"); diff --git a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TacWindow.java b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TacWindow.java index 22120d6be6..6fa3047dab 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TacWindow.java +++ b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TacWindow.java @@ -2,6 +2,7 @@ package io.bitsquare.gui.main.overlays.windows; import com.google.inject.Inject; import io.bitsquare.app.BitsquareApp; +import io.bitsquare.app.DevFlags; import io.bitsquare.gui.main.overlays.Overlay; import io.bitsquare.user.Preferences; import org.slf4j.Logger; @@ -21,7 +22,7 @@ public class TacWindow extends Overlay { } public void showIfNeeded() { - if (!preferences.getTacAccepted() && !BitsquareApp.DEV_MODE) { + if (!preferences.getTacAccepted() && !DevFlags.DEV_MODE) { headLine("User agreement"); String text = "1. This software is experimental and provided \"as is\", without warranty of any kind, " + "express or implied, including but not limited to the warranties of " + diff --git a/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java b/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java index 02d918aa1e..94199ba626 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java +++ b/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java @@ -17,7 +17,7 @@ package io.bitsquare.gui.main.portfolio.pendingtrades.steps.buyer; -import io.bitsquare.app.BitsquareApp; +import io.bitsquare.app.DevFlags; import io.bitsquare.common.util.Tuple3; import io.bitsquare.gui.components.TextFieldWithCopyIcon; import io.bitsquare.gui.components.TitledGroupBg; @@ -90,7 +90,7 @@ public class BuyerStep2View extends TradeStepView { "Bitcoin, Btc or Bitsquare.\n\n" + "If your bank charges fees you have to cover those fees."; - if (!BitsquareApp.DEV_MODE && preferences.showAgain(key)) { + if (!DevFlags.DEV_MODE && preferences.showAgain(key)) { preferences.dontShowAgain(key, true); new Popup().headLine("Attention required for trade with ID " + trade.getShortId()) .attention(message) @@ -222,7 +222,7 @@ public class BuyerStep2View extends TradeStepView { private void onPaymentStarted() { if (model.p2PService.isBootstrapped()) { String key = "confirmPaymentStarted"; - if (!BitsquareApp.DEV_MODE && preferences.showAgain(key)) { + if (!DevFlags.DEV_MODE && preferences.showAgain(key)) { Popup popup = new Popup(); popup.headLine("Confirm that you have started the payment") .confirmation("Did you initiate the " + CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode()) + diff --git a/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/buyer/BuyerStep5View.java b/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/buyer/BuyerStep5View.java index ac3b1f6019..6bec73ba8c 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/buyer/BuyerStep5View.java +++ b/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/buyer/BuyerStep5View.java @@ -17,7 +17,7 @@ package io.bitsquare.gui.main.portfolio.pendingtrades.steps.buyer; -import io.bitsquare.app.BitsquareApp; +import io.bitsquare.app.DevFlags; import io.bitsquare.app.Log; import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntryException; @@ -149,11 +149,11 @@ public class BuyerStep5View extends TradeStepView { }); withdrawToExternalWalletButton.setOnAction(e -> reviewWithdrawal()); - if (BitsquareApp.DEV_MODE) { + if (DevFlags.DEV_MODE) { withdrawAddressTextField.setText("mjYhQYSbET2bXJDyCdNqYhqSye5QX2WHPz"); } else { String key = "tradeCompleted" + trade.getId(); - if (!BitsquareApp.DEV_MODE && preferences.showAgain(key)) { + if (!DevFlags.DEV_MODE && preferences.showAgain(key)) { preferences.dontShowAgain(key, true); new Notification().headLine("Trade completed") .notification("You can withdraw your funds now to your external Bitcoin wallet or transfer it to the Bitsquare wallet.") @@ -185,12 +185,12 @@ public class BuyerStep5View extends TradeStepView { validateWithdrawAddress(); } else if (Restrictions.isAboveFixedTxFeeForTradesAndDust(senderAmount)) { - if (BitsquareApp.DEV_MODE) { + if (DevFlags.DEV_MODE) { doWithdrawal(receiverAmount); } else { BSFormatter formatter = model.formatter; String key = "reviewWithdrawalAtTradeComplete"; - if (!BitsquareApp.DEV_MODE && preferences.showAgain(key)) { + if (!DevFlags.DEV_MODE && preferences.showAgain(key)) { new Popup().headLine("Confirm withdrawal request") .confirmation("Sending: " + formatter.formatCoinWithCode(senderAmount) + "\n" + "From address: " + fromAddresses + "\n" + @@ -255,7 +255,7 @@ public class BuyerStep5View extends TradeStepView { } private void handleTradeCompleted() { - if (!BitsquareApp.DEV_MODE) { + if (!DevFlags.DEV_MODE) { String key = "tradeCompleteWithdrawCompletedInfo"; new Popup().headLine("Withdrawal completed") .feedback("Your completed trades are stored under \"Portfolio/History\".\n" + diff --git a/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java b/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java index da809bb3a0..87f797a296 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java +++ b/gui/src/main/java/io/bitsquare/gui/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java @@ -17,7 +17,7 @@ package io.bitsquare.gui.main.portfolio.pendingtrades.steps.seller; -import io.bitsquare.app.BitsquareApp; +import io.bitsquare.app.DevFlags; import io.bitsquare.common.util.Tuple3; import io.bitsquare.gui.components.TextFieldWithCopyIcon; import io.bitsquare.gui.components.TitledGroupBg; @@ -84,7 +84,7 @@ public class SellerStep3View extends TradeStepView { tradeAmountWithCode + " from the bitcoin buyer.\n\n" + "The trade ID (\"reason for payment\" text) of the transaction is: \"" + trade.getShortId() + "\""; } - if (!BitsquareApp.DEV_MODE && preferences.showAgain(key)) { + if (!DevFlags.DEV_MODE && preferences.showAgain(key)) { preferences.dontShowAgain(key, true); new Popup().headLine("Attention required for trade with ID " + trade.getShortId()) .attention(message) @@ -237,7 +237,7 @@ public class SellerStep3View extends TradeStepView { if (model.p2PService.isBootstrapped()) { Preferences preferences = model.dataModel.preferences; String key = "confirmPaymentReceived"; - if (!BitsquareApp.DEV_MODE && preferences.showAgain(key)) { + if (!DevFlags.DEV_MODE && preferences.showAgain(key)) { new Popup() .headLine("Confirm that you have received the payment") .confirmation("Have you received the " + CurrencyUtil.getNameByCode(model.dataModel.getCurrencyCode()) +