-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
298 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,102 @@ | ||
package randopackage; | ||
|
||
import java.awt.Font; | ||
import java.awt.GridLayout; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.io.*; | ||
import java.net.*; | ||
|
||
import javax.swing.JButton; | ||
import javax.swing.JDialog; | ||
import javax.swing.JLabel; | ||
import javax.swing.JPanel; | ||
|
||
public class RandochooseUpdate implements Runnable { | ||
String link; | ||
File out; | ||
|
||
public RandochooseUpdate(String link, File out) { | ||
this.link = link; | ||
this.out = out; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
URL url = new URL(link); | ||
HttpURLConnection http = (HttpURLConnection)url.openConnection(); | ||
BufferedInputStream in = new BufferedInputStream(http.getInputStream()); | ||
FileOutputStream fos = new FileOutputStream(out); | ||
BufferedOutputStream bout = new BufferedOutputStream(fos, 1024); | ||
byte[] buffer = new byte[1024]; | ||
int read = 0; | ||
|
||
while((read = in.read(buffer, 0, 1024)) >= 0) { | ||
bout.write(buffer, 0, read); | ||
} | ||
|
||
bout.close(); | ||
in.close(); | ||
} | ||
|
||
catch (Exception e) { | ||
noInternet(); | ||
} | ||
|
||
} | ||
|
||
public static void noInternet() { | ||
JDialog noEntryDialog = new JDialog(); | ||
noEntryDialog.setTitle("Randochoose Update Management"); | ||
|
||
JPanel noEntryPanel = new JPanel(new GridLayout(0, 1, 10, 10)); | ||
|
||
JLabel noticeLabel = new JLabel("Sorry, but Randochoose failed to connect to its GitHub repository!"); | ||
noticeLabel.setFont(new Font("Arial", 0, 16)); | ||
noEntryPanel.add(noticeLabel); | ||
|
||
JLabel noticeLabel2 = new JLabel("This might have one of the following reasons:"); | ||
noticeLabel2.setFont(new Font("Arial", 0, 16)); | ||
noEntryPanel.add(noticeLabel2); | ||
|
||
JLabel causeLbl1 = new JLabel("- You're most likely not connected to the internet. Please check your"); | ||
causeLbl1.setFont(new Font("Arial", 0, 14)); | ||
noEntryPanel.add(causeLbl1); | ||
|
||
JLabel causeLbl2 = new JLabel(" internet connection and try again."); | ||
causeLbl2.setFont(new Font("Arial", 0, 14)); | ||
noEntryPanel.add(causeLbl2); | ||
|
||
JLabel causeLbl3 = new JLabel("- If it still fails, your administrator might have blocked access to GitHub."); | ||
causeLbl3.setFont(new Font("Arial", 0, 14)); | ||
noEntryPanel.add(causeLbl3); | ||
|
||
JLabel causeLbl4 = new JLabel(" Contact him or her for further information."); | ||
causeLbl4.setFont(new Font("Arial", 0, 14)); | ||
noEntryPanel.add(causeLbl4); | ||
|
||
JLabel causeLbl5 = new JLabel("- If these are all not the case, GitHub servers might be down at the moment."); | ||
causeLbl5.setFont(new Font("Arial", 0, 14)); | ||
noEntryPanel.add(causeLbl5); | ||
|
||
JLabel causeLbl6 = new JLabel(" In this case, try again when GitHub is online again."); | ||
causeLbl6.setFont(new Font("Arial", 0, 14)); | ||
noEntryPanel.add(causeLbl6); | ||
|
||
JButton okBtn = new JButton("OK!"); | ||
okBtn.setFont(new Font("Arial", 0, 14)); | ||
|
||
okBtn.addActionListener(new ActionListener() { | ||
public void actionPerformed(ActionEvent arg0) { | ||
noEntryDialog.setVisible(false); | ||
} | ||
}); | ||
|
||
noEntryPanel.add(okBtn); | ||
|
||
noEntryDialog.add(noEntryPanel); | ||
noEntryDialog.pack(); | ||
noEntryDialog.setVisible(true); | ||
} | ||
} |
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,167 @@ | ||
package randopackage; | ||
|
||
import java.io.*; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.*; | ||
|
||
public class RandochooseUpdateStageTwo { | ||
static String[] newestVer = new String[3]; | ||
static int[] newestVerInt = new int[3]; | ||
|
||
public static void checkStage(int majorVer, int minorVer1, int minorVer2, boolean manual) { | ||
File file = new File("vercheck.rdc"); | ||
|
||
if (!file.canRead() || !file.isFile()) { | ||
@SuppressWarnings("unused") | ||
BufferedReader in = null; | ||
} | ||
|
||
try { | ||
BufferedReader in = new BufferedReader(new FileReader("vercheck.rdc")); | ||
String line = null; | ||
|
||
int i = 0; | ||
|
||
while ((line = in.readLine()) != null) { | ||
newestVer[i] = line; | ||
i++; | ||
} | ||
|
||
if (in != null) { | ||
try { | ||
in.close(); | ||
} | ||
|
||
catch (Exception e) { | ||
|
||
} | ||
} | ||
} | ||
|
||
catch (Exception e) { | ||
|
||
} | ||
|
||
int i = 0; | ||
|
||
while (i < newestVer.length) { | ||
int verPart = Integer.parseInt(newestVer[i]); | ||
newestVerInt[i] = verPart; | ||
i++; | ||
} | ||
|
||
if (minorVer2 < newestVerInt[2] || minorVer1 < newestVerInt[1] || majorVer < newestVerInt[0]) { | ||
int[] currentVer = {majorVer, minorVer1, minorVer2}; | ||
newVerAvailable(currentVer, newestVerInt); | ||
} | ||
|
||
else { | ||
if (manual) { | ||
isLatest(); | ||
} | ||
} | ||
} | ||
|
||
public static void newVerAvailable(int[] currVer, int[] latestVer) { | ||
JDialog noEntryDialog = new JDialog(); | ||
noEntryDialog.setTitle("Randochoose Update Management"); | ||
|
||
JPanel noEntryPanel = new JPanel(new GridLayout(0, 1, 10, 10)); | ||
|
||
JLabel noticeLabel = new JLabel("An update has been released."); | ||
noticeLabel.setFont(new Font("Arial", 0, 16)); | ||
noEntryPanel.add(noticeLabel); | ||
|
||
JLabel noticeLabel2 = new JLabel("You're currently running version " + currVer[0] + "." + currVer[1] + "." + currVer[2]); | ||
noticeLabel2.setFont(new Font("Arial", 0, 16)); | ||
noEntryPanel.add(noticeLabel2); | ||
|
||
JLabel noticeLabel3 = new JLabel("The latest version is " + latestVer[0] + "." + latestVer[1] + "." + latestVer[2]); | ||
noticeLabel3.setFont(new Font("Arial", 0, 16)); | ||
noEntryPanel.add(noticeLabel3); | ||
|
||
JLabel questionLbl = new JLabel("Do you want to be redirected to the GitHub repository of"); | ||
questionLbl.setFont(new Font("Arial", 0, 16)); | ||
noEntryPanel.add(questionLbl); | ||
|
||
JLabel questionLbl2 = new JLabel("Randochoose to download the latest version?"); | ||
questionLbl2.setFont(new Font("Arial", 0, 16)); | ||
noEntryPanel.add(questionLbl2); | ||
|
||
JPanel btnPanel = new JPanel(new GridLayout(1, 2, 10, 10)); | ||
|
||
JButton yesBtn = new JButton("Yes"); | ||
yesBtn.setFont(new Font("Arial", 0, 14)); | ||
|
||
yesBtn.addActionListener(new ActionListener() { | ||
public void actionPerformed(ActionEvent arg0) { | ||
Desktop desk = Desktop.getDesktop(); | ||
|
||
try { | ||
desk.browse(new URI("https://github.com/Tech-FZ/randochoose/releases")); | ||
} catch (IOException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} catch (URISyntaxException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
|
||
noEntryDialog.setVisible(false); | ||
} | ||
}); | ||
|
||
btnPanel.add(yesBtn); | ||
|
||
JButton noBtn = new JButton("No"); | ||
noBtn.setFont(new Font("Arial", 0, 14)); | ||
|
||
noBtn.addActionListener(new ActionListener() { | ||
public void actionPerformed(ActionEvent arg0) { | ||
noEntryDialog.setVisible(false); | ||
} | ||
}); | ||
|
||
btnPanel.add(noBtn); | ||
|
||
noEntryPanel.add(btnPanel); | ||
|
||
noEntryDialog.add(noEntryPanel); | ||
noEntryDialog.pack(); | ||
noEntryDialog.setVisible(true); | ||
} | ||
|
||
public static void isLatest() { | ||
JDialog noEntryDialog = new JDialog(); | ||
noEntryDialog.setTitle("Randochoose Update Management"); | ||
|
||
JPanel noEntryPanel = new JPanel(new GridLayout(3, 1, 10, 10)); | ||
|
||
JLabel noticeLabel = new JLabel("Don't know if you see this as good or bad, but..."); | ||
noticeLabel.setFont(new Font("Arial", 0, 16)); | ||
noEntryPanel.add(noticeLabel); | ||
|
||
JLabel noticeLabel2 = new JLabel("...you're already running the latest version."); | ||
noticeLabel2.setFont(new Font("Arial", 0, 16)); | ||
noEntryPanel.add(noticeLabel2); | ||
|
||
JButton okBtn = new JButton("OK!"); | ||
okBtn.setFont(new Font("Arial", 0, 14)); | ||
|
||
okBtn.addActionListener(new ActionListener() { | ||
public void actionPerformed(ActionEvent arg0) { | ||
noEntryDialog.setVisible(false); | ||
} | ||
}); | ||
|
||
noEntryPanel.add(okBtn); | ||
|
||
noEntryDialog.add(noEntryPanel); | ||
noEntryDialog.pack(); | ||
noEntryDialog.setVisible(true); | ||
} | ||
} |