Bladeren bron

Replaced MacFunctionsUiState using new integrations api

Sebastian Stenzel 4 jaren geleden
bovenliggende
commit
603bf99b25

+ 2 - 2
main/pom.xml

@@ -25,9 +25,9 @@
 
 		<!-- cryptomator dependencies -->
 		<cryptomator.cryptofs.version>1.9.12</cryptomator.cryptofs.version>
-		<cryptomator.integrations.version>0.1.5</cryptomator.integrations.version>
+		<cryptomator.integrations.version>0.1.6</cryptomator.integrations.version>
 		<cryptomator.integrations.win.version>0.1.0-beta1</cryptomator.integrations.win.version>
-		<cryptomator.integrations.mac.version>0.1.0-beta2</cryptomator.integrations.mac.version>
+		<cryptomator.integrations.mac.version>0.1.0-beta3</cryptomator.integrations.mac.version>
 		<cryptomator.integrations.linux.version>0.1.0-beta1</cryptomator.integrations.linux.version>
 		<cryptomator.jni.version>2.2.3</cryptomator.jni.version>
 		<cryptomator.fuse.version>1.2.5</cryptomator.fuse.version>

+ 6 - 7
main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java

@@ -6,12 +6,11 @@ import org.cryptomator.common.LicenseHolder;
 import org.cryptomator.common.settings.Settings;
 import org.cryptomator.common.settings.UiTheme;
 import org.cryptomator.common.vaults.Vault;
+import org.cryptomator.integrations.tray.TrayIntegrationProvider;
 import org.cryptomator.integrations.uiappearance.Theme;
 import org.cryptomator.integrations.uiappearance.UiAppearanceException;
 import org.cryptomator.integrations.uiappearance.UiAppearanceListener;
 import org.cryptomator.integrations.uiappearance.UiAppearanceProvider;
-import org.cryptomator.jni.MacApplicationUiState;
-import org.cryptomator.jni.MacFunctions;
 import org.cryptomator.ui.common.VaultService;
 import org.cryptomator.ui.mainwindow.MainWindowComponent;
 import org.cryptomator.ui.preferences.PreferencesComponent;
