浏览代码

add new password screen for convert hub vault flow

Armin Schrenk 2 年之前
父节点
当前提交
ec7d6eafec

+ 2 - 1
src/main/java/org/cryptomator/ui/common/FxmlFile.java

@@ -9,7 +9,8 @@ public enum FxmlFile {
 	ADDVAULT_SUCCESS("/fxml/addvault_success.fxml"), //
 	ADDVAULT_WELCOME("/fxml/addvault_welcome.fxml"), //
 	CHANGEPASSWORD("/fxml/changepassword.fxml"), //
-	CONVERTVAULT_HUBTOLOCAL("/fxml/convertvault_hubtolocal_start.fxml"), //
+	CONVERTVAULT_HUBTOLOCAL_START("/fxml/convertvault_hubtolocal_start.fxml"), //
+	CONVERTVAULT_HUBTOLOCAL_CONVERT("/fxml/convertvault_hubtolocal_convert.fxml"), //
 	ERROR("/fxml/error.fxml"), //
 	FORGET_PASSWORD("/fxml/forget_password.fxml"), //
 	HEALTH_START("/fxml/health_start.fxml"), //

+ 1 - 1
src/main/java/org/cryptomator/ui/convertvault/ConvertVaultComponent.java

@@ -23,7 +23,7 @@ public interface ConvertVaultComponent {
 	@ConvertVaultWindow
 	Stage window();
 
-	@FxmlScene(FxmlFile.CONVERTVAULT_HUBTOLOCAL)
+	@FxmlScene(FxmlFile.CONVERTVAULT_HUBTOLOCAL_START)
 	Lazy<Scene> hubToLocalScene();
 
 	default void showHubToLocalWindow() {

+ 25 - 5
src/main/java/org/cryptomator/ui/convertvault/ConvertVaultModule.java

@@ -6,6 +6,8 @@ import dagger.Provides;
 import dagger.multibindings.IntoMap;
 import org.cryptomator.common.vaults.Vault;
 import org.cryptomator.cryptofs.VaultConfig;
+import org.cryptomator.ui.changepassword.NewPasswordController;
+import org.cryptomator.ui.changepassword.PasswordStrengthUtil;
 import org.cryptomator.ui.common.DefaultSceneFactory;
 import org.cryptomator.ui.common.FxController;
 import org.cryptomator.ui.common.FxControllerKey;
@@ -13,8 +15,6 @@ import org.cryptomator.ui.common.FxmlFile;
 import org.cryptomator.ui.common.FxmlLoaderFactory;
 import org.cryptomator.ui.common.FxmlScene;
 import org.cryptomator.ui.common.StageFactory;
-import org.cryptomator.ui.quit.QuitController;
-import org.cryptomator.ui.quit.QuitForcedController;
 import org.cryptomator.ui.recoverykey.RecoveryKeyFactory;
 import org.cryptomator.ui.recoverykey.RecoveryKeyValidateController;
 
@@ -70,10 +70,17 @@ abstract class ConvertVaultModule {
 	}
 
 	@Provides
-	@FxmlScene(FxmlFile.CONVERTVAULT_HUBTOLOCAL)
+	@FxmlScene(FxmlFile.CONVERTVAULT_HUBTOLOCAL_START)
 	@ConvertVaultScoped
-	static Scene provideHubToLocalScene(@ConvertVaultWindow FxmlLoaderFactory fxmlLoaders) {
-		return fxmlLoaders.createScene(FxmlFile.CONVERTVAULT_HUBTOLOCAL);
+	static Scene provideHubToLocalStartScene(@ConvertVaultWindow FxmlLoaderFactory fxmlLoaders) {
+		return fxmlLoaders.createScene(FxmlFile.CONVERTVAULT_HUBTOLOCAL_START);
+	}
+
+	@Provides
+	@FxmlScene(FxmlFile.CONVERTVAULT_HUBTOLOCAL_CONVERT)
+	@ConvertVaultScoped
+	static Scene provideHubToLocalConvertScene(@ConvertVaultWindow FxmlLoaderFactory fxmlLoaders) {
+		return fxmlLoaders.createScene(FxmlFile.CONVERTVAULT_HUBTOLOCAL_CONVERT);
 	}
 
 	// ------------------
@@ -83,6 +90,19 @@ abstract class ConvertVaultModule {
 	@FxControllerKey(HubToLocalStartController.class)
 	abstract FxController bindHubToLocalStartController(HubToLocalStartController controller);
 
+	@Binds
+	@IntoMap
+	@FxControllerKey(HubToLocalConvertController.class)
+	abstract FxController bindHubToLocalConvertController(HubToLocalConvertController controller);
+
+
+	@Provides
+	@IntoMap
+	@FxControllerKey(NewPasswordController.class)
+	static FxController provideNewPasswordController(ResourceBundle resourceBundle, PasswordStrengthUtil strengthRater) {
+		return new NewPasswordController(resourceBundle, strengthRater);
+	}
+
 	@Provides
 	@IntoMap
 	@FxControllerKey(RecoveryKeyValidateController.class)

+ 41 - 0
src/main/java/org/cryptomator/ui/convertvault/HubToLocalConvertController.java

@@ -0,0 +1,41 @@
+package org.cryptomator.ui.convertvault;
+
+import org.cryptomator.ui.changepassword.NewPasswordController;
+import org.cryptomator.ui.common.FxController;
+
+import javax.inject.Inject;
+import javafx.fxml.FXML;
+import javafx.stage.Stage;
+
+public class HubToLocalConvertController implements FxController {
+
+	private final Stage window;
+
+	@FXML
+	NewPasswordController newPasswordController;
+
+	@Inject
+	public HubToLocalConvertController(@ConvertVaultWindow Stage window) {
+		this.window = window;
+	}
+
+	@FXML
+	public void initialize() {
+	}
+
+	@FXML
+	public void close() {
+		window.close();
+	}
+
+	@FXML
+	public void convert() {
+		//window.setScene(resetPasswordScene.get());
+	}
+
+	/* Getter/Setter */
+
+	public NewPasswordController getNewPasswordController() {
+		return newPasswordController;
+	}
+}

+ 9 - 3
src/main/java/org/cryptomator/ui/convertvault/HubToLocalStartController.java

@@ -1,22 +1,28 @@
 package org.cryptomator.ui.convertvault;
 
+import dagger.Lazy;
 import org.cryptomator.ui.common.FxController;
+import org.cryptomator.ui.common.FxmlFile;
+import org.cryptomator.ui.common.FxmlScene;
 import org.cryptomator.ui.recoverykey.RecoveryKeyValidateController;
 
 import javax.inject.Inject;
 import javafx.fxml.FXML;
+import javafx.scene.Scene;
 import javafx.stage.Stage;
 
 public class HubToLocalStartController implements FxController {
 
 	private final Stage window;
+	private final Lazy<Scene> convertScene;
 
 	@FXML
 	RecoveryKeyValidateController recoveryKeyValidateController;
 
 	@Inject
-	public HubToLocalStartController(@ConvertVaultWindow Stage window) {
+	public HubToLocalStartController(@ConvertVaultWindow Stage window, @FxmlScene(FxmlFile.CONVERTVAULT_HUBTOLOCAL_CONVERT) Lazy<Scene> convertScene) {
 		this.window = window;
+		this.convertScene = convertScene;
 	}
 
 	@FXML
@@ -29,8 +35,8 @@ public class HubToLocalStartController implements FxController {
 	}
 
 	@FXML
-	public void convert() {
-		//window.setScene(resetPasswordScene.get());
+	public void next() {
+		window.setScene(convertScene.get());
 	}
 
 	/* Getter/Setter */

+ 32 - 0
src/main/resources/fxml/convertvault_hubtolocal_convert.fxml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<?import javafx.geometry.Insets?>
+<?import javafx.scene.layout.Region?>
+<?import javafx.scene.layout.VBox?>
+<?import javafx.scene.control.ButtonBar?>
+<?import javafx.scene.control.Button?>
+<VBox xmlns:fx="http://javafx.com/fxml"
+	  xmlns="http://javafx.com/javafx"
+	  fx:controller="org.cryptomator.ui.convertvault.HubToLocalConvertController"
+	  minWidth="350"
+	  minHeight="280"
+	  spacing="12"
+	  alignment="TOP_LEFT">
+	<padding>
+		<Insets topRightBottomLeft="24"/>
+	</padding>
+	<children>
+		<fx:include fx:id="newPassword" source="new_password.fxml"/>
+
+		<Region VBox.vgrow="ALWAYS"/>
+
+		<VBox alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">
+			<ButtonBar buttonMinWidth="120" buttonOrder="+CX">
+				<buttons>
+					<Button text="%generic.button.cancel" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#close"/>
+					<Button text="TODO Convert" ButtonBar.buttonData="NEXT_FORWARD" defaultButton="true" onAction="#convert" disable="${!controller.newPasswordController.goodPassword}"/>
+				</buttons>
+			</ButtonBar>
+		</VBox>
+	</children>
+</VBox>

+ 1 - 1
src/main/resources/fxml/convertvault_hubtolocal_start.fxml

@@ -24,7 +24,7 @@
 			<ButtonBar buttonMinWidth="120" buttonOrder="+CX">
 				<buttons>
 					<Button text="%generic.button.cancel" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#close"/>
-					<Button text="%generic.button.next" ButtonBar.buttonData="NEXT_FORWARD" defaultButton="true" onAction="#convert" disable="${!controller.validateController.recoveryKeyCorrect}"/>
+					<Button text="%generic.button.next" ButtonBar.buttonData="NEXT_FORWARD" defaultButton="true" onAction="#next" disable="${!controller.validateController.recoveryKeyCorrect}"/>
 				</buttons>
 			</ButtonBar>
 		</VBox>