Adapt Password, Wallet and Restore views

This commit is contained in:
Christoph Atteneder 2018-11-14 11:51:04 +01:00
parent b3d0cad64b
commit 3d0aec5a92
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B
8 changed files with 40 additions and 56 deletions

View file

@ -1782,10 +1782,10 @@ Please note that all open offers will be closed automatically when using this to
Before you use this tool, please backup your data directory. \
You can do this at \"Account/Backup\".\n\n\
Please report us your problem and file a bug report on GitHub or at the Bisq forum so that we can investigate what was causing the problem.
emptyWalletWindow.balance=Your available wallet balance:
emptyWalletWindow.bsq.btcBalance=Balance of non-BSQ Satoshis:
emptyWalletWindow.balance=Your available wallet balance
emptyWalletWindow.bsq.btcBalance=Balance of non-BSQ Satoshis
emptyWalletWindow.address=Your destination address:
emptyWalletWindow.address=Your destination address
emptyWalletWindow.button=Send all funds
emptyWalletWindow.openOffers.warn=You have open offers which will be removed if you empty the wallet.\nAre you sure that you want to empty your wallet?
emptyWalletWindow.openOffers.yes=Yes, I am sure
@ -2206,6 +2206,7 @@ password.backupReminder=Please note that when setting a wallet password all auto
password.backupWasDone=I have already done a backup
seed.seedWords=Wallet seed words
seed.enterSeedWords=Enter wallet seed words
seed.date=Wallet date
seed.restore.title=Restore wallets from seed words
seed.restore=Restore wallets

View file

@ -1162,7 +1162,7 @@ textfield */
}
/* validation */
#validation-error {
.validation-error {
-fx-text-fill: -bs-red;
}

View file

@ -23,6 +23,6 @@ public class PasswordTextField extends JFXPasswordField {
public PasswordTextField() {
super();
setLabelFloat(true);
setMaxWidth(300);
setMaxWidth(380);
}
}

View file

