diff --git a/pom.xml b/pom.xml index bea0469ac..bfa353c1d 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ 2.6.9 - 1.4.0-beta1 + 1.4.0-beta2 1.2.5 1.2.4 1.4.5 diff --git a/src/main/java/org/cryptomator/common/CommonsModule.java b/src/main/java/org/cryptomator/common/CommonsModule.java index f1ea87c22..e5738972f 100644 --- a/src/main/java/org/cryptomator/common/CommonsModule.java +++ b/src/main/java/org/cryptomator/common/CommonsModule.java @@ -24,6 +24,7 @@ import javax.inject.Singleton; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Comparator; +import java.util.List; import java.util.Optional; import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService; @@ -131,8 +132,8 @@ public abstract class CommonsModule { @Provides @Singleton - static Optional provideQuickAccessService() { - return QuickAccessService.get().findFirst(); + static List provideQuickAccessServices() { + return QuickAccessService.get().toList(); } private static void handleUncaughtExceptionInBackgroundThread(Thread thread, Throwable throwable) { diff --git a/src/main/java/org/cryptomator/common/settings/Settings.java b/src/main/java/org/cryptomator/common/settings/Settings.java index 2f45f9856..c8acc2659 100644 --- a/src/main/java/org/cryptomator/common/settings/Settings.java +++ b/src/main/java/org/cryptomator/common/settings/Settings.java @@ -37,11 +37,11 @@ public class Settings { static final boolean DEFAULT_START_HIDDEN = false; static final boolean DEFAULT_AUTO_CLOSE_VAULTS = false; static final boolean DEFAULT_USE_KEYCHAIN = true; + static final boolean DEFAULT_USE_QUICKACCESS = true; static final int DEFAULT_PORT = 42427; static final int DEFAULT_NUM_TRAY_NOTIFICATIONS = 3; static final boolean DEFAULT_DEBUG_MODE = false; static final UiTheme DEFAULT_THEME = UiTheme.LIGHT; - static final boolean DEFAULT_ADD_TO_QUICK_ACCESS = true; @Deprecated // to be changed to "whatever is available" eventually static final String DEFAULT_KEYCHAIN_PROVIDER = SystemUtils.IS_OS_WINDOWS ? "org.cryptomator.windows.keychain.WindowsProtectedKeychainAccess" : SystemUtils.IS_OS_MAC ? "org.cryptomator.macos.keychain.MacSystemKeychainAccess" : "org.cryptomator.linux.keychain.SecretServiceKeychainAccess"; static final String DEFAULT_USER_INTERFACE_ORIENTATION = NodeOrientation.LEFT_TO_RIGHT.name(); @@ -53,12 +53,13 @@ public class Settings { public final BooleanProperty startHidden; public final BooleanProperty autoCloseVaults; public final BooleanProperty useKeychain; - public final BooleanProperty addToQuickAccess; //TODO: for now, we only support Sidebar integration per System (GNOME Nautilus for Linux) public final IntegerProperty port; public final IntegerProperty numTrayNotifications; public final BooleanProperty debugMode; public final ObjectProperty theme; public final StringProperty keychainProvider; + public final BooleanProperty useQuickAccess; + public final StringProperty quickAccessService; public final ObjectProperty userInterfaceOrientation; public final StringProperty licenseKey; public final BooleanProperty showMinimizeButton; @@ -91,7 +92,7 @@ public class Settings { this.startHidden = new SimpleBooleanProperty(this, "startHidden", json.startHidden); this.autoCloseVaults = new SimpleBooleanProperty(this, "autoCloseVaults", json.autoCloseVaults); this.useKeychain = new SimpleBooleanProperty(this, "useKeychain", json.useKeychain); - this.addToQuickAccess = new SimpleBooleanProperty(this, "addToQuickAccess", json.addToQuickAccess); + this.useQuickAccess = new SimpleBooleanProperty(this, "addToQuickAccess", json.useQuickAccess); this.port = new SimpleIntegerProperty(this, "webDavPort", json.port); this.numTrayNotifications = new SimpleIntegerProperty(this, "numTrayNotifications", json.numTrayNotifications); this.debugMode = new SimpleBooleanProperty(this, "debugMode", json.debugMode); @@ -107,6 +108,7 @@ public class Settings { this.windowHeight = new SimpleIntegerProperty(this, "windowHeight", json.windowHeight); this.language = new SimpleStringProperty(this, "language", json.language); this.mountService = new SimpleStringProperty(this, "mountService", json.mountService); + this.quickAccessService = new SimpleStringProperty(this, "quickAccessService", json.quickAccessService); this.lastSuccessfulUpdateCheck = new SimpleObjectProperty<>(this, "lastSuccessfulUpdateCheck", json.lastSuccessfulUpdateCheck); this.directories.addAll(json.directories.stream().map(VaultSettings::new).toList()); @@ -119,7 +121,7 @@ public class Settings { startHidden.addListener(this::somethingChanged); autoCloseVaults.addListener(this::somethingChanged); useKeychain.addListener(this::somethingChanged); - addToQuickAccess.addListener(this::somethingChanged); + useQuickAccess.addListener(this::somethingChanged); port.addListener(this::somethingChanged); numTrayNotifications.addListener(this::somethingChanged); debugMode.addListener(this::somethingChanged); @@ -135,6 +137,7 @@ public class Settings { windowHeight.addListener(this::somethingChanged); language.addListener(this::somethingChanged); mountService.addListener(this::somethingChanged); + quickAccessService.addListener(this::somethingChanged); lastSuccessfulUpdateCheck.addListener(this::somethingChanged); } @@ -174,7 +177,7 @@ public class Settings { json.startHidden = startHidden.get(); json.autoCloseVaults = autoCloseVaults.get(); json.useKeychain = useKeychain.get(); - json.addToQuickAccess = addToQuickAccess.get(); + json.useQuickAccess = useQuickAccess.get(); json.port = port.get(); json.numTrayNotifications = numTrayNotifications.get(); json.debugMode = debugMode.get(); @@ -190,6 +193,7 @@ public class Settings { json.windowHeight = windowHeight.get(); json.language = language.get(); json.mountService = mountService.get(); + json.quickAccessService = quickAccessService.get(); json.lastSuccessfulUpdateCheck = lastSuccessfulUpdateCheck.get(); return json; } diff --git a/src/main/java/org/cryptomator/common/settings/SettingsJson.java b/src/main/java/org/cryptomator/common/settings/SettingsJson.java index 3cddc639a..481a09dde 100644 --- a/src/main/java/org/cryptomator/common/settings/SettingsJson.java +++ b/src/main/java/org/cryptomator/common/settings/SettingsJson.java @@ -86,6 +86,9 @@ class SettingsJson { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'", timezone = "UTC") Instant lastSuccessfulUpdateCheck = Settings.DEFAULT_TIMESTAMP; - @JsonProperty("addToQuickAccess") - boolean addToQuickAccess = Settings.DEFAULT_ADD_TO_QUICK_ACCESS; + @JsonProperty("useQuickAccess") + boolean useQuickAccess = Settings.DEFAULT_USE_QUICKACCESS; + + @JsonProperty("quickAccessService") + String quickAccessService; } diff --git a/src/main/java/org/cryptomator/common/vaults/Vault.java b/src/main/java/org/cryptomator/common/vaults/Vault.java index 1b24dbb92..3504323de 100644 --- a/src/main/java/org/cryptomator/common/vaults/Vault.java +++ b/src/main/java/org/cryptomator/common/vaults/Vault.java @@ -45,8 +45,8 @@ import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.EnumSet; +import java.util.List; import java.util.Objects; -import java.util.Optional; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; @@ -74,7 +74,7 @@ public class Vault { private final ObjectBinding mountPoint; private final Mounter mounter; private final Settings settings; - private final Optional quickAccessService; + private final List quickAccessServices; private final BooleanProperty showingStats; private final AtomicReference mountHandle = new AtomicReference<>(null); @@ -86,7 +86,7 @@ public class Vault { VaultState state, // @Named("lastKnownException") ObjectProperty lastKnownException, // VaultStats stats, // - Mounter mounter, Settings settings, Optional quickAccessService) { + Mounter mounter, Settings settings, List quickAccessServices) { this.vaultSettings = vaultSettings; this.configCache = configCache; this.cryptoFileSystem = cryptoFileSystem; @@ -103,7 +103,7 @@ public class Vault { this.mountPoint = Bindings.createObjectBinding(this::getMountPoint, state); this.mounter = mounter; this.settings = settings; - this.quickAccessService = quickAccessService; + this.quickAccessServices = quickAccessServices; this.showingStats = new SimpleBooleanProperty(false); this.quickAccessEntry = new AtomicReference<>(null); } @@ -165,7 +165,7 @@ public class Vault { var rootPath = fs.getRootDirectories().iterator().next(); var mountHandle = mounter.mount(vaultSettings, rootPath); success = this.mountHandle.compareAndSet(null, mountHandle); - if (settings.addToQuickAccess.getValue()) { + if (settings.useQuickAccess.getValue()) { addToQuickAccess(); } } finally { @@ -207,9 +207,15 @@ public class Vault { return; } - quickAccessService.ifPresentOrElse( // - this::addToQuickAccessInternal, // - () -> LOG.warn("Unable to add Vault to quick access area: No implementation available.")); + + quickAccessServices.stream() // + .filter(s -> s.getClass().getName().equals(settings.quickAccessService.getValue())) // + .findFirst() // + .ifPresentOrElse( // + this::addToQuickAccessInternal, // + () -> LOG.warn("Unable to add Vault to quick access area: Desired implementation not available.") // + ); + } private void addToQuickAccessInternal(@NotNull QuickAccessService s) {