From aa9aad63468f72e06f4de1d072e080a5fbc43545 Mon Sep 17 00:00:00 2001 From: benfry Date: Sun, 6 Dec 2009 14:47:02 +0000 Subject: [PATCH] auto-download android core zip file --- .../processing/app/tools/android/Android.java | 26 +++++++++++++++++++ .../processing/app/tools/android/Build.java | 5 +++- todo.txt | 12 ++++++--- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/app/src/processing/app/tools/android/Android.java b/app/src/processing/app/tools/android/Android.java index f6b7643ed..a7b2f002a 100644 --- a/app/src/processing/app/tools/android/Android.java +++ b/app/src/processing/app/tools/android/Android.java @@ -23,6 +23,7 @@ package processing.app.tools.android; import java.io.File; import java.io.IOException; +import java.net.URL; import javax.swing.JOptionPane; //import java.util.ArrayList; @@ -63,6 +64,11 @@ public class Android implements Tool { static final String ADB_SOCKET_PORT = "29892"; + static final String ANDROID_CORE_URL = + "http://dev.processing.org/android/core.zip"; + static final String ANDROID_CORE_FILENAME = + "processing-android-core.zip"; + public String getMenuTitle() { return "Android Mode"; @@ -94,6 +100,10 @@ public class Android implements Tool { editor.statusError("Could not load Android tools."); return; } + + // Make sure that the processing.android.core.* classes are available + checkCore(); + editor.setHandlers(new RunHandler(), new PresentHandler(), new StopHandler(), new ExportHandler(), new ExportAppHandler()); @@ -185,6 +195,22 @@ public class Android implements Tool { */ return true; } + + + protected boolean checkCore() { + File target = new File(Base.getSketchbookFolder(), ANDROID_CORE_FILENAME); + if (!target.exists()) { + try { + URL url = new URL(ANDROID_CORE_URL); + PApplet.saveStream(target, url.openStream()); + } catch (Exception e) { + Base.showWarning("Download Error", + "Could not download Android core.zip", e); + return false; + } + } + return true; + } /** diff --git a/app/src/processing/app/tools/android/Build.java b/app/src/processing/app/tools/android/Build.java index d617c7b7d..2f2db272a 100644 --- a/app/src/processing/app/tools/android/Build.java +++ b/app/src/processing/app/tools/android/Build.java @@ -518,7 +518,10 @@ public class Build { void writeLibs(File libsFolder) { libsFolder.mkdirs(); - InputStream input = getClass().getResourceAsStream("processing-core.zip"); + //InputStream input = getClass().getResourceAsStream("processing-core.zip"); + File file = + new File(Base.getSketchbookFolder(), Android.ANDROID_CORE_FILENAME); + InputStream input = PApplet.createInput(file); PApplet.saveStream(new File(libsFolder, "processing-core.jar"), input); } diff --git a/todo.txt b/todo.txt index 1c8d10318..3a5b9c9fb 100644 --- a/todo.txt +++ b/todo.txt @@ -2,6 +2,14 @@ X fix ant.jar/ant-launcher.jar error in the windows/linux build scripts X http://dev.processing.org/bugs/show_bug.cgi?id=1403 +_ move build scripts to something better like ant +_ too much to maintain the multiple versions, too much code +_ http://dev.processing.org/bugs/show_bug.cgi?id=151 +_ also update build/howto.txt (of course) because it says no ant +_ this would also mean requiring a java installation for building +_ so may as well move the jdk stuff outside of the build +_ http://ant.apache.org/manual/CoreTasks/get.html + _ lack of java.awt.Polygon import breaks the yellowtail example _ just add a simple poly class? or don't use a poly? @@ -1310,10 +1318,6 @@ _ drag and drop _ including the number of items would be especially nice _ implement automatic update _ http://dev.processing.org/bugs/show_bug.cgi?id=374 -_ move build scripts to something better like ant -_ too much to maintain the multiple versions, too much code -_ http://dev.processing.org/bugs/show_bug.cgi?id=151 -_ also update build/howto.txt (of course) because it says no ant _ need .pde document icons _ need .psk file icon _ need exported application icons