Browse Source

Add vault name in unlock window titles

Armin Schrenk 3 years ago
parent
commit
550903325d

+ 18 - 4
src/main/java/org/cryptomator/ui/keyloading/masterkeyfile/MasterkeyFileLoadingModule.java

@@ -23,8 +23,10 @@ import org.slf4j.LoggerFactory;
 
 import javax.inject.Named;
 import javafx.scene.Scene;
+import javafx.stage.Stage;
 import java.nio.file.Path;
 import java.util.Optional;
+import java.util.ResourceBundle;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -93,15 +95,27 @@ public abstract class MasterkeyFileLoadingModule {
 	@Provides
 	@FxmlScene(FxmlFile.UNLOCK_ENTER_PASSWORD)
 	@KeyLoadingScoped
-	static Scene provideUnlockScene(@KeyLoading FxmlLoaderFactory fxmlLoaders) {
-		return fxmlLoaders.createScene(FxmlFile.UNLOCK_ENTER_PASSWORD);
+	static Scene provideUnlockScene(@KeyLoading FxmlLoaderFactory fxmlLoaders, @KeyLoading Stage window, @KeyLoading Vault v, ResourceBundle resourceBundle) {
+		var scene = fxmlLoaders.createScene(FxmlFile.UNLOCK_ENTER_PASSWORD);
+		scene.windowProperty().addListener((prop, oldVal, newVal) -> {
+			if (window.equals(newVal)) {
+				window.setTitle(String.format(resourceBundle.getString("unlock.title"), v.getDisplayName()));
+			}
+		});
+		return scene;
 	}
 
 	@Provides
 	@FxmlScene(FxmlFile.UNLOCK_SELECT_MASTERKEYFILE)
 	@KeyLoadingScoped
-	static Scene provideUnlockSelectMasterkeyFileScene(@KeyLoading FxmlLoaderFactory fxmlLoaders) {
-		return fxmlLoaders.createScene(FxmlFile.UNLOCK_SELECT_MASTERKEYFILE);
+	static Scene provideUnlockSelectMasterkeyFileScene(@KeyLoading FxmlLoaderFactory fxmlLoaders, @KeyLoading Stage window, @KeyLoading Vault v, ResourceBundle resourceBundle) {
+		var scene = fxmlLoaders.createScene(FxmlFile.UNLOCK_SELECT_MASTERKEYFILE);
+		scene.windowProperty().addListener((prop, oldVal, newVal) -> {
+			if (window.equals(newVal)) {
+				window.setTitle(String.format(resourceBundle.getString("unlock.chooseMasterkey.title"), v.getDisplayName()));
+			}
+		});
+		return scene;
 	}
 
 	@Binds

+ 2 - 1
src/main/resources/i18n/strings.properties

@@ -103,7 +103,8 @@ unlock.title=Unlock "%s"
 unlock.passwordPrompt=Enter password for "%s":
 unlock.savePassword=Remember Password
 unlock.unlockBtn=Unlock
-##
+## Select
+unlock.chooseMasterkey.title=Select Masterkey of "%s"
 unlock.chooseMasterkey.prompt=Could not find the masterkey file for this vault at its expected location. Please choose the key file manually.
 unlock.chooseMasterkey.filePickerTitle=Select Masterkey File
 ## Success