further additions to #1060

This commit is contained in:
Armin Schrenk
2020-02-12 16:19:42 +01:00
parent e1cf8546b7
commit 7755256956
2 changed files with 41 additions and 1 deletions

View File

@@ -1,9 +1,14 @@
package org.cryptomator.ui.recovervault;
import dagger.Lazy;
import javafx.beans.Observable;
import javafx.beans.property.StringProperty;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.stage.Stage;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.ui.common.FxController;
import org.cryptomator.ui.common.FxmlFile;
import org.cryptomator.ui.common.FxmlScene;
@@ -20,16 +25,42 @@ public class RecoverVaultController implements FxController {
private final Stage window;
private final Lazy<Scene> successScene;
private final Vault vault;
private StringProperty recoveryKey;
public TextArea textarea;
@Inject
public RecoverVaultController(@RecoverVaultWindow Stage window, @FxmlScene(FxmlFile.RECOVER_VAULT) Lazy<Scene> successScene) {
public RecoverVaultController(@RecoverVaultWindow Stage window, @FxmlScene(FxmlFile.RECOVER_VAULT) Lazy<Scene> successScene, @RecoverVaultWindow Vault vault, @RecoverVaultWindow StringProperty recoveryKey) {
this.window = window;
this.successScene = successScene;
this.vault = vault;
this.recoveryKey = recoveryKey;
}
@FXML
public void initialize() {
textarea.getParagraphs().addListener(this::updateRecoveryKeyProperty);
}
private void updateRecoveryKeyProperty(@SuppressWarnings("unused") Observable observable) {
recoveryKey.set(textarea.getText());
}
@FXML
public void close() {
window.close();
}
public void recoverData(ActionEvent actionEvent) {
//TODO: CryptoAPI call, show progress bar
}
/* Getter/Setter */
public Vault getVault() {
return vault;
}
}

View File

@@ -4,6 +4,9 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?>
<?import javafx.scene.layout.VBox?>
<?import org.cryptomator.ui.controls.FormattedLabel?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.TextArea?>
<VBox xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="org.cryptomator.ui.recovervault.RecoverVaultController"
@@ -16,10 +19,16 @@
<Insets topRightBottomLeft="12"/>
</padding>
<children>
<VBox spacing="6">
<FormattedLabel format="TODO If you lost/forgot your password for vault %s, you can get access with your backup passphrase" arg1="${controller.vault.displayableName}" wrapText="true"/>
<CheckBox fx:id="confirmation" text="TODO I have understood that all data will be decrypted. This cannot be undone."/>
<TextArea editable="true" wrapText="true" prefRowCount="4" fx:id="textarea" promptText="TODO Paste here your backup passphrase."/>
</VBox>
<VBox alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">
<ButtonBar buttonMinWidth="120" buttonOrder="C+X">
<buttons>
<Button text="%generic.button.cancel" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#close"/>
<Button text="TODO Proceed" ButtonBar.buttonData="NEXT_FORWARD" cancelButton="false" onAction="#recoverData" disable="${!confirmation.selected}"/>
</buttons>
</ButtonBar>
</VBox>