Skip to content

Commit 864efe2

Browse files
committed
some name refactor
1 parent 7785fbd commit 864efe2

File tree

2 files changed

+18
-36
lines changed

2 files changed

+18
-36
lines changed

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

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import java.io.IOException;
4242
import java.io.InputStream;
4343
import java.io.OutputStream;
44-
import java.nio.file.DirectoryStream;
4544
import java.nio.file.Files;
4645
import java.nio.file.Path;
4746
import java.nio.file.Paths;
@@ -53,7 +52,6 @@
5352
import java.nio.file.attribute.PosixFilePermission;
5453

5554
import java.io.PrintWriter;
56-
import java.util.HashSet;
5755
import java.util.Set;
5856

5957
/**
@@ -140,14 +138,14 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
140138
}
141139

142140
// Retrieve the highest platform from the available targets
143-
ArrayList<SDKTarget> targets = getAvailableSdkTargets();
144-
int highestIncremental = 1;
141+
ArrayList<Target> targets = getAvailableSdkTargets();
142+
int highestBuild = 1;
145143
int highestTarget = 1;
146144
String highestName = "";
147-
for (SDKTarget targ: targets) {
148-
if (highestIncremental < targ.version_incremental) {
149-
highestIncremental = targ.version_incremental;
150-
highestTarget = targ.version_sdk;
145+
for (Target targ: targets) {
146+
if (highestBuild < targ.build) {
147+
highestBuild = targ.build;
148+
highestTarget = targ.sdk;
151149
highestName = targ.name;
152150
}
153151
}
@@ -157,23 +155,7 @@ public AndroidSDK(File folder) throws BadSDKException, IOException {
157155
AndroidBuild.TARGET_SDK, platforms.getAbsolutePath()));
158156
}
159157

160-
// Find the platform folder with the correct android.jar file.
161-
// Path platformPath = Paths.get(platforms.getAbsolutePath());
162-
// String highestPrefix = "android-" + highest;
163-
// File tmpFile;
164-
// try (DirectoryStream<Path> stream = Files.newDirectoryStream(platformPath, highestPrefix + "*")) {
165-
// for (Path entry: stream) {
166-
// if (Files.isDirectory(entry) && entry.getFileName().toString().startsWith(highestPrefix)) {
167-
// tmpFile = new File(entry.toString(), "android.jar");
168-
// if (tmpFile.exists()) {
169-
// System.out.println(tmpFile);
170-
// }
171-
// }
172-
// }
173-
// }
174-
175158
highestPlatform = new File(platforms, highestName);
176-
177159
androidJar = new File(highestPlatform, "android.jar");
178160
if (!androidJar.exists()) {
179161
throw new BadSDKException(AndroidMode.getTextString("android_sdk.error.missing_android_jar",
@@ -893,44 +875,44 @@ public Process getAdbProcess(final String... cmd)
893875
}
894876
}
895877

896-
static private class SDKTarget {
897-
public int version_sdk = 0;
898-
public String version_release = "";
899-
public int version_incremental = 0;
878+
static private class Target {
879+
public int sdk = 0;
880+
public String release = "";
881+
public int build = 0;
900882
public String name = "";
901883
}
902884

903-
private ArrayList<SDKTarget> getAvailableSdkTargets() throws IOException {
904-
ArrayList<SDKTarget> targets = new ArrayList<SDKTarget>();
885+
private ArrayList<Target> getAvailableSdkTargets() throws IOException {
886+
ArrayList<Target> targets = new ArrayList<Target>();
905887

906888
for (File platform : platforms.listFiles()) {
907889
File propFile = new File(platform, "build.prop");
908890
if (!propFile.exists()) continue;
909891

910-
SDKTarget target = new SDKTarget();
892+
Target target = new Target();
911893

912894
BufferedReader br = new BufferedReader(new FileReader(propFile));
913895
String line;
914896
while ((line = br.readLine()) != null) {
915897
String[] lineData = line.split("=");
916898

917899
if (lineData[0].equals("ro.system.build.version.incremental")) {
918-
target.version_incremental = Integer.valueOf(lineData[1]);
900+
target.build = Integer.valueOf(lineData[1]);
919901
}
920902

921903
if (lineData[0].equals("ro.build.version.release")) {
922-
target.version_release = lineData[1];
904+
target.release = lineData[1];
923905
}
924906

925907
if (lineData[0].equals("ro.build.version.sdk")) {
926-
target.version_sdk = Integer.valueOf(lineData[1]);
908+
target.sdk = Integer.valueOf(lineData[1]);
927909
}
928910

929911
target.name = platform.getName();
930912
}
931913
br.close();
932914

933-
if (target.version_sdk != 0 && target.version_incremental != 0 && target.name != "") targets.add(target);
915+
if (target.sdk != 0 && target.build != 0 && target.name != "") targets.add(target);
934916
}
935917

936918
return targets;

processing/mode/src/processing/mode/android/AndroidUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static public void extractFolder(File file, File newPath)
199199
// grab a zip file entry
200200
ZipEntry entry = zipFileEntries.nextElement();
201201
String currentEntry = entry.getName();
202-
202+
203203
File destFile = new File(newPath, currentEntry);
204204
//destFile = new File(newPath, destFile.getName());
205205
File destinationParent = destFile.getParentFile();

0 commit comments

Comments
 (0)