From 7d66d5222cc9fbc6be52385c28c24de12cfdc48c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20P=C3=A9chard?= Date: Sun, 30 Oct 2016 09:59:38 +0100 Subject: [PATCH] SonarQube-induced minor refactoring --- .../java/fr/s13d/photobackup/PBApplication.java | 13 +++++++------ .../main/java/fr/s13d/photobackup/PBService.java | 1 + .../s13d/photobackup/PBWifiBroadcastReceiver.java | 3 +++ .../java/fr/s13d/photobackup/media/PBMedia.java | 11 +++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/fr/s13d/photobackup/PBApplication.java b/app/src/main/java/fr/s13d/photobackup/PBApplication.java index 4d4ec8a..64a1fbf 100644 --- a/app/src/main/java/fr/s13d/photobackup/PBApplication.java +++ b/app/src/main/java/fr/s13d/photobackup/PBApplication.java @@ -22,11 +22,13 @@ import android.preference.PreferenceManager; import java.util.Map; -import java.util.Set; import fr.s13d.photobackup.media.PBMediaStore; +/** + * Application of the app + */ public class PBApplication extends Application { private static final String LOG_TAG = "PBApplication"; @@ -52,11 +54,10 @@ public void onCreate() { if (BuildConfig.DEBUG) { Log.d(LOG_TAG, "Default SharedPreferences:"); - Map allPrefs = PreferenceManager.getDefaultSharedPreferences(this).getAll(); - Set set = allPrefs.keySet(); - for (String s : set) { - Log.d(LOG_TAG, s + "<" + allPrefs.get(s).getClass().getSimpleName() + "> = " - + allPrefs.get(s).toString()); + final Map allPrefs = PreferenceManager.getDefaultSharedPreferences(this).getAll(); + for (final Map.Entry entry : allPrefs.entrySet()) { + Log.d(LOG_TAG, entry.getKey() + "<" + entry.getValue().getClass().getSimpleName() + "> = " + + entry.getValue().toString()); } } } diff --git a/app/src/main/java/fr/s13d/photobackup/PBService.java b/app/src/main/java/fr/s13d/photobackup/PBService.java index f5d8486..1c6b6fa 100644 --- a/app/src/main/java/fr/s13d/photobackup/PBService.java +++ b/app/src/main/java/fr/s13d/photobackup/PBService.java @@ -149,6 +149,7 @@ public void onSyncMediaStoreTaskPostExecute() { ////////////////////////////////////// /** * Does nothing on receiving a message. + * @param message received message */ public void onMessage(final String message) { // Do nothing diff --git a/app/src/main/java/fr/s13d/photobackup/PBWifiBroadcastReceiver.java b/app/src/main/java/fr/s13d/photobackup/PBWifiBroadcastReceiver.java index 76691c0..db3aa8d 100644 --- a/app/src/main/java/fr/s13d/photobackup/PBWifiBroadcastReceiver.java +++ b/app/src/main/java/fr/s13d/photobackup/PBWifiBroadcastReceiver.java @@ -32,6 +32,9 @@ import fr.s13d.photobackup.media.PBMedia; +/** + * Receives wifi broadcast intents and starts media upload if required. + */ public class PBWifiBroadcastReceiver extends BroadcastReceiver { private static final String LOG_TAG = "PBWifiBroadcastReceiver"; private static long lastFiredOn = 0; diff --git a/app/src/main/java/fr/s13d/photobackup/media/PBMedia.java b/app/src/main/java/fr/s13d/photobackup/media/PBMedia.java index e65aac5..d79e12b 100644 --- a/app/src/main/java/fr/s13d/photobackup/media/PBMedia.java +++ b/app/src/main/java/fr/s13d/photobackup/media/PBMedia.java @@ -27,6 +27,10 @@ import fr.s13d.photobackup.Log; import fr.s13d.photobackup.PBApplication; + +/** + * Media object adding information over device medias. + */ public class PBMedia implements Serializable { private final int id; private final String path; @@ -34,6 +38,13 @@ public class PBMedia implements Serializable { private final SharedPreferences mediasPreferences; private String errorMessage; private PBMediaState state; + + /** + * Enumeration of all possible media states + * - waiting: the media waits for being uploaded; + * - synced: the media is synced with the server already; + * - error: an error occurred. + */ public enum PBMediaState { WAITING, SYNCED, ERROR }