-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added version check at startup
- Loading branch information
Showing
4 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} | ||
|
||
} |