mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-08-19 05:36:02 +00:00
implement first stub for password dialogue in create new vault wizard
This commit is contained in:
@@ -87,6 +87,13 @@ public abstract class AddVaultModule {
|
||||
return fxmlLoaders.createScene("/fxml/addvault_new_location.fxml");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@FxmlScene(FxmlFile.ADDVAULT_NEW_PASSWORD)
|
||||
@AddVaultWizardScoped
|
||||
static Scene provideCreateNewVaultPasswordScene(@AddVaultWizard FXMLLoaderFactory fxmlLoaders) {
|
||||
return fxmlLoaders.createScene("/fxml/addvault_new_password.fxml");
|
||||
}
|
||||
|
||||
// ------------------
|
||||
|
||||
@Binds
|
||||
@@ -109,4 +116,8 @@ public abstract class AddVaultModule {
|
||||
@FxControllerKey(CreateNewVaultLocationController.class)
|
||||
abstract FxController bindCreateNewVaultLocationController(CreateNewVaultLocationController controller);
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@FxControllerKey(CreateNewVaultPasswordController.class)
|
||||
abstract FxController bindCreateNewVaultPasswordController(CreateNewVaultPasswordController controller);
|
||||
}
|
||||
|
||||
+4
-2
@@ -24,6 +24,7 @@ public class CreateNewVaultLocationController implements FxController {
|
||||
|
||||
private final Stage window;
|
||||
private final Lazy<Scene> previousScene;
|
||||
private final Lazy<Scene> nextScene;
|
||||
private final ObjectProperty<Path> vaultPath;
|
||||
private final BooleanBinding vaultPathIsNull;
|
||||
private final StringProperty vaultName;
|
||||
@@ -31,9 +32,10 @@ public class CreateNewVaultLocationController implements FxController {
|
||||
|
||||
//TODO: add parameter for next window
|
||||
@Inject
|
||||
CreateNewVaultLocationController(@AddVaultWizard Stage window, @FxmlScene(FxmlFile.ADDVAULT_NEW_NAME) Lazy<Scene> previousScene, ObjectProperty<Path> vaultPath, StringProperty vaultName, ResourceBundle resourceBundle) {
|
||||
CreateNewVaultLocationController(@AddVaultWizard Stage window, @FxmlScene(FxmlFile.ADDVAULT_NEW_NAME) Lazy<Scene> previousScene, @FxmlScene(FxmlFile.ADDVAULT_NEW_PASSWORD) Lazy<Scene> nextScene, ObjectProperty<Path> vaultPath, StringProperty vaultName, ResourceBundle resourceBundle) {
|
||||
this.window = window;
|
||||
this.previousScene = previousScene;
|
||||
this.nextScene = nextScene;
|
||||
this.vaultPath = vaultPath;
|
||||
this.vaultName = vaultName;
|
||||
this.resourceBundle = resourceBundle;
|
||||
@@ -49,7 +51,7 @@ public class CreateNewVaultLocationController implements FxController {
|
||||
public void next() {
|
||||
//TODO: what if there exists already a vault?
|
||||
if (hasFullAccessToLocation()) {
|
||||
window.close();
|
||||
window.setScene(nextScene.get());
|
||||
} else {
|
||||
//TODO error handling
|
||||
}
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package org.cryptomator.ui.addvaultwizard;
|
||||
|
||||
import dagger.Lazy;
|
||||
import javafx.beans.Observable;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.common.vaults.VaultFactory;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.common.FxmlFile;
|
||||
import org.cryptomator.ui.common.FxmlScene;
|
||||
import org.cryptomator.ui.controls.SecPasswordField;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@AddVaultWizardScoped
|
||||
public class CreateNewVaultPasswordController implements FxController {
|
||||
|
||||
private final Stage window;
|
||||
private final Lazy<Scene> previousScene;
|
||||
private final StringProperty vaultName;
|
||||
private final ObjectProperty<Path> vaultPath;
|
||||
private final ObservableList<Vault> vaults;
|
||||
private final VaultFactory vaultFactory;
|
||||
private final ResourceBundle resourceBundle;
|
||||
|
||||
public SecPasswordField passwordField;
|
||||
public SecPasswordField retypeField;
|
||||
|
||||
@Inject
|
||||
CreateNewVaultPasswordController(@AddVaultWizard Stage window, @FxmlScene(FxmlFile.ADDVAULT_NEW_LOCATION) Lazy<Scene> previousScene, StringProperty vaultName, ObjectProperty<Path> vaultPath, ObservableList<Vault> vaults, VaultFactory vaultFactory, ResourceBundle resourceBundle) {
|
||||
this.window = window;
|
||||
this.previousScene = previousScene;
|
||||
this.vaultName = vaultName;
|
||||
this.vaultPath = vaultPath;
|
||||
this.vaults = vaults;
|
||||
this.vaultFactory = vaultFactory;
|
||||
this.resourceBundle = resourceBundle;
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
passwordField.textProperty().addListener(this::passwordsChanged);
|
||||
retypeField.textProperty().addListener(this::passwordsChanged);
|
||||
}
|
||||
|
||||
private boolean passwordsChanged(@SuppressWarnings("unused") Observable observable) {
|
||||
boolean passwordsEmpty = passwordField.getCharacters().length() == 0;
|
||||
boolean passwordsEqual = passwordField.getCharacters().equals(retypeField.getCharacters());
|
||||
//passwordStrength.set(strengthRater.computeRate(passwordField.getCharacters().toString()));
|
||||
return (!passwordsEmpty) && passwordsEqual;
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void back() {
|
||||
window.setScene(previousScene.get());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void finish() {
|
||||
//VaultSettings vaultSettings = VaultSettings.withRandomId();
|
||||
//vaultSettings.path().setValue(vaultPath.get().resolve(vaultName.get()));
|
||||
//vaults.add(vaultFactory.get(vaultSettings));
|
||||
window.close();
|
||||
}
|
||||
|
||||
/* Getter/Setter */
|
||||
|
||||
public String getVaultName() {
|
||||
return vaultName.get();
|
||||
}
|
||||
|
||||
public StringProperty vaultNameProperty() {
|
||||
return vaultName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,9 @@ public enum FxmlFile {
|
||||
ADDVAULT_WELCOME("/fxml/addvault_welcome.fxml"), //
|
||||
ADDVAULT_EXISTING("/fxml/addvault_existing.fxml"), //
|
||||
ADDVAULT_NEW_NAME("/fxml/addvault_new_name.fxml"), //
|
||||
ADDVAULT_NEW_LOCATION("/fxml/addvault_new_location.fxml"), PREFERENCES("/fxml/preferences.fxml"), //
|
||||
ADDVAULT_NEW_LOCATION("/fxml/addvault_new_location.fxml"),
|
||||
ADDVAULT_NEW_PASSWORD("/fxml/addvault_new_password.fxml"),
|
||||
PREFERENCES("/fxml/preferences.fxml"), //
|
||||
UNLOCK("/fxml/unlock2.fxml"), // TODO rename
|
||||
UNLOCK_SUCCESS("/fxml/unlock_success.fxml");
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ButtonBar?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.Region?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import org.cryptomator.ui.controls.SecPasswordField?>
|
||||
<VBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="org.cryptomator.ui.addvaultwizard.CreateNewVaultPasswordController"
|
||||
prefHeight="400.0" prefWidth="600.0"
|
||||
alignment="CENTER">
|
||||
<padding>
|
||||
<Insets top="12" right="12" bottom="12" left="12"/>
|
||||
</padding>
|
||||
<children>
|
||||
<Region VBox.vgrow="ALWAYS"/>
|
||||
<Label text="%addvaultwizard.new.enterPassword"/>
|
||||
<SecPasswordField fx:id="passwordField"/>
|
||||
<Region VBox.vgrow="ALWAYS"/>
|
||||
<Label text="%addvaultwizard.new.reenterPassword"/>
|
||||
<SecPasswordField fx:id="retypeField"/>
|
||||
<Region VBox.vgrow="ALWAYS"/>
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="B+I">
|
||||
<buttons>
|
||||
<Button text="TODO Back" ButtonBar.buttonData="BACK_PREVIOUS" onAction="#back"/>
|
||||
<Button text="TODO Next" ButtonBar.buttonData="FINISH" onAction="#finish" defaultButton="true" disable="true"/>
|
||||
</buttons>
|
||||
</ButtonBar>
|
||||
</children>
|
||||
</VBox>
|
||||
@@ -3,6 +3,8 @@ addvaultwizard.existing.filePickerTitle=Open Masterkey File
|
||||
addvaultwizard.new.insertName=Please enter a name for the vault.
|
||||
addvaultwizard.new.selectLocation=Please pick a directory where your vault is stored:
|
||||
addvaultwizard.new.directoryPickerTitle=Select Directory
|
||||
addvaultwizard.new.enterPassword=Please enter a Password for your vault:
|
||||
addvaultwizard.new.reenterPassword=Please retype the password:
|
||||
main.closeBtn.tooltip=Close
|
||||
main.settingsBtn.tooltip=Settings
|
||||
preferences.title=Preferences
|
||||
|
||||
@@ -3,6 +3,8 @@ addvaultwizard.existing.filePickerTitle=Open Masterkey File
|
||||
addvaultwizard.new.insertName=Please enter a name for the vault.
|
||||
addvaultwizard.new.selectLocation=Please pick a directory where your vault is stored:
|
||||
addvaultwizard.new.directoryPickerTitle=Select Directory
|
||||
addvaultwizard.new.enterPassword=Please enter a Password for your vault:
|
||||
addvaultwizard.new.reenterPassword=Please retype the password:
|
||||
main.closeBtn.tooltip=Close
|
||||
main.settingsBtn.tooltip=Settings
|
||||
preferences.autoUpdateCheck=Check for updates automatically
|
||||
|
||||
Reference in New Issue
Block a user