Skip to content

Commit 8e78d2b

Browse files
committed
deal with Base to Messages changes
1 parent eb89014 commit 8e78d2b

8 files changed

+65
-68
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: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import processing.app.Base;
3030
import processing.app.Library;
31+
import processing.app.Messages;
3132
import processing.app.Platform;
3233
import processing.app.Preferences;
3334
import processing.app.Sketch;
@@ -254,21 +255,21 @@ protected File createExportFolder() throws IOException {
254255
}
255256
if (!pr.succeeded()) {
256257
System.err.println(pr.getStderr());
257-
Base.showWarning("Failed to rename",
258-
"Could not rename the old “android” build folder.\n" +
259-
"Please delete, close, or rename the folder\n" +
260-
androidFolder.getAbsolutePath() + "\n" +
261-
"and try again." , null);
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);
262263
Platform.openFolder(sketch.getFolder());
263264
return null;
264265
}
265266
}
266267
} else {
267268
boolean result = androidFolder.mkdirs();
268269
if (!result) {
269-
Base.showWarning("Folders, folders, folders",
270-
"Could not create the necessary folders to build.\n" +
271-
"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);
272273
return null;
273274
}
274275
}

src/processing/mode/android/AndroidEditor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
package processing.mode.android;
2323

2424
import processing.app.Base;
25+
import processing.app.Messages;
2526
import processing.app.Mode;
2627
import processing.app.Platform;
2728
import processing.app.Preferences;
@@ -516,11 +517,8 @@ public void handleRunDevice() {
516517
"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>" +
517518
"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>";
518519
}
520+
Messages.showWarning("USB Driver warning", message);
519521

520-
Base.showWarning(
521-
"USB Driver warning",
522-
message
523-
);
524522
} else {
525523
new Thread() {
526524
public void run() {

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
}

src/processing/mode/android/AndroidMode.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import processing.app.Base;
2525
import processing.app.Library;
26+
import processing.app.Messages;
2627
import processing.app.Platform;
2728
import processing.app.RunnerListener;
2829
import processing.app.Sketch;
@@ -145,10 +146,9 @@ public void checkSDK(Editor parent) {
145146
}
146147
if (sdk == null) {
147148
if (!AndroidSDK.isDownloading()) {
148-
Base.showWarning("It's gonna be a bad day",
149-
"The Android SDK could not be loaded.\n" +
150-
"Use of Android Mode will be all but disabled.",
151-
null);
149+
Messages.showWarning("It's gonna be a bad day",
150+
"The Android SDK could not be loaded.\n" +
151+
"Use of Android Mode will be all but disabled.");
152152
}
153153
}
154154
}

src/processing/mode/android/AndroidPreprocessor.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
public class AndroidPreprocessor extends PdePreprocessor {
3939
Sketch sketch;
4040
String packageName;
41-
41+
4242
protected String smoothStatement;
43-
protected String sketchQuality;
43+
protected String sketchQuality;
44+
4445

45-
4646
public static final String SMOOTH_REGEX =
4747
"(?:^|\\s|;)smooth\\s*\\(\\s*([^\\s,]+)\\s*\\)\\s*\\;";
4848

@@ -68,8 +68,8 @@ public SurfaceInfo initSketchSize(String code) throws SketchException {
6868
sketchRenderer = surfaceInfo.getRenderer();*/
6969
return surfaceInfo;
7070
}
71-
72-
71+
72+
7373
public String[] initSketchSmooth(String code) throws SketchException {
7474
String[] info = parseSketchSmooth(code, true);
7575
if (info == null) {
@@ -78,17 +78,17 @@ public String[] initSketchSmooth(String code) throws SketchException {
7878
throw new SketchException("Could not parse the size() command.");
7979
}
8080
smoothStatement = info[0];
81-
sketchQuality = info[1];
81+
sketchQuality = info[1];
8282
return info;
8383
}
84-
85-
84+
85+
8686
static public String[] parseSketchSmooth(String code, boolean fussy) {
8787
String[] matches = PApplet.match(scrubComments(code), SMOOTH_REGEX);
8888

8989
if (matches != null) {
9090
boolean badSmooth = false;
91-
91+
9292
if (PApplet.parseInt(matches[1], -1) == -1) {
9393
badSmooth = true;
9494
}
@@ -100,16 +100,16 @@ static public String[] parseSketchSmooth(String code, boolean fussy) {
100100
"be determined from your code. Use only a numeric\n" +
101101
"value (not variables) for the smooth() command.\n" +
102102
"See the smooth() reference for an explanation.";
103-
Base.showWarning("Could not find smooth level", message, null);
103+
Messages.showWarning("Could not find smooth level", message, null);
104104
// new Exception().printStackTrace(System.out);
105105
return null;
106106
}
107-
107+
108108
return matches;
109109
}
110110
return new String[] { null, null }; // not an error, just empty
111111
}
112-
112+
113113

114114
/*
115115
protected boolean parseSketchSize() {
@@ -214,7 +214,7 @@ protected void writeFooter(PrintWriter out, String className) {
214214
215215
if ((mode == Mode.STATIC) || (mode == Mode.ACTIVE)) {
216216
out.println();
217-
217+
218218
if (sizeInfo.getWidth() != null) {
219219
out.println(indent + "public int sketchWidth() { return " + sizeInfo.getWidth() + "; }");
220220
}
@@ -228,7 +228,7 @@ protected void writeFooter(PrintWriter out, String className) {
228228
if (sketchQuality != null) {
229229
out.println(indent + "public int sketchQuality() { return " + sketchQuality + "; }");
230230
}
231-
231+
232232
// close off the class definition
233233
out.println("}");
234234
}
@@ -258,7 +258,7 @@ public String[] getDefaultImports() {
258258
259259
// The initial values are stored in here for the day when Android
260260
// is broken out as a separate mode.
261-
261+
262262
// In the future, this may include standard classes for phone or
263263
// accelerometer access within the Android APIs. This is currently living
264264
// in code rather than preferences.txt because Android mode needs to

src/processing/mode/android/KeyStoreManager.java

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

3-
import processing.app.Base;
3+
import processing.app.Messages;
44
import processing.app.Platform;
55
import processing.app.ui.Toolkit;
66

@@ -104,7 +104,7 @@ public void actionPerformed(ActionEvent e) {
104104
resetKeystoreButton.addActionListener(new ActionListener() {
105105
public void actionPerformed(ActionEvent e) {
106106
setVisible(false);
107-
int result = Base.showYesNoQuestion(editor, "Android keystore",
107+
int result = Messages.showYesNoQuestion(editor, "Android keystore",
108108
"Are you sure you want to reset the password?", "<html><body>We will have to reset the keystore to do this, " +
109109
"which means you won't be able to upload an update for your app signed with the new keystore to Google Play.<br/><br/>" +
110110
"We will make a backup for the old keystore.</body></html>");
@@ -113,7 +113,7 @@ public void actionPerformed(ActionEvent e) {
113113
setVisible(true);
114114
} else {
115115
if (!AndroidKeyStore.resetKeyStore()) {
116-
Base.showWarning("Android keystore", "Failed to remove keystore");
116+
Messages.showWarning("Android keystore", "Failed to remove keystore");
117117
setVisible(true);
118118
} else {
119119
keyStore = null;
@@ -181,11 +181,11 @@ private boolean checkRequiredFields() {
181181
if (Arrays.equals(passwordField.getPassword(), repeatPasswordField.getPassword())) {
182182
return true;
183183
} else {
184-
Base.showWarning("Passwords", "Keystore passwords do not match");
184+
Messages.showWarning("Passwords", "Keystore passwords do not match");
185185
return false;
186186
}
187187
} else {
188-
Base.showWarning("Passwords", "Keystore password should be at least 6 characters long");
188+
Messages.showWarning("Passwords", "Keystore password should be at least 6 characters long");
189189
return false;
190190
}
191191
}

0 commit comments

Comments
 (0)