diff --git a/trunk/src/com/jpexs/decompiler/flash/Version.java b/trunk/src/com/jpexs/decompiler/flash/Version.java index b52007aaa..0c0c56e8e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/Version.java +++ b/trunk/src/com/jpexs/decompiler/flash/Version.java @@ -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> changes = new HashMap<>(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index ddabbfedd..72791b7b7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -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 versions = new ArrayList<>(); + final java.util.List 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) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/NewVersionDialog.java b/trunk/src/com/jpexs/decompiler/flash/gui/NewVersionDialog.java index 1303b9e5c..d1547abb1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/NewVersionDialog.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/NewVersionDialog.java @@ -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 += "
"; + } + first = false; + changesStr += "" + translate("version") + " " + v.versionName + (v.nightly ? " nightly " + v.revision : "") + "
"; 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 += "
"; + changesStr += "
";
+                for (String type : v.changes.keySet()) {
+                    changesStr += type + ":" + "
"; + for (String ch : v.changes.get(type)) { + changesStr += " - " + ch + "
"; + } } + changesStr += "
"; } - changesStr += "\r\n"; } latestVersion = null; if (!versions.isEmpty()) { latestVersion = versions.get(0); } - changesText.setText(changesStr); - JLabel newAvailableLabel = new JLabel("
" + translate("newversionavailable") + " " + latestVersion.appName + " " + translate("version") + " " + latestVersion.versionName + "
", SwingConstants.CENTER); + changesText.setContentType("text/html"); + changesText.setText("" + changesStr + ""); + JLabel newAvailableLabel = new JLabel("
" + translate("newversionavailable") + " " + latestVersion.appName + " " + translate("version") + " " + latestVersion.versionName + (latestVersion.nightly ? " " + latestVersion.revision : "") + "
", 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