2929
3030import processing .app .*;
3131import processing .core .PApplet ;
32- import processing .core .XML ;
32+ import processing .data .XML ;
3333
3434
3535public 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