@@ -126,8 +126,44 @@ public void run() {
126126 //e.printStackTrace();
127127 //System.err.println("Error while trying to check for an update.");
128128 }
129+
130+ try {
131+ // Check for updates of the splash screen
132+ List <String > lines = readFileFromURL ("https://go.bug.st/latest_splash.txt" );
133+ if (lines .size () > 0 ) {
134+ // if the splash image has been changed download the new file
135+ String newSplashUrl = lines .get (0 );
136+ String oldSplashUrl = PreferencesData .get ("splash.imageurl" );
137+ if (!newSplashUrl .equals (oldSplashUrl )) {
138+ File tmpFile = BaseNoGui .getSettingsFile ("splash.png.tmp" );
139+ downloadFileFromURL (newSplashUrl , tmpFile );
140+ File destFile = BaseNoGui .getSettingsFile ("splash.png" );
141+ Files .move (tmpFile .toPath (), destFile .toPath (),
142+ StandardCopyOption .REPLACE_EXISTING );
143+ PreferencesData .set ("splash.imageurl" , newSplashUrl );
144+ }
145+
146+ // extend expiration by 24h
147+ PreferencesData .setLong ("splash.expire" , now + ONE_DAY );
148+ }
149+ } catch (Exception e ) {
150+ // e.printStackTrace();
151+ }
129152 }
130153
154+ public static File getUpdatedSplashImageFile () {
155+ if (PreferencesData .has ("splash.expire" )) {
156+ Long expire = PreferencesData .getLong ("splash.expire" );
157+ long now = System .currentTimeMillis ();
158+ if (expire != null && now < expire ) {
159+ File f = BaseNoGui .getSettingsFile ("splash.png" );
160+ if (f .isFile ()) {
161+ return f ;
162+ }
163+ }
164+ }
165+ return null ;
166+ }
131167
132168 protected int readIntFromURL (String _url ) throws Exception {
133169 List <String > lines = readFileFromURL (_url );
0 commit comments