-
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
1 parent
2b42354
commit 04b4cfa
Showing
3 changed files
with
57 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
#Sat Jul 27 17:57:27 PKT 2024 | ||
BracketMatching=true | ||
CodeFolding=true | ||
DEV=true | ||
FontFamily=Consolas | ||
HighlightCurrentLine=true | ||
LineNumbers=true | ||
LineWrap=false | ||
editorTheme=default | ||
fontSize=16 | ||
lookAndFeel=com.formdev.flatlaf.FlatLightLaf | ||
version=1.0.4 |
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,54 @@ | ||
package com.zam.utils; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.io.*; | ||
import java.net.HttpURLConnection; | ||
import java.net.URI; | ||
import java.util.Properties; | ||
|
||
public class UpdateChecker { | ||
private static final String UPDATE_URL = "https://raw.githubusercontent.com/zohaibanwer984/BitCode-Java-IDE/development/App.properties"; | ||
private static final String CURRENT_VERSION = "1.0.0"; | ||
|
||
public static void main(String[] args) { | ||
SwingUtilities.invokeLater(UpdateChecker::checkForUpdate); | ||
} | ||
|
||
public static void checkForUpdate() { | ||
try { | ||
// Fetch the properties file | ||
Properties remoteProperties = new Properties(); | ||
HttpURLConnection connection = (HttpURLConnection) new URI(UPDATE_URL).toURL().openConnection(); | ||
connection.setRequestMethod("GET"); | ||
|
||
try (InputStream inputStream = connection.getInputStream()) { | ||
remoteProperties.load(inputStream); | ||
} | ||
|
||
// Get version | ||
String latestVersion = remoteProperties.getProperty("version"); | ||
// String downloadUrl = remoteProperties.getProperty("downloadUrl"); | ||
String downloadUrl = "LINK TO DOWNLOAD"; | ||
|
||
// Compare versions | ||
if (latestVersion != null && !CURRENT_VERSION.equals(latestVersion)) { | ||
int choice = JOptionPane.showConfirmDialog( | ||
null, | ||
"A new version (" + latestVersion + ") is available. Do you want to download it?", | ||
"Update Available", | ||
JOptionPane.YES_NO_OPTION | ||
); | ||
|
||
if (choice == JOptionPane.YES_OPTION && downloadUrl != null) { | ||
Desktop.getDesktop().browse(new URI(downloadUrl)); | ||
} | ||
} else { | ||
JOptionPane.showMessageDialog(null, "You are already using the latest version.", "No Updates", JOptionPane.INFORMATION_MESSAGE); | ||
} | ||
} catch (Exception e) { | ||
JOptionPane.showMessageDialog(null, "Failed to check for updates: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |