Skip to content

Commit 55fb4d5

Browse files
committed
fighting with Android quirks in the latest Google SDK
1 parent 8337f5d commit 55fb4d5

7 files changed

Lines changed: 224 additions & 84 deletions

File tree

android/core/src/processing/core/PImage.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,17 @@ public PImage get(int x, int y, int w, int h) {
524524
h += y; // clip off some of the height
525525
y = 0;
526526
}
527-
527+
528528
if (x + w > width) w = width - x;
529529
if (y + h > height) h = height - y;
530530

531+
if (w < 0) {
532+
w = 0;
533+
}
534+
if (h < 0) {
535+
h = 0;
536+
}
537+
531538
return getImpl(x, y, w, h);
532539
}
533540

android/todo.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ X http://code.google.com/p/processing/issues/detail?id=899
44
X http://code.google.com/p/processing/issues/detail?id=769
55
X /opt/android using version #s again? fix build script (earlier)
66
X smooth() is now the default
7+
X update to Android tools 17
8+
X add workarounds for problem with tools 17 version of dex
9+
o import statements with android.* break things
10+
X http://code.google.com/p/processing/issues/detail?id=989
11+
X was already fixed
712

813
_ now requiring SDK 10 (2.3.3) because of OpenGL issues
914
_ not SDK 9, which is 2.3.1 (and still Gingerbread)

app/src/processing/app/Base.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class Base {
5757

5858
/** True if heavy debugging error/log messages are enabled */
5959
static public boolean DEBUG = false;
60-
//static public boolean DEBUG = true;
60+
// static public boolean DEBUG = true;
6161

6262
static HashMap<Integer, String> platformNames =
6363
new HashMap<Integer, String>();

app/src/processing/app/exec/ProcessHelper.java

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*/
2020
package processing.app.exec;
2121

22-
import java.io.IOException;
23-
import java.io.StringWriter;
22+
import java.io.*;
23+
2424
import processing.core.PApplet;
2525

2626
/**
@@ -31,13 +31,26 @@
3131
*/
3232
public class ProcessHelper {
3333
private final String[] cmd;
34+
// private final String exe;
35+
// private final String[] args;
36+
private final File dir;
37+
3438

3539
public ProcessHelper(final String... cmd) {
3640
this.cmd = cmd;
41+
this.dir = null;
42+
}
43+
44+
45+
public ProcessHelper(File dir, final String... cmd) {
46+
this.cmd = cmd;
47+
this.dir = dir;
3748
}
49+
3850

3951
@Override
4052
public String toString() {
53+
/*
4154
final StringBuffer buffer = new StringBuffer();
4255
for (int i = 0; i < cmd.length; i++) {
4356
if (i != 0) {
@@ -46,8 +59,12 @@ public String toString() {
4659
buffer.append(cmd[i]);
4760
}
4861
return buffer.toString();
62+
*/
63+
// return exe + " " + PApplet.join(args, " ");
64+
return PApplet.join(cmd, " ");
4965
}
5066

67+
5168
/**
5269
* Blocking execution.
5370
* @return exit value of process
@@ -62,10 +79,13 @@ public ProcessResult execute() throws InterruptedException, IOException {
6279
final String prettyCommand = toString();
6380
// System.err.println("ProcessHelper: >>>>> " + Thread.currentThread().getId()
6481
// + " " + prettyCommand);
65-
final Process process = Runtime.getRuntime().exec(cmd);
82+
// final Process process = Runtime.getRuntime().exec(cmd);
83+
final Process process = dir == null ?
84+
Runtime.getRuntime().exec(cmd) :
85+
Runtime.getRuntime().exec(cmd, new String[] { }, dir);
6686
ProcessRegistry.watch(process);
6787
try {
68-
String title = PApplet.join(cmd, ' ');
88+
String title = prettyCommand;
6989
new StreamPump(process.getInputStream(), "out: " + title).addTarget(outWriter).start();
7090
new StreamPump(process.getErrorStream(), "err: " + title).addTarget(errWriter).start();
7191
try {
@@ -85,4 +105,39 @@ public ProcessResult execute() throws InterruptedException, IOException {
85105
ProcessRegistry.unwatch(process);
86106
}
87107
}
108+
109+
110+
// static public ProcessResult execute(String exe, String[] args, File dir)
111+
// throws InterruptedException, IOException {
112+
// final StringWriter outWriter = new StringWriter();
113+
// final StringWriter errWriter = new StringWriter();
114+
// final long startTime = System.currentTimeMillis();
115+
//
116+
// final String prettyCommand = exe + " " + PApplet.join(args, " ");
117+
// System.out.println("pretty cmd is " + prettyCommand);
118+
// final Process process = dir == null ?
119+
// Runtime.getRuntime().exec(exe, args) :
120+
// Runtime.getRuntime().exec(exe, args, dir);
121+
// ProcessRegistry.watch(process);
122+
// try {
123+
// String title = prettyCommand;
124+
// new StreamPump(process.getInputStream(), "out: " + title).addTarget(outWriter).start();
125+
// new StreamPump(process.getErrorStream(), "err: " + title).addTarget(errWriter).start();
126+
// try {
127+
// final int result = process.waitFor();
128+
// final long time = System.currentTimeMillis() - startTime;
129+
// // System.err.println("ProcessHelper: <<<<< "
130+
// // + Thread.currentThread().getId() + " " + cmd[0] + " (" + time
131+
// // + "ms)");
132+
// return new ProcessResult(prettyCommand, result, outWriter.toString(),
133+
// errWriter.toString(), time);
134+
// } catch (final InterruptedException e) {
135+
// System.err.println("Interrupted: " + prettyCommand);
136+
// throw e;
137+
// }
138+
// } finally {
139+
// process.destroy();
140+
// ProcessRegistry.unwatch(process);
141+
// }
142+
// }
88143
}

0 commit comments

Comments
 (0)