add dokany info dialog

This commit is contained in:
Jan-Peter Klein
2024-06-11 14:43:56 +02:00
parent 0585262952
commit 92bf73297a
11 changed files with 240 additions and 1 deletions

View File

@@ -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_INFO_DIALOG("/fxml/dokany_info.fxml"), //
ERROR("/fxml/error.fxml"), //
FORGET_PASSWORD("/fxml/forget_password.fxml"), //
HEALTH_START("/fxml/health_start.fxml"), //

View File

@@ -0,0 +1,34 @@
package org.cryptomator.ui.dokanyinfodialog;
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;
@DokanyInfoDialogScoped
@Subcomponent(modules = {DokanyInfoDialogModule.class})
public interface DokanyInfoDialogComponent {
@DokanyInfoDialogWindow
Stage window();
@FxmlScene(FxmlFile.DOKANY_INFO_DIALOG)
Lazy<Scene> dokanyInfoScene();
default void showDokanyInfoWindow() {
Stage stage = window();
stage.setScene(dokanyInfoScene().get());
stage.sizeToScene();
stage.show();
}
@Subcomponent.Factory
interface Factory {
DokanyInfoDialogComponent create();
}
}

View File

@@ -0,0 +1,33 @@
package org.cryptomator.ui.dokanyinfodialog;
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;
@DokanyInfoDialogScoped
public class DokanyInfoDialogController implements FxController {
private final Stage window;
private final FxApplicationWindows applicationWindows;
@Inject
DokanyInfoDialogController(@DokanyInfoDialogWindow Stage window, FxApplicationWindows applicationWindows) {
this.window = window;
this.applicationWindows = applicationWindows;
}
@FXML
public void close() {
window.close();
}
public void openVolumePreferences() {
applicationWindows.showPreferencesWindow(SelectedPreferencesTab.VOLUME);
}
}

View File

@@ -0,0 +1,57 @@
package org.cryptomator.ui.dokanyinfodialog;
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 DokanyInfoDialogModule {
@Provides
@DokanyInfoDialogWindow
@DokanyInfoDialogScoped
static FxmlLoaderFactory provideFxmlLoaderFactory(Map<Class<? extends FxController>, Provider<FxController>> factories, DefaultSceneFactory sceneFactory, ResourceBundle resourceBundle) {
return new FxmlLoaderFactory(factories, sceneFactory, resourceBundle);
}
@Provides
@DokanyInfoDialogWindow
@DokanyInfoDialogScoped
static Stage provideStage(StageFactory factory, ResourceBundle resourceBundle) {
Stage stage = factory.create();
stage.setTitle(resourceBundle.getString("dokanyInfo.title"));
stage.setMinWidth(500);
stage.setMinHeight(100);
stage.initModality(Modality.APPLICATION_MODAL);
return stage;
}
@Provides
@FxmlScene(FxmlFile.DOKANY_INFO_DIALOG)
@DokanyInfoDialogScoped
static Scene provideDokanyInfoDialogScene(@DokanyInfoDialogWindow FxmlLoaderFactory fxmlLoaders) {
return fxmlLoaders.createScene(FxmlFile.DOKANY_INFO_DIALOG);
}
@Binds
@IntoMap
@FxControllerKey(DokanyInfoDialogController.class)
abstract FxController bindDokanyInfoDialogController(DokanyInfoDialogController controller);
}

View File

@@ -0,0 +1,13 @@
package org.cryptomator.ui.dokanyinfodialog;
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 DokanyInfoDialogScoped {
}

View File

@@ -0,0 +1,14 @@
package org.cryptomator.ui.dokanyinfodialog;
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 DokanyInfoDialogWindow {
}

View File

@@ -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,6 +76,23 @@ public class FxApplication {
appWindows.checkAndShowUpdateReminderWindow();
}
var dokany = "org.cryptomator.frontend.dokany.mount.DokanyMountProvider";
boolean dokanyInfoWindowShown = false;
if (settings.mountService.getValueSafe().equals(dokany)) {
appWindows.showDokanyInfoWindow();
dokanyInfoWindowShown = true;
settings.mountService.set(null);
}
for (VaultSettings vaultSettings : settings.directories) {
if (vaultSettings.mountService.getValueSafe().equals(dokany)) {
if (!dokanyInfoWindowShown) {
appWindows.showDokanyInfoWindow();
dokanyInfoWindowShown = true;
}
vaultSettings.mountService.set(null);
}
}
launchEventHandler.startHandlingLaunchEvents();
autoUnlocker.tryUnlockForTimespan(2, TimeUnit.MINUTES);
}

View File

@@ -7,6 +7,7 @@ package org.cryptomator.ui.fxapp;
import dagger.Module;
import dagger.Provides;
import org.cryptomator.ui.dokanyinfodialog.DokanyInfoDialogComponent;
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, //
DokanyInfoDialogComponent.class, //
ShareVaultComponent.class})
abstract class FxApplicationModule {

View File

@@ -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.dokanyinfodialog.DokanyInfoDialogComponent;
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 DokanyInfoDialogComponent.Factory dokanyInfoWindowBuilder;
private final LockComponent.Factory lockWorkflowFactory;
private final ErrorComponent.Factory errorWindowFactory;
private final ExecutorService executor;
@@ -56,13 +58,14 @@ public class FxApplicationWindows {
private final FilteredList<Window> visibleWindows;
@Inject
public FxApplicationWindows(@PrimaryStage Stage primaryStage,
public FxApplicationWindows(@PrimaryStage Stage primaryStage, //
Optional<TrayIntegrationProvider> trayIntegration, //
Lazy<MainWindowComponent> mainWindow, //
Lazy<PreferencesComponent> preferencesWindow, //
QuitComponent.Builder quitWindowBuilder, //
UnlockComponent.Factory unlockWorkflowFactory, //
UpdateReminderComponent.Factory updateReminderWindowBuilder, //
DokanyInfoDialogComponent.Factory dokanyInfoWindowBuilder, //
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.dokanyInfoWindowBuilder = dokanyInfoWindowBuilder;
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 showDokanyInfoWindow() {
CompletableFuture.runAsync(() -> dokanyInfoWindowBuilder.create().showDokanyInfoWindow(), Platform::runLater);
}
public CompletionStage<Void> startUnlockWorkflow(Vault vault, @Nullable Stage owner) {
return CompletableFuture.supplyAsync(() -> {
Preconditions.checkState(vault.stateProperty().transition(VaultState.Value.LOCKED, VaultState.Value.PROCESSING), "Vault not locked.");