Skip to content

Commit 885f6d8

Browse files
committed
2 parents 567c7b4 + 8e78d2b commit 885f6d8

12 files changed

+127
-123
lines changed

src/processing/mode/android/AVD.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package processing.mode.android;
22

33
import processing.app.Base;
4+
import processing.app.Messages;
45
import processing.app.exec.ProcessHelper;
56
import processing.app.exec.ProcessResult;
67
import processing.core.PApplet;
@@ -29,7 +30,7 @@ public class AVD {
2930
"This could mean that the Android tools need to be updated,<br>" +
3031
"or that the Processing AVD should be deleted (it will<br>" +
3132
"automatically re-created the next time you run Processing).<br>" +
32-
"Open the Android SDK Manager (underneath the Android menu)<br>" +
33+
"Open the Android SDK Manager (underneath the Android menu)<br>" +
3334
"to check for any errors.";
3435

3536
static private final String AVD_TARGET_PRIMARY =
@@ -53,7 +54,7 @@ public class AVD {
5354

5455
private Map<String, String> preferredAbi = new HashMap<>(30);
5556
private static List<String> abiList = new ArrayList<>();
56-
57+
5758
/** Default virtual device used by Processing. */
5859
static public final AVD defaultAVD =
5960
new AVD("Processing-0" + Base.getRevision(),
@@ -63,10 +64,10 @@ public class AVD {
6364
public AVD(final String name, final String target) {
6465
this.name = name;
6566
this.target = target;
66-
67+
6768
initializeAbiList();
6869
}
69-
70+
7071
private void initializeAbiList() {
7172
if (abiList.size() == 0) {
7273
//The order in this list determines the preference of one abi over the other
@@ -131,9 +132,9 @@ protected boolean exists(final AndroidSDK sdk) throws IOException {
131132
}
132133

133134

134-
/**
135-
* Return true if a member of the renowned and prestigious
136-
* "The following Android Virtual Devices could not be loaded:" club.
135+
/**
136+
* Return true if a member of the renowned and prestigious
137+
* "The following Android Virtual Devices could not be loaded:" club.
137138
* (Prestigious may also not be the right word.)
138139
*/
139140
protected boolean badness() {
@@ -147,12 +148,12 @@ protected boolean badness() {
147148

148149

149150
protected boolean create(final AndroidSDK sdk) throws IOException {
150-
151+
151152
final String[] list_abi = {
152153
sdk.getAndroidToolPath(),
153154
"list", "targets"
154155
};
155-
156+
156157
ProcessHelper p = new ProcessHelper(list_abi);
157158
try {
158159
final ProcessResult abiListResult = p.execute();
@@ -163,11 +164,11 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
163164
if (m != null) {
164165
api = m[1];
165166
}
166-
167+
167168
m = PApplet.match(line, "Tag\\/ABIs\\s:\\sdefault\\/(\\S+)");
168169
if (m != null) {
169170
abi = m[1];
170-
171+
171172
if (api != null && abi != null) {
172173
if (preferredAbi.get(api) == null) {
173174
preferredAbi.put(api, abi);
@@ -180,15 +181,15 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
180181
}
181182
}
182183
} catch (InterruptedException e) {}
183-
184+
184185
if (preferredAbi.get(AndroidBuild.sdkVersion) == null) {
185186
return false;
186187
}
187-
188+
188189
final String[] params = {
189190
sdk.getAndroidToolPath(),
190191
"create", "avd",
191-
"-n", name,
192+
"-n", name,
192193
"-t", target,
193194
"-c", DEFAULT_SDCARD_SIZE,
194195
"-s", DEFAULT_SKIN,
@@ -209,12 +210,12 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
209210
}
210211
if (createAvdResult.toString().contains("Target id is not valid")) {
211212
// They didn't install the Google APIs
212-
Base.showWarningTiered("Android Error", AVD_TARGET_PRIMARY, AVD_TARGET_SECONDARY, null);
213+
Messages.showWarningTiered("Android Error", AVD_TARGET_PRIMARY, AVD_TARGET_SECONDARY, null);
213214
// throw new IOException("Missing required SDK components");
214215
} else {
215216
// Just generally not working
216217
// Base.showWarning("Android Error", AVD_CREATE_ERROR, null);
217-
Base.showWarningTiered("Android Error", AVD_CREATE_PRIMARY, AVD_CREATE_SECONDARY, null);
218+
Messages.showWarningTiered("Android Error", AVD_CREATE_PRIMARY, AVD_CREATE_SECONDARY, null);
218219
System.out.println(createAvdResult);
219220
// throw new IOException("Error creating the AVD");
220221
}
@@ -234,7 +235,7 @@ static public boolean ensureProperAVD(final AndroidSDK sdk) {
234235
// if (badList.contains(defaultAVD)) {
235236
if (defaultAVD.badness()) {
236237
// Base.showWarning("Android Error", AVD_CANNOT_LOAD, null);
237-
Base.showWarningTiered("Android Error", AVD_LOAD_PRIMARY, AVD_LOAD_SECONDARY, null);
238+
Messages.showWarningTiered("Android Error", AVD_LOAD_PRIMARY, AVD_LOAD_SECONDARY, null);
238239
return false;
239240
}
240241
if (defaultAVD.create(sdk)) {
@@ -243,8 +244,9 @@ static public boolean ensureProperAVD(final AndroidSDK sdk) {
243244
}
244245
} catch (final Exception e) {
245246
// Base.showWarning("Android Error", AVD_CREATE_ERROR, e);
246-
Base.showWarningTiered("Android Error", AVD_CREATE_PRIMARY,
247-
String.format(AVD_CREATE_SECONDARY, AndroidBuild.sdkVersion), null);
247+
Messages.showWarningTiered("Android Error", AVD_CREATE_PRIMARY,
248+
String.format(AVD_CREATE_SECONDARY,
249+
AndroidBuild.sdkVersion), null);
248250
}
249251
return false;
250252
}

src/processing/mode/android/AndroidBuild.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
import processing.app.Base;
3030
import processing.app.Library;
31+
import processing.app.Messages;
32+
import processing.app.Platform;
3133
import processing.app.Preferences;
3234
import processing.app.Sketch;
3335
import processing.app.SketchException;
@@ -138,7 +140,7 @@ public File createProject() throws IOException, SketchException {
138140
// use the src folder, since 'bin' might be used by the ant build
139141
binFolder = srcFolder;
140142
if (processing.app.Base.DEBUG) {
141-
Base.openFolder(tmpFolder);
143+
Platform.openFolder(tmpFolder);
142144
}
143145

144146
manifest = new Manifest(sketch);
@@ -253,21 +255,21 @@ protected File createExportFolder() throws IOException {
253255
}
254256
if (!pr.succeeded()) {
255257
System.err.println(pr.getStderr());
256-
Base.showWarning("Failed to rename",
257-
"Could not rename the old “android” build folder.\n" +
258-
"Please delete, close, or rename the folder\n" +
259-
androidFolder.getAbsolutePath() + "\n" +
260-
"and try again." , null);
261-
Base.openFolder(sketch.getFolder());
258+
Messages.showWarning("Failed to rename",
259+
"Could not rename the old “android” build folder.\n" +
260+
"Please delete, close, or rename the folder\n" +
261+
androidFolder.getAbsolutePath() + "\n" +
262+
"and try again." , null);
263+
Platform.openFolder(sketch.getFolder());
262264
return null;
263265
}
264266
}
265267
} else {
266268
boolean result = androidFolder.mkdirs();
267269
if (!result) {
268-
Base.showWarning("Folders, folders, folders",
269-
"Could not create the necessary folders to build.\n" +
270-
"Perhaps you have some file permissions to sort out?", null);
270+
Messages.showWarning("Folders, folders, folders",
271+
"Could not create the necessary folders to build.\n" +
272+
"Perhaps you have some file permissions to sort out?", null);
271273
return null;
272274
}
273275
}
@@ -748,7 +750,7 @@ private void writeProjectProps(final File file) {
748750
private void writeLocalProps(final File file) {
749751
final PrintWriter writer = PApplet.createWriter(file);
750752
final String sdkPath = sdk.getSdkFolder().getAbsolutePath();
751-
if (Base.isWindows()) {
753+
if (Platform.isWindows()) {
752754
// Windows needs backslashes escaped, or it will also accept forward
753755
// slashes in the build file. We're using the forward slashes since this
754756
// path gets concatenated with a lot of others that use forwards anyway.
@@ -770,7 +772,7 @@ private void writeRes(File resFolder,
770772
File layoutFolder = mkdirs(resFolder, "layout");
771773
File mainActivityLayoutFile = new File(layoutFolder, "main.xml");
772774
writeResLayoutMainActivity(mainActivityLayoutFile);
773-
775+
774776
// File mainFragmentLayoutFile = new File(layoutFolder, "fragment_main.xml");
775777
// writeResLayoutMainFragment(mainFragmentLayoutFile);
776778

@@ -860,8 +862,8 @@ private File mkdirs(final File parent, final String name) throws SketchException
860862
}
861863
return result;
862864
}
863-
864-
865+
866+
865867
private void writeMainActivity(final File srcDirectory) {
866868
File mainActivityFile = new File(new File(srcDirectory, manifest.getPackageName().replace(".", "/")),
867869
"MainActivity.java");
@@ -923,7 +925,7 @@ private void writeResLayoutMainActivity(final File file) {
923925
writer.flush();
924926
writer.close();
925927
}
926-
928+
927929
/*
928930
private void writeResLayoutMainFragment(final File file) {
929931
final PrintWriter writer = PApplet.createWriter(file);
@@ -955,7 +957,7 @@ private void copySupportV4(File libsFolder) throws SketchException {
955957
File sdkLocation = sdk.getSdkFolder();
956958
File supportV4Jar = new File(sdkLocation, "extras/android/support/v4/android-support-v4.jar");
957959
if (!supportV4Jar.exists()) {
958-
SketchException sketchException =
960+
SketchException sketchException =
959961
new SketchException("Please install support repository from SDK manager");
960962
throw sketchException;
961963
} else {

src/processing/mode/android/AndroidEditor.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222
package processing.mode.android;
2323

2424
import processing.app.Base;
25+
import processing.app.Messages;
2526
import processing.app.Mode;
27+
import processing.app.Platform;
2628
import processing.app.Preferences;
2729
import processing.app.SketchException;
30+
import processing.app.ui.EditorException;
2831
import processing.app.ui.EditorState;
2932
import processing.app.ui.EditorToolbar;
3033
import processing.app.ui.Toolkit;
@@ -34,6 +37,7 @@
3437
import javax.swing.*;
3538
import javax.swing.event.ChangeEvent;
3639
import javax.swing.event.ChangeListener;
40+
3741
import java.awt.event.ActionEvent;
3842
import java.awt.event.ActionListener;
3943
import java.io.File;
@@ -129,7 +133,7 @@ public void actionPerformed(ActionEvent e) {
129133

130134

131135
protected AndroidEditor(Base base, String path,
132-
EditorState state, Mode mode) throws Exception {
136+
EditorState state, Mode mode) throws EditorException {
133137
super(base, path, state, mode);
134138
androidMode = (AndroidMode) mode;
135139
androidMode.checkSDK(this);
@@ -247,7 +251,7 @@ public void run() {
247251
}.start();
248252

249253
menu.add(sdkMenu);
250-
254+
251255
menu.addSeparator();
252256

253257
item = new JMenuItem("Android SDK Manager");
@@ -361,16 +365,16 @@ public JMenu buildHelpMenu() {
361365
item = new JMenuItem("Processing for Android Wiki");
362366
item.addActionListener(new ActionListener() {
363367
public void actionPerformed(ActionEvent e) {
364-
Base.openURL("http://wiki.processing.org/w/Android");
368+
Platform.openURL("http://wiki.processing.org/w/Android");
365369
}
366370
});
367371
menu.add(item);
368372

369373

370-
item = new JMenuItem("Android Developers Site");
374+
item = new JMenuItem("Android Developer Site");
371375
item.addActionListener(new ActionListener() {
372376
public void actionPerformed(ActionEvent e) {
373-
Base.openURL("http://developer.android.com/index.html");
377+
Platform.openURL("http://developer.android.com/");
374378
}
375379
});
376380
menu.add(item);
@@ -381,9 +385,9 @@ public void actionPerformed(ActionEvent e) {
381385

382386
/** override the standard grab reference to just show the java reference */
383387
public void showReference(String filename) {
384-
File javaReferenceFolder = Base.getContentFile("modes/java/reference");
388+
File javaReferenceFolder = Platform.getContentFile("modes/java/reference");
385389
File file = new File(javaReferenceFolder, filename);
386-
Base.openURL(file.toURI().toString());
390+
Platform.openURL(file.toURI().toString());
387391
}
388392

389393

@@ -497,7 +501,7 @@ public void run() {
497501
* Build the sketch and run it on a device with the debugger connected.
498502
*/
499503
public void handleRunDevice() {
500-
if(Base.isWindows() && !Preferences.getBoolean("usbDriverWarningShown")) {
504+
if (Platform.isWindows() && !Preferences.getBoolean("usbDriverWarningShown")) {
501505
Preferences.setBoolean("usbDriverWarningShown", true);
502506

503507
String message = "";
@@ -513,11 +517,8 @@ public void handleRunDevice() {
513517
"Please follow the guide at <a href='http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver'>http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver</a> to install the driver.<br>" +
514518
"You will also need to download the driver from <a href='http://developer.android.com/sdk/win-usb.html'>http://developer.android.com/sdk/win-usb.html</a>";
515519
}
520+
Messages.showWarning("USB Driver warning", message);
516521

517-
Base.showWarning(
518-
"USB Driver warning",
519-
message
520-
);
521522
} else {
522523
new Thread() {
523524
public void run() {
@@ -563,7 +564,7 @@ public void run() {
563564
try {
564565
File exportFolder = build.exportProject();
565566
if (exportFolder != null) {
566-
Base.openFolder(exportFolder);
567+
Platform.openFolder(exportFolder);
567568
statusNotice("Done with export.");
568569
}
569570
} catch (IOException e) {
@@ -611,7 +612,7 @@ public void run() {
611612
File projectFolder = build.exportPackage(keyStorePassword);
612613
if (projectFolder != null) {
613614
statusNotice("Done with export.");
614-
Base.openFolder(projectFolder);
615+
Platform.openFolder(projectFolder);
615616
} else {
616617
statusError("Error with export");
617618
}

src/processing/mode/android/AndroidKeyStore.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
package processing.mode.android;
22

3-
import processing.app.Base;
3+
import processing.app.Messages;
44

55
import java.io.File;
66

7-
/**
8-
* Created with IntelliJ IDEA.
9-
* User: imilka
10-
* Date: 27.05.14
11-
* Time: 14:38
12-
*/
13-
public class AndroidKeyStore {
147

8+
public class AndroidKeyStore {
159
public static final String ALIAS_STRING = "processing-keystore";
1610
public static final String KEYSTORE_FILE_NAME = "android-release-key.keystore";
1711

@@ -28,9 +22,9 @@ public static File getKeyStoreLocation() {
2822
boolean result = keyStoreFolder.mkdirs();
2923

3024
if (!result) {
31-
Base.showWarning("Folders, folders, folders",
32-
"Could not create the necessary folders to build.\n" +
33-
"Perhaps you have some file permissions to sort out?", null);
25+
Messages.showWarning("Folders, folders, folders",
26+
"Could not create the necessary folders to build.\n" +
27+
"Perhaps you have some file permissions to sort out?");
3428
return null;
3529
}
3630
}

0 commit comments

Comments
 (0)