Skip to content

Commit 1d07037

Browse files
committed
move XML and Table to processing.data, update preproc
1 parent 1213767 commit 1d07037

File tree

11 files changed

+594
-597
lines changed

11 files changed

+594
-597
lines changed

android/core/src/processing/core/PApplet.java

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,29 @@
2323

2424
package processing.core;
2525

26-
import java.io.IOException;
27-
import java.io.InputStream;
28-
import java.io.UnsupportedEncodingException;
29-
30-
import android.content.*;
31-
import android.content.pm.ActivityInfo;
32-
import android.content.pm.ConfigurationInfo;
33-
import android.content.res.AssetManager;
34-
import android.content.res.Configuration;
35-
import android.graphics.*;
36-
3726
import java.io.*;
3827
import java.lang.reflect.*;
39-
import java.net.MalformedURLException;
40-
import java.net.URLDecoder;
41-
import java.net.URLEncoder;
28+
import java.net.*;
4229
import java.text.NumberFormat;
4330
import java.util.*;
4431
import java.util.regex.*;
4532
import java.util.zip.*;
4633

47-
import android.app.Activity;
48-
import android.app.ActivityManager;
34+
import android.app.*;
35+
import android.content.*;
36+
import android.content.pm.ActivityInfo;
37+
import android.content.pm.ConfigurationInfo;
38+
import android.content.res.AssetManager;
39+
import android.content.res.Configuration;
40+
import android.graphics.*;
4941
import android.net.Uri;
50-
import android.text.format.Time;
51-
import android.util.*;
52-
import android.view.MotionEvent;
53-
import android.view.SurfaceView;
5442
import android.opengl.GLSurfaceView;
55-
import android.view.WindowManager;
5643
import android.os.Bundle;
5744
import android.os.Handler;
45+
import android.text.format.Time;
46+
import android.util.*;
5847
import android.view.*;
59-
import android.widget.LinearLayout;
48+
import android.widget.*;
6049
import android.widget.RelativeLayout;
6150

6251
import org.apache.http.client.HttpClient;
@@ -65,9 +54,8 @@
6554
import org.apache.http.HttpResponse;
6655
import org.apache.http.HttpEntity;
6756

68-
import processing.opengl.PGraphicsOpenGL;
69-
70-
import java.net.URI;
57+
import processing.data.*;
58+
import processing.opengl.*;
7159

7260

