Skip to content

Commit f06e58f

Browse files
committed
fix: bundle the tray icon with the jar
- don't download the icon from the server
1 parent fa43ea9 commit f06e58f

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

ice-adapter/src/main/java/com/faforever/iceadapter/util/TrayIcon.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
import com.faforever.iceadapter.debug.Debug;
55
import com.faforever.iceadapter.debug.DebugWindow;
66
import com.faforever.iceadapter.debug.InfoWindow;
7-
import java.awt.*;
7+
import java.awt.AWTException;
8+
import java.awt.Image;
9+
import java.awt.SystemTray;
810
import java.awt.event.MouseEvent;
911
import java.awt.event.MouseListener;
1012
import java.io.IOException;
11-
import java.net.URL;
13+
import java.io.InputStream;
1214
import java.util.concurrent.CompletableFuture;
1315
import javax.imageio.ImageIO;
14-
import javax.swing.*;
16+
import javax.swing.SwingUtilities;
1517
import lombok.extern.slf4j.Slf4j;
1618

1719
@Slf4j
1820
public class TrayIcon {
1921

20-
public static final String FAF_LOGO_URL = "https://faforever.com/images/faf-logo.png";
22+
public static final String FAF_LOGO_FILE = "faf-logo.png";
2123
private static volatile java.awt.TrayIcon trayIcon;
2224

2325
public static void create() {
@@ -26,13 +28,18 @@ public static void create() {
2628
return;
2729
}
2830

29-
Image fafLogo = null;
30-
try {
31-
fafLogo = ImageIO.read(new URL(FAF_LOGO_URL));
32-
} catch (IOException e) {
33-
log.error("Couldn't load FAF tray icon logo from URL");
34-
return;
31+
Image fafLogo = null;
32+
try (final InputStream imageStream = TrayIcon.class.getClassLoader()
33+
.getResourceAsStream(FAF_LOGO_FILE)) {
34+
if (imageStream == null) {
35+
log.error("Couldn't find '{}' in resource folder", FAF_LOGO_FILE);
36+
return;
3537
}
38+
fafLogo = ImageIO.read(imageStream);
39+
} catch (IOException e) {
40+
log.error("Couldn't load FAF tray icon logo from resource folder", e);
41+
return;
42+
}
3643

3744
fafLogo = fafLogo.getScaledInstance(
3845
new java.awt.TrayIcon(fafLogo).getSize().width,
12.5 KB
Loading

0 commit comments

Comments
 (0)