|
@@ -1,7 +1,8 @@
|
|
|
package org.cryptomator.ui.traymenu;
|
|
|
|
|
|
+import javafx.beans.Observable;
|
|
|
import org.apache.commons.lang3.SystemUtils;
|
|
|
-import org.cryptomator.jni.MacFunctions;
|
|
|
+import org.cryptomator.common.settings.Settings;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
@@ -9,28 +10,30 @@ import javax.inject.Inject;
|
|
|
import java.awt.AWTException;
|
|
|
import java.awt.SystemTray;
|
|
|
import java.awt.TrayIcon;
|
|
|
-import java.util.Optional;
|
|
|
|
|
|
@TrayMenuScoped
|
|
|
public class TrayIconController {
|
|
|
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(TrayIconController.class);
|
|
|
|
|
|
+ private final Settings settings;
|
|
|
private final TrayImageFactory imageFactory;
|
|
|
private final TrayMenuController trayMenuController;
|
|
|
private final TrayIcon trayIcon;
|
|
|
- private final Optional<MacFunctions> macFunctions;
|
|
|
+ // private final Optional<MacFunctions> macFunctions;
|
|
|
|
|
|
@Inject
|
|
|
- TrayIconController(TrayImageFactory imageFactory, TrayMenuController trayMenuController, Optional<MacFunctions> macFunctions) {
|
|
|
+ TrayIconController(Settings settings, TrayImageFactory imageFactory, TrayMenuController trayMenuController) {
|
|
|
+ this.settings = settings;
|
|
|
this.trayMenuController = trayMenuController;
|
|
|
this.imageFactory = imageFactory;
|
|
|
this.trayIcon = new TrayIcon(imageFactory.loadImage(), "Cryptomator", trayMenuController.getMenu());
|
|
|
- this.macFunctions = macFunctions;
|
|
|
+// this.macFunctions = macFunctions;
|
|
|
}
|
|
|
|
|
|
public void initializeTrayIcon() {
|
|
|
- macFunctions.map(MacFunctions::uiAppearance).ifPresent(uiAppearance -> uiAppearance.addListener(this::macInterfaceThemeChanged));
|
|
|
+// macFunctions.map(MacFunctions::uiAppearance).ifPresent(uiAppearance -> uiAppearance.addListener(this::macInterfaceThemeChanged));
|
|
|
+ settings.theme().addListener(this::themeChanged);
|
|
|
|
|
|
if (SystemUtils.IS_OS_WINDOWS) {
|
|
|
// TODO: test on windows: is this a double click?
|
|
@@ -47,7 +50,8 @@ public class TrayIconController {
|
|
|
trayMenuController.initTrayMenu();
|
|
|
}
|
|
|
|
|
|
- public void macInterfaceThemeChanged() {
|
|
|
+ // public void macInterfaceThemeChanged() {
|
|
|
+ private void themeChanged(@SuppressWarnings("unused") Observable observable) {
|
|
|
trayIcon.setImage(imageFactory.loadImage());
|
|
|
}
|
|
|
|