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 53f1056a3..3b24a4c8b 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 @@ -36,7 +36,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 StringProperty mountPath = new SimpleStringProperty(); + private final StringProperty individualMountPath = new SimpleStringProperty(); public VaultSettings(String id) { this.id = Objects.requireNonNull(id); @@ -45,7 +45,7 @@ public class VaultSettings { } Observable[] observables() { - return new Observable[]{path, mountName, winDriveLetter, unlockAfterStartup, mountAfterUnlock, revealAfterMount}; + return new Observable[]{path, mountName, winDriveLetter, unlockAfterStartup, mountAfterUnlock, revealAfterMount, individualMountPath}; } private void deriveMountNameFromPath(Path path) { @@ -124,8 +124,8 @@ public class VaultSettings { return revealAfterMount; } - public StringProperty mountPath() { - return mountPath; + public StringProperty individualMountPath() { + return individualMountPath; } /* Hashcode/Equals */ 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 b894e40ea..dde47dcd2 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,7 +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()); - out.name("mountPath").value(value.mountPath().get()); + if(value.individualMountPath().isNotEmpty().get()){ + out.name("individualMountPath").value(value.individualMountPath().get()); + } out.endObject(); } @@ -35,7 +37,7 @@ class VaultSettingsJsonAdapter { String id = null; String path = null; String mountName = null; - String mountPath = null; + String individualMountPath = null; String winDriveLetter = null; boolean unlockAfterStartup = VaultSettings.DEFAULT_UNLOCK_AFTER_STARTUP; boolean mountAfterUnlock = VaultSettings.DEFAULT_MOUNT_AFTER_UNLOCK; @@ -66,8 +68,8 @@ class VaultSettingsJsonAdapter { case "revealAfterMount": revealAfterMount = in.nextBoolean(); break; - case "mountPath": - mountPath = in.nextString(); + case "individualMountPath": + individualMountPath = in.nextString(); break; default: LOG.warn("Unsupported vault setting found in JSON: " + name); @@ -83,7 +85,7 @@ class VaultSettingsJsonAdapter { vaultSettings.unlockAfterStartup().set(unlockAfterStartup); vaultSettings.mountAfterUnlock().set(mountAfterUnlock); vaultSettings.revealAfterMount().set(revealAfterMount); - vaultSettings.mountPath().set(mountPath); + vaultSettings.individualMountPath().set(individualMountPath); return vaultSettings; } diff --git a/main/commons/src/test/java/org/cryptomator/common/settings/VaultSettingsJsonAdapterTest.java b/main/commons/src/test/java/org/cryptomator/common/settings/VaultSettingsJsonAdapterTest.java index c00b5bdf5..8e7139d79 100644 --- a/main/commons/src/test/java/org/cryptomator/common/settings/VaultSettingsJsonAdapterTest.java +++ b/main/commons/src/test/java/org/cryptomator/common/settings/VaultSettingsJsonAdapterTest.java @@ -28,7 +28,7 @@ public class VaultSettingsJsonAdapterTest { Assert.assertEquals(Paths.get("/foo/bar"), vaultSettings.path().get()); Assert.assertEquals("test", vaultSettings.mountName().get()); Assert.assertEquals("X", vaultSettings.winDriveLetter().get()); - Assert.assertEquals("/home/test/crypto", vaultSettings.mountPath().get()); + Assert.assertEquals("/home/test/crypto", vaultSettings.individualMountPath().get()); } } diff --git a/main/pom.xml b/main/pom.xml index 02257553e..a3961971a 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -28,7 +28,7 @@ 1.4.5 1.0.3 1.0.2 - 0.1.2-SNAPSHOT + 0.1.0-SNAPSHOT 2.5 3.6 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 12dee4c33..38bd40670 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 @@ -21,6 +21,8 @@ import javafx.beans.binding.Bindings; import javafx.scene.layout.HBox; import org.apache.commons.lang3.CharUtils; import org.apache.commons.lang3.SystemUtils; +import org.cryptomator.common.settings.NioAdapterImpl; +import org.cryptomator.common.settings.Settings; import org.cryptomator.common.settings.VaultSettings; import org.cryptomator.cryptolib.api.InvalidPassphraseException; import org.cryptomator.cryptolib.api.UnsupportedVaultFormatException; @@ -75,17 +77,19 @@ public class UnlockController implements ViewController { private final WindowsDriveLetters driveLetters; private final ChangeListener driveLetterChangeListener = this::winDriveLetterDidChange; private final Optional keychainAccess; + private final Settings settings; private Vault vault; private Optional listener = Optional.empty(); private Subscription vaultSubs = Subscription.EMPTY; @Inject - public UnlockController(Application app, Localization localization, AsyncTaskService asyncTaskService, WindowsDriveLetters driveLetters, Optional keychainAccess) { + public UnlockController(Application app, Localization localization, AsyncTaskService asyncTaskService, WindowsDriveLetters driveLetters, Optional keychainAccess, Settings settings) { this.app = app; this.localization = localization; this.asyncTaskService = asyncTaskService; this.driveLetters = driveLetters; this.keychainAccess = keychainAccess; + this.settings = settings; } @FXML @@ -155,29 +159,29 @@ public class UnlockController implements ViewController { mountName.textProperty().addListener(this::mountNameDidChange); 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()); + if (SystemUtils.IS_OS_WINDOWS) { winDriveLetter.setConverter(new WinDriveLetterLabelConverter()); - mountPathBox.setMouseTransparent(true); mountPathLabel.setVisible(false); mountPathLabel.setManaged(false); - mountPath.setVisible(false); - mountPath.setManaged(false); - changeMountPathButton.setVisible(false); - changeMountPathButton.setManaged(false); + //dirty cheat + mountPathBox.setMouseTransparent(true); } else { winDriveLetterLabel.setVisible(false); winDriveLetterLabel.setManaged(false); winDriveLetter.setVisible(false); winDriveLetter.setManaged(false); + if(settings.usedNioAdapterImpl().isEqualTo(NioAdapterImpl.WEBDAV.name()).get()){ + mountPathLabel.setVisible(false); + mountPathLabel.setManaged(false); + } } changeMountPathButton.disableProperty().bind(Bindings.createBooleanBinding(this::isDirVaild, mountPath.textProperty()).not()); - changeMountPathButton.visibleProperty().bind( - Bindings.createBooleanBinding( - () -> mountPathLabel.isVisible() && mountPath.textProperty().isEmpty().not().get(), - mountPathLabel.visibleProperty(), - mountPath.textProperty().isEmpty().not() - ) - ); + } @Override @@ -230,14 +234,19 @@ public class UnlockController implements ViewController { Arrays.fill(storedPw, ' '); } } - VaultSettings settings = vault.getVaultSettings(); - unlockAfterStartup.setSelected(savePassword.isSelected() && settings.unlockAfterStartup().get()); - mountAfterUnlock.setSelected(settings.mountAfterUnlock().get()); - revealAfterMount.setSelected(settings.revealAfterMount().get()); + VaultSettings vaultSettings = vault.getVaultSettings(); + unlockAfterStartup.setSelected(savePassword.isSelected() && vaultSettings.unlockAfterStartup().get()); + mountAfterUnlock.setSelected(vaultSettings.mountAfterUnlock().get()); + revealAfterMount.setSelected(vaultSettings.revealAfterMount().get()); - vaultSubs = vaultSubs.and(EasyBind.subscribe(unlockAfterStartup.selectedProperty(), settings.unlockAfterStartup()::set)); - vaultSubs = vaultSubs.and(EasyBind.subscribe(mountAfterUnlock.selectedProperty(), settings.mountAfterUnlock()::set)); - vaultSubs = vaultSubs.and(EasyBind.subscribe(revealAfterMount.selectedProperty(), settings.revealAfterMount()::set)); + 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)); + + changeMountPathButton.visibleProperty().bind( + vaultSettings.individualMountPath().isNotEqualTo(mountPath.textProperty()) + ); + mountPath.textProperty().setValue(vaultSettings.individualMountPath().getValueSafe()); } @@ -276,8 +285,7 @@ public class UnlockController implements ViewController { Path p = Paths.get(mountPath.textProperty().get()); return Files.isDirectory(p) && Files.isReadable(p) && Files.isWritable(p) && Files.isExecutable(p); } else { - //default path will be taken - return true; + return false; } } catch (InvalidPathException e) { 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 7c55c0f97..7751dadd0 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 @@ -36,7 +36,7 @@ public class FuseVolume implements Volume { @Override public void prepare(CryptoFileSystem fs) { this.cfs = fs; - if (!(vaultSettings.mountPath().isNotNull().get() || SystemUtils.IS_OS_WINDOWS)) { + if (!(vaultSettings.individualMountPath().isNotNull().get() || SystemUtils.IS_OS_WINDOWS)) { fuseMnt.useExtraMountDir(); } } @@ -64,17 +64,12 @@ public class FuseVolume implements Volume { // auto assign drive letter selected return windowsDriveLetters.getAvailableDriveLetters().iterator().next() + ":\\"; } - } else { - if (vaultSettings.mountPath().isNotNull().get()) { + } else if (vaultSettings.individualMountPath().isNotNull().get()) { //specific path given - vaultSettings.mountPath().getValue(); - } else { - //choose default path - return SystemUtils.IS_OS_MAC ? DEFAULT_MOUNTROOTPATH_MAC : DEFAULT_MOUNTROOTPATH_LINUX; - } - - } - return null; + return vaultSettings.individualMountPath().getValue(); + } + //choose default path + return SystemUtils.IS_OS_MAC ? DEFAULT_MOUNTROOTPATH_MAC : DEFAULT_MOUNTROOTPATH_LINUX; } @Override diff --git a/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java b/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java index 6a6398a14..f1040a56e 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java +++ b/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java @@ -258,11 +258,11 @@ public class Vault { } public StringProperty getMountPathProperty() { - return vaultSettings.mountPath(); + return vaultSettings.individualMountPath(); } public void setMountPath(String mountPath) { - vaultSettings.mountPath().set(mountPath); + vaultSettings.individualMountPath().set(mountPath); } public void setMountName(String mountName) throws IllegalArgumentException {