diff --git a/src/main/java/org/cryptomator/ui/common/FxmlFile.java b/src/main/java/org/cryptomator/ui/common/FxmlFile.java index 1a2374f85..938f93687 100644 --- a/src/main/java/org/cryptomator/ui/common/FxmlFile.java +++ b/src/main/java/org/cryptomator/ui/common/FxmlFile.java @@ -12,6 +12,7 @@ public enum FxmlFile { CONVERTVAULT_HUBTOPASSWORD_START("/fxml/convertvault_hubtopassword_start.fxml"), // CONVERTVAULT_HUBTOPASSWORD_CONVERT("/fxml/convertvault_hubtopassword_convert.fxml"), // CONVERTVAULT_HUBTOPASSWORD_SUCCESS("/fxml/convertvault_hubtopassword_success.fxml"), // + DOKANY_SUPPORT_END("/fxml/dokany_support_end.fxml"), // ERROR("/fxml/error.fxml"), // FORGET_PASSWORD("/fxml/forget_password.fxml"), // HEALTH_START("/fxml/health_start.fxml"), // diff --git a/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndComponent.java b/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndComponent.java new file mode 100644 index 000000000..48a5ab36c --- /dev/null +++ b/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndComponent.java @@ -0,0 +1,34 @@ +package org.cryptomator.ui.dokanysupportend; + +import dagger.Lazy; +import dagger.Subcomponent; +import org.cryptomator.ui.common.FxmlFile; +import org.cryptomator.ui.common.FxmlScene; + +import javafx.scene.Scene; +import javafx.stage.Stage; + +@DokanySupportEndScoped +@Subcomponent(modules = {DokanySupportEndModule.class}) +public interface DokanySupportEndComponent { + + @DokanySupportEndWindow + Stage window(); + + @FxmlScene(FxmlFile.DOKANY_SUPPORT_END) + Lazy dokanySupportEndScene(); + + + default void showDokanySupportEndWindow() { + Stage stage = window(); + stage.setScene(dokanySupportEndScene().get()); + stage.sizeToScene(); + stage.show(); + } + + @Subcomponent.Factory + interface Factory { + + DokanySupportEndComponent create(); + } +} \ No newline at end of file diff --git a/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndController.java b/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndController.java new file mode 100644 index 000000000..a1d626402 --- /dev/null +++ b/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndController.java @@ -0,0 +1,34 @@ +package org.cryptomator.ui.dokanysupportend; + +import org.cryptomator.ui.common.FxController; +import org.cryptomator.ui.fxapp.FxApplicationWindows; +import org.cryptomator.ui.preferences.SelectedPreferencesTab; + +import javax.inject.Inject; +import javafx.fxml.FXML; +import javafx.stage.Stage; + + +@DokanySupportEndScoped +public class DokanySupportEndController implements FxController { + + private final Stage window; + private final FxApplicationWindows applicationWindows; + + @Inject + DokanySupportEndController(@DokanySupportEndWindow Stage window, FxApplicationWindows applicationWindows) { + this.window = window; + this.applicationWindows = applicationWindows; + } + + @FXML + public void close() { + window.close(); + } + + public void openVolumePreferences() { + applicationWindows.showPreferencesWindow(SelectedPreferencesTab.VOLUME); + window.close(); + } + +} \ No newline at end of file diff --git a/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndModule.java b/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndModule.java new file mode 100644 index 000000000..64689eb26 --- /dev/null +++ b/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndModule.java @@ -0,0 +1,57 @@ +package org.cryptomator.ui.dokanysupportend; + +import dagger.Binds; +import dagger.Module; +import dagger.Provides; +import dagger.multibindings.IntoMap; +import org.cryptomator.ui.common.DefaultSceneFactory; +import org.cryptomator.ui.common.FxController; +import org.cryptomator.ui.common.FxControllerKey; +import org.cryptomator.ui.common.FxmlFile; +import org.cryptomator.ui.common.FxmlLoaderFactory; +import org.cryptomator.ui.common.FxmlScene; +import org.cryptomator.ui.common.StageFactory; + +import javax.inject.Provider; +import javafx.scene.Scene; +import javafx.stage.Modality; +import javafx.stage.Stage; +import java.util.Map; +import java.util.ResourceBundle; + +@Module +abstract class DokanySupportEndModule { + + @Provides + @DokanySupportEndWindow + @DokanySupportEndScoped + static FxmlLoaderFactory provideFxmlLoaderFactory(Map, Provider> factories, DefaultSceneFactory sceneFactory, ResourceBundle resourceBundle) { + return new FxmlLoaderFactory(factories, sceneFactory, resourceBundle); + } + + @Provides + @DokanySupportEndWindow + @DokanySupportEndScoped + static Stage provideStage(StageFactory factory, ResourceBundle resourceBundle) { + Stage stage = factory.create(); + stage.setTitle(resourceBundle.getString("dokanySupportEnd.title")); + stage.setMinWidth(500); + stage.setMinHeight(100); + stage.initModality(Modality.APPLICATION_MODAL); + return stage; + } + + @Provides + @FxmlScene(FxmlFile.DOKANY_SUPPORT_END) + @DokanySupportEndScoped + static Scene provideDokanySupportEndScene(@DokanySupportEndWindow FxmlLoaderFactory fxmlLoaders) { + return fxmlLoaders.createScene(FxmlFile.DOKANY_SUPPORT_END); + } + + + @Binds + @IntoMap + @FxControllerKey(DokanySupportEndController.class) + abstract FxController bindDokanySupportEndController(DokanySupportEndController controller); + +} diff --git a/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndScoped.java b/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndScoped.java new file mode 100644 index 000000000..967e6f86f --- /dev/null +++ b/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndScoped.java @@ -0,0 +1,13 @@ +package org.cryptomator.ui.dokanysupportend; + +import javax.inject.Scope; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Scope +@Documented +@Retention(RetentionPolicy.RUNTIME) +@interface DokanySupportEndScoped { + +} diff --git a/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndWindow.java b/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndWindow.java new file mode 100644 index 000000000..bb9b1617c --- /dev/null +++ b/src/main/java/org/cryptomator/ui/dokanysupportend/DokanySupportEndWindow.java @@ -0,0 +1,14 @@ +package org.cryptomator.ui.dokanysupportend; + +import javax.inject.Qualifier; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Qualifier +@Documented +@Retention(RUNTIME) +@interface DokanySupportEndWindow { + +} diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java b/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java index 711a0fa44..30e40ea8c 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java @@ -3,6 +3,7 @@ package org.cryptomator.ui.fxapp; import dagger.Lazy; import org.cryptomator.common.Environment; import org.cryptomator.common.settings.Settings; +import org.cryptomator.common.settings.VaultSettings; import org.cryptomator.ui.traymenu.TrayMenuComponent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,7 +76,27 @@ public class FxApplication { appWindows.checkAndShowUpdateReminderWindow(); } + migrateAndInformDokanyRemoval(); + launchEventHandler.startHandlingLaunchEvents(); autoUnlocker.tryUnlockForTimespan(2, TimeUnit.MINUTES); } + + private void migrateAndInformDokanyRemoval() { + var dokanyProviderId = "org.cryptomator.frontend.dokany.mount.DokanyMountProvider"; + boolean dokanyFound = false; + if (settings.mountService.getValueSafe().equals(dokanyProviderId)) { + dokanyFound = true; + settings.mountService.set(null); + } + for (VaultSettings vaultSettings : settings.directories) { + if (vaultSettings.mountService.getValueSafe().equals(dokanyProviderId)) { + dokanyFound = true; + vaultSettings.mountService.set(null); + } + } + if (dokanyFound) { + appWindows.showDokanySupportEndWindow(); + } + } } diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java index af98e284c..0b8b6c70f 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java @@ -7,6 +7,7 @@ package org.cryptomator.ui.fxapp; import dagger.Module; import dagger.Provides; +import org.cryptomator.ui.dokanysupportend.DokanySupportEndComponent; import org.cryptomator.ui.error.ErrorComponent; import org.cryptomator.ui.health.HealthCheckComponent; import org.cryptomator.ui.lock.LockComponent; @@ -33,6 +34,7 @@ import java.io.InputStream; ErrorComponent.class, // HealthCheckComponent.class, // UpdateReminderComponent.class, // + DokanySupportEndComponent.class, // ShareVaultComponent.class}) abstract class FxApplicationModule { diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java index 41a7ca785..33d8491a7 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java @@ -5,6 +5,7 @@ import dagger.Lazy; import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.VaultState; import org.cryptomator.integrations.tray.TrayIntegrationProvider; +import org.cryptomator.ui.dokanysupportend.DokanySupportEndComponent; import org.cryptomator.ui.error.ErrorComponent; import org.cryptomator.ui.lock.LockComponent; import org.cryptomator.ui.mainwindow.MainWindowComponent; @@ -48,6 +49,7 @@ public class FxApplicationWindows { private final QuitComponent.Builder quitWindowBuilder; private final UnlockComponent.Factory unlockWorkflowFactory; private final UpdateReminderComponent.Factory updateReminderWindowBuilder; + private final DokanySupportEndComponent.Factory dokanySupportEndWindowBuilder; private final LockComponent.Factory lockWorkflowFactory; private final ErrorComponent.Factory errorWindowFactory; private final ExecutorService executor; @@ -56,13 +58,14 @@ public class FxApplicationWindows { private final FilteredList visibleWindows; @Inject - public FxApplicationWindows(@PrimaryStage Stage primaryStage, + public FxApplicationWindows(@PrimaryStage Stage primaryStage, // Optional trayIntegration, // Lazy mainWindow, // Lazy preferencesWindow, // QuitComponent.Builder quitWindowBuilder, // UnlockComponent.Factory unlockWorkflowFactory, // UpdateReminderComponent.Factory updateReminderWindowBuilder, // + DokanySupportEndComponent.Factory dokanySupportEndWindowBuilder, // LockComponent.Factory lockWorkflowFactory, // ErrorComponent.Factory errorWindowFactory, // VaultOptionsComponent.Factory vaultOptionsWindow, // @@ -75,6 +78,7 @@ public class FxApplicationWindows { this.quitWindowBuilder = quitWindowBuilder; this.unlockWorkflowFactory = unlockWorkflowFactory; this.updateReminderWindowBuilder = updateReminderWindowBuilder; + this.dokanySupportEndWindowBuilder = dokanySupportEndWindowBuilder; this.lockWorkflowFactory = lockWorkflowFactory; this.errorWindowFactory = errorWindowFactory; this.executor = executor; @@ -142,6 +146,11 @@ public class FxApplicationWindows { CompletableFuture.runAsync(() -> updateReminderWindowBuilder.create().checkAndShowUpdateReminderWindow(), Platform::runLater); } + public void showDokanySupportEndWindow() { + CompletableFuture.runAsync(() -> dokanySupportEndWindowBuilder.create().showDokanySupportEndWindow(), Platform::runLater); + } + + public CompletionStage startUnlockWorkflow(Vault vault, @Nullable Stage owner) { return CompletableFuture.supplyAsync(() -> { Preconditions.checkState(vault.stateProperty().transition(VaultState.Value.LOCKED, VaultState.Value.PROCESSING), "Vault not locked."); diff --git a/src/main/resources/fxml/dokany_support_end.fxml b/src/main/resources/fxml/dokany_support_end.fxml new file mode 100644 index 000000000..423a54c72 --- /dev/null +++ b/src/main/resources/fxml/dokany_support_end.fxml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +