From b132bb6412d3de30619f30203bcd7f11747b8e86 Mon Sep 17 00:00:00 2001 From: Jan-Peter Klein Date: Thu, 7 Jul 2022 12:16:04 +0200 Subject: [PATCH] implemented recoverykey reset password success notification screen --- .../org/cryptomator/ui/common/FxmlFile.java | 1 + .../ui/recoverykey/RecoveryKeyModule.java | 13 +++++ .../RecoveryKeyResetPasswordController.java | 7 +-- ...veryKeyResetPasswordSuccessController.java | 24 +++++++++ .../recoverykey_reset_password_success.fxml | 53 +++++++++++++++++++ src/main/resources/i18n/strings.properties | 4 ++ 6 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordSuccessController.java create mode 100644 src/main/resources/fxml/recoverykey_reset_password_success.fxml diff --git a/src/main/java/org/cryptomator/ui/common/FxmlFile.java b/src/main/java/org/cryptomator/ui/common/FxmlFile.java index e1912aad1..1e135e7a8 100644 --- a/src/main/java/org/cryptomator/ui/common/FxmlFile.java +++ b/src/main/java/org/cryptomator/ui/common/FxmlFile.java @@ -27,6 +27,7 @@ public enum FxmlFile { RECOVERYKEY_CREATE("/fxml/recoverykey_create.fxml"), // RECOVERYKEY_RECOVER("/fxml/recoverykey_recover.fxml"), // RECOVERYKEY_RESET_PASSWORD("/fxml/recoverykey_reset_password.fxml"), // + RECOVERYKEY_RESET_PASSWORD_SUCCESS("/fxml/recoverykey_reset_password_success.fxml"), // RECOVERYKEY_SUCCESS("/fxml/recoverykey_success.fxml"), // REMOVE_VAULT("/fxml/remove_vault.fxml"), // UNLOCK_ENTER_PASSWORD("/fxml/unlock_enter_password.fxml"), diff --git a/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyModule.java b/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyModule.java index 7e730a245..a5a0b7ec8 100644 --- a/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyModule.java +++ b/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyModule.java @@ -98,6 +98,14 @@ abstract class RecoveryKeyModule { return fxmlLoaders.createScene(FxmlFile.RECOVERYKEY_RESET_PASSWORD); } + @Provides + @FxmlScene(FxmlFile.RECOVERYKEY_RESET_PASSWORD_SUCCESS) + @RecoveryKeyScoped + static Scene provideRecoveryKeyResetPasswordSuccessScene(@RecoveryKeyWindow FxmlLoaderFactory fxmlLoaders) { + return fxmlLoaders.createScene(FxmlFile.RECOVERYKEY_RESET_PASSWORD_SUCCESS); + } + + // ------------------ @Binds @@ -127,6 +135,11 @@ abstract class RecoveryKeyModule { @FxControllerKey(RecoveryKeyResetPasswordController.class) abstract FxController bindRecoveryKeyResetPasswordController(RecoveryKeyResetPasswordController controller); + @Binds + @IntoMap + @FxControllerKey(RecoveryKeyResetPasswordSuccessController.class) + abstract FxController bindRecoveryKeyResetPasswordSuccessController(RecoveryKeyResetPasswordSuccessController controller); + @Provides @IntoMap @FxControllerKey(NewPasswordController.class) diff --git a/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordController.java b/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordController.java index ca3c4e041..a0f443c33 100644 --- a/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordController.java +++ b/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordController.java @@ -31,18 +31,20 @@ public class RecoveryKeyResetPasswordController implements FxController { private final ExecutorService executor; private final StringProperty recoveryKey; private final Lazy recoverScene; + private final Lazy recoverResetPasswordSuccessScene; private final FxApplicationWindows appWindows; public NewPasswordController newPasswordController; @Inject - public RecoveryKeyResetPasswordController(@RecoveryKeyWindow Stage window, @RecoveryKeyWindow Vault vault, RecoveryKeyFactory recoveryKeyFactory, ExecutorService executor, @RecoveryKeyWindow StringProperty recoveryKey, @FxmlScene(FxmlFile.RECOVERYKEY_RECOVER) Lazy recoverScene, FxApplicationWindows appWindows) { + public RecoveryKeyResetPasswordController(@RecoveryKeyWindow Stage window, @RecoveryKeyWindow Vault vault, RecoveryKeyFactory recoveryKeyFactory, ExecutorService executor, @RecoveryKeyWindow StringProperty recoveryKey, @FxmlScene(FxmlFile.RECOVERYKEY_RECOVER) Lazy recoverScene, @FxmlScene(FxmlFile.RECOVERYKEY_RESET_PASSWORD_SUCCESS) Lazy recoverResetPasswordSuccessScene, FxApplicationWindows appWindows) { this.window = window; this.vault = vault; this.recoveryKeyFactory = recoveryKeyFactory; this.executor = executor; this.recoveryKey = recoveryKey; this.recoverScene = recoverScene; + this.recoverResetPasswordSuccessScene = recoverResetPasswordSuccessScene; this.appWindows = appWindows; } @@ -59,8 +61,7 @@ public class RecoveryKeyResetPasswordController implements FxController { }); task.setOnSucceeded(event -> { LOG.info("Used recovery key to reset password for {}.", vault.getDisplayablePath()); - // TODO show success screen - window.close(); + window.setScene(recoverResetPasswordSuccessScene.get()); }); task.setOnFailed(event -> { LOG.error("Resetting password failed.", task.getException()); diff --git a/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordSuccessController.java b/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordSuccessController.java new file mode 100644 index 000000000..b8b106d8b --- /dev/null +++ b/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordSuccessController.java @@ -0,0 +1,24 @@ +package org.cryptomator.ui.recoverykey; + +import org.cryptomator.ui.common.FxController; + +import javax.inject.Inject; +import javafx.fxml.FXML; +import javafx.stage.Stage; + +@RecoveryKeyScoped +public class RecoveryKeyResetPasswordSuccessController implements FxController { + + private final Stage window; + + @Inject + public RecoveryKeyResetPasswordSuccessController(@RecoveryKeyWindow Stage window) { + this.window = window; + } + + @FXML + public void close() { + window.close(); + } + +} diff --git a/src/main/resources/fxml/recoverykey_reset_password_success.fxml b/src/main/resources/fxml/recoverykey_reset_password_success.fxml new file mode 100644 index 000000000..e8f2ea2e5 --- /dev/null +++ b/src/main/resources/fxml/recoverykey_reset_password_success.fxml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +