From 7612e532716359fed7484695bb95ebceb1639eaa Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Wed, 9 Mar 2016 14:23:48 +0100 Subject: [PATCH] ask for displaying seed words without password protection, remember selected subview in account --- .../content/password/PasswordView.java | 1 + .../content/seedwords/SeedWordsView.java | 44 ++++++++++++++----- .../account/settings/AccountSettingsView.java | 12 ++++- .../bitsquare/gui/main/overlays/Overlay.java | 10 ++++- .../overlays/windows/OfferDetailsWindow.java | 4 +- .../overlays/windows/TradeDetailsWindow.java | 4 +- .../steps/buyer/BuyerStep2View.java | 2 + 7 files changed, 62 insertions(+), 15 deletions(-) diff --git a/gui/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordView.java b/gui/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordView.java index 029cf79d68..5cfa630e1d 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/account/content/password/PasswordView.java @@ -86,6 +86,7 @@ public class PasswordView extends ActivatableView { Tuple3 tuple = addButtonWithStatus(root, ++gridRow, "", 0); pwButton = tuple.first; ProgressIndicator progressIndicator = tuple.second; + progressIndicator.setVisible(false); Label deriveStatusLabel = tuple.third; pwButton.setDisable(true); diff --git a/gui/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsView.java b/gui/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsView.java index a90f8a33d8..5acec07996 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/account/content/seedwords/SeedWordsView.java @@ -27,6 +27,7 @@ import io.bitsquare.gui.common.view.FxmlView; import io.bitsquare.gui.main.overlays.popups.Popup; import io.bitsquare.gui.main.overlays.windows.WalletPasswordWindow; import io.bitsquare.gui.util.Layout; +import io.bitsquare.user.Preferences; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ChangeListener; @@ -55,6 +56,7 @@ import static javafx.beans.binding.Bindings.createBooleanBinding; public class SeedWordsView extends ActivatableView { private final WalletService walletService; private final WalletPasswordWindow walletPasswordWindow; + private Preferences preferences; private Button restoreButton; private TextArea seedWordsTextArea; @@ -75,9 +77,10 @@ public class SeedWordsView extends ActivatableView { /////////////////////////////////////////////////////////////////////////////////////////// @Inject - private SeedWordsView(WalletService walletService, WalletPasswordWindow walletPasswordWindow) { + private SeedWordsView(WalletService walletService, WalletPasswordWindow walletPasswordWindow, Preferences preferences) { this.walletService = walletService; this.walletPasswordWindow = walletPasswordWindow; + this.preferences = preferences; } @Override @@ -106,24 +109,45 @@ public class SeedWordsView extends ActivatableView { datePicker.setDisable(true); askForPassword(); } else { - showSeedScreen(keyChainSeed); + String key = "showSeedWordsWarning"; + if (preferences.showAgain(key)) { + new Popup().warning("You have not setup a wallet password which would protect the display of the seed words.\n\n" + + "Do you want to display the seed words?") + .closeButtonText("Yes, and don't ask me again") + .onClose(() -> { + preferences.dontShowAgain(key, true); + showSeedScreen(keyChainSeed); + }) + .actionButtonText("No") + .show(); + } else { + showSeedScreen(keyChainSeed); + } } } @Override protected void deactivate() { - seedWordsValid.removeListener(seedWordsValidChangeListener); - seedWordsTextArea.textProperty().removeListener(seedWordsTextAreaChangeListener); - dateValid.removeListener(datePickerChangeListener); - datePicker.valueProperty().removeListener(dateChangeListener); + if (seedWordsTextAreaChangeListener != null) + seedWordsTextArea.textProperty().removeListener(seedWordsTextAreaChangeListener); seedWordsTextArea.setText(""); - datePicker.setValue(null); - restoreButton.disableProperty().unbind(); seedWordsTextArea.getStyleClass().remove("validation_error"); - datePicker.getStyleClass().remove("validation_error"); - } + if (dateChangeListener != null) + datePicker.valueProperty().removeListener(dateChangeListener); + + datePicker.setValue(null); + datePicker.getStyleClass().remove("validation_error"); + + restoreButton.disableProperty().unbind(); + + if (seedWordsValid != null && seedWordsValidChangeListener != null) + seedWordsValid.removeListener(seedWordsValidChangeListener); + + if (dateValid != null && datePickerChangeListener != null) + dateValid.removeListener(datePickerChangeListener); + } private void askForPassword() { walletPasswordWindow.onAesKey(aesKey -> { diff --git a/gui/src/main/java/io/bitsquare/gui/main/account/settings/AccountSettingsView.java b/gui/src/main/java/io/bitsquare/gui/main/account/settings/AccountSettingsView.java index c2c1741829..22c4173fc8 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/account/settings/AccountSettingsView.java +++ b/gui/src/main/java/io/bitsquare/gui/main/account/settings/AccountSettingsView.java @@ -71,7 +71,8 @@ public class AccountSettingsView extends ActivatableViewAndModel { if (viewPath.size() != 4 || viewPath.indexOf(AccountSettingsView.class) != 2) return; - loadView(viewPath.tip()); + selectedViewClass = viewPath.tip(); + loadView(selectedViewClass); }; ToggleGroup toggleGroup = new ToggleGroup(); @@ -98,7 +99,14 @@ public class AccountSettingsView extends ActivatableViewAndModel { ViewPath viewPath = navigation.getCurrentPath(); if (viewPath.size() == 3 && viewPath.indexOf(AccountSettingsView.class) == 2 || viewPath.size() == 2 && viewPath.indexOf(AccountView.class) == 1) { - navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, FiatAccountsView.class); + if (selectedViewClass == null) + selectedViewClass = FiatAccountsView.class; + + loadView(selectedViewClass); + + /* navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, FiatAccountsView.class); + else + navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, selectedViewClass);*/ } else if (viewPath.size() == 4 && viewPath.indexOf(AccountSettingsView.class) == 2) { selectedViewClass = viewPath.get(3); loadView(selectedViewClass); diff --git a/gui/src/main/java/io/bitsquare/gui/main/overlays/Overlay.java b/gui/src/main/java/io/bitsquare/gui/main/overlays/Overlay.java index d33d1b4903..3ef179473d 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/overlays/Overlay.java +++ b/gui/src/main/java/io/bitsquare/gui/main/overlays/Overlay.java @@ -76,6 +76,7 @@ public abstract class Overlay { private Button actionButton; protected Label headLineLabel; protected String dontShowAgainId; + protected String dontShowAgainText; private Preferences preferences; protected ChangeListener positionListener; protected Timer centerTime; @@ -273,6 +274,11 @@ public abstract class Overlay { return (T) this; } + public T dontShowAgainText(String dontShowAgainText) { + this.dontShowAgainText = dontShowAgainText; + return (T) this; + } + /////////////////////////////////////////////////////////////////////////////////////////// // Protected /////////////////////////////////////////////////////////////////////////////////////////// @@ -624,7 +630,9 @@ public abstract class Overlay { protected void addDontShowAgainCheckBox() { if (dontShowAgainId != null && preferences != null) { - CheckBox dontShowAgainCheckBox = addCheckBox(gridPane, rowIndex, "Don't show again", buttonDistance - 1); + if (dontShowAgainText == null) + dontShowAgainText = "Don't show again"; + CheckBox dontShowAgainCheckBox = addCheckBox(gridPane, rowIndex, dontShowAgainText, buttonDistance - 1); GridPane.setColumnIndex(dontShowAgainCheckBox, 0); GridPane.setHalignment(dontShowAgainCheckBox, HPos.LEFT); dontShowAgainCheckBox.setOnAction(e -> preferences.dontShowAgain(dontShowAgainId, dontShowAgainCheckBox.isSelected())); diff --git a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/OfferDetailsWindow.java b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/OfferDetailsWindow.java index a58be76cd7..b2affb8f6d 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/OfferDetailsWindow.java +++ b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/OfferDetailsWindow.java @@ -18,6 +18,7 @@ package io.bitsquare.gui.main.overlays.windows; import com.google.common.base.Joiner; +import io.bitsquare.btc.FeePolicy; import io.bitsquare.common.crypto.KeyRing; import io.bitsquare.common.util.Tuple3; import io.bitsquare.gui.Navigation; @@ -195,7 +196,7 @@ public class OfferDetailsWindow extends Overlay { } } - rows = 3; + rows = 4; String paymentMethodCountryCode = offer.getPaymentMethodCountryCode(); if (paymentMethodCountryCode != null) rows++; @@ -205,6 +206,7 @@ public class OfferDetailsWindow extends Overlay { addTitledGroupBg(gridPane, ++rowIndex, rows, "Details", Layout.GROUP_DISTANCE); addLabelTextField(gridPane, rowIndex, "Offer ID:", offer.getId(), Layout.FIRST_ROW_AND_GROUP_DISTANCE); addLabelTextField(gridPane, ++rowIndex, "Creation date:", formatter.formatDateTime(offer.getDate())); + addLabelTextField(gridPane, ++rowIndex, "Security deposit:", formatter.formatCoinWithCode(FeePolicy.getSecurityDeposit())); if (paymentMethodCountryCode != null) addLabelTextField(gridPane, ++rowIndex, "Offerers country of bank:", diff --git a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TradeDetailsWindow.java b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TradeDetailsWindow.java index 81eeb781ee..db252bbbbb 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TradeDetailsWindow.java +++ b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/TradeDetailsWindow.java @@ -18,6 +18,7 @@ package io.bitsquare.gui.main.overlays.windows; import io.bitsquare.arbitration.DisputeManager; +import io.bitsquare.btc.FeePolicy; import io.bitsquare.gui.main.overlays.Overlay; import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.Layout; @@ -114,7 +115,7 @@ public class TradeDetailsWindow extends Overlay { addLabelTextField(gridPane, ++rowIndex, "Currency:", offer.getCurrencyCode()); addLabelTextField(gridPane, ++rowIndex, "Payment method:", BSResources.get(offer.getPaymentMethod().getId())); - rows = 4; + rows = 5; PaymentAccountContractData buyerPaymentAccountContractData = null; PaymentAccountContractData sellerPaymentAccountContractData = null; @@ -152,6 +153,7 @@ public class TradeDetailsWindow extends Overlay { addTitledGroupBg(gridPane, ++rowIndex, rows, "Details", Layout.GROUP_DISTANCE); addLabelTextField(gridPane, rowIndex, "Trade ID:", trade.getId(), Layout.FIRST_ROW_AND_GROUP_DISTANCE); addLabelTextField(gridPane, ++rowIndex, "Trade date:", formatter.formatDateTime(trade.getDate())); + addLabelTextField(gridPane, ++rowIndex, "Security deposit:", formatter.formatCoinWithCode(FeePolicy.getSecurityDeposit())); addLabelTextField(gridPane, ++rowIndex, "Selected arbitrator:", trade.getArbitratorNodeAddress().getFullAddress()); if (contract != null) { 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 0e48ae0c2e..3328b275e0 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 @@ -72,6 +72,7 @@ public class BuyerStep2View extends TradeStepView { String message = ""; if (paymentAccountContractData instanceof BlockChainAccountContractData) message = "Your trade has reached at least one blockchain confirmation.\n\n" + + "You can wait for more confirmations if you want - 6 confirmations are considered as very secure.\n\n" + "Please transfer from your external " + CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode()) + " wallet\n" + model.formatter.formatFiatWithCode(trade.getTradeVolume()) + " to the bitcoin seller.\n\n" + @@ -80,6 +81,7 @@ public class BuyerStep2View extends TradeStepView { "You can copy & paste the values from the main screen after closing that popup."; else if (paymentAccountContractData != null) message = "Your trade has reached at least one blockchain confirmation.\n\n" + + "You can wait for more confirmations if you want - 6 confirmations are considered as very secure.\n\n" + "Please go to your online banking web page and pay " + model.formatter.formatFiatWithCode(trade.getTradeVolume()) + " to the bitcoin seller.\n\n" + "Here are the payment account details of the bitcoin seller:\n" +