Skip to content

Commit 782e794

Browse files
authored
Merge pull request #545 from processing/revert-543-GSoC19-p1.1
Revert "GSOC19 p1.1 - SDK download updates"
2 parents a64d8f1 + 9fc0698 commit 782e794

File tree

5 files changed

+166
-433
lines changed

5 files changed

+166
-433
lines changed

mode/languages/mode.properties

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ android_mode.dialog.cannot_export_package_body = The sketch still has the defaul
8888
android_mode.dialog.cannot_use_default_icons_title = Cannot export package...
8989
android_mode.dialog.cannot_use_default_icons_body = The sketch does not include all required app icons. Processing could use its default set of Android icons, which are okay to test the app on your device, but a bad idea to distribute it on the Play store. Create a full set of unique icons for your app, and copy them into the sketch folder. Once you have done that, try exporting the sketch again.<br><br>For more info on distributing apps from Processing,<br>check <a href=\"%s\">this online tutorial</a>.
9090
android_mode.warn.cannot_load_sdk_title = Bad news...
91-
android_mode.warn.cannot_load_sdk_body = The Android SDK could not be loaded, because:\n%s.\nThe Android Mode will be disabled.
91+
android_mode.warn.cannot_load_sdk_body = The Android SDK could not be loaded.\nThe Android Mode will be disabled.
9292
android_mode.info.cannot_open_sdk_path = "Android SDK path couldn't be opened.";
9393
android_mode.error.cannot_create_avd = "Could not create a virtual device for the emulator.";
9494
android_mode.dialog.no_devices_found_title = No devices found!
@@ -139,9 +139,9 @@ android_sdk.dialog.found_installed_sdk_body = Processing found a valid Android S
139139
android_sdk.option.use_existing_sdk = Use existing SDK
140140
android_sdk.option.download_new_sdk = Download new SDK
141141
android_sdk.dialog.cannot_find_sdk_title = Cannot find an Android SDK...
142-
android_sdk.dialog.cannot_find_sdk_body = Processing did not find an Android SDK on this computer. If there is one, and you know where it is, click \"Locate SDK path\" to select it, or \"Download SDK\" to let Processing download the SDK automatically.<br><br>If you want to download the SDK manually, you can get the command line tools from <a href=\"%s\">here</a>. Make sure to install the SDK platform for API 26 or higher.
142+
android_sdk.dialog.cannot_find_sdk_body = Processing did not find an Android SDK on this computer. If there is one, and you know where it is, click \"Locate SDK path\" to select it, or \"Download SDK\" to let Processing download the SDK automatically.<br><br>If you want to download the SDK manually, you can get the command line tools from <a href=\"%s\">here</a>. Make sure to install the SDK platform for API %s.
143143
android_sdk.dialog.invalid_sdk_title = Android SDK is not valid...
144-
android_sdk.dialog.invalid_sdk_body = Processing found an Android SDK, but is not valid. It could be missing some files, or might not be including the required platform for API 26 or higher.<br><br>If a valid SDK is available in a different location, click \"Locate SDK path\" to select it, or \"Download SDK\" to let Processing download the SDK automatically.<br><br>If you want to download the SDK manually, you can get the command line tools from <a href=\"%s\">here</a>. Make sure to install the SDK platform for API 26 or higher.
144+
android_sdk.dialog.invalid_sdk_body = Processing found an Android SDK, but is not valid. It could be missing some files, or might not be including the required platform for API %s.<br><br>If a valid SDK is available in a different location, click \"Locate SDK path\" to select it, or \"Download SDK\" to let Processing download the SDK automatically.<br><br>If you want to download the SDK manually, you can get the command line tools from <a href=\"%s\">here</a>. Make sure to install the SDK platform for API %s.
145145
android_sdk.option.download_sdk = Download SDK automatically
146146
android_sdk.option.locate_sdk = Locate SDK path manually
147147
android_sdk.dialog.download_phone_image_title = Download phone system image?
@@ -172,7 +172,7 @@ android_sdk.error.missing_tools_folder = There is no tools folder in %s
172172
android_sdk.error.missing_platform_tools_folder = There is no platform-tools folder in %s
173173
android_sdk.error.missing_build_tools_folder = There is no build-tools folder in %s
174174
android_sdk.error.missing_platforms_folder = There is no platforms folder in %s
175-
android_sdk.error.missing_target_platform = There is no Android %s (or greater) in %s
175+
android_sdk.error.missing_target_platform = There is no Android %s in %s
176176
android_sdk.error.missing_android_jar = android.jar for plaform %s is missing from %s
177177
android_debugger.info.removing_expired_keystore = Removing expired debug.keystore file.
178178
android_debugger.error.cannot_remove_expired_keystore = Could not remove the expired debug.keystore file.
@@ -259,8 +259,6 @@ 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
264262

265263
# ---------------------------------------
266264
# System image downloader

