From 7076c8dec78a5f34b2cfaaef9c898cec62b1263c Mon Sep 17 00:00:00 2001 From: Tobias_Groza <304016-Tobias_Groza@noreply.gitlab.com> Date: Fri, 13 Sep 2024 15:50:02 +0200 Subject: [PATCH] Fix getPercent to return the floored value instead of the rounded up val Follow up for !1424 With the previous implementation getPercent(1, 200)` returned 1 and getPercent(199, 200) returned 100. The latter is quite misleading, especially when dealing with bigger numbers where the notification could show 100% although the file is still downloading. --- app/src/main/java/org/fdroid/fdroid/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/fdroid/fdroid/Utils.java b/app/src/main/java/org/fdroid/fdroid/Utils.java index 4a69de4fb..e3724c4d8 100644 --- a/app/src/main/java/org/fdroid/fdroid/Utils.java +++ b/app/src/main/java/org/fdroid/fdroid/Utils.java @@ -747,7 +747,7 @@ public final class Utils { * @param total must never be zero! */ public static int getPercent(long current, long total) { - return (int) ((100L * current + total / 2) / total); + return (int) (100L * current / total); } @SuppressWarnings("unused")