From 11836a1097605138a4aedd434ba91e976072198d Mon Sep 17 00:00:00 2001 From: Mido Date: Mon, 25 Nov 2024 12:09:40 +0100 Subject: [PATCH] lint-related improvements --- app/src/org/commcare/utils/FileUtil.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/org/commcare/utils/FileUtil.java b/app/src/org/commcare/utils/FileUtil.java index a65c33b5f..4fbbab555 100644 --- a/app/src/org/commcare/utils/FileUtil.java +++ b/app/src/org/commcare/utils/FileUtil.java @@ -700,6 +700,11 @@ public static long bytesToMeg(long bytes) { return bytes / MEGABYTE_IN_BYTES; } + /** + * Checks if a file exceeds the maximum allowed upload size + * @param mf File to check + * @return true if file size exceeds FormUploadUtil.MAX_BYTES + */ public static boolean isFileTooLargeToUpload(File mf) { return mf.length() > FormUploadUtil.MAX_BYTES; } @@ -781,9 +786,16 @@ public static String getFileLocationFromIntent(Intent intent) { return null; } - // Retruns true if location is either a content Uri or a valid file path + /** + * Returns true if location is either a content Uri or a valid file path + * @param location Location string to validate + * @return true if valid location, false otherwise + */ public static boolean isValidFileLocation(String location) { - return location != null && (location.startsWith("content://") || new File(location).exists()); + if (location == null) { + return false; + } + return location.startsWith("content://") || new File(location).exists(); } // returns the duration for a media file otherwise -1 in case of an error