From b2545646577f7486b69458951f3473c16d27e45d Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Mon, 2 Nov 2015 13:01:25 +0100 Subject: [PATCH] fixes #77 --- main/core/pom.xml | 2 +- main/crypto-aes/pom.xml | 2 +- main/crypto-api/pom.xml | 2 +- main/installer-debian/pom.xml | 2 +- main/installer-osx/pom.xml | 2 +- main/installer-win-portable/pom.xml | 2 +- main/installer-win/pom.xml | 2 +- main/pom.xml | 2 +- main/uber-jar/pom.xml | 2 +- main/ui/pom.xml | 2 +- .../org/cryptomator/ui/util/TrayIconUtil.java | 34 +++++++++++++++--- .../ui/src/main/resources/tray_icon_white.png | Bin 0 -> 1747 bytes 12 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 main/ui/src/main/resources/tray_icon_white.png diff --git a/main/core/pom.xml b/main/core/pom.xml index 579732a69..04810f00b 100644 --- a/main/core/pom.xml +++ b/main/core/pom.xml @@ -12,7 +12,7 @@ org.cryptomator main - 0.10.0 + 0.10.1-SNAPSHOT core Cryptomator WebDAV and I/O module diff --git a/main/crypto-aes/pom.xml b/main/crypto-aes/pom.xml index fc7dd0958..78ca13d2f 100644 --- a/main/crypto-aes/pom.xml +++ b/main/crypto-aes/pom.xml @@ -12,7 +12,7 @@ org.cryptomator main - 0.10.0 + 0.10.1-SNAPSHOT crypto-aes Cryptomator cryptographic module (AES) diff --git a/main/crypto-api/pom.xml b/main/crypto-api/pom.xml index 7b5276c81..296b6f700 100644 --- a/main/crypto-api/pom.xml +++ b/main/crypto-api/pom.xml @@ -12,7 +12,7 @@ org.cryptomator main - 0.10.0 + 0.10.1-SNAPSHOT crypto-api Cryptomator cryptographic module API diff --git a/main/installer-debian/pom.xml b/main/installer-debian/pom.xml index 005d79d67..83be58073 100644 --- a/main/installer-debian/pom.xml +++ b/main/installer-debian/pom.xml @@ -3,7 +3,7 @@ org.cryptomator main - 0.10.0 + 0.10.1-SNAPSHOT installer-debian pom diff --git a/main/installer-osx/pom.xml b/main/installer-osx/pom.xml index 29830090a..a72e81b35 100644 --- a/main/installer-osx/pom.xml +++ b/main/installer-osx/pom.xml @@ -3,7 +3,7 @@ org.cryptomator main - 0.10.0 + 0.10.1-SNAPSHOT installer-osx pom diff --git a/main/installer-win-portable/pom.xml b/main/installer-win-portable/pom.xml index 3afe132e4..67a52febe 100644 --- a/main/installer-win-portable/pom.xml +++ b/main/installer-win-portable/pom.xml @@ -3,7 +3,7 @@ org.cryptomator main - 0.10.0 + 0.10.1-SNAPSHOT installer-win-portable pom diff --git a/main/installer-win/pom.xml b/main/installer-win/pom.xml index 1663dcc46..9d80938a1 100644 --- a/main/installer-win/pom.xml +++ b/main/installer-win/pom.xml @@ -3,7 +3,7 @@ org.cryptomator main - 0.10.0 + 0.10.1-SNAPSHOT installer-win pom diff --git a/main/pom.xml b/main/pom.xml index f3e4ca069..3e707fbbc 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.cryptomator main - 0.10.0 + 0.10.1-SNAPSHOT pom Cryptomator diff --git a/main/uber-jar/pom.xml b/main/uber-jar/pom.xml index be91464ac..1142d4266 100644 --- a/main/uber-jar/pom.xml +++ b/main/uber-jar/pom.xml @@ -12,7 +12,7 @@ org.cryptomator main - 0.10.0 + 0.10.1-SNAPSHOT uber-jar pom diff --git a/main/ui/pom.xml b/main/ui/pom.xml index 57e1e20d0..214554934 100644 --- a/main/ui/pom.xml +++ b/main/ui/pom.xml @@ -12,7 +12,7 @@ org.cryptomator main - 0.10.0 + 0.10.1-SNAPSHOT ui Cryptomator GUI diff --git a/main/ui/src/main/java/org/cryptomator/ui/util/TrayIconUtil.java b/main/ui/src/main/java/org/cryptomator/ui/util/TrayIconUtil.java index a33513136..9bdf7e85d 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/util/TrayIconUtil.java +++ b/main/ui/src/main/java/org/cryptomator/ui/util/TrayIconUtil.java @@ -11,9 +11,7 @@ import java.awt.TrayIcon.MessageType; import java.awt.event.ActionEvent; import java.io.IOException; import java.util.ResourceBundle; - -import javafx.application.Platform; -import javafx.stage.Stage; +import java.util.concurrent.TimeUnit; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; @@ -21,10 +19,16 @@ import javax.script.ScriptException; import javax.swing.SwingUtilities; import org.apache.commons.lang3.SystemUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javafx.application.Platform; +import javafx.stage.Stage; public final class TrayIconUtil { private static TrayIconUtil INSTANCE; + private static final Logger LOG = LoggerFactory.getLogger(TrayIconUtil.class); private final Stage mainApplicationWindow; private final ResourceBundle rb; @@ -79,10 +83,32 @@ public final class TrayIconUtil { exitItem.addActionListener(this::quitFromTray); popup.add(exitItem); - final Image image = Toolkit.getDefaultToolkit().getImage(TrayIconUtil.class.getResource("/tray_icon.png")); + final Image image; + if (SystemUtils.IS_OS_MAC_OSX && isMacMenuBarDarkMode()) { + image = Toolkit.getDefaultToolkit().getImage(TrayIconUtil.class.getResource("/tray_icon_white.png")); + } else { + image = Toolkit.getDefaultToolkit().getImage(TrayIconUtil.class.getResource("/tray_icon.png")); + } + return new TrayIcon(image, rb.getString("app.name"), popup); } + /** + * @return true if defaults read -g AppleInterfaceStyle has an exit status of 0 (i.e. _not_ returning "key not found"). + */ + private boolean isMacMenuBarDarkMode() { + try { + // check for exit status only. Once there are more modes than "dark" and "default", we might need to analyze string contents.. + final Process proc = Runtime.getRuntime().exec(new String[] {"defaults", "read", "-g", "AppleInterfaceStyle"}); + proc.waitFor(100, TimeUnit.MILLISECONDS); + return proc.exitValue() == 0; + } catch (IOException | InterruptedException | IllegalThreadStateException ex) { + // IllegalThreadStateException thrown by proc.exitValue(), if process didn't terminate + LOG.warn("Determining MAC OS X dark mode settings failed. Assuming default (light) mode."); + return false; + } + } + private void showTrayNotification(TrayIcon trayIcon) { final Runnable notificationCmd; if (SystemUtils.IS_OS_MAC_OSX) { diff --git a/main/ui/src/main/resources/tray_icon_white.png b/main/ui/src/main/resources/tray_icon_white.png new file mode 100644 index 0000000000000000000000000000000000000000..434f5e5aaec28536a0cd17c7a445d11751c2583f GIT binary patch literal 1747 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&a=au%h`kcg59UmvUF{9L`nl>DSry^7odplSvNn+hu+GdHy)QK2F?C$HG5 z!d3~a!V1U+3F|8Y3;nDA{o-C@9zzrKDK}xwt{K19`Se z86_nJR{Hwo<>h+i#(Mch>H3D2mX`VkM*2oZx=P7{9O-#x!EwNQn0$BtH5OLR{C|l=&b@WD^hbJTrzg#(KbjLYIeXwb2LVBBWde$+BQkV4k((0_ue2e>*PkoMj#i3`}00E{-7{ylQ@kwbyoV*IL?KwYqqppZvI5O$n)8>ueD&E|Zi$1sHe(r@V zeJ9n0#btJTOTRyG;`9BTjcYmoHSctOCih^=B}eh+l6P9S8}P7C-6s{hqxu7zR6<{D z$xUaw^$a}+Jum1Vx~eWS^+4#A!b=;q71=}XuwdkJHUBi z(Z5Eq%j{vNN}Ua_9Cp4Tm}L0HY(kz(1=wq{b-7BoFa4wV+k<`80WtpBs|B-Ebyz?(ji;-h%Q~lo FCIGS>XP^K8 literal 0 HcmV?d00001