@ -85,7 +85,7 @@ public class PasswordView extends ActivatableView<GridPane, Void> {
@Override
public void initialize() {
headline = FormBuilder.addTitledGroupBg(root, gridRow, 3, "");
passwordField = addPasswordTextField(root, gridRow, Res.get("password.enterPassword"), Layout.FIRST_ROW_DISTANCE);
passwordField = addPasswordTextField(root, gridRow, Res.get("password.enterPassword"), Layout.TWICE_FIRST_ROW_DISTANCE);
final RequiredFieldValidator requiredFieldValidator = new RequiredFieldValidator();
passwordField.getValidators().addAll(requiredFieldValidator, passwordValidator);
passwordFieldChangeListener = (observable, oldValue, newValue) -> {
@ -146,9 +146,7 @@ public class PasswordView extends ActivatableView<GridPane, Void> {
new Popup<>()
.feedback(Res.get("password.walletDecrypted"))
.show();
passwordField.clear();
repeatedPasswordField.clear();
walletsManager.backupWallets();
backupWalletAndResetFields();
} else {
pwButton.setDisable(false);
new Popup<>()
@ -161,10 +159,8 @@ public class PasswordView extends ActivatableView<GridPane, Void> {
new Popup<>()
.feedback(Res.get("password.walletEncrypted"))
.show();
passwordField.clear();
repeatedPasswordField.clear();
backupWalletAndResetFields();
walletsManager.clearBackup();
walletsManager.backupWallets();
} catch (Throwable t) {
new Popup<>()
.warning(Res.get("password.walletEncryptionFailed"))
@ -175,6 +171,12 @@ public class PasswordView extends ActivatableView<GridPane, Void> {
});
}
private void backupWalletAndResetFields() {
passwordField.clear();
repeatedPasswordField.clear();
walletsManager.backupWallets();
}
private void setText() {
if (walletsManager.areWalletsEncrypted()) {
pwButton.updateText(Res.get("account.password.removePw.button"));

View file

@ -117,7 +117,7 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
seedWordsTextArea.setMaxHeight(40);
restoreDatePicker = addTopLabelDatePicker(root, ++gridRow, Res.get("seed.date"), 10).second;
restoreButton = addButtonAfterGroup(root, ++gridRow, Res.get("seed.restore"));
restoreButton = addPrimaryActionButtonAFterGroup(root, ++gridRow, Res.get("seed.restore"));
addTitledGroupBg(root, ++gridRow, 1, Res.get("shared.information"), Layout.GROUP_DISTANCE);
addMultilineLabel(root, gridRow, Res.get("account.seed.info"),

View file

@ -21,7 +21,6 @@ import bisq.desktop.components.AutoTooltipButton;
import bisq.desktop.components.InputTextField;
import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.Transitions;
@ -61,6 +60,7 @@ import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static bisq.desktop.util.FormBuilder.addInputTextField;
import static bisq.desktop.util.FormBuilder.addMultilineLabel;
import static bisq.desktop.util.FormBuilder.addTopLabelTextField;
@ -152,7 +152,7 @@ public class EmptyWalletWindow extends Overlay<EmptyWalletWindow> {
getFormatter().formatCoinWithCode(totalBalance), 10).second;
if (isBtc) {
addressInputTextField = FormBuilder.addInputTextField(gridPane, ++rowIndex, Res.get("emptyWalletWindow.address"));
addressInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("emptyWalletWindow.address"));
} else {
addTopLabelTextField(gridPane, ++rowIndex, Res.get("emptyWalletWindow.bsq.btcBalance"),
bsqFormatter.formatBTCWithCode(bsqWalletService.getAvailableNonBsqBalance().value), 10);
@ -190,7 +190,6 @@ public class EmptyWalletWindow extends Overlay<EmptyWalletWindow> {
HBox hBox = new HBox();
hBox.setSpacing(10);
GridPane.setRowIndex(hBox, ++rowIndex);
GridPane.setColumnIndex(hBox, 1);
if (isBtc)
hBox.getChildren().addAll(emptyWalletButton, closeButton);

View file

@ -23,7 +23,6 @@ import bisq.desktop.components.BusyAnimation;
import bisq.desktop.components.PasswordTextField;
import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.Transitions;
@ -49,7 +48,6 @@ import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.Separator;
import javafx.scene.control.TextArea;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.ColumnConstraints;
@ -59,7 +57,6 @@ import javafx.scene.layout.Priority;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.beans.property.BooleanProperty;
@ -80,7 +77,9 @@ import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import static bisq.desktop.util.FormBuilder.addButton;
import static bisq.desktop.util.FormBuilder.addPasswordTextField;
import static bisq.desktop.util.FormBuilder.addPrimaryActionButton;
import static bisq.desktop.util.FormBuilder.addTextArea;
import static bisq.desktop.util.FormBuilder.addTopLabelDatePicker;
import static com.google.common.base.Preconditions.checkArgument;
import static javafx.beans.binding.Bindings.createBooleanBinding;
@ -102,7 +101,6 @@ public class WalletPasswordWindow extends Overlay<WalletPasswordWindow> {
private ChangeListener<String> changeListener;
private ChangeListener<String> wordsTextAreaChangeListener;
private ChangeListener<Boolean> seedWordsValidChangeListener;
private LocalDate walletCreationDate;
private boolean hideForgotPasswordButton = false;
@ -120,7 +118,7 @@ public class WalletPasswordWindow extends Overlay<WalletPasswordWindow> {
this.walletsManager = walletsManager;
this.storageDir = storageDir;
type = Type.Attention;
width = 868;
width = 900;
}
@ -191,18 +189,11 @@ public class WalletPasswordWindow extends Overlay<WalletPasswordWindow> {
}
private void addInputFields() {
Label label = new AutoTooltipLabel(Res.get("password.enterPassword"));
label.setWrapText(true);
GridPane.setMargin(label, new Insets(3, 0, 0, 0));
GridPane.setRowIndex(label, ++rowIndex);
passwordTextField = new PasswordTextField();
GridPane.setMargin(passwordTextField, new Insets(3, 0, 0, 0));
GridPane.setRowIndex(passwordTextField, rowIndex);
GridPane.setColumnIndex(passwordTextField, 1);
passwordTextField = addPasswordTextField(gridPane, ++rowIndex, Res.get("password.enterPassword"));
GridPane.setColumnSpan(passwordTextField, 1);
GridPane.setHalignment(passwordTextField, HPos.LEFT);
changeListener = (observable, oldValue, newValue) -> unlockButton.setDisable(!passwordTextField.validate());
passwordTextField.textProperty().addListener(changeListener);
gridPane.getChildren().addAll(label, passwordTextField);
}
private void addButtons() {
@ -211,6 +202,7 @@ public class WalletPasswordWindow extends Overlay<WalletPasswordWindow> {
unlockButton = new AutoTooltipButton(Res.get("shared.unlock"));
unlockButton.setDefaultButton(true);
unlockButton.getStyleClass().add("action-button");
unlockButton.setDisable(true);
unlockButton.setOnAction(e -> {
String password = passwordTextField.getText();
@ -254,9 +246,9 @@ public class WalletPasswordWindow extends Overlay<WalletPasswordWindow> {
HBox hBox = new HBox();
hBox.setMinWidth(560);
hBox.setPadding(new Insets(15, 0, 0, 0));
hBox.setSpacing(10);
GridPane.setRowIndex(hBox, ++rowIndex);
GridPane.setColumnIndex(hBox, 1);
hBox.setAlignment(Pos.CENTER_LEFT);
hBox.getChildren().add(unlockButton);
if (!hideForgotPasswordButton)
@ -268,48 +260,34 @@ public class WalletPasswordWindow extends Overlay<WalletPasswordWindow> {
ColumnConstraints columnConstraints1 = new ColumnConstraints();
columnConstraints1.setHalignment(HPos.RIGHT);
columnConstraints1.setHgrow(Priority.SOMETIMES);
ColumnConstraints columnConstraints2 = new ColumnConstraints();
columnConstraints2.setHgrow(Priority.ALWAYS);
gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
columnConstraints1.setHalignment(HPos.LEFT);
columnConstraints1.setHgrow(Priority.ALWAYS);
gridPane.getColumnConstraints().addAll(columnConstraints1);
}
private void showRestoreScreen() {
Label headLine2Label = new AutoTooltipLabel(Res.get("seed.restore.title"));
headLine2Label.setId("popup-headline");
headLine2Label.getStyleClass().add("popup-headline");
headLine2Label.setMouseTransparent(true);
GridPane.setHalignment(headLine2Label, HPos.LEFT);
GridPane.setRowIndex(headLine2Label, ++rowIndex);
GridPane.setColumnSpan(headLine2Label, 2);
GridPane.setMargin(headLine2Label, new Insets(30, 0, 0, 0));
gridPane.getChildren().add(headLine2Label);
Separator separator = new Separator();
separator.setMouseTransparent(true);
separator.setOrientation(Orientation.HORIZONTAL);
separator.getStyleClass().add("separator");
GridPane.setHalignment(separator, HPos.CENTER);
GridPane.setRowIndex(separator, ++rowIndex);
GridPane.setColumnSpan(separator, 2);
gridPane.getChildren().add(separator);
Tuple2<Label, TextArea> tuple = FormBuilder.addTopLabelTextArea(gridPane, ++rowIndex, Res.get("seed.seedWords"), "", 5);
seedWordsTextArea = tuple.second;
seedWordsTextArea = addTextArea(gridPane, ++rowIndex, Res.get("seed.enterSeedWords"), 5);
;
seedWordsTextArea.setPrefHeight(60);
seedWordsTextArea.getStyleClass().add("text-area");
Tuple2<Label, DatePicker> labelDatePickerTuple2 = addTopLabelDatePicker(gridPane, ++rowIndex,
Res.get("seed.creationDate"), 10);
datePicker = labelDatePickerTuple2.second;
restoreButton = addButton(gridPane, ++rowIndex, Res.get("seed.restore"));
restoreButton = addPrimaryActionButton(gridPane, ++rowIndex, Res.get("seed.restore"), 0);
restoreButton.setDefaultButton(true);
stage.setHeight(340);
stage.setHeight(570);
// wallet creation date is not encrypted
walletCreationDate = Instant.ofEpochSecond(walletsManager.getChainSeedCreationTimeSeconds()).atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate walletCreationDate = Instant.ofEpochSecond(walletsManager.getChainSeedCreationTimeSeconds()).atZone(ZoneId.systemDefault()).toLocalDate();
log.info("walletCreationDate " + walletCreationDate);
datePicker.setValue(walletCreationDate);
restoreButton.disableProperty().bind(createBooleanBinding(() -> !seedWordsValid.get() || !seedWordsEdited.get(),

View file

@ -1385,6 +1385,10 @@ public class FormBuilder {
return addButton(gridPane, rowIndex, title, top, true);
}
public static Button addPrimaryActionButtonAFterGroup(GridPane gridPane, int rowIndex, String title) {
return addPrimaryActionButton(gridPane, rowIndex, title, 15);
}
public static Button addButton(GridPane gridPane, int rowIndex, String title, double top) {
return addButton(gridPane, rowIndex, title, top, false);
}