Skip to content

Dynamic splash image #9827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/cc/arduino/view/SplashScreenHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.net.URL;
import java.util.Map;

import processing.app.Theme;
Expand Down Expand Up @@ -80,6 +81,12 @@ public void splashText(String text) {
ensureTextIsDiplayed();
}

public void setImageURL(URL imageURL) {
try {
splash.setImageURL(imageURL);
} catch(Exception e) {}
}

private void ensureTextIsDiplayed() {
synchronized (SplashScreen.class) {
if (splash.isVisible()) {
Expand Down
5 changes: 5 additions & 0 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.URL;
import java.util.List;
import java.util.Timer;
import java.util.*;
Expand Down Expand Up @@ -237,6 +238,10 @@ public Base(String[] args) throws Exception {

SplashScreenHelper splash;
if (parser.isGuiMode()) {
splash = new SplashScreenHelper(SplashScreen.getSplashScreen());
if (PreferencesData.has("update.splashImage"))
splash.setImageURL(new URL(PreferencesData.get("update.splashImage")));

// Setup all notification widgets
splash = new SplashScreenHelper(SplashScreen.getSplashScreen());
BaseNoGui.notifier = new GUIUserNotifier(this);
Expand Down
31 changes: 30 additions & 1 deletion app/src/processing/app/UpdateCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Random;

import static processing.app.I18n.tr;
Expand Down Expand Up @@ -87,7 +88,35 @@ public void run() {
System.getProperty("os.version") + "\t" +
System.getProperty("os.arch"), "UTF-8");

int latest = readInt(downloadURL + "?" + info);
// read data from server
BufferedReader reader = null;
int latest = -1;
HashMap<String, String> serverInfo = new HashMap<String, String>();
try {
URL url = new URL(downloadURL + "?" + info);
reader = new BufferedReader(new InputStreamReader(url.openStream()));

// parse the latest version number
latest = Integer.parseInt(reader.readLine());

// parse the key=value pairs
while (true) {
String line = reader.readLine();
if (line == null)
break;
String[] parts = line.split("=", 2);
if (parts.length == 2)
serverInfo.put(parts[0], parts[1]);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(reader);
}

if (serverInfo.containsKey("splashImage"))
PreferencesData.set("update.splashImage",
serverInfo.get("splashImage"));

String lastString = PreferencesData.get("update.last");
long now = System.currentTimeMillis();
Expand Down