@@ -43,7 +42,7 @@ public class FxApplication extends Application {
 	private final Lazy<PreferencesComponent> preferencesWindow;
 	private final Provider<UnlockComponent.Builder> unlockWindowBuilderProvider;
 	private final Provider<QuitComponent.Builder> quitWindowBuilderProvider;
-	private final Optional<MacFunctions> macFunctions;
+	private final Optional<TrayIntegrationProvider> trayIntegration;
 	private final Optional<UiAppearanceProvider> appearanceProvider;
 	private final VaultService vaultService;
 	private final LicenseHolder licenseHolder;
@@ -51,13 +50,13 @@ public class FxApplication extends Application {
 	private final UiAppearanceListener systemInterfaceThemeListener = this::systemInterfaceThemeChanged;
 
 	@Inject
-	FxApplication(Settings settings, Lazy<MainWindowComponent> mainWindow, Lazy<PreferencesComponent> preferencesWindow, Provider<UnlockComponent.Builder> unlockWindowBuilderProvider, Provider<QuitComponent.Builder> quitWindowBuilderProvider, Optional<MacFunctions> macFunctions, Optional<UiAppearanceProvider> appearanceProvider, VaultService vaultService, LicenseHolder licenseHolder, ObservableSet<Stage> visibleStages) {
+	FxApplication(Settings settings, Lazy<MainWindowComponent> mainWindow, Lazy<PreferencesComponent> preferencesWindow, Provider<UnlockComponent.Builder> unlockWindowBuilderProvider, Provider<QuitComponent.Builder> quitWindowBuilderProvider, Optional<TrayIntegrationProvider> trayIntegration, Optional<UiAppearanceProvider> appearanceProvider, VaultService vaultService, LicenseHolder licenseHolder, ObservableSet<Stage> visibleStages) {
 		this.settings = settings;
 		this.mainWindow = mainWindow;
 		this.preferencesWindow = preferencesWindow;
 		this.unlockWindowBuilderProvider = unlockWindowBuilderProvider;
 		this.quitWindowBuilderProvider = quitWindowBuilderProvider;
-		this.macFunctions = macFunctions;
+		this.trayIntegration = trayIntegration;
 		this.appearanceProvider = appearanceProvider;
 		this.vaultService = vaultService;
 		this.licenseHolder = licenseHolder;
@@ -81,9 +80,9 @@ public class FxApplication extends Application {
 
 	private void hasVisibleStagesChanged(boolean newValue) {
 		if (newValue) {
-			macFunctions.map(MacFunctions::uiState).ifPresent(MacApplicationUiState::transformToForegroundApplication);
+			trayIntegration.ifPresent(TrayIntegrationProvider::restoredFromTray);
 		} else {
-			macFunctions.map(MacFunctions::uiState).ifPresent(MacApplicationUiState::transformToAgentApplication);
+			trayIntegration.ifPresent(TrayIntegrationProvider::minimizedToTray);
 		}
 	}
 

+ 5 - 7
main/ui/src/main/java/org/cryptomator/ui/launcher/UiLauncher.java

@@ -2,9 +2,7 @@ package org.cryptomator.ui.launcher;
 
 import org.cryptomator.common.settings.Settings;
 import org.cryptomator.common.vaults.Vault;
-import org.cryptomator.jni.JniException;
-import org.cryptomator.jni.MacApplicationUiState;
-import org.cryptomator.jni.MacFunctions;
+import org.cryptomator.integrations.tray.TrayIntegrationProvider;
 import org.cryptomator.ui.fxapp.FxApplication;
 import org.cryptomator.ui.traymenu.TrayMenuComponent;
 import org.slf4j.Logger;
@@ -29,16 +27,16 @@ public class UiLauncher {
 	private final TrayMenuComponent.Builder trayComponent;
 	private final FxApplicationStarter fxApplicationStarter;
 	private final AppLaunchEventHandler launchEventHandler;
-	private final Optional<MacFunctions> macFunctions;
+	private final Optional<TrayIntegrationProvider> trayIntegration;
 
 	@Inject
-	public UiLauncher(Settings settings, ObservableList<Vault> vaults, TrayMenuComponent.Builder trayComponent, FxApplicationStarter fxApplicationStarter, AppLaunchEventHandler launchEventHandler, Optional<MacFunctions> macFunctions) {
+	public UiLauncher(Settings settings, ObservableList<Vault> vaults, TrayMenuComponent.Builder trayComponent, FxApplicationStarter fxApplicationStarter, AppLaunchEventHandler launchEventHandler, Optional<TrayIntegrationProvider> trayIntegration) {
 		this.settings = settings;
 		this.vaults = vaults;
 		this.trayComponent = trayComponent;
 		this.fxApplicationStarter = fxApplicationStarter;
 		this.launchEventHandler = launchEventHandler;
-		this.macFunctions = macFunctions;
+		this.trayIntegration = trayIntegration;
 	}
 
 	public void launch() {
@@ -53,7 +51,7 @@ public class UiLauncher {
 		// show window on start?
 		if (hasTrayIcon && settings.startHidden().get()) {
 			LOG.debug("Hiding application...");
-			macFunctions.map(MacFunctions::uiState).ifPresent(JniException.ignore(MacApplicationUiState::transformToAgentApplication));
+			trayIntegration.ifPresent(TrayIntegrationProvider::minimizedToTray);
 		} else {
 			showMainWindowAsync(hasTrayIcon);
 		}

+ 7 - 1
main/ui/src/main/java/org/cryptomator/ui/launcher/UiLauncherModule.java

@@ -3,9 +3,9 @@ package org.cryptomator.ui.launcher;
 import dagger.Module;
 import dagger.Provides;
 import org.cryptomator.common.JniModule;
+import org.cryptomator.integrations.tray.TrayIntegrationProvider;
 import org.cryptomator.integrations.uiappearance.UiAppearanceProvider;
 import org.cryptomator.ui.fxapp.FxApplicationComponent;
-import org.cryptomator.ui.fxapp.FxApplicationScoped;
 import org.cryptomator.ui.traymenu.TrayMenuComponent;
 
 import javax.inject.Named;
@@ -25,6 +25,12 @@ public abstract class UiLauncherModule {
 		return ServiceLoader.load(UiAppearanceProvider.class).findFirst();
 	}
 
+	@Provides
+	@Singleton
+	static Optional<TrayIntegrationProvider> provideTrayIntegrationProvider() {
+		return ServiceLoader.load(TrayIntegrationProvider.class).findFirst();
+	}
+
 	@Provides
 	@Singleton
 	static ResourceBundle provideLocalization() {