Skip to content

Commit 2b2bfe4

Browse files
committed
warn about default pacakge name and missing icons, fixes #327
1 parent b8f26c0 commit 2b2bfe4

File tree

4 files changed

+85
-14
lines changed

4 files changed

+85
-14
lines changed

src/processing/mode/android/AndroidBuild.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ public File exportProject() throws IOException, SketchException {
627627
}
628628

629629
public File exportPackage(String keyStorePassword) throws Exception {
630-
File projectFolder = null;
630+
File projectFolder = null;
631631
if (appComponent == WATCHFACE) {
632632
this.target = "release";
633633
String targetID = getTargetID();

src/processing/mode/android/AndroidEditor.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,21 @@ public EditorToolbar createToolbar() {
194194
return new AndroidToolbar(this, base);
195195
}
196196

197+
198+
/*
199+
// Not for now, it is unclear if the package name should be reset after save
200+
// as, i.e.: sketch_1 -> sketch_2 ...
201+
@Override
202+
public boolean handleSaveAs() {
203+
boolean saved = super.handleSaveAs();
204+
if (saved) {
205+
// Reset the manifest so package name and versions are blank
206+
androidMode.resetManifest(sketch, appComponent);
207+
}
208+
return saved;
209+
}
210+
*/
211+
197212

198213
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
199214

@@ -494,10 +509,10 @@ public JMenu buildHelpMenu() {
494509

495510
menu.addSeparator();
496511

497-
item = new JMenuItem("Processing for Android Wiki");
512+
item = new JMenuItem("Processing for Android Site");
498513
item.addActionListener(new ActionListener() {
499514
public void actionPerformed(ActionEvent e) {
500-
Platform.openURL("http://wiki.processing.org/w/Android");
515+
Platform.openURL("http://android.processing.org/");
501516
}
502517
});
503518
menu.add(item);
@@ -727,10 +742,8 @@ public void run() {
727742
* attached device.
728743
*/
729744
public void handleExportPackage() {
730-
// Need to implement an entire signing setup first
731-
// http://dev.processing.org/bugs/show_bug.cgi?id=1430
732-
if (handleExportCheckModified()) {
733-
// deactivateExport();
745+
if (androidMode.checkPackageName(sketch, appComponent) &&
746+
androidMode.checkAppIcons(sketch) && handleExportCheckModified()) {
734747
new KeyStoreManager(this);
735748
}
736749
}

src/processing/mode/android/AndroidMode.java

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/processing/mode/android/Manifest.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ public class Manifest {
7272
private XML xml;
7373

7474

75-
// public Manifest(Editor editor) {
76-
// this.editor = editor;
77-
// this.sketch = editor.getSketch();
78-
// load();
79-
// }
8075
public Manifest(Sketch sketch, int appComp, File modeFolder, boolean forceNew) {
8176
this.sketch = sketch;
8277
this.appComp = appComp;
@@ -86,7 +81,6 @@ public Manifest(Sketch sketch, int appComp, File modeFolder, boolean forceNew) {
8681

8782

8883
private String defaultPackageName() {
89-
// Sketch sketch = editor.getSketch();
9084
return AndroidBuild.basePackage + "." + sketch.getName().toLowerCase();
9185
}
9286

@@ -301,7 +295,7 @@ protected void load(boolean forceNew) {
301295
String versionCode = null;
302296
String versionName = null;
303297
if (xml != null && forceNew) {
304-
permissionNames = getPermissions();
298+
permissionNames = getPermissions();
305299
pkgName = getPackageName();
306300
versionCode = getVersionCode();
307301
versionName = getVersionName();

0 commit comments

Comments
 (0)