Check for updates upon macOS app reopen

This commit is contained in:
SiboVG 2022-09-30 05:07:42 +02:00
parent 68dd2af95d
commit b7d809b568
2 changed files with 20 additions and 11 deletions

View File

@ -7,6 +7,7 @@ import java.awt.desktop.PreferencesHandler;
import java.awt.desktop.QuitHandler;
import java.awt.desktop.AppReopenedListener;
import net.sf.openrocket.communication.UpdateInfoRetriever;
import net.sf.openrocket.gui.util.DummyFrameMenuOSX;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -56,6 +57,10 @@ final class OSXSetup {
if (BasicFrame.isFramesEmpty()) {
log.info("App re-opened");
BasicFrame.reopen();
// Also check for software updates
final UpdateInfoRetriever updateRetriever = SwingStartup.startUpdateChecker();
SwingStartup.checkUpdateStatus(updateRetriever);
}
};

View File

@ -193,15 +193,7 @@ public class SwingStartup {
guiModule.startLoader();
// Start update info fetching
final UpdateInfoRetriever updateRetriever;
if (Application.getPreferences().getCheckUpdates()) {
log.info("Starting update check");
updateRetriever = new UpdateInfoRetriever();
updateRetriever.startFetchUpdateInfo();
} else {
log.info("Update check disabled");
updateRetriever = null;
}
final UpdateInfoRetriever updateRetriever = startUpdateChecker();
// Set the best available look-and-feel
log.info("Setting best LAF");
@ -249,8 +241,20 @@ public class SwingStartup {
}
public static UpdateInfoRetriever startUpdateChecker() {
final UpdateInfoRetriever updateRetriever;
if (Application.getPreferences().getCheckUpdates()) {
log.info("Starting update check");
updateRetriever = new UpdateInfoRetriever();
updateRetriever.startFetchUpdateInfo();
} else {
log.info("Update check disabled");
updateRetriever = null;
}
return updateRetriever;
}
private void checkUpdateStatus(final UpdateInfoRetriever updateRetriever) {
public static void checkUpdateStatus(final UpdateInfoRetriever updateRetriever) {
if (updateRetriever == null)
return;