瀏覽代碼

GM.java divided into more sections sections.

References across the code have been changed. All classes and values have been thoroughly documented.
seavenois 9 年之前
父節點
當前提交
d6866347ba

+ 1 - 1
app/build.gradle

@@ -19,7 +19,7 @@ android {
     }
 
     dexOptions {
-        incremental = true
+        //incremental = true
         preDexLibraries = false
         javaMaxHeapSize "2g"
     }

+ 1 - 1
app/src/main/java/com/ivalentin/margolariak/ActivityFutureLayout.java

@@ -135,7 +135,7 @@ public class ActivityFutureLayout extends Fragment implements OnMapReadyCallback
                 fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/");
                 //noinspection ResultOfMethodCallIgnored
                 fpath.mkdirs();
-                new DownloadImage(GM.API.SERVER + "/img/actividades/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image, images[i], GM.IMG.PREVIEW).execute();
+                new DownloadImage(GM.API.SERVER + "/img/actividades/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image, images[i], GM.IMG.SIZE.PREVIEW).execute();
             }
             images[i].setVisibility(View.VISIBLE);
             i ++;

+ 2 - 2
app/src/main/java/com/ivalentin/margolariak/ActivityLayout.java

@@ -137,7 +137,7 @@ public class ActivityLayout extends Fragment{
                         File fpath;
                         fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
                         fpath.mkdirs();
-                        new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.MINIATURE).execute();
+                        new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
                     }
                 }
                 cursorImage.close();
@@ -231,7 +231,7 @@ public class ActivityLayout extends Fragment{
                     File fpath;
                     fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
                     fpath.mkdirs();
-                    new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.MINIATURE).execute();
+                    new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
                 }
             }
             cursorImage.close();

+ 1 - 1
app/src/main/java/com/ivalentin/margolariak/ActivityPastLayout.java

