Skip to content

Commit 2afe132

Browse files
[Fix]Autoreload SDK,rem test code
1 parent d380380 commit 2afe132

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

mode/languages/mode.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +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.broken_sdk_folder = Your SDK path seems to be broken as %s
9192
android_mode.warn.cannot_load_sdk_body = The Android SDK could not be loaded, because:\n%s.\nThe Android Mode will be disabled.
9293
android_mode.info.cannot_open_sdk_path = "Android SDK path couldn't be opened.";
9394
android_mode.error.cannot_create_avd = "Could not create a virtual device for the emulator.";

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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,17 @@ public void checkSDK(Editor editor) {
157157
if (userCancelledSDKSearch) return;
158158
checkingSDK = true;
159159
Throwable tr = null;
160-
if (sdk == null) {
160+
Boolean broken = false;
161+
if (sdk != null) { //when mode changes, sdk object is not recreated, this ensures that
162+
try {
163+
sdk = new AndroidSDK(sdk.getSdkFolder());
164+
} catch (AndroidSDK.BadSDKException | IOException e) {
165+
Messages.showWarning(AndroidMode.getTextString("android_mode.warn.cannot_load_sdk_title"),
166+
AndroidMode.getTextString("android_mode.warn.broken_sdk_folder",e.getMessage()));
167+
broken = true;
168+
}
169+
}
170+
if (sdk == null || broken) {
161171
try {
162172
sdk = AndroidSDK.load(true, editor);
163173
if (sdk == null) {

0 commit comments

Comments
 (0)