Start LibreWolf Updater thingy

This commit is contained in:
idk
2022-12-21 05:06:06 +00:00
parent 3c9a34bc5f
commit b4b7e385c2
3 changed files with 54 additions and 11 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Mon Dec 19 22:31:46 UTC 2022
build.number=308
#Wed Dec 21 05:02:39 UTC 2022
build.number=320

View File

@ -1,6 +1,7 @@
package net.i2p.i2pfirefox;
import java.awt.AWTException;
import java.awt.Component;
import java.awt.Image;
import java.awt.Menu;
import java.awt.MenuItem;
@ -10,6 +11,9 @@ import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
@ -101,7 +105,9 @@ public class I2PBrowser extends I2PCommonBrowser {
*
* @since 0.0.16
*/
public I2PBrowser() { initIconFile(); }
public I2PBrowser() {
initIconFile();
}
/**
* Construct an I2PBrowser class which automatically determines which browser
@ -287,11 +293,8 @@ public class I2PBrowser extends I2PCommonBrowser {
ArrayList<String> visitURL = parseArgs(args);
try {
if (useSystray) {
logger.info("Starting systray");
if (systray()) {
logger.info("Systray started");
}
startupSystray();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
@ -339,22 +342,30 @@ public class I2PBrowser extends I2PCommonBrowser {
}
private File initIconFile() {
File icon = new File(runtimeDirectory(""), "icon.png");
if (!icon.exists()) {
File iconFile = new File(runtimeDirectory(""), "icon.png");
if (!iconFile.exists()) {
InputStream resources =
I2PBrowser.class.getClassLoader().getResourceAsStream("icon.png");
try {
OutputStream fos = new FileOutputStream(icon);
OutputStream fos = new FileOutputStream(iconFile);
copy(resources, fos);
} catch (IOException e) {
logger.warning(e.toString());
}
}
return icon;
return iconFile;
}
private TrayIcon initIcon() {
TrayIcon icon = new TrayIcon(image, "I2P Browser Profile Controller", menu);
icon.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 1) {
logger.info("Menu clicked");
//menu.show(tray, 0, 0);
}
}
});
icon.setImageAutoSize(true);
return icon;
}
@ -364,6 +375,17 @@ public class I2PBrowser extends I2PCommonBrowser {
new File(runtimeDirectory(""), "systray.running");
if (systrayIsRunningFile.exists()) {
try {
if (useSystray) {
logger.info("Starting systray");
try {
if (systray()) {
logger.info("Systray started");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
logger.info("Adding icon to systray");
tray.add(icon);
} catch (AWTException e) {
@ -429,6 +451,7 @@ public class I2PBrowser extends I2PCommonBrowser {
public void actionPerformed(ActionEvent e) { shutdownSystray(); }
});
menu.add(closeItem);
icon.setPopupMenu(menu);
logger.info("Added close menu item");
return true;
}

View File

@ -0,0 +1,20 @@
package net.i2p.i2pfirefox;
/**
* I2PLibreWolf.java
* Copyright (C) 2022 idk <hankhill19580@gmail.com>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the MIT License. See LICENSE.md for details.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* I2PLibreWolf adds the LibreWolf Updater browser extension if the browser
* detected by the Firefox variant launcher is LibreWolf specifically.
*
* @author idk
* @since 1.0.6
*/
public class I2PLibreWolf {
}