From 809c0c32d716076a66d75a4defed20ba0f39a884 Mon Sep 17 00:00:00 2001 From: Reid Date: Thu, 20 Dec 2018 16:12:18 -0500 Subject: [PATCH] Add missing Javadocs to License, Media, and Utils classes (#1965) * Add missing Javadocs to License, Media, and Utils classes --- app/src/main/java/fr/free/nrw/commons/License.java | 4 ++++ app/src/main/java/fr/free/nrw/commons/Media.java | 7 +++++++ app/src/main/java/fr/free/nrw/commons/Utils.java | 9 +++++++++ .../commons/notification/NotificationUtils.java | 14 ++++++++++++-- .../nrw/commons/upload/DescriptionsAdapter.java | 4 ++++ .../free/nrw/commons/utils/ContributionUtils.java | 7 +++++++ 6 files changed, 43 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/License.java b/app/src/main/java/fr/free/nrw/commons/License.java index db893de16..017ded922 100644 --- a/app/src/main/java/fr/free/nrw/commons/License.java +++ b/app/src/main/java/fr/free/nrw/commons/License.java @@ -50,6 +50,10 @@ public class License { return template; } + /** + * Gets the license name. If name is null, return license key. + * @return license name as string. if name null, license key as String + */ public String getName() { if (name == null) { // hack diff --git a/app/src/main/java/fr/free/nrw/commons/Media.java b/app/src/main/java/fr/free/nrw/commons/Media.java index bae29b011..c70fb6da1 100644 --- a/app/src/main/java/fr/free/nrw/commons/Media.java +++ b/app/src/main/java/fr/free/nrw/commons/Media.java @@ -414,10 +414,17 @@ public class Media implements Parcelable { parcel.writeMap(descriptions); } + /** + * Set requested deletion to true + */ public void setRequestedDeletion(){ requestedDeletion = true; } + /** + * Get the value of requested deletion + * @return boolean requestedDeletion + */ public boolean getRequestedDeletion(){ return requestedDeletion; } diff --git a/app/src/main/java/fr/free/nrw/commons/Utils.java b/app/src/main/java/fr/free/nrw/commons/Utils.java index 12967639b..7ea05c668 100644 --- a/app/src/main/java/fr/free/nrw/commons/Utils.java +++ b/app/src/main/java/fr/free/nrw/commons/Utils.java @@ -173,6 +173,10 @@ public class Utils { return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("theme", false); } + /** + * Launches intent to rate app + * @param context + */ public static void rateApp(Context context) { final String appPackageName = BuildConfig.class.getPackage().getName(); try { @@ -183,6 +187,11 @@ public class Utils { } } + /** + * Launches intent for web URL + * @param context + * @param url + */ public static void handleWebUrl(Context context, Uri url) { Timber.d("Launching web url %s", url.toString()); Intent browserIntent = new Intent(Intent.ACTION_VIEW, url); diff --git a/app/src/main/java/fr/free/nrw/commons/notification/NotificationUtils.java b/app/src/main/java/fr/free/nrw/commons/notification/NotificationUtils.java index 7c19c516c..575e1a4dc 100644 --- a/app/src/main/java/fr/free/nrw/commons/notification/NotificationUtils.java +++ b/app/src/main/java/fr/free/nrw/commons/notification/NotificationUtils.java @@ -24,6 +24,11 @@ public class NotificationUtils { private static final String WIKIDATA_WIKI = "wikidatawiki"; private static final String WIKIPEDIA_WIKI = "enwiki"; + /** + * Returns true if the wiki attribute corresponds to commonswiki + * @param document + * @return boolean representing whether the wiki attribute corresponds to commonswiki + */ public static boolean isCommonsNotification(Node document) { if (document == null || !document.hasAttributes()) { return false; @@ -35,7 +40,7 @@ public class NotificationUtils { /** * Returns true if the wiki attribute corresponds to wikidatawiki * @param document - * @return + * @return boolean representing whether the wiki attribute corresponds to wikidatawiki */ public static boolean isWikidataNotification(Node document) { if (document == null || !document.hasAttributes()) { @@ -58,6 +63,11 @@ public class NotificationUtils { return WIKIPEDIA_WIKI.equals(element.getAttribute("wiki")); } + /** + * Returns document notification type + * @param document + * @return the document's NotificationType + */ public static NotificationType getNotificationType(Node document) { Element element = (Element) document; String type = element.getAttribute("type"); @@ -99,7 +109,7 @@ public class NotificationUtils { * Currently the app is interested in showing notifications just from the following three wikis: commons, wikidata, wikipedia * This function returns true only if the notification belongs to any of the above wikis and is of a known notification type * @param node - * @return + * @return whether a notification is from one of Commons, Wikidata or Wikipedia */ private static boolean isUsefulNotification(Node node) { return (isCommonsNotification(node) diff --git a/app/src/main/java/fr/free/nrw/commons/upload/DescriptionsAdapter.java b/app/src/main/java/fr/free/nrw/commons/upload/DescriptionsAdapter.java index 7186a519f..aae370e65 100644 --- a/app/src/main/java/fr/free/nrw/commons/upload/DescriptionsAdapter.java +++ b/app/src/main/java/fr/free/nrw/commons/upload/DescriptionsAdapter.java @@ -88,6 +88,10 @@ class DescriptionsAdapter extends RecyclerView.Adapter getDescriptions() { return descriptions; } diff --git a/app/src/main/java/fr/free/nrw/commons/utils/ContributionUtils.java b/app/src/main/java/fr/free/nrw/commons/utils/ContributionUtils.java index 7d080f4fc..6cb6d9281 100644 --- a/app/src/main/java/fr/free/nrw/commons/utils/ContributionUtils.java +++ b/app/src/main/java/fr/free/nrw/commons/utils/ContributionUtils.java @@ -63,6 +63,10 @@ public class ContributionUtils { } } + /** + * Creates a temporary directory and returns pathname + * @return + */ private static String decideTempDestinationFileName() { int i = 0; while (new File(TEMP_EXTERNAL_DIRECTORY + File.separatorChar + i + "_tmp").exists()) { @@ -79,6 +83,9 @@ public class ContributionUtils { return TEMP_EXTERNAL_DIRECTORY + File.separatorChar + timeStamp + multipleUploadRandomParameter + "_tmp"; } + /** + * Empties files in Temporary Directory + */ public static void emptyTemporaryDirectory() { File dir = new File(TEMP_EXTERNAL_DIRECTORY); if (dir.isDirectory())