TheCacophonyProject / bird-monitor

Android application to regularly record birdsong for analysis
GNU General Public License v3.0
11 stars 9 forks source link

Consider upgrading Java version to 8 #38

Closed jackodsteel closed 5 years ago

jackodsteel commented 5 years ago

Currently it seems there's an attempt to restrict the code to be compatible with Java 6, for example using explicit types in generic creation (e.g: ArrayList<String> strings = new ArrayList<String>();).

There's really no need to do so, as upgrading the Java version will not break it on old devices. Currently the target version isn't explicitly defined in the build.gradle anyway, and if it is set to Java 6 (1.6), there are errors such as strings in switch are not supported in 1.6.

For this reason I'd recommend explicitly setting the target/source version to Java 8 (1.8), allowing for more language features such as generic type defs (ArrayList<>()), lambdas, and more.

Note that the IDE will still be smart enough to not allow Java 8 features that aren't supported on the minSdkVersion, such as streams. Although these are added in Java 8, they're not supported on Icecream Sandwich, so it will throw an error. This allows the best of both worlds.

timhot commented 5 years ago

Hi Jack, I hadn't realized Android would work with Java 8 - so thanks for enlightening me. So yes, I think your suggestion is a great idea.

mjs commented 5 years ago

:+1:

@jackodsteel Are you able to make the change and create a PR?