@@ -107,7 +107,7 @@ public class ActivityPastLayout extends Fragment {
                 File fpath;
                 fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/");
                 fpath.mkdirs();
-                new DownloadImage(GM.API.SERVER + "/img/actividades/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image, images[i], GM.IMG.PREVIEW).execute();
+                new DownloadImage(GM.API.SERVER + "/img/actividades/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image, images[i], GM.IMG.SIZE.PREVIEW).execute();
              }
             images[i].setVisibility(View.VISIBLE);
             i ++;

+ 4 - 4
app/src/main/java/com/ivalentin/margolariak/AlbumLayout.java

@@ -117,7 +117,7 @@ public class AlbumLayout extends Fragment {
                 //If the image exists, set it.
 				try{
 					File file = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image);
-					ivLeft.setImageBitmap(GM.decodeSampledBitmapFromFile(file.getAbsolutePath(), GM.IMG.PREVIEW));
+					ivLeft.setImageBitmap(GM.decodeSampledBitmapFromFile(file.getAbsolutePath(), GM.IMG.SIZE.PREVIEW));
 				}
 				catch (Exception ex){
 					Log.e("Bitmap error", "Not loading image " + image + ": " + ex.toString());
@@ -128,7 +128,7 @@ public class AlbumLayout extends Fragment {
                 File fpath;
                 fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/");
                 fpath.mkdirs();
-				new DownloadImage(GM.API.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivLeft, GM.IMG.PREVIEW).execute();
+				new DownloadImage(GM.API.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivLeft, GM.IMG.SIZE.PREVIEW).execute();
             }
 
 			//Count comments
@@ -187,7 +187,7 @@ public class AlbumLayout extends Fragment {
                     //If the image exists, set it.
 					try {
 						File file = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image);
-						ivRight.setImageBitmap(GM.decodeSampledBitmapFromFile(file.getAbsolutePath(), GM.IMG.PREVIEW));
+						ivRight.setImageBitmap(GM.decodeSampledBitmapFromFile(file.getAbsolutePath(), GM.IMG.SIZE.PREVIEW));
 					}
 					catch (Exception ex){
 						Log.e("Bitmap error", "Not loading image " + image + ": " + ex.toString());
@@ -198,7 +198,7 @@ public class AlbumLayout extends Fragment {
                     File fpath;
                     fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/");
                     fpath.mkdirs();
-					new DownloadImage(GM.API.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivRight, GM.IMG.PREVIEW).execute();
+					new DownloadImage(GM.API.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivRight, GM.IMG.SIZE.PREVIEW).execute();
                 }
 
 				//Count comments

+ 1 - 1
app/src/main/java/com/ivalentin/margolariak/BlogLayout.java

@@ -201,7 +201,7 @@ public class BlogLayout extends Fragment{
                     File fpath;
                     fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/");
                     fpath.mkdirs();
-                    new DownloadImage(GM.API.SERVER + "/img/blog/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image, iv, GM.IMG.MINIATURE).execute();
+                    new DownloadImage(GM.API.SERVER + "/img/blog/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
                 }
             }
             else{

+ 500 - 47
app/src/main/java/com/ivalentin/margolariak/GM.java

@@ -316,62 +316,264 @@ final class GM {
 			/**
 			 * Queries to empty tables.
 			 */
+			@SuppressWarnings("unused")
 			final class EMPTY {
+
+				/**
+				 * Empties the table "activity".
+				 */
 				static final String ACTIVITY = "DELETE FROM activity;";
+
+				/**
+				 * Empties the table "activity_comment".
+				 */
 				static final String ACTIVITY_COMMENT = "DELETE FROM activity_comment;";
+
+				/**
+				 * Empties the table "activity_image".
+				 */
 				static final String ACTIVITY_IMAGE = "DELETE FROM activity_image;";
+
+				/**
+				 * Empties the table "activity_itinerary".
+				 */
 				static final String ACTIVITY_ITINERARY = "DELETE FROM activity_itinerary;";
+
+				/**
+				 * Empties the table "activity_tag".
+				 */
 				static final String ACTIVITY_TAG = "DELETE FROM activity_tag;";
+
+				/**
+				 * Empties the table "album".
+				 */
 				static final String ALBUM = "DELETE FROM album;";
+
+				/**
+				 * Empties the table "festival".
+				 */
 				static final String FESTIVAL = "DELETE FROM festival;";
+
+				/**
+				 * Empties the table "festival_day".
+				 */
 				static final String FESTIVAL_DAY = "DELETE FROM festival_day;";
+
+				/**
+				 * Empties the table "festival_event".
+				 */
 				static final String FESTIVAL_EVENT = "DELETE FROM festival_event;";
+
+				/**
+				 * Empties the table "festival_event".
+				 */
 				static final String FESTIVAL_EVENT_IMAGE = "DELETE FROM festival_event_image;";
+
+				/**
+				 * Empties the table "festival_offer".
+				 */
 				static final String FESTIVAL_OFFER = "DELETE FROM festival_offer;";
+
+				/**
+				 * Empties the table "location".
+				 */
 				static final String LOCATION = "DELETE FROM location;";
+
+				/**
+				 * Empties the table "notification".
+				 */
 				static final String NOTIFICATION = "DELETE FROM notification;";
+
+				/**
+				 * Empties the table "people".
+				 */
 				static final String PEOPLE = "DELETE FROM people;";
+
+				/**
+				 * Empties the table "photo".
+				 */
 				static final String PHOTO = "DELETE FROM photo;";
+
+				/**
+				 * Empties the table "photo_album".
+				 */
 				static final String PHOTO_ALBUM = "DELETE FROM photo_album;";
+
+				/**
+				 * Empties the table "photo_comment".
+				 */
 				static final String PHOTO_COMMENT = "DELETE FROM photo_comment;";
+
+				/**
+				 * Empties the table "place".
+				 */
 				static final String PLACE = "DELETE FROM place;";
+
+				/**
+				 * Empties the table "post".
+				 */
 				static final String POST = "DELETE FROM post;";
+
+				/**
+				 * Empties the table "post_comment".
+				 */
 				static final String POST_COMMENT = "DELETE FROM post_comment;";
+
+				/**
+				 * Empties the table "post_image".
+				 */
 				static final String POST_IMAGE = "DELETE FROM post_image;";
+
+				/**
+				 * Empties the table "post_tag".
+				 */
 				static final String POST_TAG = "DELETE FROM post_tag;";
+
+				/**
+				 * Empties the table "settings".
+				 */
 				static final String SETTINGS = "DELETE FROM settings;";
+
+				/**
+				 * Empties the table "sponsor".
+				 */
 				static final String SPONSOR = "DELETE FROM sponsor;";
+
+				/**
+				 * Empties the table "version".
+				 */
 				static final String VERSION = "DELETE FROM version;";
 			}
 
 			/**
 			 * Queries to remove and the recreate tables.
 			 */
+			@SuppressWarnings("unused")
 			final class RECREATE {
+
+				/**
+				 * Deletes and then recreates the table "activity".
+				 */
 				static final String ACTIVITY = GM.DB.QUERY.DROP.ACTIVITY + GM.DB.QUERY.CREATE.ACTIVITY;
+
+				/**
+				 * Deletes and then recreates the table "activity_comment".
+				 */
 				static final String ACTIVITY_COMMENT = GM.DB.QUERY.DROP.ACTIVITY_COMMENT + GM.DB.QUERY.CREATE.ACTIVITY_COMMENT;
+
+				/**
+				 * Deletes and then recreates the table "activity_image".
+				 */
 				static final String ACTIVITY_IMAGE = GM.DB.QUERY.DROP.ACTIVITY_IMAGE + GM.DB.QUERY.CREATE.ACTIVITY_IMAGE;
+
+				/**
+				 * Deletes and then recreates the table "itinerary".
+				 */
 				static final String ACTIVITY_ITINERARY = GM.DB.QUERY.DROP.ACTIVITY_ITINERARY + GM.DB.QUERY.CREATE.ACTIVITY_ITINERARY;
+
+				/**
+				 * Deletes and then recreates the table "activity_tag".
+				 */
 				static final String ACTIVITY_TAG = GM.DB.QUERY.DROP.ACTIVITY_TAG + GM.DB.QUERY.CREATE.ACTIVITY_TAG;
+
+				/**
+				 * Deletes and then recreates the table "album".
+				 */
 				static final String ALBUM = GM.DB.QUERY.DROP.ALBUM + GM.DB.QUERY.CREATE.ALBUM;
+
+				/**
+				 * Deletes and then recreates the table "festival".
+				 */
 				static final String FESTIVAL = GM.DB.QUERY.DROP.FESTIVAL + GM.DB.QUERY.CREATE.FESTIVAL;
+
+				/**
+				 * Deletes and then recreates the table "festival_day".
+				 */
 				static final String FESTIVAL_DAY = GM.DB.QUERY.DROP.FESTIVAL_DAY + GM.DB.QUERY.CREATE.FESTIVAL_DAY;
+
+				/**
+				 * Deletes and then recreates the table "festival_event".
+				 */
 				static final String FESTIVAL_EVENT = GM.DB.QUERY.DROP.FESTIVAL_EVENT + GM.DB.QUERY.CREATE.FESTIVAL_EVENT;
+
+				/**
+				 * Deletes and then recreates the table "festival_event_image".
+				 */
 				static final String FESTIVAL_EVENT_IMAGE = GM.DB.QUERY.DROP.FESTIVAL_EVENT_IMAGE + GM.DB.QUERY.CREATE.FESTIVAL_EVENT_IMAGE;
+
+				/**
+				 * Deletes and then recreates the table "festival_offer".
+				 */
 				static final String FESTIVAL_OFFER = GM.DB.QUERY.DROP.FESTIVAL_OFFER + GM.DB.QUERY.CREATE.FESTIVAL_OFFER;
+
+				/**
+				 * Deletes and then recreates the table "location".
+				 */
 				static final String LOCATION = GM.DB.QUERY.DROP.LOCATION + GM.DB.QUERY.CREATE.LOCATION;
+
+				/**
+				 * Deletes and then recreates the table "notification".
+				 */
 				static final String NOTIFICATION = GM.DB.QUERY.DROP.NOTIFICATION + GM.DB.QUERY.CREATE.NOTIFICATION;
+
+				/**
+				 * Deletes and then recreates the table "people".
+				 */
 				static final String PEOPLE = GM.DB.QUERY.DROP.PEOPLE + GM.DB.QUERY.CREATE.PEOPLE;
+
+				/**
+				 * Deletes and then recreates the table "photo".
+				 */
 				static final String PHOTO = GM.DB.QUERY.DROP.PHOTO + GM.DB.QUERY.CREATE.PHOTO;
+
+				/**
+				 * Deletes and then recreates the table "photo_album".
+				 */
 				static final String PHOTO_ALBUM = GM.DB.QUERY.DROP.PHOTO_ALBUM + GM.DB.QUERY.CREATE.PHOTO_ALBUM;
+
+				/**
+				 * Deletes and then recreates the table "photo_comment".
+				 */
 				static final String PHOTO_COMMENT = GM.DB.QUERY.DROP.PHOTO_COMMENT + GM.DB.QUERY.CREATE.PHOTO_COMMENT;
+
+				/**
+				 * Deletes and then recreates the table "place".
+				 */
 				static final String PLACE = GM.DB.QUERY.DROP.PLACE + GM.DB.QUERY.CREATE.PLACE;
+
+				/**
+				 * Deletes and then recreates the table "post".
+				 */
 				static final String POST = GM.DB.QUERY.DROP.POST + GM.DB.QUERY.CREATE.POST;
+
+				/**
+				 * Deletes and then recreates the table "post_comment".
+				 */
 				static final String POST_COMMENT = GM.DB.QUERY.DROP.POST_COMMENT + GM.DB.QUERY.CREATE.POST_COMMENT;
+
+				/**
+				 * Deletes and then recreates the table "post_image".
+				 */
 				static final String POST_IMAGE = GM.DB.QUERY.DROP.POST_IMAGE + GM.DB.QUERY.CREATE.POST_IMAGE;
+
+				/**
+				 * Deletes and then recreates the table "post_tag".
+				 */
 				static final String POST_TAG = GM.DB.QUERY.DROP.POST_TAG + GM.DB.QUERY.CREATE.POST_TAG;
+
+				/**
+				 * Deletes and then recreates the table "settings".
+				 */
 				static final String SETTINGS = GM.DB.QUERY.DROP.SETTINGS + GM.DB.QUERY.CREATE.SETTINGS;
+
+				/**
+				 * Deletes and then recreates the table "sponsor".
+				 */
 				static final String SPONSOR = GM.DB.QUERY.DROP.SPONSOR + GM.DB.QUERY.CREATE.SPONSOR;
+
+				/**
+				 * Deletes and then recreates the table "version".
+				 */
 				static final String VERSION = GM.DB.QUERY.DROP.VERSION + GM.DB.QUERY.CREATE.VERSION;
 			}
 		}
@@ -392,8 +594,19 @@ final class GM {
 		 */
 		static final class KEY {
 
+			/**
+			 * Key of the data string to store the user id with.
+			 */
 			static final String USER = "user_id";
+
+			/**
+			 * Key of the data to store the previous app version with.
+			 */
 			static final String PREVIOUS_APP_VERSION = "previous_app_version";
+
+			/**
+			 * Key of the data to store if ther is a festival season..
+			 */
 			static final String LABLANCA = "lablanca";
 		}
 
@@ -402,8 +615,20 @@ final class GM {
 		 */
 		static final class DEFAULT {
 
+
+			/**
+			 * Default string for the user.
+			 */
 			static final String USER = "";
+
+			/**
+			 * Default value for the previous app version data.
+			 */
 			static final int PREVIOUS_APP_VERSION = 0;
+
+			/**
+			 * Default value for the data that indicates if it's festival season.
+			 */
 			static final boolean LABLANCA = false;
 		}
 	}
@@ -413,6 +638,9 @@ final class GM {
 	 */
 	static final class PREFERENCES {
 
+		/**
+		 * Name of the file where preferences will be stored.
+		 */
 		static final String PREFERNCES = "preferences";
 
 		/**
@@ -420,7 +648,14 @@ final class GM {
 		 */
 		static final class KEY {
 
+			/**
+			 * Key to store the sync status.
+			 */
 			static final String SYNC = "performBackgroundSyncs";
+
+			/**
+			 * Key to store the notification preference status.
+			 */
 			static final String NOTIFICATIONS = "recieveNotificacions";
 		}
 
@@ -429,7 +664,14 @@ final class GM {
 		 */
 		static final class DEFAULT {
 
+			/**
+			 * Default value for the sync preference.
+			 */
 			static final boolean SYNC = true;
+
+			/**
+			 * Default value for the notification preference.
+			 */
 			static final boolean NOTIFICATIONS = true;
 		}
 	}
@@ -438,42 +680,196 @@ final class GM {
 	 * Used URLs.
 	 */
 	static class URL {
+
+		/**
+		 * URL of the project on GitHub.
+		 */
 		static final String GITHUB = "https://github.com/GasteizkoMargolariak/GasteizkoMargolariakApp";
+
+		/**
+		 * URL of the server.
+		 */
+		static final String SERVER = "http://margolariak.com";
 	}
 
 	/**
 	 * Info about the API.
 	 */
-	public static final class API {
-
+	static final class API {
 
+		/**
+		 * Name of the client.
+		 */
 		static final String CLIENT = "com.ivalentin.margolariak";
 
-		static final String SERVER = "http://margolariak.com";
+		/**
+		 * URL of the server.
+		 */
+		static final String SERVER = URL.SERVER;
+
+		/**
+		 * Utilities for the Sync V1 API.
+		 */
+		static final class SYNC {
+
+			/**
+			 * Path to the API.
+			 */
+			static final String PATH = "/API/v1/sync.php";
+
+			/**
+			 * Keys fotr the API parameters.
+			 */
+			static final class KEY {
+
+				/**
+				 * Key for the client identifier.
+				 */
+				static final String CLIENT = "client";
+
+				/**
+				 * Key for the user identifier.
+				 */
+				static final String USER = "user";
+
+				/**
+				 * Key for the action to perform with the API ("sync" or "version").
+				 */
+				static final String ACTION = "action";
+
+				/**
+				 * Key for the section to sync.
+				 */
+				static final String SECTION = "section";
 
-		static final String SYNC = "/API/v1/sync.php";
+				/**
+				 * Key for the current version of the database to send to the API.
+				 */
+				static final String VERSION = "version";
 
-		static final String ACTION = "sync";
-		static final String SECTION = "all";
-		static final String FORMAT = "json";
+				/**
+				 * Key to indicate to the API if the sync is being performed on the foreground.
+				 */
+				static final String FOREGROUND = "foreground";
+
+				/**
+				 * Key to indicate the format of the data for the API to send.
+				 */
+				static final String FORMAT = "format";
+
+				/**
+				 * Key to indicate the language to the API.
+				 */
+				static final String LANG = "lang";
+			}
+
+			/**
+			 * Values for the parameters.
+			 */
+			 static final class VALUE {
+
+				/**
+				 * Value for the ACTION key.
+				 */
+				static final String ACTION = "sync";
 
-		static final class KEY{
+				/**
+				 * Value for the SECTION key,
+				 */
+				 static final String SECTION = "all";
 
-			static final String CLIENT = "client";
-			static final String USER = "user";
-			static final String ACTION = "action";
-			static final String SECTION = "section";
-			static final String VERSION = "version";
-			static final String FOREGROUND = "foreground";
-			static final String FORMAT = "format";
-			static final String LANG = "lang";
+				/**
+				 * Value for the FORMAT key.
+				 */
+				static final String FORMAT = "json";
+			 }
 		}
 
+		/**
+		 * Utilities for the Location V1 API.
+		 */
+		static final class LOCATION {
 
+			/**
+			 * Path to the API.
+			 */
+			static final String PATH = "/API/v1/location.php";
 
+			/**
+			 * Keys fotr the API parameters.
+			 */
+			static final class KEY {
 
+				/**
+				 * Key to indicate the format of the data for the API to send.
+				 */
+				static final String FORMAT = "format";
+			}
+
+			/**
+			 * Values for the parameters.
+			 */
+			static final class VALUE {
+
+				/**
+				 * Value for the FORMAT key.
+				 */
+				static final String FORMAT = "json";
+			}
+		}
+
+		/**
+		 * Utilities for the Notifications V1 API.
+		 */
+		static final class NOTIFICATION {
+
+			/**
+			 * Path to the API.
+			 */
+			static final String PATH = "/API/v1/sync.php";
+
+			/**
+			 * Keys fotr the API parameters.
+			 */
+			static final class KEY {
+
+				/**
+				 * Key for the client identifier.
+				 */
+				static final String CLIENT = "client";
+
+				/**
+				 * Key for the user identifier.
+				 */
+				static final String USER = "user";
+
+				/**
+				 * Key for the action to perform with the API ("sync" or "version").
+				 */
+				static final String TARGET = "target";
+
+				/**
+				 * Key to indicate the format of the data for the API to send.
+				 */
+				static final String FORMAT = "format";
+			}
+
+			/**
+			 * Values for the parameters.
+			 */
+			static final class VALUE {
+
+				/**
+				 * Value for the FORMAT key.
+				 */
+				static final String FORMAT = "json";
+			}
+		}
 	}
 
+	/**
+	 * App permissions.
+	 */
 	static final class PERMISSION {
 
 		/**
@@ -483,6 +879,9 @@ final class GM {
 	}
 
 
+	/**
+	 * Periods to perform syncs.
+	 */
 	static final class PERIOD_SYNC {
 
 		/**
@@ -496,82 +895,93 @@ final class GM {
 		static final int NORMAL = 60 * 60 * 1000;
 	}
 
+	/**
+	 * Identifiers to differenciate schedules.
+	 */
 	static final class SCHEDULE {
 
+		/**
+		 * Key to pass as bundle.
+		 */
 		static final String KEY = "schedule";
 
 		/**
-		 * Constant to diferentiate schedules".
+		 * City schedule.
 		 */
 		static final int CITY = 0;
-		
+
+		/**
+		 * Margolari schedule.
+		 */
 		static final int MARGOLARIAK = 1;
 	}
-	
+
+	/**
+	 * Extras to pass to the main activity to open notifications.
+	 */
 	static final class EXTRA {
 
 		/**
-		 * Constant to set extras on the main intent.
+		 * Title of the notification.
 		 */
 		static final String TITLE = "title";
 
 		/**
-		 * Constant to set extras on the main intent.
+		 * Text of the notification.
 		 */
 		static final String TEXT = "text";
 
 		/**
-		 * Constant to set extras on the main intent.
+		 * Action for the button in the notification.
 		 */
 		static final String ACTION = "action";
 
+		/**
+		 * Sections to open with the notification.
+		 */
 		static final class SECTION {
 
 			/**
-			 * Value for {@see GM.EXTRA_ACTION} that opens the lablanca section.
+			 * Value for {@see GM.EXTRA.ACTION} that opens the lablanca section.
 			 */
 			static final String LABLANCA = "lablanca";
 
 			/**
-			 * Value for {@see GM.EXTRA_ACTION} that opens the official schedule.
+			 * Value for {@see GM.EXTRA.ACTION} that opens the official schedule.
 			 */
 			static final String SCHEDULE = "cityschedule";
 
 			/**
-			 * Value for {@see GM.EXTRA_ACTION} that opens the GM schedule.
+			 * Value for {@see GM.EXTRA.ACTION} that opens the GM schedule.
 			 */
 			static final String GMSCHEDULE = "gmschedule";
 
 			/**
-			 * Value for {@see GM.EXTRA_ACTION} that opens the location secton.
+			 * Value for {@see GM.EXTRA.ACTION} that opens the location secton.
 			 */
 			static final String LOCATION = "location";
 
 			/**
-			 * Value for {@see GM.EXTRA_ACTION} that opens the blog.
+			 * Value for {@see GM.EXTRA.ACTION} that opens the blog.
 			 */
 			static final String BLOG = "blog";
 
 			/**
-			 * Value for {@see GM.EXTRA_ACTION} that opens the activities section.
+			 * Value for {@see GM.EXTRA.ACTION} that opens the activities section.
 			 */
 			static final String ACTIVITIES = "activities";
 
 			/**
-			 * Value for {@see GM.EXTRA_ACTION} that opens the gallery section.
+			 * Value for {@see GM.EXTRA.ACTION} that opens the gallery section.
 			 */
 			static final String GALLERY = "gallery";
 		}
-		
-
 	}
 
-	public static final class SECTION {
-
-		/**
-		 *Bundle identifier to pass between fragments.
-		 */
-		static final String BUNDLE = "section";
+	/**
+	 * Identifiers for app sections.
+	 */
+	static final class SECTION {
 
 		/**
 		 * Constant for section "Home".
@@ -614,11 +1024,16 @@ final class GM {
 		static final byte GALLERY = 5;
 	}
 
-
-
+	/**
+	 * Keys for the location manager.
+	 */
 	static class LOCATION {
 
+		/**
+		 * Required accuracy for the location manager.
+		 */
 		static class ACCURACY {
+
 			/**
 			 * The desired accuracy of the GPS coordinates, used to provide location updates, in meters.
 			 */
@@ -630,25 +1045,56 @@ final class GM {
 			static final int TIME = 10000;
 		}
 
+		/**
+		 * Time interval to retrieve notifications.
+		 */
 		static final int INTERVAL = 10000;
 	}
 
+	/**
+	 * Data for the images.
+	 */
 	static final class IMG {
 
 		/**
 		 * Dimensions of the images in the database.
 		 */
-		static final int MINIATURE = 340;
-		static final int PREVIEW = 600;
-		static final int THUMB = 180;
-		static final int VIEW = 800;
+		static final class SIZE {
+
+			/**
+			 * Max width and height for miniature images.
+			 */
+			static final int MINIATURE = 340;
+
+			/**
+			 * Max width and height for preview images.
+			 */
+			static final int PREVIEW = 600;
+
+			/**
+			 * Max width and height for thumbnail images.
+			 */
+			@SuppressWarnings("unused")
+			static final int THUMB = 180;
+
+			/**
+			 * Max width and height for view images.
+			 */
+			static final int VIEW = 800;
+		}
 	}
 
 
 	/**
-	 *Programaticall loaded rows needs their margin to also be set programatically
+	 * Programmatically loaded rows needs their margin to also be set programmatically.
 	 */
-	static final int ENTRY_MARGIN = 8;
+	static final class UI {
+
+		/**
+		 * Margin for entries.
+		 */
+		static final int ENTRY_MARGIN = 8;
+	}
 
 	/**
 	 * Gets the language code for sql queries.
@@ -683,7 +1129,7 @@ final class GM {
 	 *
 	 * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
 	 */
-	public static String formatDate(String dateString, String lang, boolean includeTime){
+	static String formatDate(String dateString, String lang, boolean includeTime){
 
 		String output = "";
 
@@ -748,7 +1194,14 @@ final class GM {
 		return output;
 	}
 
-	public static Bitmap decodeSampledBitmapFromFile(String path, int size) { // BEST QUALITY MATCH
+	/**
+	 * Creates a bitmap from a image.
+	 *
+	 * @param path Path of the image.
+	 * @param size Max width and height.
+	 * @return A bitmap with the image.
+	 */
+	static Bitmap decodeSampledBitmapFromFile(String path, int size) { // BEST QUALITY MATCH
 
 		// First decode with inJustDecodeBounds=true to check dimensions
 		final BitmapFactory.Options options = new BitmapFactory.Options();

+ 1 - 1
app/src/main/java/com/ivalentin/margolariak/GalleryLayout.java

@@ -128,7 +128,7 @@ public class GalleryLayout extends Fragment{
                     File fpath;
                     fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/");
                     fpath.mkdirs();
-                    new DownloadImage(GM.API.SERVER + "/img/galeria/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/" + image, preview[i], GM.IMG.MINIATURE).execute();
+                    new DownloadImage(GM.API.SERVER + "/img/galeria/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/" + image, preview[i], GM.IMG.SIZE.MINIATURE).execute();
                 }
 
                 //Rotate the image

+ 8 - 8
app/src/main/java/com/ivalentin/margolariak/HomeLayout.java

@@ -475,7 +475,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 						File fpath;
 						fpath = new File(this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/");
 						fpath.mkdirs();
-						new DownloadImage(GM.API.SERVER + "/img/fiestas/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image, ivImage, GM.IMG.PREVIEW).execute();
+						new DownloadImage(GM.API.SERVER + "/img/fiestas/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image, ivImage, GM.IMG.SIZE.PREVIEW).execute();
 					}
 				}
 				else {
@@ -572,7 +572,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 				File fpath;
 				fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/");
 				fpath.mkdirs();
-				new DownloadImage(GM.API.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivPhoto[counter], GM.IMG.PREVIEW).execute();
+				new DownloadImage(GM.API.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivPhoto[counter], GM.IMG.SIZE.PREVIEW).execute();
 			}
 
 			//Set listeners for images
@@ -651,7 +651,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 
 			//Set margins
 			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-			layoutParams.setMargins(GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN);
+			layoutParams.setMargins(GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN);
 			entry.setLayoutParams(layoutParams);
 
 			//Set title
@@ -705,7 +705,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 					File fpath;
 					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
 					fpath.mkdirs();
-					new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.MINIATURE).execute();
+					new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
 				}
 			}
 			cursorImage.close();
@@ -789,7 +789,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 
 				//Set margins
 				LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-				layoutParams.setMargins(GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN);
+				layoutParams.setMargins(GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN);
 				entry.setLayoutParams(layoutParams);
 
 				//Set title
@@ -836,7 +836,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 						File fpath;
 						fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
 						fpath.mkdirs();
-						new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.MINIATURE).execute();
+						new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
 					}
 				}
 
@@ -916,7 +916,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 
 			//Set margins
 			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-			layoutParams.setMargins(GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN, GM.ENTRY_MARGIN);
+			layoutParams.setMargins(GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN, GM.UI.ENTRY_MARGIN);
 			entry.setLayoutParams(layoutParams);
 
 			//Set title
@@ -955,7 +955,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 					File fpath;
 					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/");
 					fpath.mkdirs();
-					new DownloadImage(GM.API.SERVER + "/img/blog/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image, iv, GM.IMG.MINIATURE).execute();
+					new DownloadImage(GM.API.SERVER + "/img/blog/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
 				}
 			}
 

+ 1 - 1
app/src/main/java/com/ivalentin/margolariak/LablancaLayout.java

@@ -91,7 +91,7 @@ public class LablancaLayout extends Fragment {
 				File fpath;
 				fpath = new File(this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/");
 				fpath.mkdirs();
-				new DownloadImage(GM.API.SERVER + "/img/fiestas/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image, headerImage, GM.IMG.PREVIEW).execute();
+				new DownloadImage(GM.API.SERVER + "/img/fiestas/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image, headerImage, GM.IMG.SIZE.PREVIEW).execute();
 			}
 		}
 		else{

+ 1 - 1
app/src/main/java/com/ivalentin/margolariak/PhotoLayout.java

@@ -208,7 +208,7 @@ public class PhotoLayout extends Fragment {
 			File fpath;
 			fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/view/");
 			fpath.mkdirs();
-			new DownloadImage(GM.API.SERVER + "/img/galeria/view/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/view/" + image, imageView, GM.IMG.VIEW).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+			new DownloadImage(GM.API.SERVER + "/img/galeria/view/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/view/" + image, imageView, GM.IMG.SIZE.VIEW).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
 		}
 
 		//Hide or show comments, as needed

+ 1 - 1
app/src/main/java/com/ivalentin/margolariak/PostLayout.java

@@ -110,7 +110,7 @@ public class PostLayout extends Fragment {
                 File fpath;
                 fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/preview/");
                 fpath.mkdirs();
-				new DownloadImage(GM.API.SERVER + "/img/blog/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/preview/" + image, images[i], GM.IMG.PREVIEW).execute();
+				new DownloadImage(GM.API.SERVER + "/img/blog/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/preview/" + image, images[i], GM.IMG.SIZE.PREVIEW).execute();
             }
             images[i].setVisibility(View.VISIBLE);
             i ++;

+ 9 - 9
app/src/main/java/com/ivalentin/margolariak/Sync.java

@@ -245,15 +245,15 @@ class Sync extends AsyncTask<Void, Void, Void> {
 	private String buildUrl(String user, int version, int foreground, String lang){
 		String url = "";
 		try {
-			url = GM.API.SERVER + GM.API.SYNC + "?" +
-					GM.API.KEY.CLIENT + "=" + URLEncoder.encode(GM.API.CLIENT, "UTF-8") + "&" +
-					GM.API.KEY.USER + "=" + URLEncoder.encode(user, "UTF-8") + "&" +
-					GM.API.KEY.ACTION + "=" + URLEncoder.encode(GM.API.ACTION, "UTF-8") + "&" +
-					GM.API.KEY.SECTION + "=" + URLEncoder.encode(GM.API.SECTION, "UTF-8") + "&" +
-					GM.API.KEY.VERSION + "=" + version + "&" +
-					GM.API.KEY.FOREGROUND + "=" + foreground + "&" +
-					GM.API.KEY.FORMAT + "=" + URLEncoder.encode(GM.API.FORMAT, "UTF-8") + "&" +
-					GM.API.KEY.LANG + "=" + URLEncoder.encode(lang, "UTF-8");
+			url = GM.API.SERVER + GM.API.SYNC.PATH + "?" +
+					GM.API.SYNC.KEY.CLIENT + "=" + URLEncoder.encode(GM.API.CLIENT, "UTF-8") + "&" +
+					GM.API.SYNC.KEY.USER + "=" + URLEncoder.encode(user, "UTF-8") + "&" +
+					GM.API.SYNC.KEY.ACTION + "=" + URLEncoder.encode(GM.API.SYNC.VALUE.ACTION, "UTF-8") + "&" +
+					GM.API.SYNC.KEY.SECTION + "=" + URLEncoder.encode(GM.API.SYNC.VALUE.SECTION, "UTF-8") + "&" +
+					GM.API.SYNC.KEY.VERSION + "=" + version + "&" +
+					GM.API.SYNC.KEY.FOREGROUND + "=" + foreground + "&" +
+					GM.API.SYNC.KEY.FORMAT + "=" + URLEncoder.encode(GM.API.SYNC.VALUE.FORMAT, "UTF-8") + "&" +
+					GM.API.SYNC.KEY.LANG + "=" + URLEncoder.encode(lang, "UTF-8");
 		}
 		catch (java.io.UnsupportedEncodingException ex){
 			Log.e("UTF-8", "Error encoding url for sync \"" + url + "\" - " + ex.toString());