hide wallet restore functionality until supported

This commit is contained in:
woodser 2024-01-19 10:49:58 -05:00
parent a6b8723ebe
commit f8b78368f8

View file

@ -48,15 +48,16 @@ import java.io.IOException;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.util.TimeZone; import java.util.TimeZone;
import static haveno.desktop.util.FormBuilder.addMultilineLabel; import static haveno.desktop.util.FormBuilder.addMultilineLabel;
import static haveno.desktop.util.FormBuilder.addPrimaryActionButtonAFterGroup; //import static haveno.desktop.util.FormBuilder.addPrimaryActionButtonAFterGroup;
import static haveno.desktop.util.FormBuilder.addTitledGroupBg; import static haveno.desktop.util.FormBuilder.addTitledGroupBg;
import static haveno.desktop.util.FormBuilder.addTopLabelDatePicker; import static haveno.desktop.util.FormBuilder.addTopLabelDatePicker;
import static haveno.desktop.util.FormBuilder.addTopLabelTextArea; import static haveno.desktop.util.FormBuilder.addTopLabelTextArea;
import static javafx.beans.binding.Bindings.createBooleanBinding; //import static javafx.beans.binding.Bindings.createBooleanBinding;
@FxmlView @FxmlView
public class SeedWordsView extends ActivatableView<GridPane, Void> { public class SeedWordsView extends ActivatableView<GridPane, Void> {
@ -108,14 +109,21 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
datePicker = addTopLabelDatePicker(root, ++gridRow, Res.get("seed.date"), 10).second; datePicker = addTopLabelDatePicker(root, ++gridRow, Res.get("seed.date"), 10).second;
datePicker.setMouseTransparent(true); datePicker.setMouseTransparent(true);
addTitledGroupBg(root, ++gridRow, 3, Res.get("seed.restore.title"), Layout.GROUP_DISTANCE); // TODO: to re-enable restore functionality:
seedWordsTextArea = addTopLabelTextArea(root, gridRow, Res.get("seed.seedWords"), "", Layout.FIRST_ROW_AND_GROUP_DISTANCE).second; // - uncomment code throughout this file
seedWordsTextArea.getStyleClass().add("wallet-seed-words"); // - support getting wallet's restore height
seedWordsTextArea.setPrefHeight(40); // - support translating between date and restore height
seedWordsTextArea.setMaxHeight(40); // - clear XmrAddressEntries which are incompatible with new wallet and other tests
// - update mnemonic validation and restore calls
restoreDatePicker = addTopLabelDatePicker(root, ++gridRow, Res.get("seed.date"), 10).second; // addTitledGroupBg(root, ++gridRow, 3, Res.get("seed.restore.title"), Layout.GROUP_DISTANCE);
restoreButton = addPrimaryActionButtonAFterGroup(root, ++gridRow, Res.get("seed.restore")); // seedWordsTextArea = addTopLabelTextArea(root, gridRow, Res.get("seed.seedWords"), "", Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
// seedWordsTextArea.getStyleClass().add("wallet-seed-words");
// seedWordsTextArea.setPrefHeight(40);
// seedWordsTextArea.setMaxHeight(40);
// restoreDatePicker = addTopLabelDatePicker(root, ++gridRow, Res.get("seed.date"), 10).second;
// restoreButton = addPrimaryActionButtonAFterGroup(root, ++gridRow, Res.get("seed.restore"));
addTitledGroupBg(root, ++gridRow, 1, Res.get("shared.information"), Layout.GROUP_DISTANCE); addTitledGroupBg(root, ++gridRow, 1, Res.get("shared.information"), Layout.GROUP_DISTANCE);
addMultilineLabel(root, gridRow, Res.get("account.seed.info"), addMultilineLabel(root, gridRow, Res.get("account.seed.info"),
@ -143,21 +151,21 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
@Override @Override
public void activate() { public void activate() {
seedWordsValid.addListener(seedWordsValidChangeListener); // seedWordsValid.addListener(seedWordsValidChangeListener);
seedWordsTextArea.textProperty().addListener(seedWordsTextAreaChangeListener); // seedWordsTextArea.textProperty().addListener(seedWordsTextAreaChangeListener);
restoreButton.disableProperty().bind(createBooleanBinding(() -> !seedWordsValid.get() || !seedWordsEdited.get(), // restoreButton.disableProperty().bind(createBooleanBinding(() -> !seedWordsValid.get() || !seedWordsEdited.get(),
seedWordsValid, seedWordsEdited)); // seedWordsValid, seedWordsEdited));
restoreButton.setOnAction(e -> { // restoreButton.setOnAction(e -> {
new Popup().information(Res.get("account.seed.restore.info")) // new Popup().information(Res.get("account.seed.restore.info"))
.closeButtonText(Res.get("shared.cancel")) // .closeButtonText(Res.get("shared.cancel"))
.actionButtonText(Res.get("account.seed.restore.ok")) // .actionButtonText(Res.get("account.seed.restore.ok"))
.onAction(this::onRestore) // .onAction(this::onRestore)
.show(); // .show();
}); // });
seedWordsTextArea.getStyleClass().remove("validation-error"); // seedWordsTextArea.getStyleClass().remove("validation-error");
restoreDatePicker.getStyleClass().remove("validation-error"); // restoreDatePicker.getStyleClass().remove("validation-error");
String key = "showBackupWarningAtSeedPhrase"; String key = "showBackupWarningAtSeedPhrase";
if (DontShowAgainLookup.showAgain(key)) { if (DontShowAgainLookup.showAgain(key)) {
@ -197,19 +205,20 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
@Override @Override
protected void deactivate() { protected void deactivate() {
seedWordsValid.removeListener(seedWordsValidChangeListener);
seedWordsTextArea.textProperty().removeListener(seedWordsTextAreaChangeListener);
restoreButton.disableProperty().unbind();
restoreButton.setOnAction(null);
displaySeedWordsTextArea.setText(""); displaySeedWordsTextArea.setText("");
seedWordsTextArea.setText("");
restoreDatePicker.setValue(null);
datePicker.setValue(null); datePicker.setValue(null);
seedWordsTextArea.getStyleClass().remove("validation-error"); // seedWordsValid.removeListener(seedWordsValidChangeListener);
restoreDatePicker.getStyleClass().remove("validation-error"); // seedWordsTextArea.textProperty().removeListener(seedWordsTextAreaChangeListener);
// restoreButton.disableProperty().unbind();
// restoreButton.setOnAction(null);
// seedWordsTextArea.setText("");
// restoreDatePicker.setValue(null);
// seedWordsTextArea.getStyleClass().remove("validation-error");
// restoreDatePicker.getStyleClass().remove("validation-error");
} }
private void askForPassword() { private void askForPassword() {
@ -225,6 +234,7 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
private void showSeedScreen() { private void showSeedScreen() {
displaySeedWordsTextArea.setText(seedWordText); displaySeedWordsTextArea.setText(seedWordText);
walletCreationDate = Instant.ofEpochSecond(xmrWalletService.getWalletCreationDate()).atZone(ZoneId.systemDefault()).toLocalDate();
datePicker.setValue(walletCreationDate); datePicker.setValue(walletCreationDate);
} }