diff --git a/src/main/java/org/cryptomator/common/CommonsModule.java b/src/main/java/org/cryptomator/common/CommonsModule.java index 8ecfa51b6..4ac07495e 100644 --- a/src/main/java/org/cryptomator/common/CommonsModule.java +++ b/src/main/java/org/cryptomator/common/CommonsModule.java @@ -139,9 +139,9 @@ public abstract class CommonsModule { @Provides @Singleton static ObservableValue provideServerSocketAddressBinding(Settings settings) { - return settings.port().map(port -> { + return settings.port.map(port -> { String host = SystemUtils.IS_OS_WINDOWS ? "127.0.0.1" : "localhost"; - return InetSocketAddress.createUnresolved(host, settings.port().intValue()); + return InetSocketAddress.createUnresolved(host, settings.port.intValue()); }); } diff --git a/src/main/java/org/cryptomator/common/LicenseHolder.java b/src/main/java/org/cryptomator/common/LicenseHolder.java index be36e6968..bc52966ea 100644 --- a/src/main/java/org/cryptomator/common/LicenseHolder.java +++ b/src/main/java/org/cryptomator/common/LicenseHolder.java @@ -30,7 +30,7 @@ public class LicenseHolder { this.licenseSubject = validJwtClaims.map(DecodedJWT::getSubject); this.validLicenseProperty = validJwtClaims.isNotNull(); - Optional claims = licenseChecker.check(settings.licenseKey().get()); + Optional claims = licenseChecker.check(settings.licenseKey.get()); validJwtClaims.set(claims.orElse(null)); } @@ -38,7 +38,7 @@ public class LicenseHolder { Optional claims = licenseChecker.check(licenseKey); validJwtClaims.set(claims.orElse(null)); if (claims.isPresent()) { - settings.licenseKey().set(licenseKey); + settings.licenseKey.set(licenseKey); return true; } else { return false; diff --git a/src/main/java/org/cryptomator/common/keychain/KeychainModule.java b/src/main/java/org/cryptomator/common/keychain/KeychainModule.java index 604dfb40d..43b24eac3 100644 --- a/src/main/java/org/cryptomator/common/keychain/KeychainModule.java +++ b/src/main/java/org/cryptomator/common/keychain/KeychainModule.java @@ -23,14 +23,14 @@ public class KeychainModule { @Singleton static ObjectExpression provideKeychainAccessProvider(Settings settings, List providers) { return Bindings.createObjectBinding(() -> { - if (!settings.useKeychain().get()) { + if (!settings.useKeychain.get()) { return null; } - var selectedProviderClass = settings.keychainProvider().get(); + var selectedProviderClass = settings.keychainProvider.get(); var selectedProvider = providers.stream().filter(provider -> provider.getClass().getName().equals(selectedProviderClass)).findAny(); var fallbackProvider = providers.stream().findFirst().orElse(null); return selectedProvider.orElse(fallbackProvider); - }, settings.keychainProvider(), settings.useKeychain()); + }, settings.keychainProvider, settings.useKeychain); } } diff --git a/src/main/java/org/cryptomator/common/mount/MountModule.java b/src/main/java/org/cryptomator/common/mount/MountModule.java index 0978c44db..cbcb23e82 100644 --- a/src/main/java/org/cryptomator/common/mount/MountModule.java +++ b/src/main/java/org/cryptomator/common/mount/MountModule.java @@ -37,7 +37,7 @@ public class MountModule { static ObservableValue provideMountService(Settings settings, List serviceImpls, @Named("FUPFMS") AtomicReference fupfms) { var fallbackProvider = serviceImpls.stream().findFirst().orElse(null); - var observableMountService = ObservableUtil.mapWithDefault(settings.mountService(), // + var observableMountService = ObservableUtil.mapWithDefault(settings.mountService, // desiredServiceImpl -> { // var serviceFromSettings = serviceImpls.stream().filter(serviceImpl -> serviceImpl.getClass().getName().equals(desiredServiceImpl)).findAny(); // var targetedService = serviceFromSettings.orElse(fallbackProvider); diff --git a/src/main/java/org/cryptomator/common/mount/Mounter.java b/src/main/java/org/cryptomator/common/mount/Mounter.java index a56f2b01b..593cb6666 100644 --- a/src/main/java/org/cryptomator/common/mount/Mounter.java +++ b/src/main/java/org/cryptomator/common/mount/Mounter.java @@ -54,19 +54,19 @@ public class Mounter { switch (capability) { case FILE_SYSTEM_NAME -> builder.setFileSystemName("cryptoFs"); case LOOPBACK_PORT -> - builder.setLoopbackPort(settings.port().get()); //TODO: move port from settings to vaultsettings (see https://github.com/cryptomator/cryptomator/tree/feature/mount-setting-per-vault) + builder.setLoopbackPort(settings.port.get()); //TODO: move port from settings to vaultsettings (see https://github.com/cryptomator/cryptomator/tree/feature/mount-setting-per-vault) case LOOPBACK_HOST_NAME -> env.getLoopbackAlias().ifPresent(builder::setLoopbackHostName); - case READ_ONLY -> builder.setReadOnly(vaultSettings.usesReadOnlyMode().get()); + case READ_ONLY -> builder.setReadOnly(vaultSettings.usesReadOnlyMode.get()); case MOUNT_FLAGS -> { - var mountFlags = vaultSettings.mountFlags().get(); + var mountFlags = vaultSettings.mountFlags.get(); if (mountFlags == null || mountFlags.isBlank()) { builder.setMountFlags(service.getDefaultMountFlags()); } else { builder.setMountFlags(mountFlags); } } - case VOLUME_ID -> builder.setVolumeId(vaultSettings.getId()); - case VOLUME_NAME -> builder.setVolumeName(vaultSettings.mountName().get()); + case VOLUME_ID -> builder.setVolumeId(vaultSettings.id); + case VOLUME_NAME -> builder.setVolumeName(vaultSettings.mountName.get()); } } @@ -75,7 +75,7 @@ public class Mounter { private Runnable prepareMountPoint() throws IOException { Runnable cleanup = () -> {}; - var userChosenMountPoint = vaultSettings.getMountPoint(); + var userChosenMountPoint = vaultSettings.mountPoint.get(); var defaultMountPointBase = env.getMountPointsDir().orElseThrow(); var canMountToDriveLetter = service.hasCapability(MOUNT_AS_DRIVE_LETTER); var canMountToParent = service.hasCapability(MOUNT_WITHIN_EXISTING_PARENT); @@ -91,7 +91,7 @@ public class Mounter { Files.createDirectories(defaultMountPointBase); builder.setMountpoint(defaultMountPointBase); } else if (canMountToDir) { - var mountPoint = defaultMountPointBase.resolve(vaultSettings.mountName().get()); + var mountPoint = defaultMountPointBase.resolve(vaultSettings.mountName.get()); Files.createDirectories(mountPoint); builder.setMountpoint(mountPoint); } diff --git a/src/main/java/org/cryptomator/common/settings/Settings.java b/src/main/java/org/cryptomator/common/settings/Settings.java index 4100b4714..d52b104c1 100644 --- a/src/main/java/org/cryptomator/common/settings/Settings.java +++ b/src/main/java/org/cryptomator/common/settings/Settings.java @@ -45,28 +45,28 @@ public class Settings { static final String DEFAULT_USER_INTERFACE_ORIENTATION = NodeOrientation.LEFT_TO_RIGHT.name(); static final boolean DEFAULT_SHOW_MINIMIZE_BUTTON = false; - private final ObservableList directories; - private final BooleanProperty askedForUpdateCheck; - private final BooleanProperty checkForUpdates; - private final BooleanProperty startHidden; - private final BooleanProperty autoCloseVaults; - private final BooleanProperty useKeychain; - private final IntegerProperty port; - private final IntegerProperty numTrayNotifications; - private final BooleanProperty debugMode; - private final ObjectProperty theme; - private final StringProperty keychainProvider; - private final ObjectProperty userInterfaceOrientation; - private final StringProperty licenseKey; - private final BooleanProperty showMinimizeButton; - private final BooleanProperty showTrayIcon; - private final IntegerProperty windowXPosition; - private final IntegerProperty windowYPosition; - private final IntegerProperty windowWidth; - private final IntegerProperty windowHeight; - private final StringProperty displayConfiguration; - private final StringProperty language; - private final StringProperty mountService; + public final ObservableList directories; + public final BooleanProperty askedForUpdateCheck; + public final BooleanProperty checkForUpdates; + public final BooleanProperty startHidden; + public final BooleanProperty autoCloseVaults; + public final BooleanProperty useKeychain; + public final IntegerProperty port; + public final IntegerProperty numTrayNotifications; + public final BooleanProperty debugMode; + public final ObjectProperty theme; + public final StringProperty keychainProvider; + public final ObjectProperty userInterfaceOrientation; + public final StringProperty licenseKey; + public final BooleanProperty showMinimizeButton; + public final BooleanProperty showTrayIcon; + public final IntegerProperty windowXPosition; + public final IntegerProperty windowYPosition; + public final IntegerProperty windowWidth; + public final IntegerProperty windowHeight; + public final StringProperty displayConfiguration; + public final StringProperty language; + public final StringProperty mountService; private Consumer saveCmd; @@ -213,91 +213,4 @@ public class Settings { } } - /* Getter/Setter */ - // TODO: remove accessors, make fields public - - public ObservableList getDirectories() { - return directories; - } - - public BooleanProperty askedForUpdateCheck() { - return askedForUpdateCheck; - } - - public BooleanProperty checkForUpdates() { - return checkForUpdates; - } - - public BooleanProperty startHidden() { - return startHidden; - } - - public BooleanProperty autoCloseVaults() { - return autoCloseVaults; - } - - public BooleanProperty useKeychain() {return useKeychain;} - - public IntegerProperty port() { - return port; - } - - public IntegerProperty numTrayNotifications() { - return numTrayNotifications; - } - - public BooleanProperty debugMode() { - return debugMode; - } - - public StringProperty mountService() { - return mountService; - } - - public ObjectProperty theme() { - return theme; - } - - public StringProperty keychainProvider() {return keychainProvider;} - - public ObjectProperty userInterfaceOrientation() { - return userInterfaceOrientation; - } - - public StringProperty licenseKey() { - return licenseKey; - } - - public BooleanProperty showMinimizeButton() { - return showMinimizeButton; - } - - public BooleanProperty showTrayIcon() { - return showTrayIcon; - } - - public IntegerProperty windowXPositionProperty() { - return windowXPosition; - } - - public IntegerProperty windowYPositionProperty() { - return windowYPosition; - } - - public IntegerProperty windowWidthProperty() { - return windowWidth; - } - - public IntegerProperty windowHeightProperty() { - return windowHeight; - } - - public StringProperty displayConfigurationProperty() { - return displayConfiguration; - } - - public StringProperty languageProperty() { - return language; - } - } diff --git a/src/main/java/org/cryptomator/common/settings/VaultSettings.java b/src/main/java/org/cryptomator/common/settings/VaultSettings.java index 8989858e1..aa4d99663 100644 --- a/src/main/java/org/cryptomator/common/settings/VaultSettings.java +++ b/src/main/java/org/cryptomator/common/settings/VaultSettings.java @@ -42,19 +42,19 @@ public class VaultSettings { private static final Random RNG = new Random(); - private final String id; - private final ObjectProperty path; - private final StringProperty displayName; - private final BooleanProperty unlockAfterStartup; - private final BooleanProperty revealAfterMount; - private final BooleanProperty usesReadOnlyMode; - private final StringProperty mountFlags; - private final IntegerProperty maxCleartextFilenameLength; - private final ObjectProperty actionAfterUnlock; - private final BooleanProperty autoLockWhenIdle; - private final IntegerProperty autoLockIdleSeconds; - private final ObjectProperty mountPoint; - private final StringExpression mountName; + public final String id; + public final ObjectProperty path; + public final StringProperty displayName; + public final BooleanProperty unlockAfterStartup; + public final BooleanProperty revealAfterMount; + public final BooleanProperty usesReadOnlyMode; + public final StringProperty mountFlags; + public final IntegerProperty maxCleartextFilenameLength; + public final ObjectProperty actionAfterUnlock; + public final BooleanProperty autoLockWhenIdle; + public final IntegerProperty autoLockIdleSeconds; + public final ObjectProperty mountPoint; + public final StringExpression mountName; VaultSettings(VaultSettingsJson json) { this.id = json.id; @@ -139,69 +139,6 @@ public class VaultSettings { return CharMatcher.anyOf("<>:\"/\\|?*").or(CharMatcher.javaIsoControl()).collapseFrom(withoutFancyWhitespaces, '_'); } - /* Getter/Setter */ - // TODO: remove accessors, make fields public - - public String getId() { - return id; - } - - public ObjectProperty path() { - return path; - } - - public StringProperty displayName() { - return displayName; - } - - public StringExpression mountName() { - return mountName; - } - - public BooleanProperty unlockAfterStartup() { - return unlockAfterStartup; - } - - public BooleanProperty revealAfterMount() { - return revealAfterMount; - } - - public Path getMountPoint() { - return mountPoint.get(); - } - - public ObjectProperty mountPoint() { - return mountPoint; - } - - public BooleanProperty usesReadOnlyMode() { - return usesReadOnlyMode; - } - - public StringProperty mountFlags() { - return mountFlags; - } - - public IntegerProperty maxCleartextFilenameLength() { - return maxCleartextFilenameLength; - } - - public ObjectProperty actionAfterUnlock() { - return actionAfterUnlock; - } - - public WhenUnlocked getActionAfterUnlock() { - return actionAfterUnlock.get(); - } - - public BooleanProperty autoLockWhenIdle() { - return autoLockWhenIdle; - } - - public IntegerProperty autoLockIdleSeconds() { - return autoLockIdleSeconds; - } - /* Hashcode/Equals */ @Override diff --git a/src/main/java/org/cryptomator/common/vaults/AutoLocker.java b/src/main/java/org/cryptomator/common/vaults/AutoLocker.java index 8342367a4..beaa747ea 100644 --- a/src/main/java/org/cryptomator/common/vaults/AutoLocker.java +++ b/src/main/java/org/cryptomator/common/vaults/AutoLocker.java @@ -50,8 +50,8 @@ public class AutoLocker { private boolean exceedsIdleTime(Vault vault) { assert vault.isUnlocked(); - if (vault.getVaultSettings().autoLockWhenIdle().get()) { - int maxIdleSeconds = vault.getVaultSettings().autoLockIdleSeconds().get(); + if (vault.getVaultSettings().autoLockWhenIdle.get()) { + int maxIdleSeconds = vault.getVaultSettings().autoLockIdleSeconds.get(); var deadline = vault.getStats().getLastActivity().plusSeconds(maxIdleSeconds); return deadline.isBefore(Instant.now()); } else { diff --git a/src/main/java/org/cryptomator/common/vaults/Vault.java b/src/main/java/org/cryptomator/common/vaults/Vault.java index de77f17b5..d1aacfe53 100644 --- a/src/main/java/org/cryptomator/common/vaults/Vault.java +++ b/src/main/java/org/cryptomator/common/vaults/Vault.java @@ -80,7 +80,7 @@ public class Vault { this.state = state; this.lastKnownException = lastKnownException; this.stats = stats; - this.displayablePath = Bindings.createStringBinding(this::getDisplayablePath, vaultSettings.path()); + this.displayablePath = Bindings.createStringBinding(this::getDisplayablePath, vaultSettings.path); this.locked = Bindings.createBooleanBinding(this::isLocked, state); this.processing = Bindings.createBooleanBinding(this::isProcessing, state); this.unlocked = Bindings.createBooleanBinding(this::isUnlocked, state); @@ -98,29 +98,29 @@ public class Vault { private CryptoFileSystem createCryptoFileSystem(MasterkeyLoader keyLoader) throws IOException, MasterkeyLoadingFailedException { Set flags = EnumSet.noneOf(FileSystemFlags.class); - if (vaultSettings.usesReadOnlyMode().get()) { + if (vaultSettings.usesReadOnlyMode.get()) { flags.add(FileSystemFlags.READONLY); - } else if (vaultSettings.maxCleartextFilenameLength().get() == -1) { + } else if (vaultSettings.maxCleartextFilenameLength.get() == -1) { LOG.debug("Determining cleartext filename length limitations..."); var checker = new FileSystemCapabilityChecker(); int shorteningThreshold = configCache.get().allegedShorteningThreshold(); int ciphertextLimit = checker.determineSupportedCiphertextFileNameLength(getPath()); if (ciphertextLimit < shorteningThreshold) { int cleartextLimit = checker.determineSupportedCleartextFileNameLength(getPath()); - vaultSettings.maxCleartextFilenameLength().set(cleartextLimit); + vaultSettings.maxCleartextFilenameLength.set(cleartextLimit); } else { - vaultSettings.maxCleartextFilenameLength().setValue(UNLIMITED_FILENAME_LENGTH); + vaultSettings.maxCleartextFilenameLength.setValue(UNLIMITED_FILENAME_LENGTH); } } - if (vaultSettings.maxCleartextFilenameLength().get() < UNLIMITED_FILENAME_LENGTH) { - LOG.warn("Limiting cleartext filename length on this device to {}.", vaultSettings.maxCleartextFilenameLength().get()); + if (vaultSettings.maxCleartextFilenameLength.get() < UNLIMITED_FILENAME_LENGTH) { + LOG.warn("Limiting cleartext filename length on this device to {}.", vaultSettings.maxCleartextFilenameLength.get()); } CryptoFileSystemProperties fsProps = CryptoFileSystemProperties.cryptoFileSystemProperties() // .withKeyLoader(keyLoader) // .withFlags(flags) // - .withMaxCleartextNameLength(vaultSettings.maxCleartextFilenameLength().get()) // + .withMaxCleartextNameLength(vaultSettings.maxCleartextFilenameLength.get()) // .withVaultConfigFilename(Constants.VAULTCONFIG_FILENAME) // .build(); return CryptoFileSystemProvider.newFileSystem(getPath(), fsProps); @@ -253,11 +253,11 @@ public class Vault { } public ReadOnlyStringProperty displayNameProperty() { - return vaultSettings.displayName(); + return vaultSettings.displayName; } public String getDisplayName() { - return vaultSettings.displayName().get(); + return vaultSettings.displayName.get(); } public ObjectBinding mountPointProperty() { @@ -274,7 +274,7 @@ public class Vault { } public String getDisplayablePath() { - Path p = vaultSettings.path().get(); + Path p = vaultSettings.path.get(); if (p.startsWith(HOME_DIR)) { Path relativePath = HOME_DIR.relativize(p); String homePrefix = SystemUtils.IS_OS_WINDOWS ? "~\\" : "~/"; @@ -311,7 +311,7 @@ public class Vault { } public Path getPath() { - return vaultSettings.path().getValue(); + return vaultSettings.path.get(); } /** @@ -346,7 +346,7 @@ public class Vault { } public String getId() { - return vaultSettings.getId(); + return vaultSettings.id; } // ****************************************************************************** diff --git a/src/main/java/org/cryptomator/common/vaults/VaultConfigCache.java b/src/main/java/org/cryptomator/common/vaults/VaultConfigCache.java index 80d70ffbf..b879b1f81 100644 --- a/src/main/java/org/cryptomator/common/vaults/VaultConfigCache.java +++ b/src/main/java/org/cryptomator/common/vaults/VaultConfigCache.java @@ -27,7 +27,7 @@ public class VaultConfigCache { void reloadConfig() throws IOException { try { - config.set(readConfigFromStorage(this.settings.path().get())); + config.set(readConfigFromStorage(this.settings.path.get())); } catch (IOException e) { config.set(null); throw e; diff --git a/src/main/java/org/cryptomator/common/vaults/VaultListManager.java b/src/main/java/org/cryptomator/common/vaults/VaultListManager.java index 138d74e36..53616c3db 100644 --- a/src/main/java/org/cryptomator/common/vaults/VaultListManager.java +++ b/src/main/java/org/cryptomator/common/vaults/VaultListManager.java @@ -49,8 +49,8 @@ public class VaultListManager { this.vaultComponentFactory = vaultComponentFactory; this.defaultVaultName = resourceBundle.getString("defaults.vault.vaultName"); - addAll(settings.getDirectories()); - vaultList.addListener(new VaultListChangeListener(settings.getDirectories())); + addAll(settings.directories); + vaultList.addListener(new VaultListChangeListener(settings.directories)); autoLocker.init(); } @@ -70,11 +70,11 @@ public class VaultListManager { private VaultSettings newVaultSettings(Path path) { VaultSettings vaultSettings = VaultSettings.withRandomId(); - vaultSettings.path().set(path); + vaultSettings.path.set(path); if (path.getFileName() != null) { - vaultSettings.displayName().set(path.getFileName().toString()); + vaultSettings.displayName.set(path.getFileName().toString()); } else { - vaultSettings.displayName().set(defaultVaultName); + vaultSettings.displayName.set(defaultVaultName); } return vaultSettings; } @@ -95,13 +95,13 @@ public class VaultListManager { private Vault create(VaultSettings vaultSettings) { var wrapper = new VaultConfigCache(vaultSettings); try { - var vaultState = determineVaultState(vaultSettings.path().get()); + var vaultState = determineVaultState(vaultSettings.path.get()); if (vaultState == LOCKED) { //for legacy reasons: pre v8 vault do not have a config, but they are in the NEEDS_MIGRATION state wrapper.reloadConfig(); } return vaultComponentFactory.create(vaultSettings, wrapper, vaultState, null).vault(); } catch (IOException e) { - LOG.warn("Failed to determine vault state for " + vaultSettings.path().get(), e); + LOG.warn("Failed to determine vault state for " + vaultSettings.path.get(), e); return vaultComponentFactory.create(vaultSettings, wrapper, ERROR, e).vault(); } } diff --git a/src/main/java/org/cryptomator/launcher/SupportedLanguages.java b/src/main/java/org/cryptomator/launcher/SupportedLanguages.java index 2aa7c6abd..99477177b 100644 --- a/src/main/java/org/cryptomator/launcher/SupportedLanguages.java +++ b/src/main/java/org/cryptomator/launcher/SupportedLanguages.java @@ -29,7 +29,7 @@ public class SupportedLanguages { @Inject public SupportedLanguages(Settings settings) { - var preferredLanguage = settings.languageProperty().get(); + var preferredLanguage = settings.language.get(); preferredLocale = preferredLanguage == null ? Locale.getDefault() : Locale.forLanguageTag(preferredLanguage); var collator = Collator.getInstance(preferredLocale); collator.setStrength(Collator.PRIMARY); diff --git a/src/main/java/org/cryptomator/logging/DebugMode.java b/src/main/java/org/cryptomator/logging/DebugMode.java index 386b0fd43..74bbfb1a5 100644 --- a/src/main/java/org/cryptomator/logging/DebugMode.java +++ b/src/main/java/org/cryptomator/logging/DebugMode.java @@ -26,8 +26,8 @@ public class DebugMode { } public void initialize() { - setLogLevels(settings.debugMode().get()); - settings.debugMode().addListener(this::logLevelChanged); + setLogLevels(settings.debugMode.get()); + settings.debugMode.addListener(this::logLevelChanged); } private void logLevelChanged(@SuppressWarnings("unused") ObservableValue observable, @SuppressWarnings("unused") Boolean oldValue, Boolean newValue) { diff --git a/src/main/java/org/cryptomator/ui/common/DefaultSceneFactory.java b/src/main/java/org/cryptomator/ui/common/DefaultSceneFactory.java index 7f6daa44d..85e85ff71 100644 --- a/src/main/java/org/cryptomator/ui/common/DefaultSceneFactory.java +++ b/src/main/java/org/cryptomator/ui/common/DefaultSceneFactory.java @@ -36,7 +36,7 @@ public class DefaultSceneFactory implements Function { } protected void configureRoot(Parent root) { - root.nodeOrientationProperty().bind(settings.userInterfaceOrientation()); + root.nodeOrientationProperty().bind(settings.userInterfaceOrientation); } protected void configureScene(Scene scene) { diff --git a/src/main/java/org/cryptomator/ui/fxapp/AutoUnlocker.java b/src/main/java/org/cryptomator/ui/fxapp/AutoUnlocker.java index e99cd6680..719071ed2 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/AutoUnlocker.java +++ b/src/main/java/org/cryptomator/ui/fxapp/AutoUnlocker.java @@ -36,7 +36,7 @@ public class AutoUnlocker { public void tryUnlockForTimespan(int timespan, TimeUnit timeUnit) { // Unlock all available auto unlock vaults - Predicate shouldAutoUnlock = v -> v.getVaultSettings().unlockAfterStartup().get(); + Predicate shouldAutoUnlock = v -> v.getVaultSettings().unlockAfterStartup.get(); unlockSequentially(vaults.stream().filter(shouldAutoUnlock)).thenRun(() -> startUnlockMissing(timespan, timeUnit)); } @@ -80,6 +80,6 @@ public class AutoUnlocker { private Stream getMissingAutoUnlockVaults() { return vaults.stream() .filter(Vault::isMissing) - .filter(v -> v.getVaultSettings().unlockAfterStartup().get()); + .filter(v -> v.getVaultSettings().unlockAfterStartup.get()); } } diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java b/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java index cfc7ba62b..b71da265c 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java @@ -45,7 +45,7 @@ public class FxApplication { // init system tray final boolean hasTrayIcon; - if (settings.showTrayIcon().get() && trayMenu.get().isSupported()) { + if (settings.showTrayIcon.get() && trayMenu.get().isSupported()) { trayMenu.get().initializeTrayIcon(); Platform.setImplicitExit(false); // don't quit when closing all windows hasTrayIcon = true; @@ -55,7 +55,7 @@ public class FxApplication { // show main window appWindows.showMainWindow().thenAccept(stage -> { - if (settings.startHidden().get()) { + if (settings.startHidden.get()) { if (hasTrayIcon) { stage.hide(); } else { diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationStyle.java b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationStyle.java index b6681f728..ee187fd65 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationStyle.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationStyle.java @@ -36,8 +36,8 @@ public class FxApplicationStyle { } public void initialize() { - settings.theme().addListener(this::appThemeChanged); - loadSelectedStyleSheet(settings.theme().get()); + settings.theme.addListener(this::appThemeChanged); + loadSelectedStyleSheet(settings.theme.get()); } private void appThemeChanged(@SuppressWarnings("unused") ObservableValue observable, @SuppressWarnings("unused") UiTheme oldValue, UiTheme newValue) { diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationTerminator.java b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationTerminator.java index f19cb3ed4..74938bc64 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationTerminator.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationTerminator.java @@ -107,7 +107,7 @@ public class FxApplicationTerminator { if (allowQuitWithoutPrompt.get()) { exitingResponse.performQuit(); - } else if (settings.autoCloseVaults().get() && !preventQuitWithGracefulLock.get()) { + } else if (settings.autoCloseVaults.get() && !preventQuitWithGracefulLock.get()) { var lockAllTask = vaultService.createLockAllTask(vaults.filtered(Vault::isUnlocked), false); lockAllTask.setOnSucceeded(event -> { LOG.info("Locked remaining vaults was succesful."); diff --git a/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java b/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java index b83fe8515..4418f79b5 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java +++ b/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java @@ -38,7 +38,7 @@ public class UpdateChecker { } public void automaticallyCheckForUpdatesIfEnabled() { - if (settings.checkForUpdates().get()) { + if (settings.checkForUpdates.get()) { startCheckingForUpdates(AUTOCHECK_DELAY); } } diff --git a/src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerModule.java b/src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerModule.java index dd7c5bf77..ffc2a3d2f 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerModule.java +++ b/src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerModule.java @@ -70,7 +70,7 @@ public abstract class UpdateCheckerModule { @Named("checkForUpdatesInterval") @FxApplicationScoped static ObjectBinding provideCheckForUpdateInterval(Settings settings) { - return Bindings.when(settings.checkForUpdates()).then(UPDATE_CHECK_INTERVAL).otherwise(DISABLED_UPDATE_CHECK_INTERVAL); + return Bindings.when(settings.checkForUpdates).then(UPDATE_CHECK_INTERVAL).otherwise(DISABLED_UPDATE_CHECK_INTERVAL); } @Provides diff --git a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java index 70dea5366..479a2d860 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowTitleController.java @@ -49,7 +49,7 @@ public class MainWindowTitleController implements FxController { this.updateAvailable = updateChecker.latestVersionProperty().isNotNull(); this.licenseHolder = licenseHolder; this.settings = settings; - this.showMinimizeButton = Bindings.createBooleanBinding(this::isShowMinimizeButton, settings.showMinimizeButton(), settings.showTrayIcon()); + this.showMinimizeButton = Bindings.createBooleanBinding(this::isShowMinimizeButton, settings.showMinimizeButton, settings.showTrayIcon); } @FXML @@ -85,10 +85,10 @@ public class MainWindowTitleController implements FxController { } private void saveWindowSettings() { - settings.windowYPositionProperty().setValue(window.getY()); - settings.windowXPositionProperty().setValue(window.getX()); - settings.windowWidthProperty().setValue(window.getWidth()); - settings.windowHeightProperty().setValue(window.getHeight()); + settings.windowXPosition.setValue(window.getX()); + settings.windowYPosition.setValue(window.getY()); + settings.windowWidth.setValue(window.getWidth()); + settings.windowHeight.setValue(window.getHeight()); } @FXML @@ -139,7 +139,7 @@ public class MainWindowTitleController implements FxController { } public ReadOnlyBooleanProperty debugModeEnabledProperty() { - return settings.debugMode(); + return settings.debugMode; } public boolean isDebugModeEnabled() { @@ -152,6 +152,6 @@ public class MainWindowTitleController implements FxController { public boolean isShowMinimizeButton() { // always show the minimize button if no tray icon is present OR it is explicitly enabled - return !trayMenuInitialized || settings.showMinimizeButton().get(); + return !trayMenuInitialized || settings.showMinimizeButton.get(); } } diff --git a/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java b/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java index 11f035124..1b3f1b69f 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java @@ -54,7 +54,7 @@ public class ResizeController implements FxController { LOG.trace("init ResizeController"); if (neverTouched()) { - settings.displayConfigurationProperty().setValue(getMonitorSizes()); + settings.displayConfiguration.set(getMonitorSizes()); return; } else { if (didDisplayConfigurationChange()) { @@ -65,24 +65,24 @@ public class ResizeController implements FxController { window.setWidth(window.getMinWidth()); window.setHeight(window.getMinHeight()); } else { - window.setHeight(settings.windowHeightProperty().get() > window.getMinHeight() ? settings.windowHeightProperty().get() : window.getMinHeight()); - window.setWidth(settings.windowWidthProperty().get() > window.getMinWidth() ? settings.windowWidthProperty().get() : window.getMinWidth()); - window.setX(settings.windowXPositionProperty().get()); - window.setY(settings.windowYPositionProperty().get()); + window.setHeight(settings.windowHeight.get() > window.getMinHeight() ? settings.windowHeight.get() : window.getMinHeight()); + window.setWidth(settings.windowWidth.get() > window.getMinWidth() ? settings.windowWidth.get() : window.getMinWidth()); + window.setX(settings.windowXPosition.get()); + window.setY(settings.windowYPosition.get()); } } savePositionalSettings(); } private boolean neverTouched() { - return (settings.windowHeightProperty().get() == 0) && (settings.windowWidthProperty().get() == 0) && (settings.windowXPositionProperty().get() == 0) && (settings.windowYPositionProperty().get() == 0); + return (settings.windowHeight.get() == 0) && (settings.windowWidth.get() == 0) && (settings.windowXPosition.get() == 0) && (settings.windowYPosition.get() == 0); } private boolean didDisplayConfigurationChange() { String currentDisplayConfiguration = getMonitorSizes(); - String settingsDisplayConfiguration = settings.displayConfigurationProperty().get(); + String settingsDisplayConfiguration = settings.displayConfiguration.get(); boolean configurationHasChanged = !settingsDisplayConfiguration.equals(currentDisplayConfiguration); - if (configurationHasChanged) settings.displayConfigurationProperty().setValue(currentDisplayConfiguration); + if (configurationHasChanged) settings.displayConfiguration.set(currentDisplayConfiguration); return configurationHasChanged; } @@ -170,10 +170,10 @@ public class ResizeController implements FxController { @FXML public void savePositionalSettings() { - settings.windowHeightProperty().setValue(window.getHeight()); - settings.windowWidthProperty().setValue(window.getWidth()); - settings.windowYPositionProperty().setValue(window.getY()); - settings.windowXPositionProperty().setValue(window.getX()); + settings.windowWidth.setValue(window.getWidth()); + settings.windowHeight.setValue(window.getHeight()); + settings.windowXPosition.setValue(window.getX()); + settings.windowYPosition.setValue(window.getY()); } public BooleanBinding showResizingArrowsProperty() { diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailMissingVaultController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailMissingVaultController.java index bc372341a..372d29040 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailMissingVaultController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailMissingVaultController.java @@ -50,7 +50,7 @@ public class VaultDetailMissingVaultController implements FxController { fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(resourceBundle.getString("addvaultwizard.existing.filePickerMimeDesc"), CRYPTOMATOR_FILENAME_GLOB)); File masterkeyFile = fileChooser.showOpenDialog(window); if (masterkeyFile != null) { - vault.get().getVaultSettings().path().setValue(masterkeyFile.toPath().toAbsolutePath().getParent()); + vault.get().getVaultSettings().path.setValue(masterkeyFile.toPath().toAbsolutePath().getParent()); recheck(); } } diff --git a/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java b/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java index d2381b869..12fdeaab4 100644 --- a/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java +++ b/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java @@ -55,17 +55,17 @@ public class GeneralPreferencesController implements FxController { @FXML public void initialize() { - startHiddenCheckbox.selectedProperty().bindBidirectional(settings.startHidden()); - autoCloseVaultsCheckbox.selectedProperty().bindBidirectional(settings.autoCloseVaults()); - debugModeCheckbox.selectedProperty().bindBidirectional(settings.debugMode()); + startHiddenCheckbox.selectedProperty().bindBidirectional(settings.startHidden); + autoCloseVaultsCheckbox.selectedProperty().bindBidirectional(settings.autoCloseVaults); + debugModeCheckbox.selectedProperty().bindBidirectional(settings.debugMode); autoStartProvider.ifPresent(autoStart -> autoStartCheckbox.setSelected(autoStart.isEnabled())); var keychainSettingsConverter = new KeychainProviderClassNameConverter(keychainAccessProviders); keychainBackendChoiceBox.getItems().addAll(keychainAccessProviders); - keychainBackendChoiceBox.setValue(keychainSettingsConverter.fromString(settings.keychainProvider().get())); + keychainBackendChoiceBox.setValue(keychainSettingsConverter.fromString(settings.keychainProvider.get())); keychainBackendChoiceBox.setConverter(new KeychainProviderDisplayNameConverter()); - Bindings.bindBidirectional(settings.keychainProvider(), keychainBackendChoiceBox.valueProperty(), keychainSettingsConverter); - useKeychainCheckbox.selectedProperty().bindBidirectional(settings.useKeychain()); + Bindings.bindBidirectional(settings.keychainProvider, keychainBackendChoiceBox.valueProperty(), keychainSettingsConverter); + useKeychainCheckbox.selectedProperty().bindBidirectional(settings.useKeychain); keychainBackendChoiceBox.disableProperty().bind(useKeychainCheckbox.selectedProperty().not()); } diff --git a/src/main/java/org/cryptomator/ui/preferences/InterfacePreferencesController.java b/src/main/java/org/cryptomator/ui/preferences/InterfacePreferencesController.java index 05b733f86..40983c3f0 100644 --- a/src/main/java/org/cryptomator/ui/preferences/InterfacePreferencesController.java +++ b/src/main/java/org/cryptomator/ui/preferences/InterfacePreferencesController.java @@ -57,22 +57,22 @@ public class InterfacePreferencesController implements FxController { @FXML public void initialize() { themeChoiceBox.getItems().addAll(UiTheme.applicableValues()); - if (!themeChoiceBox.getItems().contains(settings.theme().get())) { - settings.theme().set(UiTheme.LIGHT); + if (!themeChoiceBox.getItems().contains(settings.theme.get())) { + settings.theme.set(UiTheme.LIGHT); } - themeChoiceBox.valueProperty().bindBidirectional(settings.theme()); + themeChoiceBox.valueProperty().bindBidirectional(settings.theme); themeChoiceBox.setConverter(new UiThemeConverter(resourceBundle)); - showMinimizeButtonCheckbox.selectedProperty().bindBidirectional(settings.showMinimizeButton()); + showMinimizeButtonCheckbox.selectedProperty().bindBidirectional(settings.showMinimizeButton); - showTrayIconCheckbox.selectedProperty().bindBidirectional(settings.showTrayIcon()); + showTrayIconCheckbox.selectedProperty().bindBidirectional(settings.showTrayIcon); preferredLanguageChoiceBox.getItems().addAll(supportedLanguages.getLanguageTags()); - preferredLanguageChoiceBox.valueProperty().bindBidirectional(settings.languageProperty()); + preferredLanguageChoiceBox.valueProperty().bindBidirectional(settings.language); preferredLanguageChoiceBox.setConverter(new LanguageTagConverter(resourceBundle)); - nodeOrientationLtr.setSelected(settings.userInterfaceOrientation().get() == NodeOrientation.LEFT_TO_RIGHT); - nodeOrientationRtl.setSelected(settings.userInterfaceOrientation().get() == NodeOrientation.RIGHT_TO_LEFT); + nodeOrientationLtr.setSelected(settings.userInterfaceOrientation.get() == NodeOrientation.LEFT_TO_RIGHT); + nodeOrientationRtl.setSelected(settings.userInterfaceOrientation.get() == NodeOrientation.RIGHT_TO_LEFT); nodeOrientation.selectedToggleProperty().addListener(this::toggleNodeOrientation); } @@ -87,9 +87,9 @@ public class InterfacePreferencesController implements FxController { private void toggleNodeOrientation(@SuppressWarnings("unused") ObservableValue observable, @SuppressWarnings("unused") Toggle oldValue, Toggle newValue) { if (nodeOrientationLtr.equals(newValue)) { - settings.userInterfaceOrientation().set(NodeOrientation.LEFT_TO_RIGHT); + settings.userInterfaceOrientation.set(NodeOrientation.LEFT_TO_RIGHT); } else if (nodeOrientationRtl.equals(newValue)) { - settings.userInterfaceOrientation().set(NodeOrientation.RIGHT_TO_LEFT); + settings.userInterfaceOrientation.set(NodeOrientation.RIGHT_TO_LEFT); } else { LOG.warn("Unexpected toggle option {}", newValue); } diff --git a/src/main/java/org/cryptomator/ui/preferences/SupporterCertificateController.java b/src/main/java/org/cryptomator/ui/preferences/SupporterCertificateController.java index db2554d67..bff56bc3c 100644 --- a/src/main/java/org/cryptomator/ui/preferences/SupporterCertificateController.java +++ b/src/main/java/org/cryptomator/ui/preferences/SupporterCertificateController.java @@ -48,7 +48,7 @@ public class SupporterCertificateController implements FxController { private void registrationKeyChanged(@SuppressWarnings("unused") ObservableValue observable, @SuppressWarnings("unused") String oldValue, String newValue) { licenseHolder.validateAndStoreLicense(newValue); if (!licenseHolder.isValidLicense()) { - settings.theme().set(UiTheme.LIGHT); + settings.theme.set(UiTheme.LIGHT); } } diff --git a/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java b/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java index 6a47b992d..630b82776 100644 --- a/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java +++ b/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java @@ -42,7 +42,7 @@ public class UpdatesPreferencesController implements FxController { } public void initialize() { - checkForUpdatesCheckbox.selectedProperty().bindBidirectional(settings.checkForUpdates()); + checkForUpdatesCheckbox.selectedProperty().bindBidirectional(settings.checkForUpdates); } @FXML diff --git a/src/main/java/org/cryptomator/ui/preferences/VolumePreferencesController.java b/src/main/java/org/cryptomator/ui/preferences/VolumePreferencesController.java index 0df67cb53..653c4c6e6 100644 --- a/src/main/java/org/cryptomator/ui/preferences/VolumePreferencesController.java +++ b/src/main/java/org/cryptomator/ui/preferences/VolumePreferencesController.java @@ -53,7 +53,7 @@ public class VolumePreferencesController implements FxController { this.resourceBundle = resourceBundle; var fallbackProvider = mountProviders.stream().findFirst().orElse(null); - this.selectedMountService = ObservableUtil.mapWithDefault(settings.mountService(), serviceName -> mountProviders.stream().filter(s -> s.getClass().getName().equals(serviceName)).findFirst().orElse(fallbackProvider), fallbackProvider); + this.selectedMountService = ObservableUtil.mapWithDefault(settings.mountService, serviceName -> mountProviders.stream().filter(s -> s.getClass().getName().equals(serviceName)).findFirst().orElse(fallbackProvider), fallbackProvider); this.loopbackPortSupported = BooleanExpression.booleanExpression(selectedMountService.map(s -> s.hasCapability(MountCapability.LOOPBACK_PORT))); this.mountToDirSupported = selectedMountService.map(s -> s.hasCapability(MountCapability.MOUNT_WITHIN_EXISTING_PARENT) || s.hasCapability(MountCapability.MOUNT_TO_EXISTING_DIR)); this.mountToDriveLetterSupported = selectedMountService.map(s -> s.hasCapability(MountCapability.MOUNT_AS_DRIVE_LETTER)); @@ -71,15 +71,15 @@ public class VolumePreferencesController implements FxController { volumeTypeChoiceBox.getItems().add(null); volumeTypeChoiceBox.getItems().addAll(mountProviders); volumeTypeChoiceBox.setConverter(new MountServiceConverter()); - boolean autoSelected = settings.mountService().get() == null; + boolean autoSelected = settings.mountService.get() == null; volumeTypeChoiceBox.getSelectionModel().select(autoSelected ? null : selectedMountService.getValue()); volumeTypeChoiceBox.valueProperty().addListener((observableValue, oldProvider, newProvider) -> { var toSet = Optional.ofNullable(newProvider).map(nP -> nP.getClass().getName()).orElse(null); - settings.mountService().set(toSet); + settings.mountService.set(toSet); }); - loopbackPortField.setText(String.valueOf(settings.port().get())); - loopbackPortApplyButton.visibleProperty().bind(settings.port().asString().isNotEqualTo(loopbackPortField.textProperty())); + loopbackPortField.setText(String.valueOf(settings.port.get())); + loopbackPortApplyButton.visibleProperty().bind(settings.port.asString().isNotEqualTo(loopbackPortField.textProperty())); loopbackPortApplyButton.disableProperty().bind(Bindings.createBooleanBinding(this::validateLoopbackPort, loopbackPortField.textProperty()).not()); } @@ -95,7 +95,7 @@ public class VolumePreferencesController implements FxController { public void doChangeLoopbackPort() { if (validateLoopbackPort()) { - settings.port().set(Integer.parseInt(loopbackPortField.getText())); + settings.port.set(Integer.parseInt(loopbackPortField.getText())); } } diff --git a/src/main/java/org/cryptomator/ui/unlock/UnlockSuccessController.java b/src/main/java/org/cryptomator/ui/unlock/UnlockSuccessController.java index 835654242..c1ac5a509 100644 --- a/src/main/java/org/cryptomator/ui/unlock/UnlockSuccessController.java +++ b/src/main/java/org/cryptomator/ui/unlock/UnlockSuccessController.java @@ -50,7 +50,7 @@ public class UnlockSuccessController implements FxController { LOG.trace("UnlockSuccessController.close()"); window.close(); if (rememberChoiceCheckbox.isSelected()) { - vault.getVaultSettings().actionAfterUnlock().setValue(WhenUnlocked.IGNORE); + vault.getVaultSettings().actionAfterUnlock.setValue(WhenUnlocked.IGNORE); } } @@ -73,7 +73,7 @@ public class UnlockSuccessController implements FxController { }); executor.execute(revealTask); if (rememberChoiceCheckbox.isSelected()) { - vault.getVaultSettings().actionAfterUnlock().setValue(WhenUnlocked.REVEAL); + vault.getVaultSettings().actionAfterUnlock.setValue(WhenUnlocked.REVEAL); } } diff --git a/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java b/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java index 985f1b471..cd4f5fcba 100644 --- a/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java +++ b/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java @@ -94,7 +94,7 @@ public class UnlockWorkflow extends Task { protected void succeeded() { LOG.info("Unlock of '{}' succeeded.", vault.getDisplayName()); - switch (vault.getVaultSettings().actionAfterUnlock().get()) { + switch (vault.getVaultSettings().actionAfterUnlock.get()) { case ASK -> Platform.runLater(() -> { window.setScene(successScene.get()); window.show(); diff --git a/src/main/java/org/cryptomator/ui/vaultoptions/GeneralVaultOptionsController.java b/src/main/java/org/cryptomator/ui/vaultoptions/GeneralVaultOptionsController.java index 633797820..59a52adf2 100644 --- a/src/main/java/org/cryptomator/ui/vaultoptions/GeneralVaultOptionsController.java +++ b/src/main/java/org/cryptomator/ui/vaultoptions/GeneralVaultOptionsController.java @@ -45,21 +45,21 @@ public class GeneralVaultOptionsController implements FxController { @FXML public void initialize() { - vaultName.textProperty().set(vault.getVaultSettings().displayName().get()); + vaultName.textProperty().set(vault.getVaultSettings().displayName.get()); vaultName.focusedProperty().addListener(this::trimVaultNameOnFocusLoss); vaultName.setTextFormatter(new TextFormatter<>(this::checkVaultNameLength)); - unlockOnStartupCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().unlockAfterStartup()); + unlockOnStartupCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().unlockAfterStartup); actionAfterUnlockChoiceBox.getItems().addAll(WhenUnlocked.values()); - actionAfterUnlockChoiceBox.valueProperty().bindBidirectional(vault.getVaultSettings().actionAfterUnlock()); + actionAfterUnlockChoiceBox.valueProperty().bindBidirectional(vault.getVaultSettings().actionAfterUnlock); actionAfterUnlockChoiceBox.setConverter(new WhenUnlockedConverter(resourceBundle)); - lockAfterTimeCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().autoLockWhenIdle()); - Bindings.bindBidirectional(lockTimeInMinutesTextField.textProperty(), vault.getVaultSettings().autoLockIdleSeconds(), new IdleTimeSecondsConverter()); + lockAfterTimeCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().autoLockWhenIdle); + Bindings.bindBidirectional(lockTimeInMinutesTextField.textProperty(), vault.getVaultSettings().autoLockIdleSeconds, new IdleTimeSecondsConverter()); } private void trimVaultNameOnFocusLoss(Observable observable, Boolean wasFocussed, Boolean isFocussed) { if (!isFocussed) { var trimmed = vaultName.getText().trim(); - vault.getVaultSettings().displayName().set(trimmed); + vault.getVaultSettings().displayName.set(trimmed); } } diff --git a/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java b/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java index 502d4312a..5eeab43e0 100644 --- a/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java +++ b/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java @@ -74,18 +74,18 @@ public class MountOptionsController implements FxController { this.mountpointDriveLetterSupported = mountService.map(as -> as.service().hasCapability(MountCapability.MOUNT_AS_DRIVE_LETTER)); this.mountFlagsSupported = mountService.map(as -> as.service().hasCapability(MountCapability.MOUNT_FLAGS)); this.readOnlySupported = mountService.map(as -> as.service().hasCapability(MountCapability.READ_ONLY)); - this.directoryPath = vault.getVaultSettings().mountPoint().map(p -> isDriveLetter(p) ? null : p.toString()); + this.directoryPath = vault.getVaultSettings().mountPoint.map(p -> isDriveLetter(p) ? null : p.toString()); this.applicationWindows = applicationWindows; } @FXML public void initialize() { // readonly: - readOnlyCheckbox.selectedProperty().bindBidirectional(vaultSettings.usesReadOnlyMode()); + readOnlyCheckbox.selectedProperty().bindBidirectional(vaultSettings.usesReadOnlyMode); // custom mount flags: mountFlagsField.disableProperty().bind(customMountFlagsCheckbox.selectedProperty().not()); - customMountFlagsCheckbox.setSelected(!Strings.isNullOrEmpty(vaultSettings.mountFlags().getValue())); + customMountFlagsCheckbox.setSelected(!Strings.isNullOrEmpty(vaultSettings.mountFlags.getValue())); toggleUseCustomMountFlags(); //driveLetter choice box @@ -93,14 +93,14 @@ public class MountOptionsController implements FxController { driveLetterSelection.setConverter(new WinDriveLetterLabelConverter(windowsDriveLetters, resourceBundle)); //mountPoint toggle group - var mountPoint = vaultSettings.getMountPoint(); + var mountPoint = vaultSettings.mountPoint.get(); if (mountPoint == null) { //prepare and select auto mountPointToggleGroup.selectToggle(mountPointAutoBtn); } else if (mountPoint.getParent() == null && isDriveLetter(mountPoint)) { //prepare and select drive letter mountPointToggleGroup.selectToggle(mountPointDriveLetterBtn); - driveLetterSelection.valueProperty().bindBidirectional(vaultSettings.mountPoint()); + driveLetterSelection.valueProperty().bindBidirectional(vaultSettings.mountPoint); } else { //prepare and select dir mountPointToggleGroup.selectToggle(mountPointDirBtn); @@ -118,14 +118,14 @@ public class MountOptionsController implements FxController { if (customMountFlagsCheckbox.isSelected()) { readOnlyCheckbox.setSelected(false); // to prevent invalid states mountFlagsField.textProperty().unbind(); - var mountFlags = vaultSettings.mountFlags().get(); + var mountFlags = vaultSettings.mountFlags.get(); if (mountFlags == null || mountFlags.isBlank()) { - vaultSettings.mountFlags().set(defaultMountFlags.getValue()); + vaultSettings.mountFlags.set(defaultMountFlags.getValue()); } - mountFlagsField.textProperty().bindBidirectional(vaultSettings.mountFlags()); + mountFlagsField.textProperty().bindBidirectional(vaultSettings.mountFlags); } else { - mountFlagsField.textProperty().unbindBidirectional(vaultSettings.mountFlags()); - vaultSettings.mountFlags().set(null); + mountFlagsField.textProperty().unbindBidirectional(vaultSettings.mountFlags); + vaultSettings.mountFlags.set(null); mountFlagsField.textProperty().bind(defaultMountFlags); } } @@ -134,7 +134,7 @@ public class MountOptionsController implements FxController { public void chooseCustomMountPoint() { try { Path chosenPath = chooseCustomMountPointInternal(); - vaultSettings.mountPoint().set(chosenPath); + vaultSettings.mountPoint.set(chosenPath); } catch (NoDirSelectedException e) { //no-op } @@ -151,7 +151,7 @@ public class MountOptionsController implements FxController { DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setTitle(resourceBundle.getString("vaultOptions.mount.mountPoint.directoryPickerTitle")); try { - var mp = vaultSettings.mountPoint().get(); + var mp = vaultSettings.mountPoint.get(); var initialDir = mp != null && !isDriveLetter(mp) ? mp : Path.of(System.getProperty("user.home")); if (Files.isDirectory(initialDir)) { @@ -170,13 +170,13 @@ public class MountOptionsController implements FxController { private void selectedToggleChanged(ObservableValue observable, Toggle oldToggle, Toggle newToggle) { //Remark: the mountpoint corresponding to the newToggle must be null, otherwise it would not be new! - driveLetterSelection.valueProperty().unbindBidirectional(vaultSettings.mountPoint()); + driveLetterSelection.valueProperty().unbindBidirectional(vaultSettings.mountPoint); if (mountPointDriveLetterBtn.equals(newToggle)) { - vaultSettings.mountPoint().set(windowsDriveLetters.getFirstDesiredAvailable().orElse(windowsDriveLetters.getAll().stream().findAny().get())); - driveLetterSelection.valueProperty().bindBidirectional(vaultSettings.mountPoint()); + vaultSettings.mountPoint.set(windowsDriveLetters.getFirstDesiredAvailable().orElse(windowsDriveLetters.getAll().stream().findAny().get())); + driveLetterSelection.valueProperty().bindBidirectional(vaultSettings.mountPoint); } else if (mountPointDirBtn.equals(newToggle)) { try { - vaultSettings.mountPoint().set(chooseCustomMountPointInternal()); + vaultSettings.mountPoint.set(chooseCustomMountPointInternal()); } catch (NoDirSelectedException e) { if (oldToggle != null && !mountPointDirBtn.equals(oldToggle)) { mountPointToggleGroup.selectToggle(oldToggle); @@ -185,7 +185,7 @@ public class MountOptionsController implements FxController { } } } else { - vaultSettings.mountPoint().set(null); + vaultSettings.mountPoint.set(null); } } diff --git a/src/test/java/org/cryptomator/common/settings/SettingsTest.java b/src/test/java/org/cryptomator/common/settings/SettingsTest.java index 4f18ee866..cd737ac11 100644 --- a/src/test/java/org/cryptomator/common/settings/SettingsTest.java +++ b/src/test/java/org/cryptomator/common/settings/SettingsTest.java @@ -24,15 +24,15 @@ public class SettingsTest { Mockito.verify(changeListener, Mockito.times(0)).accept(settings); // first change (to property): - settings.port().set(42428); + settings.port.set(42428); Mockito.verify(changeListener, Mockito.times(1)).accept(settings); // second change (to list): - settings.getDirectories().add(vaultSettings); + settings.directories.add(vaultSettings); Mockito.verify(changeListener, Mockito.times(2)).accept(settings); // third change (to property of list item): - vaultSettings.displayName().set("asd"); + vaultSettings.displayName.set("asd"); Mockito.verify(changeListener, Mockito.times(3)).accept(settings); } diff --git a/src/test/java/org/cryptomator/common/vaults/VaultModuleTest.java b/src/test/java/org/cryptomator/common/vaults/VaultModuleTest.java index 2fcc0cf3b..9d0395123 100644 --- a/src/test/java/org/cryptomator/common/vaults/VaultModuleTest.java +++ b/src/test/java/org/cryptomator/common/vaults/VaultModuleTest.java @@ -20,9 +20,9 @@ public class VaultModuleTest { @BeforeEach public void setup(@TempDir Path tmpDir) { - Mockito.when(vaultSettings.mountName()).thenReturn(Bindings.createStringBinding(() -> "TEST")); - Mockito.when(vaultSettings.usesReadOnlyMode()).thenReturn(new SimpleBooleanProperty(true)); - Mockito.when(vaultSettings.displayName()).thenReturn(new SimpleStringProperty("Vault")); + Mockito.when(vaultSettings.mountName).thenReturn(Bindings.createStringBinding(() -> "TEST")); + Mockito.when(vaultSettings.usesReadOnlyMode).thenReturn(new SimpleBooleanProperty(true)); + Mockito.when(vaultSettings.displayName).thenReturn(new SimpleStringProperty("Vault")); System.setProperty("user.home", tmpDir.toString()); }