mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-20 17:46:52 -04:00
reverted jni version for merging, kept new code as comment
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
<!-- dependency versions -->
|
||||
<cryptomator.cryptolib.version>1.2.1</cryptomator.cryptolib.version>
|
||||
<cryptomator.cryptofs.version>1.8.7</cryptomator.cryptofs.version>
|
||||
<cryptomator.jni.version>2.2.0-SNAPSHOT</cryptomator.jni.version>
|
||||
<cryptomator.jni.version>2.1.0</cryptomator.jni.version>
|
||||
<cryptomator.fuse.version>1.2.0</cryptomator.fuse.version>
|
||||
<cryptomator.dokany.version>1.1.11</cryptomator.dokany.version>
|
||||
<cryptomator.webdav.version>1.0.10</cryptomator.webdav.version>
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
package org.cryptomator.ui.traymenu;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.cryptomator.jni.MacApplicationUiAppearance;
|
||||
import org.cryptomator.jni.MacApplicationUiInterfaceStyle;
|
||||
import org.cryptomator.jni.MacFunctions;
|
||||
import org.cryptomator.common.settings.Settings;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
import java.util.Optional;
|
||||
|
||||
@TrayMenuScoped
|
||||
class TrayImageFactory {
|
||||
|
||||
private final Optional<MacFunctions> macFunctions;
|
||||
// private final Optional<MacFunctions> macFunctions;
|
||||
private final Settings settings;
|
||||
|
||||
|
||||
@Inject
|
||||
TrayImageFactory(Optional<MacFunctions> macFunctions) {
|
||||
this.macFunctions = macFunctions;
|
||||
// TrayImageFactory(Optional<MacFunctions> macFunctions) {
|
||||
// this.macFunctions = macFunctions;
|
||||
TrayImageFactory(Settings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public Image loadImage() {
|
||||
@@ -26,10 +27,11 @@ class TrayImageFactory {
|
||||
}
|
||||
|
||||
private String getMacResourceName() {
|
||||
MacApplicationUiInterfaceStyle interfaceStyle = macFunctions.map(MacFunctions::uiAppearance) //
|
||||
.map(MacApplicationUiAppearance::getCurrentInterfaceStyle) //
|
||||
.orElse(MacApplicationUiInterfaceStyle.LIGHT);
|
||||
switch (interfaceStyle) {
|
||||
// MacApplicationUiInterfaceStyle interfaceStyle = macFunctions.map(MacFunctions::uiAppearance) //
|
||||
// .map(MacApplicationUiAppearance::getCurrentInterfaceStyle) //
|
||||
// .orElse(MacApplicationUiInterfaceStyle.LIGHT);
|
||||
// switch (interfaceStyle) {
|
||||
switch (settings.theme().get()) {
|
||||
case DARK:
|
||||
return "/tray_icon_mac_white.png";
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user