Skip to content

Commit 6d8aa4d

Browse files
Merge pull request #2 from DeerajTheepshi/GSoC19-p1
[FEAT] Pre-Downloader window, Path Selection for install, New UX
2 parents 1abe67d + c8cf4c0 commit 6d8aa4d

File tree

4 files changed

+268
-60
lines changed

4 files changed

+268
-60
lines changed

mode/languages/mode.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ sdk_downloader.error_cannot_find_emulator = Cannot find the emulator
259259
sdk_downloader.error.cannot_unpack_platform = Error unpacking platform to "%s"
260260
sdk_downloader.download_title = SDK download
261261
sdk_downloader.download_sdk_label = Downloading Android SDK...
262+
sdk_downloader.download_error_title = Incomplete download
263+
sdk_downloader.download_error_message = SDK Installation is incomplete due to: \n%s
262264

263265
# ---------------------------------------
264266
# System image downloader

mode/src/processing/mode/android/AndroidMode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ public void checkSDK(Editor editor) {
171171
}
172172
}
173173
if (sdk == null) {
174-
Messages.showWarning(AndroidMode.getTextString("android_mode.warn.cannot_load_sdk_title"),
175-
AndroidMode.getTextString("android_mode.warn.cannot_load_sdk_body"), tr);
174+
Messages.showWarning(AndroidMode.getTextString("android_mode.warn.cannot_load_sdk_title"),
175+
AndroidMode.getTextString("android_mode.warn.cannot_load_sdk_body"), tr);
176176
} else {
177177
Devices devices = Devices.getInstance();
178178
devices.setSDK(sdk);

mode/src/processing/mode/android/AndroidSDK.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class AndroidSDK {
9292
private static final int INVALID_SDK = 3;
9393
private static int loadError = NO_ERROR;
9494

95+
private static boolean backOptionSelected;
96+
9597
public AndroidSDK(File folder) throws BadSDKException, IOException {
9698
this.folder = folder;
9799
if (!folder.exists()) {
@@ -403,11 +405,17 @@ public static AndroidSDK load(boolean checkEnvSDK, Frame editor) throws IOExcept
403405

404406
static public AndroidSDK locate(final Frame window, final AndroidMode androidMode)
405407
throws BadSDKException, CancelException, IOException {
406-
408+
backOptionSelected = false;
409+
407410
if (loadError == SKIP_ENV_SDK) {
408411
// The user does not want to use the environment SDK, so let's simply
409412
// download a new one to the sketchbook folder.
410-
return download(window, androidMode);
413+
AndroidSDK sdk = download(window, androidMode);
414+
if(sdk==null && backOptionSelected){
415+
return locate(window,androidMode);
416+
} else {
417+
return sdk;
418+
}
411419
}
412420

413421
// At this point, there is no ANDROID_SDK env variable, no SDK in the preferences,
@@ -416,7 +424,11 @@ static public AndroidSDK locate(final Frame window, final AndroidMode androidMod
416424
int result = showLocateDialog(window);
417425

418426
if (result == JOptionPane.YES_OPTION) {
419-
return download(window, androidMode);
427+
AndroidSDK sdk = download(window, androidMode);
428+
if(sdk==null && backOptionSelected){
429+
return locate(window,androidMode);
430+
}
431+
return sdk;
420432
} else if (result == JOptionPane.NO_OPTION) {
421433
// User will manually select folder containing SDK folder
422434
File folder = selectFolder(AndroidMode.getTextString("android_sdk.dialog.select_sdk_folder"), null, window);
@@ -448,9 +460,13 @@ static public boolean locateSysImage(final Frame window,
448460
static public AndroidSDK download(final Frame editor, final AndroidMode androidMode)
449461
throws BadSDKException, CancelException {
450462
final SDKDownloader downloader = new SDKDownloader(editor);
451-
downloader.run(); // This call blocks until the SDK download complete, or user cancels.
452-
453-
if (downloader.cancelled()) {
463+
//downloader.run(); // This call blocks until the SDK download complete, or user cancels.
464+
465+
if (downloader.isGoBack()){
466+
backOptionSelected = true;
467+
return null;
468+
}
469+
else if (downloader.cancelled()) {
454470
throw new CancelException(AndroidMode.getTextString("android_sdk.error.sdk_download_canceled"));
455471
}
456472
AndroidSDK sdk = downloader.getSDK();

0 commit comments

Comments
 (0)