Skip to content

Commit 9bc0b80

Browse files
committed
Change no sdk dialog options and texts
1 parent f350607 commit 9bc0b80

File tree

2 files changed

+60
-19
lines changed

2 files changed

+60
-19
lines changed

src/processing/mode/android/AndroidMode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ public void checkSDK(Editor parent) {
120120
if (sdk == null) {
121121
try {
122122
sdk = AndroidSDK.load();
123-
if (sdk == null) {
123+
// FIXME REVERT THIS STATEMENT AFTER TESTING (should be ==)
124+
if (sdk != null) {
124125
sdk = AndroidSDK.locate(parent);
125126
}
126127
} catch (BadSDKException e) {

src/processing/mode/android/AndroidSDK.java

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

3-
import java.awt.FileDialog;
4-
import java.awt.Frame;
5-
import java.io.File;
6-
import java.io.IOException;
7-
import java.text.DateFormat;
8-
import java.text.ParseException;
9-
import java.text.SimpleDateFormat;
10-
import java.util.Date;
11-
12-
import javax.swing.JFileChooser;
13-
import javax.swing.JOptionPane;
14-
153
import processing.app.Base;
164
import processing.app.Platform;
175
import processing.app.Preferences;
186
import processing.app.exec.ProcessHelper;
197
import processing.app.exec.ProcessResult;
208
import processing.core.PApplet;
219

10+
import javax.swing.*;
11+
import java.awt.*;
12+
import java.io.File;
13+
import java.io.IOException;
14+
import java.text.DateFormat;
15+
import java.text.ParseException;
16+
import java.text.SimpleDateFormat;
17+
import java.util.Date;
18+
2219
class AndroidSDK {
2320
private final File folder;
2421
private final File tools;
@@ -31,8 +28,10 @@ class AndroidSDK {
3128
private static final String ANDROID_SDK_SECONDARY =
3229
"The Android SDK does not appear to be installed, <br>" +
3330
"because the ANDROID_SDK variable is not set. <br>" +
34-
"If it is installed, click “Yes” to select the <br>" +
35-
"location of the SDK, or “No” to visit the SDK<br>" +
31+
"If it is installed, click “Locate SDK path” to select the <br>" +
32+
"location of the SDK, or “Download SDK” to let <br>" +
33+
"Processing download SDK automatically.<br><br>" +
34+
"If you want to download SDK manually, you can visit <br>"+
3635
"download site at http://developer.android.com/sdk.";
3736

3837
private static final String SELECT_ANDROID_SDK_FOLDER =
@@ -236,13 +235,12 @@ public static AndroidSDK load() throws BadSDKException, IOException {
236235

237236
static public AndroidSDK locate(final Frame window)
238237
throws BadSDKException, IOException {
239-
final int result = Base.showYesNoQuestion(window, "Android SDK",
240-
ANDROID_SDK_PRIMARY, ANDROID_SDK_SECONDARY);
238+
final int result = showLocateDialog(window);
241239
if (result == JOptionPane.CANCEL_OPTION) {
242240
throw new BadSDKException("User canceled attempt to find SDK.");
243241
}
244-
if (result == JOptionPane.NO_OPTION) {
245-
// user admitted they don't have the SDK installed, and need help.
242+
if (result == JOptionPane.YES_OPTION) {
243+
// here we are going to download sdk automatically
246244
Base.openURL(ANDROID_SDK_URL);
247245
throw new BadSDKException("No SDK installed.");
248246
}
@@ -263,6 +261,48 @@ static public AndroidSDK locate(final Frame window)
263261
}
264262
}
265263

264+
static public int showLocateDialog(Frame editor) {
265+
if (!Base.isMacOS()) {
266+
return JOptionPane.showConfirmDialog(editor,
267+
"<html><body>" +
268+
"<b>" + ANDROID_SDK_PRIMARY + "</b>" +
269+
"<br>" + ANDROID_SDK_SECONDARY, "Android SDK",
270+
JOptionPane.YES_NO_OPTION,
271+
JOptionPane.QUESTION_MESSAGE);
272+
} else {
273+
// Pane formatting adapted from the Quaqua guide
274+
// http://www.randelshofer.ch/quaqua/guide/joptionpane.html
275+
JOptionPane pane =
276+
new JOptionPane("<html> " +
277+
"<head> <style type=\"text/css\">"+
278+
"b { font: 13pt \"Lucida Grande\" }"+
279+
"p { font: 11pt \"Lucida Grande\"; margin-top: 8px; width: 300px }"+
280+
"</style> </head>" +
281+
"<b>" + ANDROID_SDK_PRIMARY + "</b>" +
282+
"<p>" + ANDROID_SDK_SECONDARY + "</p>",
283+
JOptionPane.QUESTION_MESSAGE);
284+
285+
String[] options = new String[] {
286+
"Download SDK automatically", "Locate SDK path manually"
287+
};
288+
pane.setOptions(options);
289+
290+
// highlight the safest option ala apple hig
291+
pane.setInitialValue(options[0]);
292+
293+
JDialog dialog = pane.createDialog(editor, null);
294+
dialog.setVisible(true);
295+
296+
Object result = pane.getValue();
297+
if (result == options[0]) {
298+
return JOptionPane.YES_OPTION;
299+
} else if (result == options[1]) {
300+
return JOptionPane.NO_OPTION;
301+
} else {
302+
return JOptionPane.CLOSED_OPTION;
303+
}
304+
}
305+
}
266306

267307
// this was banished from Base because it encourages bad practice.
268308
// TODO figure out a better way to handle the above.

0 commit comments

Comments
 (0)