@@ -17,42 +17,75 @@ public class Update {
17
17
18
18
public static void main (String [] args )
19
19
{
20
- loadUpdate ("TeXCalc-all.jar" ,"APN-Pucky" ,"TeXCalc" );
20
+ //loadUpdate("TeXCalc-all.jar","APN-Pucky","TeXCalc");
21
+ Version d = new Version ("9999" );
22
+ Version t = new Version ("5.5.5" );
23
+ System .out .println (d .compareTo (t ));
24
+
21
25
}
22
26
23
- public boolean someLibraryMethod () {
24
- return true ;
25
- }
26
-
27
27
28
28
public static void loadUpdate (String fname , String github_user ,String github_project )
29
29
{
30
30
StreamUtil .copyFile ("new-" + fname ,fname );
31
- String up = checkUpdates (github_user ,github_project );
31
+ String up = getUpdateText (github_user ,github_project );
32
32
if (!up .equals ("" ))
33
33
{
34
34
int selection = JOptionPane .showConfirmDialog (null , up ,"Update" ,JOptionPane .OK_CANCEL_OPTION ,JOptionPane .WARNING_MESSAGE );
35
35
if (selection == JOptionPane .OK_OPTION )update (fname ,github_user ,github_project );
36
36
}
37
37
}
38
38
39
- public static String checkUpdates (String github_user ,String github_project )
39
+ public static boolean checkUpdates (String github_user ,String github_project )
40
40
{
41
41
String ret = "" ;
42
42
String jsf = "git_jar_version.json" ;
43
43
Wget .wGet (jsf , "https://api.github.com/repos/" + github_user + "/" + github_project + "/releases/latest" );
44
44
String tumjson =StreamUtil .readFile (jsf ).replaceAll ("\n " , "" );
45
45
JSONObject tum = new JSONObject (tumjson );
46
46
String tum_tag_name = tum .getString ("tag_name" );
47
- if (!tum_tag_name .equals (Info .VERSION ) && !Info .VERSION .equals ( "9999" ))
47
+ if (new Version (tum_tag_name ).compareTo (new Version (Info .VERSION )) > 0 )
48
+ {
49
+ return true ;
50
+ }
51
+ return false ;
52
+ }
53
+ public static String [] getUpdateInfos (String github_user ,String github_project ) {
54
+ String ret = "" ;
55
+ String jsf = "git_jar_version.json" ;
56
+ Wget .wGet (jsf , "https://api.github.com/repos/" + github_user + "/" + github_project + "/releases/latest" );
57
+ String tumjson =StreamUtil .readFile (jsf ).replaceAll ("\n " , "" );
58
+ JSONObject tum = new JSONObject (tumjson );
59
+ String tum_tag_name = tum .getString ("tag_name" );
60
+ if (new Version (tum_tag_name ).compareTo (new Version (Info .VERSION )) > 0 )
48
61
{
49
62
ret += "New version: " + tum_tag_name + " available:\n " ;
50
63
ret += " - " + tum .getString ("name" ) + "\n " ;
51
64
ret += "Current version: " + Info .VERSION ;
65
+
66
+ return new String [] {tum_tag_name ,tum .getString ("name" )};
52
67
}
68
+ return new String [] {};
53
69
70
+ }
71
+
72
+ public static String getUpdateText (String github_user ,String github_project ) {
73
+ String ret = "" ;
74
+ String jsf = "git_jar_version.json" ;
75
+ Wget .wGet (jsf , "https://api.github.com/repos/" + github_user + "/" + github_project + "/releases/latest" );
76
+ String tumjson =StreamUtil .readFile (jsf ).replaceAll ("\n " , "" );
77
+ JSONObject tum = new JSONObject (tumjson );
78
+ String tum_tag_name = tum .getString ("tag_name" );
79
+ if (new Version (tum_tag_name ).compareTo (new Version (Info .VERSION )) > 0 )
80
+ {
81
+ ret += "New version: " + tum_tag_name + " available:\n " ;
82
+ ret += " - " + tum .getString ("name" ) + "\n " ;
83
+ ret += "Current version: " + Info .VERSION ;
84
+
85
+ }
54
86
return ret ;
55
- }
87
+
88
+ }
56
89
57
90
public static void update (String fname , String github_user , String github_project )
58
91
{
0 commit comments