Move dev flags to core class

This commit is contained in:
Manfred Karrer 2016-05-25 12:58:36 +02:00
parent bb0f9ddedf
commit 0488ef4668
17 changed files with 53 additions and 41 deletions

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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();

View File

@ -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<TabPane, AccountViewModel> {
}
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 " +

View File

@ -154,7 +154,7 @@ public class AltCoinAccountsView extends ActivatableViewAndModel<GridPane, AltCo
"dispute case. The XMR sender is responsible to be able to verify the XMR transfer to the " +
"arbitrator in case of a dispute.\n\n" +
"There is no payment ID required, just the normal public address.\n\n" +
"If you are not sure about that process visit the Monero forum to find more information.")
"If you are not sure about that process visit the Monero forum (https://forum.getmonero.org) to find more information.")
.closeButtonText("I understand")
.show();
}

View File

@ -17,7 +17,7 @@
package io.bitsquare.gui.main.disputes;
import io.bitsquare.app.BitsquareApp;
import io.bitsquare.app.DevFlags;
import io.bitsquare.arbitration.Arbitrator;
import io.bitsquare.arbitration.ArbitratorManager;
import io.bitsquare.common.crypto.KeyRing;
@ -119,7 +119,7 @@ public class DisputesView extends ActivatableViewAndModel<TabPane, Activatable>
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 " +

View File

@ -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<VBox, Void> {
Tuple2<Label, InputTextField> 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);

View File

@ -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<VBox, Void> {
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<VBox, Void> {
withdrawToTextField.setText("");
withdrawToTextField.setPromptText("Fill in your destination address");
if (BitsquareApp.DEV_MODE)
if (DevFlags.DEV_MODE)
withdrawToTextField.setText("mjYhQYSbET2bXJDyCdNqYhqSye5QX2WHPz");
}

View File

@ -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<AnchorPane, CreateO
balanceTextField.setTargetAmount(model.dataModel.totalToPayAsCoin.get());
if (!BitsquareApp.DEV_MODE) {
if (!DevFlags.DEV_MODE) {
String key = "securityDepositInfo";
new Popup().backgroundInfo("To ensure that both traders follow the trade protocol they need to pay a security deposit.\n\n" +
"The deposit will stay in your local trading wallet until the offer gets accepted by another trader.\n" +
@ -611,7 +611,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
};
placeOfferCompletedListener = (o, oldValue, newValue) -> {
if (BitsquareApp.DEV_MODE) {
if (DevFlags.DEV_MODE) {
close();
navigation.navigateTo(MainView.class, PortfolioView.class, OpenOffersView.class);
} else if (newValue) {

View File

@ -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<CreateOfferDataModel
@Override
protected void activate() {
if (BitsquareApp.DEV_MODE) {
if (DevFlags.DEV_MODE) {
amount.set("0.0001");
minAmount.set(amount.get());
price.set("400");

View File

@ -18,7 +18,7 @@
package io.bitsquare.gui.main.offer.takeoffer;
import com.google.inject.Inject;
import io.bitsquare.app.BitsquareApp;
import io.bitsquare.app.DevFlags;
import io.bitsquare.arbitration.Arbitrator;
import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.FeePolicy;
@ -170,7 +170,7 @@ class TakeOfferDataModel extends ActivatableDataModel {
amountAsCoin.set(offer.getAmount());
if (BitsquareApp.DEV_MODE)
if (DevFlags.DEV_MODE)
amountAsCoin.set(offer.getAmount());
calculateVolume();

View File

@ -19,7 +19,7 @@ package io.bitsquare.gui.main.offer.takeoffer;
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;
@ -303,7 +303,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
balanceTextField.setTargetAmount(model.dataModel.totalToPayAsCoin.get());
if (!BitsquareApp.DEV_MODE) {
if (!DevFlags.DEV_MODE) {
String key = "securityDepositInfo";
new Popup().backgroundInfo("To ensure that both traders follow the trade protocol they need to pay a security deposit.\n\n" +
"The deposit will stay in your local trading wallet until the offer gets accepted by another trader.\n" +
@ -503,7 +503,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
});
showTransactionPublishedScreenSubscription = EasyBind.subscribe(model.showTransactionPublishedScreen, newValue -> {
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) {

View File

@ -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<EmptyWalletWindow> {
Tuple2<Label, InputTextField> 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");

View File

@ -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<TacWindow> {
}
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 " +

View File

@ -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()) +

View File

@ -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" +

View File

@ -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()) +