Skip to content

Commit

Permalink
Version 0.5.2c
Browse files Browse the repository at this point in the history
Added version check at startup
  • Loading branch information
jonteohr committed Apr 7, 2017
1 parent 36af45c commit 99f747f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/net/hypr/core/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
public class MainFrame extends JFrame {

// The software version. This sets the text in the toolbar also!
protected static String version = "0.5.2b";
protected static String version = "0.5.2c";

protected TextPanel textPanel = new TextPanel();
private Toolbar toolbar = new Toolbar();
protected FormPanel formPanel = new FormPanel();
protected FooterBar footerPanel = new FooterBar();
protected VersionCheck versionCheck = new VersionCheck();
private cmdExec cmdExec = new cmdExec(formPanel, footerPanel, textPanel);
private WorkspaceWarning workWarning;
private OSWarning osWarning;
Expand Down
2 changes: 0 additions & 2 deletions src/net/hypr/core/TextPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import com.sun.awt.SecurityWarning;

public class TextPanel extends JPanel {

protected JTextArea textArea = new JTextArea();
Expand Down
25 changes: 25 additions & 0 deletions src/net/hypr/core/UpdateAvailable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.hypr.core;

import javax.swing.JDialog;
import javax.swing.JOptionPane;

public class UpdateAvailable extends JDialog {

protected Toolbar toolBar = new Toolbar();

private static String updateTxt = "There's a new update available.\nWant to update now?";
private static String updateURL = "https://sourceforge.net/projects/usb3installer/";

public UpdateAvailable() {

}

public void showMsg() {
String updateButtons[] = {"Update", "No"};
int promptResult = JOptionPane.showOptionDialog(rootPane, updateTxt, "Update Available", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, updateButtons, updateButtons[0]);
if(promptResult == JOptionPane.YES_OPTION) {
toolBar.openSite(updateURL);
}
}

}
34 changes: 34 additions & 0 deletions src/net/hypr/core/VersionCheck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package net.hypr.core;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

public class VersionCheck {

protected UpdateAvailable updateClass = new UpdateAvailable();

public VersionCheck() {
try {
URL url = new URL("https://raw.githubusercontent.com/condolent/USB3Installer/master/version.md");
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));

if(in.readLine().equalsIgnoreCase(MainFrame.version)) {

// DO NOTHING

} else {

// TODO: Show 'update available' popup
updateClass.showMsg();

}
} catch (IOException e1) {
e1.printStackTrace();
}

}

}

0 comments on commit 99f747f

Please sign in to comment.