Skip to content

Commit 539a446

Browse files
committed
removed wear, appcompat, and support-v4 packages from mode
1 parent 2bac06d commit 539a446

File tree

8 files changed

+61
-12
lines changed

8 files changed

+61
-12
lines changed

build.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@
7575
description="Create AndroidMode.zip and AndroidMode.txt">
7676
<mkdir dir="release" />
7777

78+
<!--
7879
<copy todir="mode">
7980
<fileset dir="core/library">
8081
<include name="*.jar" />
8182
</fileset>
8283
</copy>
83-
84+
-->
85+
8486
<zip destfile="${mode.dist.path}">
8587
<zipfileset dir="." prefix="AndroidMode">
8688
<include name="android-core.zip" />

mode/android-support-v4.jar

-1.36 MB
Binary file not shown.

mode/appcompat.zip

-2.17 MB
Binary file not shown.

mode/wearable-2.0.0.jar

-492 KB
Binary file not shown.

src/processing/mode/android/AndroidBuild.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,17 @@ public File createProject(boolean wear) throws IOException, SketchException {
310310
// Need to add appcompat as a library project (includes v4 support)
311311

312312
////////////////////////////////////////////////////////////////////////
313-
// first step: unpack the cardboard packages in the project's
314-
// libs folder:
315-
File appCompatFile = mode.getContentFile("mode/appcompat.zip");
316-
AndroidMode.extractFolder(appCompatFile, libsFolder, true);
313+
// first step: copy appcompat library project
314+
315+
// TODO: the support-v7 library project should be copied from the Android
316+
// Support Repository, and not from the Support Library.
317+
File appCompatFolderSrc = new File(sdk.getSupportLibrary(), "v7/appcompat");
318+
// Delete the project.properties files because Processing will regenerate
319+
// it when building the project
320+
File propFile = new File(appCompatFolderSrc, "project.properties");
321+
propFile.delete();
317322
File appCompatFolder = new File(libsFolder, "appcompat");
323+
Util.copyDir(appCompatFolderSrc, appCompatFolder);
318324

319325
////////////////////////////////////////////////////////////////////////
320326
// second step: create library projects
@@ -339,7 +345,7 @@ public File createProject(boolean wear) throws IOException, SketchException {
339345
} else {
340346
// Copy the v4 support package only, needed for the permission handling
341347
// in all other components
342-
File compatJarFile = mode.getContentFile("mode/android-support-v4.jar");
348+
File compatJarFile = new File(sdk.getSupportLibrary(), "v4/android-support-v4.jar");
343349
Util.copyFile(compatJarFile, new File(libsFolder, "android-support-v4.jar"));
344350
}
345351

@@ -349,9 +355,9 @@ public File createProject(boolean wear) throws IOException, SketchException {
349355
// cannot be resolved.
350356
// TODO: temporary hack until I find a better way to include the wearable aar
351357
// package included in the SDK:
352-
File wearJarFile = mode.getContentFile("mode/wearable-" + wear_version + ".jar");
353-
// System.out.println(wearJarFile.toString());
354-
Util.copyFile(wearJarFile, new File(libsFolder, "wearable-" + wear_version + ".jar"));
358+
File wearAarFile = new File(sdk.getWearableFolder(), wear_version + "/wearable-" + wear_version + ".aar");
359+
File explodeDir = new File(tmpFolder, "aar");
360+
AndroidMode.explodeAar(wearAarFile, explodeDir, new File(libsFolder, "wearable-" + wear_version + ".jar"));
355361
// }
356362

357363
// Copy any imported libraries (their libs and assets),
@@ -472,7 +478,7 @@ public File createHandheldProject(File wearFolder, File wearPackage)
472478

473479
// Copy the compatibility package, needed for the permission handling
474480
final File libsFolder = mkdirs(tmpFolder, "libs");
475-
File compatJarFile = mode.getContentFile("mode/android-support-v4.jar");
481+
File compatJarFile = new File(sdk.getSupportLibrary(), "v4/android-support-v4.jar");
476482
Util.copyFile(compatJarFile, new File(libsFolder, "android-support-v4.jar"));
477483

478484
// Create manifest file

src/processing/mode/android/AndroidMode.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import processing.app.RunnerListener;
3030
import processing.app.Sketch;
3131
import processing.app.SketchException;
32+
import processing.app.Util;
3233
import processing.app.ui.Editor;
3334
import processing.app.ui.EditorException;
3435
import processing.app.ui.EditorState;
@@ -442,6 +443,21 @@ public static void extractFolder(File file, File newPath,
442443
zip.close();
443444
}
444445

446+
447+
static public void explodeAar(File wearFile, File explodeDir, File jarFile)
448+
throws IOException {
449+
explodeAar(wearFile, explodeDir, jarFile, true);
450+
}
451+
452+
453+
static public void explodeAar(File wearFile, File explodeDir, File jarFile,
454+
boolean removeDir) throws IOException {
455+
extractFolder(wearFile, explodeDir, false);
456+
File classFile = new File(explodeDir, "classes.jar");
457+
Util.copyFile(classFile, jarFile);
458+
Util.removeDir(explodeDir);
459+
}
460+
445461

446462
static public void showMessage(String title, String text) {
447463
if (title == null) title = "Message";

src/processing/mode/android/AndroidSDK.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class AndroidSDK {
5555
private final File platformTools;
5656
private final File buildTools;
5757
private final File androidTool;
58+
private final File wearablePath;
59+
private final File supportLibPath;
5860

5961
private static final String SDK_DOWNLOAD_URL =
6062
"https://developer.android.com/studio/index.html#downloads";
@@ -148,6 +150,16 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
148150
AndroidBuild.target_sdk + " is missing from " + targetPlatform.getAbsolutePath());
149151
}
150152

153+
wearablePath = new File(folder, "extras/google/m2repository/com/google/android/support/wearable");
154+
if (!wearablePath.exists()) {
155+
throw new BadSDKException("There is no wearable folder in " + folder);
156+
}
157+
158+
supportLibPath = new File(folder, "extras/android/support");
159+
if (!supportLibPath.exists()) {
160+
throw new BadSDKException("There is no support library folder in " + folder);
161+
}
162+
151163
androidTool = findAndroidTool(tools);
152164

153165
String path = Platform.getenv("PATH");
@@ -251,6 +263,16 @@ public File getPlatformToolsFolder() {
251263
return platformTools;
252264
}
253265

266+
267+
public File getWearableFolder() {
268+
return wearablePath;
269+
}
270+
271+
272+
public File getSupportLibrary() {
273+
return supportLibPath;
274+
}
275+
254276

255277
/**
256278
* Checks a path to see if there's a tools/android file inside, a rough check

src/processing/mode/android/SDKDownloader.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,13 @@ public class SDKDownloader extends JDialog implements PropertyChangeListener {
5454
private static final String REPOSITORY_LIST = "repository-11.xml";
5555
private static final String ADDON_LIST = "addon.xml";
5656

57-
// The Android Support Repository does not include the android-support-v4 jar
58-
// file, so downloading the latest support library package available.
57+
// The Android Support Repository does not seem to include the
58+
// android-support-v4 jar file, even somewhere inside the aar packages, so
59+
// downloading the latest support library package available.
5960
// More info on the Support Library and latest releases:
6061
// https://developer.android.com/topic/libraries/support-library/index.html
62+
// This probably needs to be fixed so the Support Repository is used moving
63+
// forward.
6164
private static final String LEGACY_SUPPORT_LIBRARY = "support_r23.2.1.zip";
6265
private static final int SUPPORT_LIBRARY_SIZE = 10850402;
6366

0 commit comments

Comments
 (0)