Skip to content

Commit 99caf7e

Browse files
author
Dimitry Ivanov
committed
Update to include Pie (28)
1 parent 07be336 commit 99caf7e

File tree

6 files changed

+56
-13
lines changed

6 files changed

+56
-13
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
group 'ru.noties'
11-
version '1.0.1'
11+
version '1.0.2'
1212

1313
apply plugin: 'java'
1414
apply plugin: 'application'
@@ -36,8 +36,8 @@ dependencies {
3636
compile 'commons-io:commons-io:2.6'
3737
}
3838

39-
task wrapper(type: Wrapper) {
40-
gradleVersion '4.5'
39+
wrapper {
40+
gradleVersion '4.10.2'
4141
distributionType 'all'
4242
}
4343

gradle/wrapper/gradle-wrapper.jar

-459 Bytes
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Mon Jan 29 21:52:20 MSK 2018
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
43
zipStoreBase=GRADLE_USER_HOME
54
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

gradlew

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
3333
# Use the maximum available, or set MAX_FD != -1 to use that value.
3434
MAX_FD="maximum"
3535

36-
warn ( ) {
36+
warn () {
3737
echo "$*"
3838
}
3939

40-
die ( ) {
40+
die () {
4141
echo
4242
echo "$*"
4343
echo
@@ -155,7 +155,7 @@ if $cygwin ; then
155155
fi
156156

157157
# Escape application args
158-
save ( ) {
158+
save () {
159159
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160160
echo " "
161161
}

src/main/java/ru/noties/enhance/ApiVersion.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44

55
public class ApiVersion {
66

7+
@Nonnull
8+
public static ApiVersion latest() {
9+
return VERSIONS[VERSIONS.length - 1];
10+
}
11+
712
@Nonnull
813
public static ApiVersion of(int sdkInt) {
914
final ApiVersion version;
1015
if (sdkInt < 0
1116
|| (sdkInt - 1) >= LENGTH) {
12-
version = new ApiVersion(sdkInt, "unknown", "unknown");
17+
version = new ApiVersion(sdkInt, "unknown", "unknown", true);
1318
} else {
1419
version = VERSIONS[sdkInt - 1];
1520
}
@@ -19,11 +24,17 @@ public static ApiVersion of(int sdkInt) {
1924
private final int sdkInt;
2025
private final String versionName;
2126
private final String codeName;
27+
private final boolean unknown;
2228

2329
private ApiVersion(int sdkInt, @Nonnull String versionName, @Nonnull String codeName) {
30+
this(sdkInt, versionName, codeName, false);
31+
}
32+
33+
private ApiVersion(int sdkInt, @Nonnull String versionName, @Nonnull String codeName, boolean unknown) {
2434
this.sdkInt = sdkInt;
2535
this.versionName = versionName;
2636
this.codeName = codeName;
37+
this.unknown = unknown;
2738
}
2839

2940
public int getSdkInt() {
@@ -40,12 +51,17 @@ public String getCodeName() {
4051
return codeName;
4152
}
4253

54+
public boolean isUnknown() {
55+
return unknown;
56+
}
57+
4358
@Override
4459
public String toString() {
4560
return "ApiVersion{" +
4661
"sdkInt=" + sdkInt +
4762
", versionName='" + versionName + '\'' +
4863
", codeName='" + codeName + '\'' +
64+
", unknown=" + unknown +
4965
'}';
5066
}
5167

@@ -76,7 +92,8 @@ public String toString() {
7692
new ApiVersion(24, "7.0", "Nougat"),
7793
new ApiVersion(25, "7.1", "Nougat"),
7894
new ApiVersion(26, "8.0", "Oreo"),
79-
new ApiVersion(27, "8.1", "Oreo")
95+
new ApiVersion(27, "8.1", "Oreo"),
96+
new ApiVersion(28, "9.0", "Pie")
8097
};
8198

8299
private static final int LENGTH = VERSIONS.length;

src/main/java/ru/noties/enhance/Enhance.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
import ru.noties.enhance.options.EnhanceOptions;
55

66
import javax.annotation.Nonnull;
7+
import java.io.BufferedReader;
78
import java.io.File;
89
import java.io.IOException;
10+
import java.io.InputStreamReader;
11+
import java.util.Locale;
912

1013
import static ru.noties.enhance.Log.log;
1114

@@ -15,12 +18,36 @@ public class Enhance {
1518

1619
public static void main(String[] args) {
1720

18-
log("[Enhance] version: %s", EnhanceVersion.NAME);
21+
final ApiVersionFormatter apiVersionFormatter = ApiVersionFormatter.create();
1922

20-
final long start = System.currentTimeMillis();
23+
log("[Enhance] version: %s", EnhanceVersion.NAME);
24+
log("[Enhance] latest SDK version: %s", apiVersionFormatter.format(ApiVersion.latest()));
25+
log("[Enhance] https://github.com/noties/Enhance");
2126

2227
final EnhanceOptions options = EnhanceOptions.create(args);
2328

29+
// @since 1.0.2
30+
// check if we have this version info included and ask user if he/she want to proceed if
31+
// supplied sdk is not known to this library version
32+
final ApiVersion apiVersion = ApiVersion.of(options.sdk());
33+
if (apiVersion.isUnknown()) {
34+
35+
System.err.printf(Locale.US, "[Enhance] WARNING: specified SDK version %d (`%s`) is unknown to this " +
36+
"library version, do you wish to proceed anyway? (Y|N)%n", options.sdk(),
37+
apiVersionFormatter.format(apiVersion));
38+
39+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
40+
final String line = reader.readLine();
41+
if (!"y".equalsIgnoreCase(line)) {
42+
return;
43+
}
44+
} catch (IOException e) {
45+
throw new RuntimeException(e);
46+
}
47+
}
48+
49+
final long start = System.currentTimeMillis();
50+
2451
log("[Enhance] obtaining required files/folders");
2552

2653
final SdkHelper sdkHelper = SdkHelper.create(options);
@@ -94,7 +121,7 @@ public static void main(String[] args) {
94121

95122
log("[Enhance] processing source files");
96123

97-
final EnhanceWriter writer = EnhanceWriter.create(options.sourceFormat(), store, ApiVersionFormatter.create());
124+
final EnhanceWriter writer = EnhanceWriter.create(options.sourceFormat(), store, apiVersionFormatter);
98125
writer.write(source, sdkSources);
99126

100127
final long took = System.currentTimeMillis() - start;

0 commit comments

Comments
 (0)