From 3f64fd4930448bfba8a560cadf2895eed20798ae Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 10 Jan 2020 17:18:28 +0100 Subject: [PATCH] init suggestedVersionCode to Integer.MIN_VALUE Java inits ints to 0. Since it is valid to have a negative Version Code, versionCodes are inited to Integer.MIN_VALUE; https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html closes #1063 --- app/src/main/java/org/fdroid/fdroid/data/App.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/data/App.java b/app/src/main/java/org/fdroid/fdroid/data/App.java index ed6288c23..8086a7124 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/App.java +++ b/app/src/main/java/org/fdroid/fdroid/data/App.java @@ -170,11 +170,13 @@ public class App extends ValueObject implements Comparable, Parcelable { public String suggestedVersionName; /** - * This matches {@code CurrentVersionCode} in build metadata files. + * This matches {@code CurrentVersionCode} in build metadata files. Java + * inits {@code int}s to 0. Since it is valid to have a negative Version + * Code, this is inited to {@link Integer#MIN_VALUE}; * * @see CurrentVersionCode */ - public int suggestedVersionCode; + public int suggestedVersionCode = Integer.MIN_VALUE; /** * Unlike other public fields, this is only accessible via a getter, to @@ -187,6 +189,7 @@ public class App extends ValueObject implements Comparable, Parcelable { /** * The version that will be automatically installed if the user does not * choose a specific version. + * TODO this should probably be converted to init to {@link Integer#MIN_VALUE} like {@link #suggestedVersionCode} */ public int autoInstallVersionCode;