Skip to content

Commit eb89014

Browse files
committed
update for API changes in Base
1 parent 3d20a37 commit eb89014

8 files changed

+45
-42
lines changed

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.Platform;
3132
import processing.app.Preferences;
3233
import processing.app.Sketch;
3334
import processing.app.SketchException;
@@ -138,7 +139,7 @@ public File createProject() throws IOException, SketchException {
138139
// use the src folder, since 'bin' might be used by the ant build
139140
binFolder = srcFolder;
140141
if (processing.app.Base.DEBUG) {
141-
Base.openFolder(tmpFolder);
142+
Platform.openFolder(tmpFolder);
142143
}
143144

144145
manifest = new Manifest(sketch);
@@ -258,7 +259,7 @@ protected File createExportFolder() throws IOException {
258259
"Please delete, close, or rename the folder\n" +
259260
androidFolder.getAbsolutePath() + "\n" +
260261
"and try again." , null);
261-
Base.openFolder(sketch.getFolder());
262+
Platform.openFolder(sketch.getFolder());
262263
return null;
263264
}
264265
}
@@ -748,7 +749,7 @@ private void writeProjectProps(final File file) {
748749
private void writeLocalProps(final File file) {
749750
final PrintWriter writer = PApplet.createWriter(file);
750751
final String sdkPath = sdk.getSdkFolder().getAbsolutePath();
751-
if (Base.isWindows()) {
752+
if (Platform.isWindows()) {
752753
// Windows needs backslashes escaped, or it will also accept forward
753754
// slashes in the build file. We're using the forward slashes since this
754755
// path gets concatenated with a lot of others that use forwards anyway.
@@ -770,7 +771,7 @@ private void writeRes(File resFolder,
770771
File layoutFolder = mkdirs(resFolder, "layout");
771772
File mainActivityLayoutFile = new File(layoutFolder, "main.xml");
772773
writeResLayoutMainActivity(mainActivityLayoutFile);
773-
774+
774775
// File mainFragmentLayoutFile = new File(layoutFolder, "fragment_main.xml");
775776
// writeResLayoutMainFragment(mainFragmentLayoutFile);
776777

@@ -860,8 +861,8 @@ private File mkdirs(final File parent, final String name) throws SketchException
860861
}
861862
return result;
862863
}
863-
864-
864+
865+
865866
private void writeMainActivity(final File srcDirectory) {
866867
File mainActivityFile = new File(new File(srcDirectory, manifest.getPackageName().replace(".", "/")),
867868
"MainActivity.java");
@@ -923,7 +924,7 @@ private void writeResLayoutMainActivity(final File file) {
923924
writer.flush();
924925
writer.close();
925926
}
926-
927+
927928
/*
928929
private void writeResLayoutMainFragment(final File file) {
929930
final PrintWriter writer = PApplet.createWriter(file);
@@ -955,7 +956,7 @@ private void copySupportV4(File libsFolder) throws SketchException {
955956
File sdkLocation = sdk.getSdkFolder();
956957
File supportV4Jar = new File(sdkLocation, "extras/android/support/v4/android-support-v4.jar");
957958
if (!supportV4Jar.exists()) {
958-
SketchException sketchException =
959+
SketchException sketchException =
959960
new SketchException("Please install support repository from SDK manager");
960961
throw sketchException;
961962
} else {

src/processing/mode/android/AndroidEditor.java

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

2424
import processing.app.Base;
2525
import processing.app.Mode;
26+
import processing.app.Platform;
2627
import processing.app.Preferences;
2728
import processing.app.SketchException;
2829
import processing.app.ui.EditorException;
@@ -35,6 +36,7 @@
3536
import javax.swing.*;
3637
import javax.swing.event.ChangeEvent;
3738
import javax.swing.event.ChangeListener;
39+
3840
import java.awt.event.ActionEvent;
3941
import java.awt.event.ActionListener;
4042
import java.io.File;
@@ -248,7 +250,7 @@ public void run() {
248250
}.start();
249251

250252
menu.add(sdkMenu);
251-
253+
252254
menu.addSeparator();
253255

254256
item = new JMenuItem("Android SDK Manager");
@@ -362,16 +364,16 @@ public JMenu buildHelpMenu() {
362364
item = new JMenuItem("Processing for Android Wiki");
363365
item.addActionListener(new ActionListener() {
364366
public void actionPerformed(ActionEvent e) {
365-
Base.openURL("http://wiki.processing.org/w/Android");
367+
Platform.openURL("http://wiki.processing.org/w/Android");
366368
}
367369
});
368370
menu.add(item);
369371

370372

371-
item = new JMenuItem("Android Developers Site");
373+
item = new JMenuItem("Android Developer Site");
372374
item.addActionListener(new ActionListener() {
373375
public void actionPerformed(ActionEvent e) {
374-
Base.openURL("http://developer.android.com/index.html");
376+
Platform.openURL("http://developer.android.com/");
375377
}
376378
});
377379
menu.add(item);
@@ -382,9 +384,9 @@ public void actionPerformed(ActionEvent e) {
382384

383385
/** override the standard grab reference to just show the java reference */
384386
public void showReference(String filename) {
385-
File javaReferenceFolder = Base.getContentFile("modes/java/reference");
387+
File javaReferenceFolder = Platform.getContentFile("modes/java/reference");
386388
File file = new File(javaReferenceFolder, filename);
387-
Base.openURL(file.toURI().toString());
389+
Platform.openURL(file.toURI().toString());
388390
}
389391

390392

@@ -498,7 +500,7 @@ public void run() {
498500
* Build the sketch and run it on a device with the debugger connected.
499501
*/
500502
public void handleRunDevice() {
501-
if(Base.isWindows() && !Preferences.getBoolean("usbDriverWarningShown")) {
503+
if (Platform.isWindows() && !Preferences.getBoolean("usbDriverWarningShown")) {
502504
Preferences.setBoolean("usbDriverWarningShown", true);
503505

504506
String message = "";
@@ -564,7 +566,7 @@ public void run() {
564566
try {
565567
File exportFolder = build.exportProject();
566568
if (exportFolder != null) {
567-
Base.openFolder(exportFolder);
569+
Platform.openFolder(exportFolder);
568570
statusNotice("Done with export.");
569571
}
570572
} catch (IOException e) {
@@ -612,7 +614,7 @@ public void run() {
612614
File projectFolder = build.exportPackage(keyStorePassword);
613615
if (projectFolder != null) {
614616
statusNotice("Done with export.");
615-
Base.openFolder(projectFolder);
617+
Platform.openFolder(projectFolder);
616618
} else {
617619
statusError("Error with export");
618620
}

src/processing/mode/android/AndroidMode.java

Lines changed: 2 additions & 1 deletion
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.Platform;
2627
import processing.app.RunnerListener;
2728
import processing.app.Sketch;
2829
import processing.app.SketchException;
@@ -63,7 +64,7 @@ public String getTitle() {
6364

6465
public File[] getKeywordFiles() {
6566
return new File[] {
66-
Base.getContentFile("modes/java/keywords.txt")
67+
Platform.getContentFile("modes/java/keywords.txt")
6768
};
6869
}
6970

src/processing/mode/android/AndroidSDK.java

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

3-
import processing.app.Base;
43
import processing.app.Platform;
54
import processing.app.Preferences;
65
import processing.app.exec.ProcessHelper;
@@ -19,6 +18,7 @@
1918
import java.util.ArrayList;
2019
import java.util.Date;
2120

21+
2222
class AndroidSDK {
2323
private final File folder;
2424
private final File tools;
@@ -74,21 +74,18 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
7474

7575
androidTool = findAndroidTool(tools);
7676

77-
final Platform p = Base.getPlatform();
78-
79-
String path = p.getenv("PATH");
77+
String path = Platform.getenv("PATH");
8078

81-
p.setenv("ANDROID_SDK", folder.getCanonicalPath());
79+
Platform.setenv("ANDROID_SDK", folder.getCanonicalPath());
8280
path = platformTools.getCanonicalPath() + File.pathSeparator +
8381
tools.getCanonicalPath() + File.pathSeparator + path;
8482

8583
String javaHomeProp = System.getProperty("java.home");
8684
File javaHome = new File(javaHomeProp).getCanonicalFile();
87-
p.setenv("JAVA_HOME", javaHome.getCanonicalPath());
85+
Platform.setenv("JAVA_HOME", javaHome.getCanonicalPath());
8886

8987
path = new File(javaHome, "bin").getCanonicalPath() + File.pathSeparator + path;
90-
91-
p.setenv("PATH", path);
88+
Platform.setenv("PATH", path);
9289

9390
checkDebugCertificate();
9491
}
@@ -210,10 +207,8 @@ private static File findAndroidTool(final File tools) throws BadSDKException {
210207
* @throws IOException
211208
*/
212209
public static AndroidSDK load() throws BadSDKException, IOException {
213-
final Platform platform = Base.getPlatform();
214-
215210
// The environment variable is king. The preferences.txt entry is a page.
216-
final String sdkEnvPath = platform.getenv("ANDROID_SDK");
211+
final String sdkEnvPath = Platform.getenv("ANDROID_SDK");
217212
if (sdkEnvPath != null) {
218213
try {
219214
final AndroidSDK androidSDK = new AndroidSDK(new File(sdkEnvPath));
@@ -329,7 +324,7 @@ static public int showLocateDialog(Frame editor) {
329324
// this was banished from Base because it encourages bad practice.
330325
// TODO figure out a better way to handle the above.
331326
static public File selectFolder(String prompt, File folder, Frame frame) {
332-
if (Base.isMacOS()) {
327+
if (Platform.isMacOS()) {
333328
if (frame == null) frame = new Frame(); //.pack();
334329
FileDialog fd = new FileDialog(frame, prompt, FileDialog.LOAD);
335330
if (folder != null) {

src/processing/mode/android/Commander.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.Arrays;
3030

3131
import processing.app.Base;
32+
import processing.app.Platform;
3233
import processing.app.Preferences;
3334
import processing.app.RunnerListener;
3435
import processing.app.Sketch;
@@ -83,7 +84,7 @@ static public void main(String[] args) {
8384
// Do this early so that error messages go to the console
8485
Base.setCommandLine();
8586
// init the platform so that prefs and other native code is ready to go
86-
Base.initPlatform();
87+
Platform.init();
8788

8889
// launch command line handler
8990
Commander commander = new Commander(args);
@@ -181,7 +182,7 @@ private void initValues() {
181182
checkOrQuit(sketchPath != null, "No sketch path specified.", true);
182183
checkOrQuit(!outputPath.equals(sketchPath), "The sketch path and output path cannot be identical.", false);
183184

184-
androidMode = (AndroidMode) ModeContribution.load(null, Base.getContentFile("modes/android"),
185+
androidMode = (AndroidMode) ModeContribution.load(null, Platform.getContentFile("modes/android"),
185186
"processing.mode.android.AndroidMode").getMode();
186187
androidMode.checkSDK(null);
187188
}

src/processing/mode/android/KeyStoreManager.java

Lines changed: 3 additions & 2 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.Platform;
45
import processing.app.ui.Toolkit;
56

67
import javax.swing.*;
@@ -124,7 +125,7 @@ public void actionPerformed(ActionEvent e) {
124125
resetKeystoreButton.setEnabled(true);
125126

126127
// think different, biznatchios!
127-
if (Base.isMacOS()) {
128+
if (Platform.isMacOS()) {
128129
buttons.add(cancelButton);
129130

130131
if (keyStore != null) buttons.add(resetKeystoreButton);
@@ -201,7 +202,7 @@ private void showKeystoreCredentialsLayout(Box pain) {
201202
textarea.setPreferredSize(new Dimension(400, 100));
202203
textarea.addMouseListener(new MouseAdapter() {
203204
public void mouseClicked(MouseEvent e) {
204-
Base.openURL(GUIDE_URL);
205+
Platform.openURL(GUIDE_URL);
205206
}
206207
});
207208
textarea.setAlignmentX(LEFT_ALIGNMENT);

src/processing/mode/android/Permissions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import javax.swing.border.*;
3333
import javax.swing.event.*;
3434

35-
import processing.app.Base;
35+
import processing.app.Platform;
3636
import processing.app.Sketch;
3737
import processing.app.ui.Toolkit;
3838

@@ -180,7 +180,7 @@ public void keyTyped(KeyEvent e) {
180180
textarea.setPreferredSize(new Dimension(400, 100));
181181
textarea.addMouseListener(new MouseAdapter() {
182182
public void mouseClicked(MouseEvent e) {
183-
Base.openURL(GUIDE_URL);
183+
Platform.openURL(GUIDE_URL);
184184
}
185185
});
186186
//textarea.setHorizontalAlignment(SwingConstants.LEFT);
@@ -262,7 +262,7 @@ public void actionPerformed(ActionEvent e) {
262262
cancelButton.setEnabled(true);
263263

264264
// think different, biznatchios!
265-
if (Base.isMacOS()) {
265+
if (Platform.isMacOS()) {
266266
buttons.add(cancelButton);
267267
// buttons.add(Box.createHorizontalStrut(8));
268268
buttons.add(okButton);

src/processing/mode/android/SDKDownloader.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.xml.sax.SAXException;
88

99
import processing.app.Base;
10+
import processing.app.Platform;
1011
import processing.app.Preferences;
1112
import processing.app.ui.Toolkit;
1213

@@ -61,7 +62,6 @@ class SDKDownloadTask extends SwingWorker<Object, Object> {
6162

6263
@Override
6364
protected Object doInBackground() throws Exception {
64-
String hostOs = getOsString();
6565
File modeFolder = new File(Base.getSketchbookModesFolder() + "/AndroidMode");
6666

6767
// creating sdk folders
@@ -79,7 +79,7 @@ protected Object doInBackground() throws Exception {
7979
if (!tempFolder.exists()) tempFolder.mkdir();
8080

8181
try {
82-
SDKUrlHolder downloadUrls = getDownloadUrls(URL_REPOSITORY, hostOs);
82+
SDKUrlHolder downloadUrls = getDownloadUrls(URL_REPOSITORY, Platform.getName());
8383
firePropertyChange(PROPERTY_CHANGE_EVENT_TOTAL, 0, downloadUrls.totalSize);
8484
totalSize = downloadUrls.totalSize;
8585

@@ -100,19 +100,19 @@ protected Object doInBackground() throws Exception {
100100
downloadAndUnpack(downloadUrls.platformUrl, downloadedPlatform, platformsFolder);
101101

102102
// usb driver
103-
if (Base.isWindows()) {
103+
if (Platform.isWindows()) {
104104
File usbDriverFolder = new File(extrasFolder, "google");
105105
File downloadedFolder = new File(tempFolder, "latest_usb_driver_windows.zip");
106106
downloadAndUnpack(URL_USB_DRIVER, downloadedFolder, usbDriverFolder);
107107
}
108108

109-
if (Base.isLinux() || Base.isMacOS()) {
109+
if (Platform.isLinux() || Platform.isMacOS()) {
110110
Runtime.getRuntime().exec("chmod -R 755 " + sdkFolder.getAbsolutePath());
111111
}
112112

113113
tempFolder.delete();
114114

115-
Base.getPlatform().setenv("ANDROID_SDK", sdkFolder.getAbsolutePath());
115+
Platform.setenv("ANDROID_SDK", sdkFolder.getAbsolutePath());
116116
Preferences.set("android.sdk.path", sdkFolder.getAbsolutePath());
117117
androidMode.loadSDK();
118118
} catch (ParserConfigurationException e) {
@@ -157,6 +157,7 @@ private void downloadAndUnpack(String urlString, File saveTo,
157157
extractFolder(saveTo, unpackTo);
158158
}
159159

160+
/*
160161
private String getOsString() {
161162
if (Base.isWindows()) {
162163
return "windows";
@@ -166,6 +167,7 @@ private String getOsString() {
166167
return "macosx";
167168
}
168169
}
170+
*/
169171

170172
private SDKUrlHolder getDownloadUrls(String repositoryUrl, String requiredHostOs) throws ParserConfigurationException, IOException, SAXException {
171173
SDKUrlHolder urlHolder = new SDKUrlHolder();

0 commit comments

Comments
 (0)