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