mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 13:10:46 +00:00
improved update system, new version dialog
This commit is contained in:
@@ -27,11 +27,13 @@ import java.util.Map;
|
||||
public class Version {
|
||||
|
||||
public int versionId;
|
||||
public String revision;
|
||||
public String versionName;
|
||||
public String longVersionName;
|
||||
public String releaseDate;
|
||||
public String appName;
|
||||
public String appFullName;
|
||||
public String updateLink;
|
||||
public boolean nightly;
|
||||
public Map<String, List<String>> changes = new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ public class Main {
|
||||
private static TrayIcon trayIcon;
|
||||
private static MenuItem stopMenuItem;
|
||||
private static MainFrame mainFrame;
|
||||
private static final int UPDATE_SYSTEM_MAJOR = 1;
|
||||
private static final int UPDATE_SYSTEM_MINOR = 0;
|
||||
public static final int UPDATE_SYSTEM_MAJOR = 1;
|
||||
public static final int UPDATE_SYSTEM_MINOR = 1;
|
||||
public static LoadFromMemoryFrame loadFromMemoryFrame;
|
||||
public static LoadFromCacheFrame loadFromCacheFrame;
|
||||
private static final Logger logger = Logger.getLogger(Main.class.getName());
|
||||
@@ -1053,6 +1053,8 @@ public class Main {
|
||||
os.write(("GET /flash/update.html?action=check¤tVersion=" + ApplicationInfo.version + "¤tBuild=" + ApplicationInfo.build + "¤tNightly=" + ApplicationInfo.nightly + " HTTP/1.1\r\n"
|
||||
+ "Host: www.free-decompiler.com\r\n"
|
||||
+ "X-Accept-Versions: " + acceptVersions + "\r\n"
|
||||
+ "X-Update-Major: " + UPDATE_SYSTEM_MAJOR + "\r\n"
|
||||
+ "X-Update-Minor: " + UPDATE_SYSTEM_MINOR + "\r\n"
|
||||
+ "User-Agent: " + ApplicationInfo.shortApplicationVerName + "\r\n"
|
||||
+ "Accept-Language: " + currentLoc + ("en".equals(currentLoc) ? "" : ", en;q=0.8") + "\r\n"
|
||||
+ "Connection: close\r\n"
|
||||
@@ -1060,7 +1062,7 @@ public class Main {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream()));
|
||||
String s;
|
||||
boolean start = false;
|
||||
java.util.List<Version> versions = new ArrayList<>();
|
||||
final java.util.List<Version> versions = new ArrayList<>();
|
||||
String header = "";
|
||||
Pattern headerPat = Pattern.compile("\\[([a-zA-Z0-9]+)\\]");
|
||||
int updateMajor = 0;
|
||||
@@ -1100,6 +1102,12 @@ public class Main {
|
||||
if (key.equals("versionName")) {
|
||||
ver.versionName = val;
|
||||
}
|
||||
if (key.equals("nightly")) {
|
||||
ver.nightly = val.equals("true");
|
||||
}
|
||||
if (key.equals("revision")) {
|
||||
ver.revision = val;
|
||||
}
|
||||
if (key.equals("longVersionName")) {
|
||||
ver.longVersionName = val;
|
||||
}
|
||||
@@ -1134,9 +1142,15 @@ public class Main {
|
||||
}
|
||||
|
||||
if (!versions.isEmpty()) {
|
||||
NewVersionDialog newVersionDialog = new NewVersionDialog(versions);
|
||||
newVersionDialog.setVisible(true);
|
||||
Configuration.lastUpdatesCheckDate.set(Calendar.getInstance());
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NewVersionDialog newVersionDialog = new NewVersionDialog(versions);
|
||||
newVersionDialog.setVisible(true);
|
||||
Configuration.lastUpdatesCheckDate.set(Calendar.getInstance());
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (IOException | NumberFormatException ex) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.Version;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
@@ -34,6 +35,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
@@ -57,7 +59,7 @@ public class NewVersionDialog extends AppDialog implements ActionListener {
|
||||
setSize(new Dimension(500, 300));
|
||||
Container cnt = getContentPane();
|
||||
cnt.setLayout(new BoxLayout(cnt, BoxLayout.PAGE_AXIS));
|
||||
JTextArea changesText = new JTextArea();
|
||||
JEditorPane changesText = new JEditorPane();
|
||||
changesText.setEditable(false);
|
||||
changesText.setFont(UIManager.getFont("TextField.font"));
|
||||
String changesStr = "";
|
||||
@@ -69,9 +71,13 @@ public class NewVersionDialog extends AppDialog implements ActionListener {
|
||||
} else {
|
||||
formatter = new SimpleDateFormat(customFormat);
|
||||
}
|
||||
boolean first = true;
|
||||
for (Version v : versions) {
|
||||
changesStr += translate("version") + " " + v.versionName + "\r\n";
|
||||
changesStr += "-----------------------\r\n";
|
||||
if (!first) {
|
||||
changesStr += "<hr />";
|
||||
}
|
||||
first = false;
|
||||
changesStr += "<b>" + translate("version") + " " + v.versionName + (v.nightly ? " nightly " + v.revision : "") + "</b><br />";
|
||||
String releaseDate = v.releaseDate;
|
||||
try {
|
||||
Date date = serverFormatter.parse(releaseDate);
|
||||
@@ -79,21 +85,26 @@ public class NewVersionDialog extends AppDialog implements ActionListener {
|
||||
} catch (ParseException ex) {
|
||||
Logger.getLogger(NewVersionDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
changesStr += translate("releasedate") + " " + releaseDate + "\r\n";
|
||||
for (String type : v.changes.keySet()) {
|
||||
changesStr += type + ":" + "\r\n";
|
||||
for (String ch : v.changes.get(type)) {
|
||||
changesStr += " - " + ch + "\r\n";
|
||||
changesStr += translate("releasedate") + " " + releaseDate;
|
||||
if (!v.changes.isEmpty()) {
|
||||
changesStr += "<br />";
|
||||
changesStr += "<pre>";
|
||||
for (String type : v.changes.keySet()) {
|
||||
changesStr += type + ":" + "<br />";
|
||||
for (String ch : v.changes.get(type)) {
|
||||
changesStr += " - " + ch + "<br />";
|
||||
}
|
||||
}
|
||||
changesStr += "</pre>";
|
||||
}
|
||||
changesStr += "\r\n";
|
||||
}
|
||||
latestVersion = null;
|
||||
if (!versions.isEmpty()) {
|
||||
latestVersion = versions.get(0);
|
||||
}
|
||||
changesText.setText(changesStr);
|
||||
JLabel newAvailableLabel = new JLabel("<html><b><center>" + translate("newversionavailable") + " " + latestVersion.appName + " " + translate("version") + " " + latestVersion.versionName + "</center></b></html>", SwingConstants.CENTER);
|
||||
changesText.setContentType("text/html");
|
||||
changesText.setText("<html>" + changesStr + "</html>");
|
||||
JLabel newAvailableLabel = new JLabel("<html><b><center>" + translate("newversionavailable") + " " + latestVersion.appName + " " + translate("version") + " " + latestVersion.versionName + (latestVersion.nightly ? " " + latestVersion.revision : "") + "</center></b></html>", SwingConstants.CENTER);
|
||||
newAvailableLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
|
||||
cnt.add(newAvailableLabel);
|
||||
|
||||
@@ -128,6 +139,7 @@ public class NewVersionDialog extends AppDialog implements ActionListener {
|
||||
View.centerScreen(this);
|
||||
setModalityType(ModalityType.APPLICATION_MODAL);
|
||||
changesText.setCaretPosition(0);
|
||||
View.setWindowIcon(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user