mode/src/processing/mode/android/AndroidEditor.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,6 @@ public void actionPerformed(ActionEvent e) {
183183
});
184184
androidMenu.add(item);
185185

186-
//For testing SDK Downloader - Remove Later. --------------------------------------
187-
item = new JMenuItem("SDK Downloader");
188-
item.addActionListener(new ActionListener() {
189-
public void actionPerformed(ActionEvent e) {
190-
try {
191-
AndroidSDK.download(null,androidMode);
192-
} catch (AndroidSDK.BadSDKException ex) {
193-
ex.printStackTrace();
194-
} catch (AndroidSDK.CancelException ex) {
195-
ex.printStackTrace();
196-
}
197-
}
198-
});
199-
androidMenu.add(item);
200-
//--------------------------------------------------------------------
201-
202186
androidMenu.addSeparator();
203187

204188
fragmentItem = new JCheckBoxMenuItem(AndroidMode.getTextString("menu.android.app"));

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: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ class AndroidSDK {
9292
private static final int INVALID_SDK = 3;
9393
private static int loadError = NO_ERROR;
9494

95-
private static boolean backOptionSelected;
96-
9795
public AndroidSDK(File folder) throws BadSDKException, IOException {
9896
this.folder = folder;
9997
if (!folder.exists()) {
@@ -119,17 +117,11 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
119117
if (!platforms.exists()) {
120118
throw new BadSDKException(AndroidMode.getTextString("android_sdk.error.missing_platforms_folder", folder));
121119
}
122-
123-
String[] availPlatforms = platforms.list();
124-
int maxVersion = 26;
125-
for (String availPlatform:availPlatforms){
126-
int platformVersion = Integer.parseInt(availPlatform.substring(availPlatform.length()-2));
127-
if (platformVersion >= maxVersion) maxVersion = platformVersion;
128-
}
129-
targetPlatform = new File(platforms, "android-"+maxVersion);
120+
121+
targetPlatform = new File(platforms, AndroidBuild.TARGET_PLATFORM);
130122
if (!targetPlatform.exists()) {
131123
throw new BadSDKException(AndroidMode.getTextString("android_sdk.error.missing_target_platform",
132-
maxVersion, platforms.getAbsolutePath()));
124+
AndroidBuild.TARGET_SDK, platforms.getAbsolutePath()));
133125
}
134126

135127
androidJar = new File(targetPlatform, "android.jar");
@@ -141,8 +133,6 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
141133
avdManager = findCliTool(new File(tools, "bin"), "avdmanager");
142134
sdkManager = findCliTool(new File(tools, "bin"), "sdkmanager");
143135

144-
Preferences.set("android.sdk.target",maxVersion+"");
145-
146136
String path = Platform.getenv("PATH");
147137

148138
Platform.setenv("ANDROID_SDK", folder.getCanonicalPath());
@@ -413,17 +403,11 @@ public static AndroidSDK load(boolean checkEnvSDK, Frame editor) throws IOExcept
413403

414404
static public AndroidSDK locate(final Frame window, final AndroidMode androidMode)
415405
throws BadSDKException, CancelException, IOException {
416-
backOptionSelected = false;
417-
406+
418407
if (loadError == SKIP_ENV_SDK) {
419408
// The user does not want to use the environment SDK, so let's simply
420409
// download a new one to the sketchbook folder.
421-
AndroidSDK sdk = download(window, androidMode);
422-
if(sdk==null && backOptionSelected){
423-
return locate(window,androidMode);
424-
} else {
425-
return sdk;
426-
}
410+
return download(window, androidMode);
427411
}
428412

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

434418
if (result == JOptionPane.YES_OPTION) {
435-
AndroidSDK sdk = download(window, androidMode);
436-
if(sdk==null && backOptionSelected){
437-
return locate(window,androidMode);
438-
}
439-
return sdk;
419+
return download(window, androidMode);
440420
} else if (result == JOptionPane.NO_OPTION) {
441421
// User will manually select folder containing SDK folder
442422
File folder = selectFolder(AndroidMode.getTextString("android_sdk.dialog.select_sdk_folder"), null, window);
@@ -468,13 +448,9 @@ static public boolean locateSysImage(final Frame window,
468448
static public AndroidSDK download(final Frame editor, final AndroidMode androidMode)
469449
throws BadSDKException, CancelException {
470450
final SDKDownloader downloader = new SDKDownloader(editor);
471-
//downloader.run(); // This call blocks until the SDK download complete, or user cancels.
472-
473-
if (downloader.isGoBack()){
474-
backOptionSelected = true;
475-
return null;
476-
}
477-
else if (downloader.cancelled()) {
451+
downloader.run(); // This call blocks until the SDK download complete, or user cancels.
452+
453+
if (downloader.cancelled()) {
478454
throw new CancelException(AndroidMode.getTextString("android_sdk.error.sdk_download_canceled"));
479455
}
480456
AndroidSDK sdk = downloader.getSDK();

0 commit comments

Comments
 (0)