mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-25 06:01:31 +00:00
make settings' fields public, remove accessor methods
This commit is contained in:
@@ -139,9 +139,9 @@ public abstract class CommonsModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
static ObservableValue<InetSocketAddress> 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());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class LicenseHolder {
|
||||
this.licenseSubject = validJwtClaims.map(DecodedJWT::getSubject);
|
||||
this.validLicenseProperty = validJwtClaims.isNotNull();
|
||||
|
||||
Optional<DecodedJWT> claims = licenseChecker.check(settings.licenseKey().get());
|
||||
Optional<DecodedJWT> claims = licenseChecker.check(settings.licenseKey.get());
|
||||
validJwtClaims.set(claims.orElse(null));
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class LicenseHolder {
|
||||
Optional<DecodedJWT> 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;
|
||||
|
||||
@@ -23,14 +23,14 @@ public class KeychainModule {
|
||||
@Singleton
|
||||
static ObjectExpression<KeychainAccessProvider> provideKeychainAccessProvider(Settings settings, List<KeychainAccessProvider> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class MountModule {
|
||||
static ObservableValue<ActualMountService> provideMountService(Settings settings, List<MountService> serviceImpls, @Named("FUPFMS") AtomicReference<MountService> 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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<VaultSettings> 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<UiTheme> theme;
|
||||
private final StringProperty keychainProvider;
|
||||
private final ObjectProperty<NodeOrientation> 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<VaultSettings> 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<UiTheme> theme;
|
||||
public final StringProperty keychainProvider;
|
||||
public final ObjectProperty<NodeOrientation> 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<Settings> saveCmd;
|
||||
|
||||
@@ -213,91 +213,4 @@ public class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
/* Getter/Setter */
|
||||
// TODO: remove accessors, make fields public
|
||||
|
||||
public ObservableList<VaultSettings> 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<UiTheme> theme() {
|
||||
return theme;
|
||||
}
|
||||
|
||||
public StringProperty keychainProvider() {return keychainProvider;}
|
||||
|
||||
public ObjectProperty<NodeOrientation> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,19 +42,19 @@ public class VaultSettings {
|
||||
|
||||
private static final Random RNG = new Random();
|
||||
|
||||
private final String id;
|
||||
private final ObjectProperty<Path> 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<WhenUnlocked> actionAfterUnlock;
|
||||
private final BooleanProperty autoLockWhenIdle;
|
||||
private final IntegerProperty autoLockIdleSeconds;
|
||||
private final ObjectProperty<Path> mountPoint;
|
||||
private final StringExpression mountName;
|
||||
public final String id;
|
||||
public final ObjectProperty<Path> 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<WhenUnlocked> actionAfterUnlock;
|
||||
public final BooleanProperty autoLockWhenIdle;
|
||||
public final IntegerProperty autoLockIdleSeconds;
|
||||
public final ObjectProperty<Path> 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> 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<Path> mountPoint() {
|
||||
return mountPoint;
|
||||
}
|
||||
|
||||
public BooleanProperty usesReadOnlyMode() {
|
||||
return usesReadOnlyMode;
|
||||
}
|
||||
|
||||
public StringProperty mountFlags() {
|
||||
return mountFlags;
|
||||
}
|
||||
|
||||
public IntegerProperty maxCleartextFilenameLength() {
|
||||
return maxCleartextFilenameLength;
|
||||
}
|
||||
|
||||
public ObjectProperty<WhenUnlocked> actionAfterUnlock() {
|
||||
return actionAfterUnlock;
|
||||
}
|
||||
|
||||
public WhenUnlocked getActionAfterUnlock() {
|
||||
return actionAfterUnlock.get();
|
||||
}
|
||||
|
||||
public BooleanProperty autoLockWhenIdle() {
|
||||
return autoLockWhenIdle;
|
||||
}
|
||||
|
||||
public IntegerProperty autoLockIdleSeconds() {
|
||||
return autoLockIdleSeconds;
|
||||
}
|
||||
|
||||
/* Hashcode/Equals */
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<FileSystemFlags> 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<Mountpoint> 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;
|
||||
}
|
||||
|
||||
// ******************************************************************************
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<? extends Boolean> observable, @SuppressWarnings("unused") Boolean oldValue, Boolean newValue) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DefaultSceneFactory implements Function<Parent, Scene> {
|
||||
}
|
||||
|
||||
protected void configureRoot(Parent root) {
|
||||
root.nodeOrientationProperty().bind(settings.userInterfaceOrientation());
|
||||
root.nodeOrientationProperty().bind(settings.userInterfaceOrientation);
|
||||
}
|
||||
|
||||
protected void configureScene(Scene scene) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class AutoUnlocker {
|
||||
|
||||
public void tryUnlockForTimespan(int timespan, TimeUnit timeUnit) {
|
||||
// Unlock all available auto unlock vaults
|
||||
Predicate<Vault> shouldAutoUnlock = v -> v.getVaultSettings().unlockAfterStartup().get();
|
||||
Predicate<Vault> shouldAutoUnlock = v -> v.getVaultSettings().unlockAfterStartup.get();
|
||||
unlockSequentially(vaults.stream().filter(shouldAutoUnlock)).thenRun(() -> startUnlockMissing(timespan, timeUnit));
|
||||
}
|
||||
|
||||
@@ -80,6 +80,6 @@ public class AutoUnlocker {
|
||||
private Stream<Vault> getMissingAutoUnlockVaults() {
|
||||
return vaults.stream()
|
||||
.filter(Vault::isMissing)
|
||||
.filter(v -> v.getVaultSettings().unlockAfterStartup().get());
|
||||
.filter(v -> v.getVaultSettings().unlockAfterStartup.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<? extends UiTheme> observable, @SuppressWarnings("unused") UiTheme oldValue, UiTheme newValue) {
|
||||
|
||||
@@ -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.");
|
||||
|
||||
@@ -38,7 +38,7 @@ public class UpdateChecker {
|
||||
}
|
||||
|
||||
public void automaticallyCheckForUpdatesIfEnabled() {
|
||||
if (settings.checkForUpdates().get()) {
|
||||
if (settings.checkForUpdates.get()) {
|
||||
startCheckingForUpdates(AUTOCHECK_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public abstract class UpdateCheckerModule {
|
||||
@Named("checkForUpdatesInterval")
|
||||
@FxApplicationScoped
|
||||
static ObjectBinding<Duration> 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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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<? extends Toggle> 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);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SupporterCertificateController implements FxController {
|
||||
private void registrationKeyChanged(@SuppressWarnings("unused") ObservableValue<? extends String> observable, @SuppressWarnings("unused") String oldValue, String newValue) {
|
||||
licenseHolder.validateAndStoreLicense(newValue);
|
||||
if (!licenseHolder.isValidLicense()) {
|
||||
settings.theme().set(UiTheme.LIGHT);
|
||||
settings.theme.set(UiTheme.LIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class UpdatesPreferencesController implements FxController {
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
checkForUpdatesCheckbox.selectedProperty().bindBidirectional(settings.checkForUpdates());
|
||||
checkForUpdatesCheckbox.selectedProperty().bindBidirectional(settings.checkForUpdates);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public class UnlockWorkflow extends Task<Boolean> {
|
||||
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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<? extends Toggle> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user