Skip to content

Commit d49f9fe

Browse files
Ivan-ShamlBrutus5000
authored andcommitted
fix: bundle the tray icon with the jar
- don't download the icon from the server
1 parent fa43ea9 commit d49f9fe

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

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

Lines changed: 13 additions & 7 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() {
@@ -27,10 +29,14 @@ public static void create() {
2729
}
2830

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

12.5 KB
Loading

0 commit comments

Comments
 (0)