diff --git a/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettings.java b/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettings.java index 3b24a4c8b..f6a0aa805 100644 --- a/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettings.java +++ b/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettings.java @@ -28,6 +28,7 @@ public class VaultSettings { public static final boolean DEFAULT_UNLOCK_AFTER_STARTUP = false; public static final boolean DEFAULT_MOUNT_AFTER_UNLOCK = true; public static final boolean DEFAULT_REAVEAL_AFTER_MOUNT = true; + public static final boolean DEFAULT_USES_INDIVIDUAL_MOUNTPATH = false; private final String id; private final ObjectProperty path = new SimpleObjectProperty<>(); @@ -36,6 +37,7 @@ public class VaultSettings { private final BooleanProperty unlockAfterStartup = new SimpleBooleanProperty(DEFAULT_UNLOCK_AFTER_STARTUP); private final BooleanProperty mountAfterUnlock = new SimpleBooleanProperty(DEFAULT_MOUNT_AFTER_UNLOCK); private final BooleanProperty revealAfterMount = new SimpleBooleanProperty(DEFAULT_REAVEAL_AFTER_MOUNT); + private final BooleanProperty usesIndividualMountPath = new SimpleBooleanProperty(DEFAULT_USES_INDIVIDUAL_MOUNTPATH); private final StringProperty individualMountPath = new SimpleStringProperty(); public VaultSettings(String id) { @@ -45,7 +47,7 @@ public class VaultSettings { } Observable[] observables() { - return new Observable[]{path, mountName, winDriveLetter, unlockAfterStartup, mountAfterUnlock, revealAfterMount, individualMountPath}; + return new Observable[]{path, mountName, winDriveLetter, unlockAfterStartup, mountAfterUnlock, revealAfterMount, usesIndividualMountPath, individualMountPath}; } private void deriveMountNameFromPath(Path path) { @@ -124,6 +126,10 @@ public class VaultSettings { return revealAfterMount; } + public BooleanProperty usesIndividualMountPath() { + return usesIndividualMountPath; + } + public StringProperty individualMountPath() { return individualMountPath; } diff --git a/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettingsJsonAdapter.java b/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettingsJsonAdapter.java index dde47dcd2..f63ab3c33 100644 --- a/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettingsJsonAdapter.java +++ b/main/commons/src/main/java/org/cryptomator/common/settings/VaultSettingsJsonAdapter.java @@ -27,9 +27,9 @@ class VaultSettingsJsonAdapter { out.name("unlockAfterStartup").value(value.unlockAfterStartup().get()); out.name("mountAfterUnlock").value(value.mountAfterUnlock().get()); out.name("revealAfterMount").value(value.revealAfterMount().get()); - if(value.individualMountPath().isNotEmpty().get()){ - out.name("individualMountPath").value(value.individualMountPath().get()); - } + out.name("usesIndividualMountPath").value(value.usesIndividualMountPath().get()); + //TODO: should this always be written? ( because it could contain metadata, which the user does not want to save!) + out.name("individualMountPath").value(value.individualMountPath().get()); out.endObject(); } @@ -42,6 +42,7 @@ class VaultSettingsJsonAdapter { boolean unlockAfterStartup = VaultSettings.DEFAULT_UNLOCK_AFTER_STARTUP; boolean mountAfterUnlock = VaultSettings.DEFAULT_MOUNT_AFTER_UNLOCK; boolean revealAfterMount = VaultSettings.DEFAULT_REAVEAL_AFTER_MOUNT; + boolean usesIndividualMountPath = VaultSettings.DEFAULT_USES_INDIVIDUAL_MOUNTPATH; in.beginObject(); while (in.hasNext()) { @@ -68,6 +69,9 @@ class VaultSettingsJsonAdapter { case "revealAfterMount": revealAfterMount = in.nextBoolean(); break; + case "usesIndividualMountPath": + usesIndividualMountPath = in.nextBoolean(); + break; case "individualMountPath": individualMountPath = in.nextString(); break; @@ -85,6 +89,7 @@ class VaultSettingsJsonAdapter { vaultSettings.unlockAfterStartup().set(unlockAfterStartup); vaultSettings.mountAfterUnlock().set(mountAfterUnlock); vaultSettings.revealAfterMount().set(revealAfterMount); + vaultSettings.usesIndividualMountPath().set(usesIndividualMountPath); vaultSettings.individualMountPath().set(individualMountPath); return vaultSettings; } diff --git a/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java b/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java index 1e2c8f294..fe2c2ca90 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java @@ -122,6 +122,9 @@ public class UnlockController implements ViewController { @FXML private ChoiceBox winDriveLetter; + @FXML + private CheckBox useOwnMountPath; + @FXML private HBox mountPathBox; @@ -163,13 +166,18 @@ public class UnlockController implements ViewController { savePassword.setDisable(!keychainAccess.isPresent()); unlockAfterStartup.disableProperty().bind(savePassword.disabledProperty().or(savePassword.selectedProperty().not())); - mountPathBox.managedProperty().bind(mountPathLabel.visibleProperty()); - mountPath.managedProperty().bind(mountPathLabel.visibleProperty()); - changeMountPathButton.managedProperty().bind(mountPathLabel.visibleProperty()); + mountPathLabel.setVisible(false); + mountPathBox.visibleProperty().bind(mountPathLabel.visibleProperty()); + mountPathBox.managedProperty().bind(mountPathLabel.managedProperty()); + mountPath.visibleProperty().bind(mountPathLabel.visibleProperty()); + mountPath.managedProperty().bind(mountPathLabel.managedProperty()); + changeMountPathButton.visibleProperty().bind(mountPathLabel.visibleProperty()); + changeMountPathButton.managedProperty().bind(mountPathLabel.managedProperty()); if (SystemUtils.IS_OS_WINDOWS) { winDriveLetter.setConverter(new WinDriveLetterLabelConverter()); - mountPathLabel.setVisible(false); + useOwnMountPath.setVisible(false); + useOwnMountPath.setManaged(false); mountPathLabel.setManaged(false); //dirty cheat mountPathBox.setMouseTransparent(true); @@ -178,8 +186,9 @@ public class UnlockController implements ViewController { winDriveLetterLabel.setManaged(false); winDriveLetter.setVisible(false); winDriveLetter.setManaged(false); - if(VolumeImpl.WEBDAV.equals(settings.volumeImpl().get())){ - mountPathLabel.setVisible(false); + if (VolumeImpl.WEBDAV.equals(settings.volumeImpl().get())) { + useOwnMountPath.setVisible(false); + useOwnMountPath.setManaged(false); mountPathLabel.setManaged(false); } } @@ -243,15 +252,18 @@ public class UnlockController implements ViewController { unlockAfterStartup.setSelected(savePassword.isSelected() && vaultSettings.unlockAfterStartup().get()); mountAfterUnlock.setSelected(vaultSettings.mountAfterUnlock().get()); revealAfterMount.setSelected(vaultSettings.revealAfterMount().get()); + useOwnMountPath.setSelected(vaultSettings.usesIndividualMountPath().get()); vaultSubs = vaultSubs.and(EasyBind.subscribe(unlockAfterStartup.selectedProperty(), vaultSettings.unlockAfterStartup()::set)); vaultSubs = vaultSubs.and(EasyBind.subscribe(mountAfterUnlock.selectedProperty(), vaultSettings.mountAfterUnlock()::set)); vaultSubs = vaultSubs.and(EasyBind.subscribe(revealAfterMount.selectedProperty(), vaultSettings.revealAfterMount()::set)); + vaultSubs = vaultSubs.and(EasyBind.subscribe(useOwnMountPath.selectedProperty(), vaultSettings.usesIndividualMountPath()::set)); changeMountPathButton.visibleProperty().bind( - vaultSettings.individualMountPath().isNotEqualTo(mountPath.textProperty()) + vaultSettings.individualMountPath().isNotEqualTo(mountPath.textProperty()) ); mountPath.textProperty().setValue(vaultSettings.individualMountPath().getValueSafe()); + mountPathLabel.visibleProperty().bind(useOwnMountPath.selectedProperty()); } diff --git a/main/ui/src/main/java/org/cryptomator/ui/model/FuseVolume.java b/main/ui/src/main/java/org/cryptomator/ui/model/FuseVolume.java index 360d46f3a..2b8000344 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/model/FuseVolume.java +++ b/main/ui/src/main/java/org/cryptomator/ui/model/FuseVolume.java @@ -57,7 +57,7 @@ public class FuseVolume implements Volume { // auto assign drive letter mountPath = windowsDriveLetters.getAvailableDriveLetters().iterator().next() + ":\\"; } - } else if (vaultSettings.individualMountPath().get() != null) { + } else if (vaultSettings.usesIndividualMountPath().get()) { //specific path given mountPath = vaultSettings.individualMountPath().get(); } else { diff --git a/main/ui/src/main/resources/fxml/unlock.fxml b/main/ui/src/main/resources/fxml/unlock.fxml index 89516cd92..3442ae73e 100644 --- a/main/ui/src/main/resources/fxml/unlock.fxml +++ b/main/ui/src/main/resources/fxml/unlock.fxml @@ -91,12 +91,15 @@ -