Skip to content

Commit 9cc2dd9

Browse files
committed
set minimum dependency version
1 parent bfba601 commit 9cc2dd9

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

mode/src/processing/mode/android/AndroidBuild.java

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class AndroidBuild extends JavaBuild {
6363
static {
6464
TARGET_SDK = Preferences.get("android.sdk.target");
6565
if (TARGET_SDK == null || PApplet.parseInt(TARGET_SDK) < 26) {
66-
// Must be 8.0 or higher
6766
TARGET_SDK = "26";
6867
Preferences.set("android.sdk.target", TARGET_SDK);
6968
}
@@ -76,7 +75,7 @@ class AndroidBuild extends JavaBuild {
7675
static public String SUPPORT_VER;
7776
static {
7877
SUPPORT_VER = Preferences.get("android.sdk.support");
79-
if (SUPPORT_VER == null) {
78+
if (SUPPORT_VER == null || !versionCheck(SUPPORT_VER, "26.0.2")) {
8079
SUPPORT_VER = "26.0.2";
8180
Preferences.set("android.sdk.support", SUPPORT_VER);
8281
}
@@ -85,7 +84,7 @@ class AndroidBuild extends JavaBuild {
8584
static public String PLAY_SERVICES_VER;
8685
static {
8786
PLAY_SERVICES_VER = Preferences.get("android.sdk.play_services");
88-
if (PLAY_SERVICES_VER == null) {
87+
if (PLAY_SERVICES_VER == null || !versionCheck(PLAY_SERVICES_VER, "11.0.4")) {
8988
PLAY_SERVICES_VER = "11.0.4";
9089
Preferences.set("android.sdk.play_services", PLAY_SERVICES_VER);
9190
}
@@ -94,7 +93,7 @@ class AndroidBuild extends JavaBuild {
9493
static public String WEAR_VER;
9594
static {
9695
WEAR_VER = Preferences.get("android.sdk.wear");
97-
if (WEAR_VER == null) {
96+
if (WEAR_VER == null || !versionCheck(WEAR_VER, "2.1.0")) {
9897
WEAR_VER = "2.1.0";
9998
Preferences.set("android.sdk.wear", WEAR_VER);
10099
}
@@ -103,7 +102,7 @@ class AndroidBuild extends JavaBuild {
103102
static public String GVR_VER;
104103
static {
105104
GVR_VER = Preferences.get("android.sdk.gvr");
106-
if (GVR_VER == null) {
105+
if (GVR_VER == null || !versionCheck(GVR_VER, "1.150.0")) {
107106
GVR_VER = "1.150.0";
108107
Preferences.set("android.sdk.gvr", GVR_VER);
109108
}
@@ -980,4 +979,43 @@ private void installGradlew(File exportFolder) throws IOException {
980979
private File createExportFolder(String name) throws IOException {
981980
return AndroidUtil.createSubFolder(sketch.getFolder(), name);
982981
}
982+
983+
984+
static private boolean versionCheck(String currentVersion, String minVersion) {
985+
String[] currentPieces = currentVersion.split("\\.");
986+
String[] minPieces = minVersion.split("\\.");
987+
988+
if (currentPieces.length == 3 && minPieces.length == 3) {
989+
int currentMajor = PApplet.parseInt(currentPieces[0], -1);
990+
int currentMinor = PApplet.parseInt(currentPieces[1], -1);
991+
int currentMicro = PApplet.parseInt(currentPieces[2], -1);
992+
993+
int minMajor = PApplet.parseInt(minPieces[0], -1);
994+
int minMinor = PApplet.parseInt(minPieces[1], -1);
995+
int minMicro = PApplet.parseInt(minPieces[2], -1);
996+
997+
if (-1 < currentMajor && -1 < currentMinor && -1 < currentMicro &&
998+
-1 < minMajor && -1 < minMinor && -1 < minMicro) {
999+
if (currentMajor < minMajor) {
1000+
return false;
1001+
} else if (currentMajor == minMajor) {
1002+
if (currentMinor < minMinor) {
1003+
return false;
1004+
} if (currentMinor == minMinor) {
1005+
if (currentMicro < minMicro) {
1006+
return false;
1007+
} else {
1008+
return true;
1009+
}
1010+
} else {
1011+
return true;
1012+
}
1013+
} else {
1014+
return true;
1015+
}
1016+
}
1017+
}
1018+
1019+
return false;
1020+
}
9831021
}

0 commit comments

Comments
 (0)