7361
public class PApplet extends Activity implements PConstants, Runnable {

android/core/src/processing/core/PShapeSVG.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
package processing.core;
2525

26+
import processing.data.*;
27+
2628
import java.util.HashMap;
2729

2830
import android.graphics.*;

android/core/src/processing/data/XML.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Boston, MA 02111-1307 USA
2121
*/
2222

23-
package processing.core;
23+
package processing.data;
2424

2525
import java.io.*;
2626

app/src/processing/mode/android/AndroidPreprocessor.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@
4040
public class AndroidPreprocessor extends PdePreprocessor {
4141
Sketch sketch;
4242
String packageName;
43-
43+
4444
String sizeStatement;
45-
String sketchWidth;
45+
String sketchWidth;
4646
String sketchHeight;
4747
String sketchRenderer;
4848

4949

50-
public AndroidPreprocessor(final Sketch sketch,
50+
public AndroidPreprocessor(final Sketch sketch,
5151
final String packageName) throws IOException {
5252
super(sketch.getName());
5353
this.sketch = sketch;
5454
this.packageName = packageName;
5555
}
5656

57-
57+
5858
// TODO this needs to be a generic function inside Sketch or elsewhere
5959

6060
protected boolean parseSketchSize() {
@@ -70,7 +70,7 @@ protected boolean parseSketchSize() {
7070

7171
if (matches != null) {
7272
boolean badSize = false;
73-
73+
7474
if (!matches[1].equals("screenWidth") &&
7575
!matches[1].equals("screenHeight") &&
7676
PApplet.parseInt(matches[1], -1) == -1) {
@@ -84,7 +84,7 @@ protected boolean parseSketchSize() {
8484

8585
if (badSize) {
8686
// found a reference to size, but it didn't seem to contain numbers
87-
final String message =
87+
final String message =
8888
"The size of this applet could not automatically be determined\n" +
8989
"from your code. Use only numeric values (not variables) for the\n" +
9090
"size() command. See the size() reference for more information.";
@@ -116,7 +116,7 @@ public PreprocessorResult write(Writer out, String program, String codeFolderPac
116116
throws SketchException, RecognitionException, TokenStreamException {
117117
if (sizeStatement != null) {
118118
int start = program.indexOf(sizeStatement);
119-
program = program.substring(0, start) +
119+
program = program.substring(0, start) +
120120
program.substring(start + sizeStatement.length());
121121
}
122122
// String[] found = PApplet.match(program, "import\\s+processing.opengl.*\\s*");
@@ -166,8 +166,9 @@ protected void writeFooter(PrintWriter out, String className) {
166166

167167
@Override
168168
public String[] getCoreImports() {
169-
return new String[] {
170-
"processing.core.*"
169+
return new String[] {
170+
"processing.core.*",
171+
"processing.data.*"
171172
};
172173
}
173174

@@ -192,7 +193,7 @@ public String[] getDefaultImports() {
192193
//"java.util.zip.*", "java.util.regex.*" // not necessary w/ newer i/o
193194
};
194195

195-
Preferences.set("android.preproc.imports.list",
196+
Preferences.set("android.preproc.imports.list",
196197
PApplet.join(androidImports, ","));
197198

198199
return androidImports;

app/src/processing/mode/android/Manifest.java

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@
2929

3030
import processing.app.*;
3131
import processing.core.PApplet;
32-
import processing.core.XML;
32+
import processing.data.XML;
3333

3434

3535
public class Manifest {
3636
static final String MANIFEST_XML = "AndroidManifest.xml";
3737

38-
static final String WORLD_OF_HURT_COMING =
39-
"Errors occurred while reading or writing " + MANIFEST_XML + ",\n" +
38+
static final String WORLD_OF_HURT_COMING =
39+
"Errors occurred while reading or writing " + MANIFEST_XML + ",\n" +
4040
"which means lots of things are likely to stop working properly.\n" +
41-
"To prevent losing any data, it's recommended that you use “Save As”\n" +
42-
"to save a separate copy of your sketch, and the restart Processing.";
43-
static final String MULTIPLE_ACTIVITIES =
41+
"To prevent losing any data, it's recommended that you use “Save As”\n" +
42+
"to save a separate copy of your sketch, and the restart Processing.";
43+
static final String MULTIPLE_ACTIVITIES =
4444
"Processing only supports a single Activity in the AndroidManifest.xml\n" +
45-
"file. Only the first activity entry will be updated, and you better \n" +
45+
"file. Only the first activity entry will be updated, and you better \n" +
4646
"hope that's the right one, smartypants.";
4747

4848
// private Editor editor;
4949
private Sketch sketch;
50-
50+
5151
// entries we care about from the manifest file
5252
// private String packageName;
53-
53+
5454
/** the manifest data read from the file */
5555
private XML xml;
5656

@@ -64,34 +64,34 @@ public Manifest(Sketch sketch) {
6464
this.sketch = sketch;
6565
load();
6666
}
67-
68-
67+
68+
6969
private String defaultPackageName() {
7070
// Sketch sketch = editor.getSketch();
7171
return AndroidBuild.basePackage + "." + sketch.getName().toLowerCase();
7272
}
73-
73+
7474

7575
// called by other classes who want an actual package name
7676
// internally, we'll figure this out ourselves whether it's filled or not
7777
public String getPackageName() {
7878
String pkg = xml.getString("package");
7979
return pkg.length() == 0 ? defaultPackageName() : pkg;
8080
}
81-
82-
81+
82+
8383
public void setPackageName(String packageName) {
8484
// this.packageName = packageName;
8585
// this is the package attribute in the root <manifest> object
8686
xml.setString("package", packageName);
8787
save();
8888
}
89-
90-
89+
90+
9191
//writer.println(" <uses-permission android:name=\"android.permission.INTERNET\" />");
9292
//writer.println(" <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />");
9393
static final String PERMISSION_PREFIX = "android.permission.";
94-
94+
9595
public String[] getPermissions() {
9696
XML[] elements = xml.getChildren("uses-permission");
9797
int count = elements.length;
@@ -101,8 +101,8 @@ public String[] getPermissions() {
101101
}
102102
return names;
103103
}
104-
105-
104+
105+
106106
public void setPermissions(String[] names) {
107107
// just remove all the old ones
108108
for (XML kid : xml.getChildren("uses-permission")) {
@@ -141,14 +141,14 @@ private void writeBlankManifest(final File file) {
141141
writer.println("<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" ");
142142
// writer.println(" package=\"" + defaultPackageName() + "\" ");
143143
writer.println(" package=\"\" ");
144-
145-
// Tempting to use 'preferExternal' here, but might annoy some users.
144+
145+
// Tempting to use 'preferExternal' here, but might annoy some users.
146146
// 'auto' at least enables it to be moved back and forth
147147
// http://developer.android.com/guide/appendix/install-location.html
148148
// writer.println(" android:installLocation=\"auto\" ");
149149
// Disabling this for now (0190), requires default.properties to use API 8
150150

151-
// This is just a number (like the Processing 'revision'). It should
151+
// This is just a number (like the Processing 'revision'). It should
152152
// increment with each release. Perhaps P5 should do this automatically
153153
// with each build or read/write of the manifest file?
154154
writer.println(" android:versionCode=\"1\" ");
@@ -168,8 +168,8 @@ private void writeBlankManifest(final File file) {
168168
//// writer.println(" android:label=\"@string/app_name\">"); // pretty name
169169
// writer.println(" android:label=\"\">");
170170

171-
// activity/android:name should be the full name (package + class name) of
172-
// the actual activity class. or the package can be replaced by a single
171+
// activity/android:name should be the full name (package + class name) of
172+
// the actual activity class. or the package can be replaced by a single
173173
// dot as a prefix as an easier shorthand.
174174
writer.println(" <activity android:name=\"\">");
175175

@@ -186,14 +186,14 @@ private void writeBlankManifest(final File file) {
186186

187187

188188
/**
189-
* Save a new version of the manifest info to the build location.
189+
* Save a new version of the manifest info to the build location.
190190
* Also fill in any missing attributes that aren't yet set properly.
191191
*/
192-
protected void writeBuild(File file, String className,
192+
protected void writeBuild(File file, String className,
193193
boolean debug) throws IOException {
194194
// write a copy to the build location
195195
save(file);
196-
196+
197197
// load the copy from the build location and start messing with it
198198
XML mf = new XML(new FileReader(file));
199199

@@ -235,7 +235,7 @@ protected void load() {
235235
} catch (Exception e) {
236236
e.printStackTrace();
237237
System.err.println("Problem reading AndroidManifest.xml, creating a new version");
238-
238+
239239
// remove the old manifest file, rename it with date stamp
240240
long lastModified = manifestFile.lastModified();
241241
String stamp = AndroidMode.getDateStamp(lastModified);
@@ -247,7 +247,7 @@ protected void load() {
247247
return;
248248
}
249249
}
250-
}
250+
}
251251
if (xml == null) {
252252
writeBlankManifest(manifestFile);
253253
try {
@@ -262,13 +262,13 @@ protected void load() {
262262
}
263263
// return xml;
264264
}
265-
266-
265+
266+
267267
protected void save() {
268268
save(getManifestFile());
269269
}
270270

271-
271+
272272
/**
273273
* Save to the sketch folder, so that it can be copied in later.
274274
*/

0 commit comments

Comments
 (0)