@@ -90,6 +90,34 @@ public class AndroidMode extends JavaMode {
9090 "You need to open the wallpaper picker in the device in order " +
9191 "to select it as the new background." ;
9292
93+ private static final String DISTRIBUTING_APPS_TUT_URL =
94+ "http://android.processing.org/tutorials/distributing/index.html" ;
95+
96+ private static final String EXPORT_DEFAULT_PACKAGE_TITLE =
97+ "Cannot export package..." ;
98+
99+ private static final String EXPORT_DEFAULT_PACKAGE_MESSAGE =
100+ "The sketch still has the default package name. " +
101+ "Not good, since this name will uniquely identify your app on the Play store... for ever!<br>" +
102+ "Come up with a different package name and write in the AndroidManifest.xml file in the sketch folder, " +
103+ "after the \" package=\" attribute inside the manifest tag, which also contains version code and name. " +
104+ "Once you have done that, try exporting the sketch again.<br><br>" +
105+ "For more info on distributing apps from Processing,<br>" +
106+ "check <a href=\" " + DISTRIBUTING_APPS_TUT_URL + "\" >this online tutorial</a>." ;
107+
108+ private static final String EXPORT_DEFAULT_ICONS_TITLE =
109+ "Cannot export package..." ;
110+
111+ private static final String EXPORT_DEFAULT_ICONS_MESSAGE =
112+ "The sketch does not include any app icons. " +
113+ "Processing could use use its default set of Android icons, which are okay " +
114+ "to test the app on your devices, but a bad idea to distribute on the Play store. " +
115+ "Create a full set of unique icons for your app, and copy them into the sketch folder. " +
116+ "Once you have done that, try exporting the sketch again.<br><br>" +
117+ "For more info on distributing apps from Processing,<br>" +
118+ "check <a href=\" " + DISTRIBUTING_APPS_TUT_URL + "\" >this online tutorial</a>." ;
119+
120+
93121 public AndroidMode (Base base , File folder ) {
94122 super (base , folder );
95123 }
@@ -352,6 +380,42 @@ public void handleStop(RunnerListener listener) {
352380 }
353381
354382
383+ public boolean checkPackageName (Sketch sketch , int comp ) {
384+ Manifest manifest = new Manifest (sketch , comp , getFolder (), false );
385+ String defName = AndroidBuild .basePackage + "." + sketch .getName ().toLowerCase ();
386+ String name = manifest .getPackageName ();
387+ if (name .toLowerCase ().equals (defName .toLowerCase ())) {
388+ // The user did not set the package name, show error and stop
389+ AndroidMode .showMessage (EXPORT_DEFAULT_PACKAGE_TITLE , EXPORT_DEFAULT_PACKAGE_MESSAGE );
390+ return false ;
391+ }
392+ return true ;
393+ }
394+
395+
396+ public boolean checkAppIcons (Sketch sketch ) {
397+ File sketchFolder = sketch .getFolder ();
398+ File localIcon36 = new File (sketchFolder , AndroidBuild .ICON_36 );
399+ File localIcon48 = new File (sketchFolder , AndroidBuild .ICON_48 );
400+ File localIcon72 = new File (sketchFolder , AndroidBuild .ICON_72 );
401+ File localIcon96 = new File (sketchFolder , AndroidBuild .ICON_96 );
402+ File localIcon144 = new File (sketchFolder , AndroidBuild .ICON_144 );
403+ File localIcon192 = new File (sketchFolder , AndroidBuild .ICON_192 );
404+ boolean allExist = localIcon36 .exists () &&
405+ localIcon48 .exists () &&
406+ localIcon72 .exists () &&
407+ localIcon96 .exists () &&
408+ localIcon144 .exists () &&
409+ localIcon192 .exists ();
410+ if (!allExist ) {
411+ // The user did not set custom icons, show error and stop
412+ AndroidMode .showMessage (EXPORT_DEFAULT_ICONS_TITLE , EXPORT_DEFAULT_ICONS_MESSAGE );
413+ return false ;
414+ }
415+ return true ;
416+ }
417+
418+
355419 public void initManifest (Sketch sketch , int comp ) {
356420 new Manifest (sketch , comp , getFolder (), false );
357421 }
0 commit comments