Răsfoiți Sursa

GM.java divided into sections.

seavenois 9 ani în urmă
părinte
comite
500fcb5edd

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

@@ -78,7 +78,7 @@ public class ActivityFutureLayout extends Fragment implements OnMapReadyCallback
         }
 
         //Get data from database
-        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
         final Cursor cursor;
 		String lang = GM.getLang();
 
@@ -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.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.PREVIEW).execute();
             }
             images[i].setVisibility(View.VISIBLE);
             i ++;
@@ -244,7 +244,7 @@ public class ActivityFutureLayout extends Fragment implements OnMapReadyCallback
         Button btClose = (Button) dialog.findViewById(R.id.bt_schedule_close);
 
         //Get info about the event
-        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
         String lang = GM.getLang();
         Cursor cursor = db.rawQuery("SELECT activity_itinerary.id, activity_itinerary.name_" + lang + ", description_" + lang + ", place, start, end, place.name_" + lang + ", address_" + lang + ", lat, lon FROM activity_itinerary, place WHERE place = place.id AND activity_itinerary.id = " + id + ";", null);
         if (cursor.getCount() > 0){

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

@@ -72,7 +72,7 @@ public class ActivityLayout extends Fragment{
         //An inflater
         LayoutInflater factory = LayoutInflater.from(getActivity());
 
-        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
         final Cursor cursor;
         String lang = GM.getLang();
 
@@ -139,7 +139,7 @@ public class ActivityLayout extends Fragment{
                         File fpath;
                         fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
                         fpath.mkdirs();
-                        new DownloadImage(GM.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.MINIATURE).execute();
                     }
                 }
                 cursorImage.close();
@@ -235,7 +235,7 @@ public class ActivityLayout extends Fragment{
                     File fpath;
                     fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
                     fpath.mkdirs();
-                    new DownloadImage(GM.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.MINIATURE).execute();
                 }
             }
             cursorImage.close();

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

@@ -47,7 +47,7 @@ public class ActivityPastLayout extends Fragment {
         }
 
         //Get data from database
-        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
         final Cursor cursor;
         String lang = GM.getLang();
         cursor = db.rawQuery("SELECT id, title_" + lang+ " AS title, text_" + lang + " AS text, date, city, after_" + lang + " AS after FROM activity WHERE id = " + id + ";", null);
@@ -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.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.PREVIEW).execute();
              }
             images[i].setVisibility(View.VISIBLE);
             i ++;

+ 67 - 53
app/src/main/java/com/ivalentin/margolariak/AlarmReceiver.java

@@ -1,5 +1,7 @@
 package com.ivalentin.margolariak;
 
+//TODO: This doesn't work. Revise once the notification API is ready
+
 import android.app.AlarmManager;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
@@ -8,6 +10,8 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
 import android.graphics.BitmapFactory;
 import android.media.RingtoneManager;
 import android.support.v4.app.NotificationCompat;
@@ -51,7 +55,7 @@ public class AlarmReceiver extends BroadcastReceiver {
 			//Get the file
 			try{
 				fu = new FetchURL();
-				fu.Run(GM.SERVER + "/app/notifications.php");
+				fu.Run(GM.API.SERVER + "/app/notifications.php");
 				Log.d("Alarm", "Fetched notifications");
 
 				//Parse info
@@ -64,57 +68,67 @@ public class AlarmReceiver extends BroadcastReceiver {
 
 					//Is the notification seen already?
 					//TODO: Create a db table for this
-					if(!preferences.getBoolean(GM.NOTIFICATION_SEEN_ + id, false)){
-
-						String lang = GM.getLang();
-						String title = notification.substring(notification.indexOf("<title_" + lang + ">") + 10, notification.indexOf("</title_" + lang + ">"));
-						String text = notification.substring(notification.indexOf("<text_" + lang + ">") + 9, notification.indexOf("</text_" + lang + ">"));
-
-
-						//Get the notification manager ready
-						NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
-
-						//Variables to create intents for each notification
-						Intent resultIntent;
-						TaskStackBuilder stackBuilder;
-
-						//Send the notification.
-						NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
-								.setSmallIcon(R.drawable.ic_notification)
-								.setContentTitle(title)
-								.setAutoCancel(true)
-								.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
-								.setVibrate((new long[] { 400, 400, 400}))
-								.setColor(context.getResources().getColor(R.color.background_notification))
-								.setSubText(context.getString(R.string.app_name))
-								.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
-								.setContentText(text);
-
-						// Creates an intent for an Activity to be launched from the notification.
-						resultIntent = new Intent(context, MainActivity.class);
-						resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
-
-						//Set extras depending on type.
-						resultIntent.putExtra(GM.EXTRA_TEXT, text);
-						resultIntent.putExtra(GM.EXTRA_TITLE, title);
-						resultIntent.putExtra(GM.EXTRA_ACTION, action);
-
-						//Add the intent to the notification.
-						stackBuilder = TaskStackBuilder.create(context);
-						stackBuilder.addParentStack(MainActivity.class);
-
-						// Adds the Intent that starts the Activity to the top of the stack.
-						stackBuilder.addNextIntent(resultIntent);
-						PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
-						mBuilder.setContentIntent(resultPendingIntent);
-
-						//Actually send the notification.
-						mNotificationManager.notify(Integer.parseInt(id), mBuilder.build());
-
-						//Mark as notified
-						SharedPreferences.Editor editor = preferences.edit();
-						editor.putBoolean(GM.NOTIFICATION_SEEN_ + id, true);
-						editor.apply();
+
+					//Get data from database
+					SQLiteDatabase db = SQLiteDatabase.openDatabase(context.getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+					final Cursor cursor;
+					cursor = db.rawQuery("SELECT id, seen FROM notification WHERE id = " + id + ";", null);
+					if (cursor.getCount() == 0){
+
+					}
+					else {
+
+						if (cursor.getInt(1) == 0) {
+
+
+							String lang = GM.getLang();
+							String title = notification.substring(notification.indexOf("<title_" + lang + ">") + 10, notification.indexOf("</title_" + lang + ">"));
+							String text = notification.substring(notification.indexOf("<text_" + lang + ">") + 9, notification.indexOf("</text_" + lang + ">"));
+
+
+							//Get the notification manager ready
+							NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+
+							//Variables to create intents for each notification
+							Intent resultIntent;
+							TaskStackBuilder stackBuilder;
+
+							//Send the notification.
+							NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
+									.setSmallIcon(R.drawable.ic_notification)
+									.setContentTitle(title)
+									.setAutoCancel(true)
+									.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
+									.setVibrate((new long[]{400, 400, 400}))
+									.setColor(context.getResources().getColor(R.color.background_notification))
+									.setSubText(context.getString(R.string.app_name))
+									.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
+									.setContentText(text);
+
+							// Creates an intent for an Activity to be launched from the notification.
+							resultIntent = new Intent(context, MainActivity.class);
+							resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+
+							//Set extras depending on type.
+							resultIntent.putExtra(GM.EXTRA.TEXT, text);
+							resultIntent.putExtra(GM.EXTRA.TITLE, title);
+							resultIntent.putExtra(GM.EXTRA.ACTION, action);
+
+							//Add the intent to the notification.
+							stackBuilder = TaskStackBuilder.create(context);
+							stackBuilder.addParentStack(MainActivity.class);
+
+							// Adds the Intent that starts the Activity to the top of the stack.
+							stackBuilder.addNextIntent(resultIntent);
+							PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
+							mBuilder.setContentIntent(resultPendingIntent);
+
+							//Actually send the notification.
+							mNotificationManager.notify(Integer.parseInt(id), mBuilder.build());
+
+							//Mark as notified
+							db.execSQL("UPDATE notification SET seen = 1 WHERE id = " + id);
+						}
 					}
 				o = o.substring(o.indexOf("</notification>") + 15);
 				}
@@ -143,7 +157,7 @@ public class AlarmReceiver extends BroadcastReceiver {
 			PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
 
 			//Set the alarm cycle.
-			alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, GM.PERIOD_SYNC, GM.PERIOD_SYNC, alarmIntent);
+			alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, GM.PERIOD_SYNC.FESTIVALS, GM.PERIOD_SYNC.NORMAL, alarmIntent);
 
 			// Enable SampleBootReceiver to automatically restart the alarm when the device is rebooted.
 			ComponentName receiver = new ComponentName(context, BootReceiver.class);

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

@@ -49,7 +49,7 @@ public class AlbumLayout extends Fragment {
         }
 
         //Get data from database
-        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
         final Cursor cursor;
 		String lang = GM.getLang();
         cursor = db.rawQuery("SELECT id, name_" + lang + " AS name, description_" + lang + " AS description FROM album WHERE id = " + id + ";", null);
@@ -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.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.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.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.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.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.PREVIEW).execute();
                 }
 
 				//Count comments

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

@@ -60,7 +60,7 @@ public class BlogLayout extends Fragment{
         ((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_blog));
 
         //Get total posts
-        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
         Cursor cursor = db.rawQuery("SELECT id FROM post;", null);
         totalPost = cursor.getCount();
         cursor.close();
@@ -142,7 +142,7 @@ public class BlogLayout extends Fragment{
         //An inflater
         LayoutInflater factory = LayoutInflater.from(getActivity());
 
-        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
         final Cursor cursor;
         String lang = GM.getLang();
 
@@ -203,7 +203,7 @@ public class BlogLayout extends Fragment{
                     File fpath;
                     fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/");
                     fpath.mkdirs();
-                    new DownloadImage(GM.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.MINIATURE).execute();
                 }
             }
             cursorImage.close();

+ 425 - 240
app/src/main/java/com/ivalentin/margolariak/GM.java

@@ -18,72 +18,304 @@ import java.util.Locale;
  */
 final class GM {
 
+	/**
+	 * Contains info about the database.
+	 */
 	final class DB {
 
+		static final String NAME = "gm";
+
+		/**
+		 * Column types
+		 */
 		final class COLUMN {
+
+			/**
+			 * INT column.
+			 */
 			static final int INT = 0;
+
+			/**
+			 * VARCHAR column.
+			 */
 			static final int VARCHAR = 1;
+
+			/**
+			 * Datetime column.
+			 */
 			static final int DATETIME = 2;
 		}
 
+		/**
+		 * Usefull queries
+		 */
 		final class QUERY {
 
+			/**
+			 * Queries to create tables.
+			 */
 			final class CREATE {
+
+				/**
+				 * Creates the table "activity" on the database.
+				 */
 				static final String ACTIVITY = "CREATE TABLE IF NOT EXISTS activity (id INT, permalink VARCHAR, date DATETIME, city VARCHAR, title_es VARCHAR, title_en VARCHAR, title_eu VARCHAR, text_es VARCHAR, text_en VARCHAR, text_eu VARCHAR, after_es VARCHAR, after_en VARCHAR, after_eu VARCHAR, price INT, inscription INT, max_people INT, album INT, dtime DATETIME, comments INT);";
+
+				/**
+				 * Creates the table "activity_comment" on the database.
+				 */
 				static final String ACTIVITY_COMMENT = "CREATE TABLE IF NOT EXISTS activity_comment (id INT, activity INT, text VARCHAR, dtime DATETIME, username VARCHAR, lang VARCHAR);";
+
+				/**
+				 * Creates the table "activity_image" on the database.
+				 */
 				static final String ACTIVITY_IMAGE = "CREATE TABLE IF NOT EXISTS activity_image (id INT, activity INT, image VARCHAR, idx INT);";
+
+				/**
+				 * Creates the table "activity_itinerary" on the database.
+				 */
 				static final String ACTIVITY_ITINERARY = "CREATE TABLE IF NOT EXISTS activity_itinerary (id INT, activity INT, name_es VARCHAR, name_en VARCHAR, name_eu VARCHAR, description_es VARCHAR, description_en VARCHAR, description_eu VARCHAR, start DATETIME, end DATETIME, place INT);";
+
+				/**
+				 * Creates the table "activity_tag" on the database.
+				 */
 				static final String ACTIVITY_TAG = "CREATE TABLE IF NOT EXISTS activity_tag (activity INT, tag VARCHAR);";
+
+				/**
+				 * Creates the table "album" on the database.
+				 */
 				static final String ALBUM = "CREATE TABLE IF NOT EXISTS album (id INT, permalink VARCHAR, title_es VARCHAR, title_en VARCHAR, title_eu VARCHAR, description_es VARCHAR, description_en VARCHAR, description_eu VARCHAR, open INT, time DATETIME);";
+
+				/**
+				 * Creates the table "festival" on the database.
+				 */
 				static final String FESTIVAL = "CREATE TABLE IF NOT EXISTS festival (id INT, year INT, text_es VARCHAR, text_en VARCHAR, text_eu VARCHAR, summary_es VARCHAR, summary_en VARCHAR, summary_eu VARCHAR, img VARCHAR);";
+
+				/**
+				 * Creates the table "festival_day" on the database.
+				 */
 				static final String FESTIVAL_DAY = "CREATE TABLE IF NOT EXISTS festival_day (id INT, date DATETIME, name_es VARCHAR, name_en VARCHAR, name_eu VARCHAR, price INT);";
+
+				/**
+				 * Creates the table "festival_event" on the database.
+				 */
 				static final String FESTIVAL_EVENT = "CREATE TABLE IF NOT EXISTS festival_event (id INT, gm INT, title_es VARCHAR, title_en VARCHAR, title_eu VARCHAR, description_es VARCHAR, description_en VARCHAR, description_eu VARCHAR, host INT, place INT, start DATETIME, end DATETIME);";
+
+				/**
+				 * Creates the table "festival_event_image" on the database.
+				 */
 				static final String FESTIVAL_EVENT_IMAGE = "CREATE TABLE IF NOT EXISTS festival_event_image (id INT, event INT, image VARCHAR, idx INT);";
+
+				/**
+				 * Creates the table "festival_offer" on the database.
+				 */
 				static final String FESTIVAL_OFFER = "CREATE TABLE IF NOT EXISTS festival_offer (id INT, year INT, name_es VARCHAR, name_en VARCHAR, name_eu VARCHAR, description_es VARCHAR, description_en VARCHAR, description_eu VARCHAR, days INT, price INT);";
+
+				/**
+				 * Creates the table "location" on the database.
+				 */
 				static final String LOCATION = "CREATE TABLE IF NOT EXISTS location (id INT, dtime DATETIME, lat FLOAT, lon FLOAT, manual INT);";
-				static final String NOTIFICATION = "CREATE TABLE IF NOT EXISTS notification (id INT, dtime DATETIME, duration INT, action VARCHAR, title_es VARCHAR, title_en VARCHAR, title_eu VARCHAR, text_es VARCHAR, text_en VARCHAR, text_eu VARCHAR, internal INT);";
+
+				/**
+				 * Creates the table "notification" on the database.
+				 */
+				static final String NOTIFICATION = "CREATE TABLE IF NOT EXISTS notification (id INT, dtime DATETIME, duration INT, action VARCHAR, title_es VARCHAR, title_en VARCHAR, title_eu VARCHAR, text_es VARCHAR, text_en VARCHAR, text_eu VARCHAR, internal INT, seen INT DEFAULT 0);";
+
+				/**
+				 * Creates the table "people" on the database.
+				 */
 				static final String PEOPLE = "CREATE TABLE IF NOT EXISTS people (id INT, name_es VARCHAR, name_en VARCHAR, name_eu VARCHAR, link VARCHAR);";
+
+				/**
+				 * Creates the table "photo" on the database.
+				 */
 				static final String PHOTO = "CREATE TABLE IF NOT EXISTS photo (id INT, file VARCHAR, permalink VARCHAR, title_es VARCHAR, title_en VARCHAR, title_eu VARCHAR, description_es VARCHAR, description_en VARCHAR, description_eu VARCHAR, dtime DATETIME, uploaded DATETIME, place INT, width INT, height INT, size INT, username VARCHAR);";
+
+				/**
+				 * Creates the table "photo_album" on the database.
+				 */
 				static final String PHOTO_ALBUM = "CREATE TABLE IF NOT EXISTS photo_album (photo INT, album INT);";
+
+				/**
+				 * Creates the table "photo_comment" on the database.
+				 */
 				static final String PHOTO_COMMENT = "CREATE TABLE IF NOT EXISTS photo_comment (id INT, photo INT, text VARCHAR, dtime DATETIME, username VARCHAR, lang VARCHAR);";
+
+				/**
+				 * Creates the table "place" on the database.
+				 */
 				static final String PLACE = "CREATE TABLE IF NOT EXISTS place (id INT, name_es VARCHAR, name_en VARCHAR, name_eu VARCHAR, address_es VARCHAR, address_en VARCHAR, address_eu VARCHAR, cp VARCHAR, lat FLOAT, lon FLOAT);";
+
+				/**
+				 * Creates the table "post" on the database.
+				 */
 				static final String POST = "CREATE TABLE IF NOT EXISTS post (id INT, permalink VARCHAR, title_es VARCHAR, title_en VARCHAR, title_eu VARCHAR, text_es VARCHAR, text_en VARCHAR, text_eu VARCHAR, comments INT, username VARCHAR, dtime DATETIME);";
+
+				/**
+				 * Creates the table "post_comment" on the database.
+				 */
 				static final String POST_COMMENT = "CREATE TABLE IF NOT EXISTS post_comment (id INT, post INT, text VARCHAR, dtime DATETIME, username VARCHAR, lang VARCHAR);";
+
+				/**
+				 * Creates the table "photo" on the database.
+				 */
 				static final String POST_IMAGE = "CREATE TABLE IF NOT EXISTS post_image (id INT, post INT, image VARCHAR, idx INT);";
+
+				/**
+				 * Creates the table "post_tag" on the database.
+				 */
 				static final String POST_TAG = "CREATE TABLE IF NOT EXISTS post_tag (post INT, tag VARCHAR);";
+
+				/**
+				 * Creates the table "settings" on the database.
+				 */
 				static final String SETTINGS = "CREATE TABLE IF NOT EXISTS settings (name VARCHAR, value VARCHAR);";
+
+				/**
+				 * Creates the table "sponsor" on the database.
+				 */
 				static final String SPONSOR = "CREATE TABLE IF NOT EXISTS sponsor (id INT, name_es VARCHAR, name_en VARCHAR, name_eu VARCHAR, text_es VARCHAR, text_en VARCHAR, text_eu VARCHAR, image VARCHAR, address_es VARCHAR, address_en VARCHAR, address_eu VARCHAR, link VARCHAR, lat FLOAT, lon FLOAT);";
+
+				/**
+				 * Creates the table "version" on the database.
+				 */
 				static final String VERSION = "CREATE TABLE IF NOT EXISTS version (section VARCHAR, version INT);";
 			}
 
+			/**
+			 * Queries to remove tables.
+			 */
 			final class DROP {
+
+				/**
+				 * Deletes the table "activity" from the database.
+				 */
 				static final String ACTIVITY = "DROP TABLE activity;";
+
+				/**
+				 * Deletes the table "activity_comment" from the database.
+				 */
 				static final String ACTIVITY_COMMENT = "DROP TABLE activity_comment;";
+
+				/**
+				 * Deletes the table "activity_comment" from the database.
+				 */
 				static final String ACTIVITY_IMAGE = "DROP TABLE activity_image;";
+
+				/**
+				 * Deletes the table "activity_comment" from the database.
+				 */
 				static final String ACTIVITY_ITINERARY = "DROP TABLE activity_itinerary;";
+
+				/**
+				 * Deletes the table "activity_comment" from the database.
+				 */
 				static final String ACTIVITY_TAG = "DROP TABLE activity_tag;";
+
+				/**
+				 * Deletes the table "album" from the database.
+				 */
 				static final String ALBUM = "DROP TABLE album;";
+
+				/**
+				 * Deletes the table "festival" from the database.
+				 */
 				static final String FESTIVAL = "DROP TABLE festival;";
+
+				/**
+				 * Deletes the table "festival_day" from the database.
+				 */
 				static final String FESTIVAL_DAY = "DROP TABLE festival_day;";
+
+				/**
+				 * Deletes the table "festival_event" from the database.
+				 */
 				static final String FESTIVAL_EVENT = "DROP TABLE festival_event;";
+
+				/**
+				 * Deletes the table "festival_event_image" from the database.
+				 */
 				static final String FESTIVAL_EVENT_IMAGE = "DROP TABLE festival_event_image;";
+
+				/**
+				 * Deletes the table "festival_offer" from the database.
+				 */
 				static final String FESTIVAL_OFFER = "DROP TABLE festival_offer;";
+
+				/**
+				 * Deletes the table "location" from the database.
+				 */
 				static final String LOCATION = "DROP TABLE location;";
+
+				/**
+				 * Deletes the table "notification" from the database.
+				 */
 				static final String NOTIFICATION = "DROP TABLE notification;";
+
+				/**
+				 * Deletes the table "people" from the database.
+				 */
 				static final String PEOPLE = "DROP TABLE people;";
+
+				/**
+				 * Deletes the table "photo" from the database.
+				 */
 				static final String PHOTO = "DROP TABLE photo;";
+
+				/**
+				 * Deletes the table "photo_album" from the database.
+				 */
 				static final String PHOTO_ALBUM = "DROP TABLE photo_album;";
+
+				/**
+				 * Deletes the table "photo_comment" from the database.
+				 */
 				static final String PHOTO_COMMENT = "DROP TABLE photo_comment;";
+
+				/**
+				 * Deletes the table "place" from the database.
+				 */
 				static final String PLACE = "DROP TABLE place;";
+
+				/**
+				 * Deletes the table "post" from the database.
+				 */
 				static final String POST = "DROP TABLE post;";
+
+				/**
+				 * Deletes the table "post_comment" from the database.
+				 */
 				static final String POST_COMMENT = "DROP TABLE post_comment;";
+
+				/**
+				 * Deletes the table "post_image" from the database.
+				 */
 				static final String POST_IMAGE = "DROP TABLE post_image;";
+
+				/**
+				 * Deletes the table "post_tag" from the database.
+				 */
 				static final String POST_TAG = "DROP TABLE post_tag;";
+
+				/**
+				 * Deletes the table "settings" from the database.
+				 */
 				static final String SETTINGS = "DROP TABLE settings;";
+
+				/**
+				 * Deletes the table "sponsor" from the database.
+				 */
 				static final String SPONSOR = "DROP TABLE sponsor;";
+
+				/**
+				 * Deletes the table "version" from the database.
+				 */
 				static final String VERSION = "DROP TABLE version;";
 			}
 
+			/**
+			 * Queries to empty tables.
+			 */
 			final class EMPTY {
 				static final String ACTIVITY = "DELETE FROM activity;";
 				static final String ACTIVITY_COMMENT = "DELETE FROM activity_comment;";
@@ -112,6 +344,9 @@ final class GM {
 				static final String VERSION = "DELETE FROM version;";
 			}
 
+			/**
+			 * Queries to remove and the recreate tables.
+			 */
 			final class RECREATE {
 				static final String ACTIVITY = GM.DB.QUERY.DROP.ACTIVITY + GM.DB.QUERY.CREATE.ACTIVITY;
 				static final String ACTIVITY_COMMENT = GM.DB.QUERY.DROP.ACTIVITY_COMMENT + GM.DB.QUERY.CREATE.ACTIVITY_COMMENT;
@@ -142,17 +377,29 @@ final class GM {
 		}
 	}
 
+	/**
+	 * Keys and values of data that the app needs to store.
+	 */
 	static final class DATA {
 
+		/**
+		 * Name of the file where data will be stored.
+		 */
 		static final String DATA = "data";
 
+		/**
+		 * Keys of data that the app needs to store.
+		 */
 		static final class KEY {
 
-			static final String USER = "user-id";
+			static final String USER = "user_id";
 			static final String PREVIOUS_APP_VERSION = "previous_app_version";
 			static final String LABLANCA = "lablanca";
 		}
 
+		/**
+		 * Default values of data that the app needs to store.
+		 */
 		static final class DEFAULT {
 
 			static final String USER = "";
@@ -161,16 +408,25 @@ final class GM {
 		}
 	}
 
+	/**
+	 * Keys and values of the app settings.
+	 */
 	static final class PREFERENCES {
 
 		static final String PREFERNCES = "preferences";
 
+		/**
+		 * Keys of the app settings.
+		 */
 		static final class KEY {
 
 			static final String SYNC = "performBackgroundSyncs";
 			static final String NOTIFICATIONS = "recieveNotificacions";
 		}
 
+		/**
+		 * Default values of the app settings.
+		 */
 		static final class DEFAULT {
 
 			static final boolean SYNC = true;
@@ -178,287 +434,216 @@ final class GM {
 		}
 	}
 
+	/**
+	 * Used URLs.
+	 */
 	static class URL {
 		static final String GITHUB = "https://github.com/GasteizkoMargolariak/GasteizkoMargolariakApp";
 	}
 
-	static final String CLIENT = "com.ivalentin.margolariak";
-
 	/**
-	 * Address where the web server is
+	 * Info about the API.
 	 */
-	static final String SERVER = "http://margolariak.com";
+	public static final class API {
 
-	static final String SERVER_SYNC = "/API/v1/sync.php";
 
-	static final String SERVER_SYNC_KEY_CLIENT = "client";
-	static final String SERVER_SYNC_KEY_USER = "user";
-	static final String SERVER_SYNC_KEY_ACTION = "action";
-	static final String SERVER_SYNC_KEY_SECTION = "section";
-	static final String SERVER_SYNC_KEY_VERSION = "version";
-	static final String SERVER_SYNC_KEY_FOREGROUND = "foreground";
-	static final String SERVER_SYNC_KEY_FORMAT = "format";
-	static final String SERVER_SYNC_KEY_LANG = "lang";
+		static final String CLIENT = "com.ivalentin.margolariak";
 
-	static final String SERVER_SYNC_VALUE_ACTION = "sync";
-	static final String SERVER_SYNC_VALUE_SECTION = "all";
-	static final String SERVER_SYNC_VALUE_FORMAT = "json";
-
-	/**
-	 * Code for the location permission request
-	 */
-	static final int PERMISSION_LOCATION = 1;
-	
-	/**
-	 * Period of time (in seconds) at the end of witch the app will perform a sync.
-	 */
-	static final int PERIOD_SYNC = 20 * 60 * 1000;
-	
-	/**
-	 * Name of the preference to store the user code with.
-	 */
-	static final String USER_CODE = "prefcode";
-
-	/**
-	 * Constant to diferentiate schedules".
-	 */
-	static final String SCHEDULE = "schedule";
-	
-	/**
-	 * Constant to set extras on the main intent.
-	 */
-	static final String EXTRA_TITLE = "title";
-	
-	/**
-	 * Constant to set extras on the main intent.
-	 */
-	static final String EXTRA_TEXT = "text";
-	
-	/**
-	 * Constant to set extras on the main intent.
-	 */
-	static final String EXTRA_ACTION = "action";
-
-	/**
-	 * Value for {@see GM.EXTRA_ACTION} that opens the lablanca section.
-	 */
-	static final String EXTRA_ACTION_LABLANCA = "lablanca";
-
-	/**
-	 * Value for {@see GM.EXTRA_ACTION} that opens the official schedule.
-	 */
-	static final String EXTRA_ACTION_CITYSCHEDULE = "cityschedule";
-	
-	/**
-	 * Value for {@see GM.EXTRA_ACTION} that opens the GM schedule.
-	 */
-	static final String EXTRA_ACTION_GMSCHEDULE = "gmschedule";
-
-	/**
-	 * Value for {@see GM.EXTRA_ACTION} that opens the location secton.
-	 */
-	static final String EXTRA_ACTION_LOCATION = "location";
+		static final String SERVER = "http://margolariak.com";
 
-	/**
-	 * Value for {@see GM.EXTRA_ACTION} that opens the blog.
-	 */
-	static final String EXTRA_ACTION_BLOG = "blog";
+		static final String SYNC = "/API/v1/sync.php";
 
-	/**
-	 * Value for {@see GM.EXTRA_ACTION} that opens the activities section.
-	 */
-	static final String EXTRA_ACTION_ACTIVITIES = "activities";
+		static final String ACTION = "sync";
+		static final String SECTION = "all";
+		static final String FORMAT = "json";
 
-	/**
-	 * Value for {@see GM.EXTRA_ACTION} that opens the gallery section.
-	 */
-	static final String EXTRA_ACTION_GALLERY = "gallery";
-	
-	/**
-	 * Constant for section "Home".
-	 */
-	static final byte SECTION_HOME = 0;
+		static final class KEY{
 
-	/**
-	 * Constant for La Blanca section "Location".
-	 */
-	static final byte SECTION_LOCATION = 1;
+			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";
+		}
 
-	/**
-	 * Constant for section "La Blanca".
-	 */
-	static final byte SECTION_LABLANCA = 2;
 
-	/**
-	 * Constant for La Blanca section "Festival schedule".
-	 */
-	static final byte SECTION_LABLANCA_SCHEDULE = 20;
 
-	/**
-	 * Constant for La Blanca section "Gasteizko Margolariak Schedule".
-	 */
-	static final byte SECTION_LABLANCA_GM_SCHEDULE = 21;
 
-	/**
-	 * Constant for section "Activities".
-	 */
-	static final byte SECTION_ACTIVITIES = 3;
+	}
 
-	/**
-	 * Constant for section "Blog".
-	 */
-	static final byte SECTION_BLOG = 4;
+	static final class PERMISSION {
 
-	/**
-	 * Constant for section "Gallery".
-	 */
-	static final byte SECTION_GALLERY = 5;
+		/**
+		 * Code for the location permission request
+		 */
+		static final int LOCATION = 1;
+	}
 
-	/**
-	 * Name of the preference group for the app.
-	 */
-	//static final String PREF = "gmpreferences";
-	
-	/**
-	 * Name of the preference to store the database version with.
-	 */
-	//static final String PREF_DB_VERSION = "prefDbVersion";
 
-	/**
-	 * Name of the preference to store the previous app version.
-	 */
-	//static final String PREF_PREVIOUS_VERSION = "prefAppPreviousVersion";
+	static final class PERIOD_SYNC {
 
-	/**
-	 * Name of the preference to store the setting that allows user to upload comments.
-	 */
-	//static final String PREF_DB_PHOTOS = "prefDbPhotos";
+		/**
+		 * Period of time (in seconds) at the end of witch the app will perform a sync during the festivals.
+		 */
+		static final int FESTIVALS = 20 * 60 * 1000;
 
-	/**
-	 * Name of the preference that indicates if we are on festivals.
-	 */
-	//static final String PREF_DB_FESTIVALS = "prefDbFestivals";
+		/**
+		 * Period of time (in seconds) at the end of witch the app will perform a sync if no festivals.
+		 */
+		static final int NORMAL = 60 * 60 * 1000;
+	}
 
-	/**
-	 * Name of the preference indicating if the user wants to to receive notifications intended for the general public.
-	 */
-	//static final String PREF_NOTIFICATION = "prefNotification";
+	static final class SCHEDULE {
 
-	/**
-	 * Default value of the preference indicating if the user wants to to receive notifications intended for the general public.
-	 */
-	//static final int DEFAULT_PREF_NOTIFICATION = 1;
+		static final String KEY = "schedule";
 
-	/**
-	 * Header of a preference to indicate received notifications.
-	 */
-	static final String NOTIFICATION_SEEN_ ="notificationSeen";
-	
-	/**
-	 * Default value for the {//@link GM.PREF_DB_VERSION}  preference
-	 */
-	static final int DEFAULT_PREF_DB_VERSION = -2;
-	
-	/**
-	 * Name of the preference to store GM location's latitude.
-	 */
-	static final String PREF_GM_LATITUDE = "gmlat";
-	
-	/**
-	 * Name of the preference to store GM location's longitude.
-	 */
-	static final String PREF_GM_LONGITUDE = "gmlon";
+		/**
+		 * Constant to diferentiate schedules".
+		 */
+		static final int CITY = 0;
+		
+		static final int MARGOLARIAK = 1;
+	}
 	
-	/**
-	 * Name of the preference to store GM last location timestamp.
-	 */
-	static final String PREF_GM_LOCATION = "gmlocationtime";
-
-	/**
-	 * Name of the preference to store GM last location timestamp.
-	 */
-	static final String DEFAULT_PREF_GM_LOCATION = "19700101000000";
+	static final class EXTRA {
 
-	/**
-	 * Name of the preference indicating if the user wants to perform background syncs.
-	 */
-	static final String PREFERENCE_SYNC_SYNC = "pref_sync_sync";
-
-	/**
-	 * Default value for PREFERENCE_SYNC_SYNC.
-	 */
-	static final boolean DEFAULT_PREFERENCE_SYNC_SYNC = true;
+		/**
+		 * Constant to set extras on the main intent.
+		 */
+		static final String TITLE = "title";
 
-	/**
-	 * Name of the preference indicating if the user wants to to receive notifications intended for the general public.
-	 */
-	static final String PREFERENCE_SYNC_NOTIFICATIONS = "pref_sync_notifications";
+		/**
+		 * Constant to set extras on the main intent.
+		 */
+		static final String TEXT = "text";
 
-	/**
-	 * Default value for PREFERENCE_SYNC_NOTIFICATIONS.
-	 */
-	static final boolean DEFAULT_PREFERENCE_SYNC_NOTIFICATIONS = true;
+		/**
+		 * Constant to set extras on the main intent.
+		 */
+		static final String ACTION = "action";
 
-	/**
-	 * Name of the SharedPreference that stores how many kb have been sent in the foreground.
-	 */
-	static final String STORAGE_TRAFFIC_FG_SENT = "storage_traffic_fg_sent";
+		static final class SECTION {
 
-	/**
-	 * Name of the SharedPreference that stores how many kb have been received in the foreground.
-	 */
-	static final String STORAGE_TRAFFIC_FG_RECEIVED = "storage_traffic_fg_received";
-
-	/**
-	 * Name of the SharedPreference that stores how many kb have been sent in the background.
-	 */
-	static final String STORAGE_TRAFFIC_BG_SENT = "storage_traffic_bg_received";
-
-	/**
-	 * Name of the SharedPreference that stores how many kb have been received in the background.
-	 */
-	static final String STORAGE_TRAFFIC_BG_RECEIVED = "storage_traffic_bg_received";
-
-	static final String KEY_PREFERENCE_SYNC = "preference_key_sync";
+			/**
+			 * Value for {@see GM.EXTRA_ACTION} that opens the lablanca section.
+			 */
+			static final String LABLANCA = "lablanca";
 
-	static final String KEY_PREFERENCE_NOTIFICATION = "preference_key_notification";
+			/**
+			 * 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.
+			 */
+			static final String GMSCHEDULE = "gmschedule";
+
+			/**
+			 * 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.
+			 */
+			static final String BLOG = "blog";
+
+			/**
+			 * 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.
+			 */
+			static final String GALLERY = "gallery";
+		}
+		
 
-	static final String KEY_PREFERENCE_DATA = "preference_key_data";
+	}
 
-	static final String KEY_PREFERENCE_VERSION = "preference_key_version";
+	public static final class SECTION {
+
+		/**
+		 *Bundle identifier to pass between fragments.
+		 */
+		static final String BUNDLE = "section";
+
+		/**
+		 * Constant for section "Home".
+		 */
+		static final byte HOME = 0;
+
+		/**
+		 * Constant for La Blanca section "Location".
+		 */
+		static final byte LOCATION = 1;
+
+		/**
+		 * Constant for section "La Blanca".
+		 */
+		static final byte LABLANCA = 2;
+
+		/**
+		 * Constant for La Blanca section "Festival schedule".
+		 */
+		static final byte SCHEDULE = 20;
+
+		/**
+		 * Constant for La Blanca section "Gasteizko Margolariak Schedule".
+		 */
+		static final byte GM_SCHEDULE = 21;
+
+		/**
+		 * Constant for section "Activities".
+		 */
+		static final byte ACTIVITIES = 3;
+
+		/**
+		 * Constant for section "Blog".
+		 */
+		static final byte BLOG = 4;
+
+		/**
+		 * Constant for section "Gallery".
+		 */
+		static final byte GALLERY = 5;
+	}
 
-	static final String KEY_PREFERENCE_SOURCE = "preference_key_source";
 
-	static final String KEY_PREFERENCE_FEEDBACK = "preference_key_feedback";
 
-	static final int INTERVAL_LOCATION = 240000; //4 min
+	static class LOCATION {
 
-	static final int INTERVAL_SYNC_FESTIVALS = 600000; //10 min
+		static class ACCURACY {
+			/**
+			 * The desired accuracy of the GPS coordinates, used to provide location updates, in meters.
+			 */
+			static final int SPACE = 10;
 
-	static final int INTERVAL_SYNC_NO_FESTIVALS = 3600000; //60 min
+			/**
+			 * The desired accuracy of the GPS coordinates, used to provide location updates, in milliseconds.
+			 */
+			static final int TIME = 10000;
+		}
 
-	/**
-	 * Name of the database
-	 */
-	static final String DB_NAME = "gm";
+		static final int INTERVAL = 10000;
+	}
 
-	/**
-	 * The desired accuracy of the GPS coordinates, used to provide location updates, in meters.
-	 */
-	static final int LOCATION_ACCURACY_SPACE = 10;
+	static final class IMG {
 
-	/**
-	 * The desired accuracy of the GPS coordinates, used to provide location updates, in milliseconds.
-	 */
-	static final int LOCATION_ACCURACY_TIME = 10000;
+		/**
+		 * 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;
+	}
 
-	/**
-	 * Dimensions of the images in the database.
-	 */
-	static final int IMG_MINIATURE = 340;
-	static final int IMG_PREVIEW = 600;
-	static final int IMG_THUMB = 180;
-	static final int IMG_VIEW = 800;
 
 	/**
 	 *Programaticall loaded rows needs their margin to also be set programatically
@@ -473,7 +658,7 @@ final class GM {
 	 * @return Language two-letter code
 	 */
 	public static String getLang(){
-		String currLang = Locale.getDefault().getISO3Language();//getDisplayLanguage();
+		String currLang = Locale.getDefault().getISO3Language();
 		switch (currLang){
 			case "eng":
 				currLang = "en";

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

@@ -71,7 +71,7 @@ public class GalleryLayout extends Fragment{
         //An inflater
         LayoutInflater factory = LayoutInflater.from(getActivity());
 
-        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
         final Cursor cursor;
 		String lang = GM.getLang();
 
@@ -125,7 +125,7 @@ public class GalleryLayout extends Fragment{
                     File fpath;
                     fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/");
                     fpath.mkdirs();
-                    new DownloadImage(GM.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.MINIATURE).execute();
                 }
                 i ++;
             }

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

@@ -109,14 +109,14 @@ public class HomeLayout extends Fragment implements LocationListener {
 
 		//Request location permissions if not set
 		if (ActivityCompat.checkSelfPermission(view.getContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(view.getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
-			ActivityCompat.requestPermissions(this.getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, GM.PERMISSION_LOCATION);
+			ActivityCompat.requestPermissions(this.getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, GM.PERMISSION.LOCATION);
 		}
 
 		//Set Location manager
 		//TODO: Only do this if location is required
 		locationManager = (LocationManager) view.getContext().getSystemService(Context.LOCATION_SERVICE);
 		if (!(ActivityCompat.checkSelfPermission(view.getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(view.getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
-			locationManager.requestLocationUpdates(locationManager.getBestProvider(new Criteria(), true), GM.LOCATION_ACCURACY_TIME, GM.LOCATION_ACCURACY_SPACE, this);
+			locationManager.requestLocationUpdates(locationManager.getBestProvider(new Criteria(), true), GM.LOCATION.ACCURACY.TIME, GM.LOCATION.ACCURACY.SPACE, this);
 			onLocationChanged(locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER));
 		}
 
@@ -165,7 +165,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 			return count;
 		}
 
-		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 		Calendar calendar = Calendar.getInstance();
 		Calendar calendarEnd;
 		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
@@ -226,7 +226,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 			tvRowPlace.setText(cursorNow.getString(6));
 
 			//Set icon
-			if (gm == GM.SECTION_LABLANCA_GM_SCHEDULE) {
+			if (gm == GM.SECTION.GM_SCHEDULE) {
 				ImageView pinPoint = (ImageView) entry.findViewById(R.id.iv_row_home_schedule_pinpoint);
 				pinPoint.setImageResource(getResources().getIdentifier("com.ivalentin.gm:drawable/pinpoint_gm", null, null));
 			}
@@ -270,7 +270,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 			tvRowPlace.setText(cursorNext.getString(6));
 
 			//Set icon
-			if (gm == GM.SECTION_LABLANCA_GM_SCHEDULE) {
+			if (gm == GM.SECTION.GM_SCHEDULE) {
 				ImageView pinPoint = (ImageView) entry.findViewById(R.id.iv_row_home_schedule_pinpoint);
 				pinPoint.setImageResource(getResources().getIdentifier("com.ivalentin.gm:drawable/pinpoint_gm", null, null));
 			}
@@ -293,7 +293,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 				section.setOnClickListener(new OnClickListener() {
 					@Override
 					public void onClick(View v) {
-						((MainActivity) getActivity()).loadSection(GM.SECTION_LABLANCA_GM_SCHEDULE);
+						((MainActivity) getActivity()).loadSection(GM.SECTION.GM_SCHEDULE);
 					}
 				});
 
@@ -301,7 +301,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 				section.setOnClickListener(new OnClickListener() {
 					@Override
 					public void onClick(View v) {
-						((MainActivity) getActivity()).loadSection(GM.SECTION_LABLANCA_SCHEDULE);
+						((MainActivity) getActivity()).loadSection(GM.SECTION.SCHEDULE);
 					}
 				});
 			}
@@ -429,12 +429,12 @@ public class HomeLayout extends Fragment implements LocationListener {
 			llSection.setOnClickListener(new OnClickListener() {
 				@Override
 				public void onClick(View v) {
-					((MainActivity) getActivity()).loadSection(GM.SECTION_LABLANCA);
+					((MainActivity) getActivity()).loadSection(GM.SECTION.LABLANCA);
 				}
 			});
 
 			//Get data from the database of the future activities
-			SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+			SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 			int year = Calendar.getInstance().get(Calendar.YEAR);
 			String lang = GM.getLang();
 			Cursor cursor = db.rawQuery("SELECT text_" + lang + ", img FROM festival WHERE year = " + year + ";", null);
@@ -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.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.PREVIEW).execute();
 					}
 				}
 				else {
@@ -497,8 +497,8 @@ public class HomeLayout extends Fragment implements LocationListener {
 	 */
 	private boolean setUpLocation(Location location, View view) {
 		SharedPreferences preferences = view.getContext().getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
-		//Do this from db
-		if (!preferences.getString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION).equals(GM.DEFAULT_PREF_GM_LOCATION)) {
+		//TODO Do this from db
+		/*if (!preferences.getString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION).equals(GM.DEFAULT_PREF_GM_LOCATION)) {
 			try {
 				Double lat = Double.longBitsToDouble(preferences.getLong(GM.PREF_GM_LATITUDE, 0));
 				Double lon = Double.longBitsToDouble(preferences.getLong(GM.PREF_GM_LONGITUDE, 0));
@@ -516,7 +516,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 				Log.e("Location", "Couldn't set up home location section: " + ex.toString());
 			}
 
-		}
+		}*/
 		return false;
 	}
 
@@ -537,7 +537,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		llGallery.setOnClickListener(new OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				((MainActivity) getActivity()).loadSection(GM.SECTION_GALLERY);
+				((MainActivity) getActivity()).loadSection(GM.SECTION.GALLERY);
 			}
 		});
 
@@ -549,7 +549,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		ivPhoto[3] = (ImageView) view.findViewById(R.id.iv_home_section_gallery_3);
 
 		//Get data from the database of the future activities
-		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 		Cursor cursor = db.rawQuery("SELECT id, album, file, uploaded FROM photo, photo_album WHERE id = photo ORDER BY uploaded DESC LIMIT 4;", null);
 
 		while (cursor.moveToNext()) {
@@ -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.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.PREVIEW).execute();
 			}
 
 			//Set listeners for images
@@ -623,7 +623,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		String lang = GM.getLang();
 
 		//Get data from the database of the future activities
-		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 		Cursor cursor = db.rawQuery("SELECT id, date, city, title_" + lang + " AS title, text_" + lang + " AS text, price, after_" + lang + " AS after FROM activity WHERE date < date('now') ORDER BY date DESC LIMIT 2;", null);
 
 		//Show section
@@ -634,7 +634,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		llActivitiesPast.setOnClickListener(new OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				((MainActivity) getActivity()).loadSection(GM.SECTION_ACTIVITIES);
+				((MainActivity) getActivity()).loadSection(GM.SECTION.ACTIVITIES);
 			}
 		});
 
@@ -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.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.MINIATURE).execute();
 				}
 			}
 			cursorImage.close();
@@ -764,7 +764,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		LayoutInflater factory = LayoutInflater.from(getActivity());
 
 		//Get data from the database of the future activities
-		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 		Cursor cursor = db.rawQuery("SELECT id, date, city, title_" + lang + " AS title, text_" + lang + " AS text, price FROM activity WHERE date >= date('now') ORDER BY date LIMIT 2;", null);
 
 		//If there are future activities...
@@ -778,7 +778,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 			llActivitiesFuture.setOnClickListener(new OnClickListener() {
 				@Override
 				public void onClick(View v) {
-					((MainActivity) getActivity()).loadSection(GM.SECTION_ACTIVITIES);
+					((MainActivity) getActivity()).loadSection(GM.SECTION.ACTIVITIES);
 				}
 			});
 
@@ -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.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.MINIATURE).execute();
 					}
 				}
 
@@ -891,7 +891,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		llBlog.setOnClickListener(new OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				((MainActivity) getActivity()).loadSection(GM.SECTION_BLOG);
+				((MainActivity) getActivity()).loadSection(GM.SECTION.BLOG);
 			}
 		});
 
@@ -902,7 +902,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		//An inflater
 		LayoutInflater factory = LayoutInflater.from(getActivity());
 
-		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 		final Cursor cursor;
 
 		//Get data from the database
@@ -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.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.MINIATURE).execute();
 				}
 			}
 

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

@@ -50,7 +50,7 @@ class HomeSectionLocation extends AsyncTask<Void, Void, Void> {
 		try {
 
 			FetchURL fu = new FetchURL();
-			fu.Run(GM.SERVER + "/app/location.php");
+			fu.Run(GM.API.SERVER + "/app/location.php");
 			//All the info
 			o = fu.getOutput().toString();
 
@@ -78,12 +78,12 @@ class HomeSectionLocation extends AsyncTask<Void, Void, Void> {
 		if (isLocationReported){
 
 			//TODO: Do this on a db table
-			SharedPreferences preferences = view.getContext().getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
+			/*SharedPreferences preferences = view.getContext().getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
 			SharedPreferences.Editor editor = preferences.edit();
 			editor.putLong(GM.PREF_GM_LATITUDE, Double.doubleToLongBits(coord.latitude));
 			editor.putLong(GM.PREF_GM_LONGITUDE, Double.doubleToLongBits(coord.longitude));
 			editor.putString(GM.PREF_GM_LOCATION, new SimpleDateFormat("yyyyMMddHHmmss", Locale.US).format(Calendar.getInstance().getTime()));
-			editor.apply();
+			editor.apply();*/
 
 			//Show menu entry
 			//LinearLayout menuEntry = (LinearLayout) activity.findViewById(R.id.rl_menu_location);
@@ -95,7 +95,7 @@ class HomeSectionLocation extends AsyncTask<Void, Void, Void> {
 			section.setOnClickListener(new View.OnClickListener(){
 				@Override
 				public void onClick(View v) {
-					((MainActivity) v.getContext()).loadSection(GM.SECTION_LOCATION);
+					((MainActivity) v.getContext()).loadSection(GM.SECTION.LOCATION);
 				}
 			});
 

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

@@ -58,7 +58,7 @@ public class LablancaLayout extends Fragment {
 		//Get database info from the database
 		String lang = GM.getLang();
 		int year = Calendar.getInstance().get(Calendar.YEAR);
-		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 		Cursor cursor = db.rawQuery("SELECT text_" + lang + ", img FROM festival WHERE year = " + year + ";", null);
 		cursor.moveToFirst();
 
@@ -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.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.PREVIEW).execute();
 			}
 		}
 		else{
@@ -189,14 +189,14 @@ public class LablancaLayout extends Fragment {
 		gmSchedule.setOnClickListener(new View.OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				((MainActivity) getActivity()).loadSection(GM.SECTION_LABLANCA_GM_SCHEDULE);
+				((MainActivity) getActivity()).loadSection(GM.SECTION.GM_SCHEDULE);
 			}
 		});
 
 		citySchedule.setOnClickListener(new View.OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				((MainActivity) getActivity()).loadSection(GM.SECTION_LABLANCA_SCHEDULE);
+				((MainActivity) getActivity()).loadSection(GM.SECTION.SCHEDULE);
 			}
 		});
 

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

@@ -70,7 +70,7 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 		//Set up
 		locationManager = (LocationManager) v.getContext().getSystemService(Context.LOCATION_SERVICE);
 		if (!(ActivityCompat.checkSelfPermission(v.getContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(v.getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)){
-			locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, GM.LOCATION_ACCURACY_TIME, GM.LOCATION_ACCURACY_SPACE, this);
+			locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, GM.LOCATION.ACCURACY.TIME, GM.LOCATION.ACCURACY.SPACE, this);
 		}
 
 		//Set the title
@@ -98,7 +98,7 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 			mapView.onResume();
 		}
 		if (!(ActivityCompat.checkSelfPermission(v.getContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(v.getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)){
-			locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, GM.LOCATION_ACCURACY_TIME, GM.LOCATION_ACCURACY_SPACE, this);
+			locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, GM.LOCATION.ACCURACY.TIME, GM.LOCATION.ACCURACY.SPACE, this);
 		}
 		super.onResume();
 	}
@@ -175,8 +175,8 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 		//Set GM marker
 		//TODO: Use db
 		SharedPreferences preferences = v.getContext().getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
-		Double lat = Double.longBitsToDouble(preferences.getLong(GM.PREF_GM_LATITUDE, 0));
-		Double lon = Double.longBitsToDouble(preferences.getLong(GM.PREF_GM_LONGITUDE, 0));
+		Double lat = 0.0; //Double.longBitsToDouble(preferences.getLong(GM.PREF_GM_LATITUDE, 0));
+		Double lon = 0.0; //Double.longBitsToDouble(preferences.getLong(GM.PREF_GM_LONGITUDE, 0));
 		gmLocation = new LatLng(lat, lon);
 		moGm = new MarkerOptions();
 		moGm.title(v.getContext().getString(R.string.app_name));
@@ -187,7 +187,7 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 
 		//Start device location requests
 		if (!(ActivityCompat.checkSelfPermission(v.getContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(v.getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
-			locationManager.requestLocationUpdates(locationManager.getBestProvider(new Criteria(), true), GM.LOCATION_ACCURACY_TIME, GM.LOCATION_ACCURACY_SPACE, this);
+			locationManager.requestLocationUpdates(locationManager.getBestProvider(new Criteria(), true), GM.LOCATION.ACCURACY.TIME, GM.LOCATION.ACCURACY.SPACE, this);
 			onLocationChanged(locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER));
 		}
 	}
@@ -221,7 +221,8 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 	@Override
 	public void onLocationChanged(Location location) {
 		//TODO: Read again the GM Location.
-		SharedPreferences preferences = v.getContext().getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
+		//TODO From database
+		/*SharedPreferences preferences = v.getContext().getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
 		if (!preferences.getString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION).equals(GM.DEFAULT_PREF_GM_LOCATION)) {
 
 			Double lat = Double.longBitsToDouble(preferences.getLong(GM.PREF_GM_LATITUDE, 0));
@@ -231,7 +232,7 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 			if (moGm != null){
 				moGm.visible(true);
 			}
-		}
+		}*/
 	}
 
 	/**

+ 45 - 46
app/src/main/java/com/ivalentin/margolariak/MainActivity.java

@@ -69,7 +69,7 @@ public class MainActivity extends Activity {
 			boolean result = false;
 			FetchURL fu = new FetchURL();
 			//TODO: This needs a simple API too
-			fu.Run(GM.SERVER + "/app/location.php");
+			fu.Run(GM.API.SERVER + "/app/location.php");
 			String lat = "", lon = "";
 			String o = fu.getOutput().toString();
 			Log.d("Location", "Fetched location page");
@@ -85,16 +85,16 @@ public class MainActivity extends Activity {
 			SharedPreferences settings = getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
 			SharedPreferences.Editor editor = settings.edit();
 			if (result) {
-				editor.putLong(GM.PREF_GM_LATITUDE, Double.doubleToLongBits(Double.parseDouble(lat)));
-				editor.putLong(GM.PREF_GM_LONGITUDE, Double.doubleToLongBits(Double.parseDouble(lon)));
-				editor.putString(GM.PREF_GM_LOCATION, new SimpleDateFormat("yyyyMMddHHmmss", Locale.US).format(Calendar.getInstance().getTime()));
+				//TODO editor.putLong(GM.PREF_GM_LATITUDE, Double.doubleToLongBits(Double.parseDouble(lat)));
+				//TODO editor.putLong(GM.PREF_GM_LONGITUDE, Double.doubleToLongBits(Double.parseDouble(lon)));
+				//TODO editor.putString(GM.PREF_GM_LOCATION, new SimpleDateFormat("yyyyMMddHHmmss", Locale.US).format(Calendar.getInstance().getTime()));
 
 				//Show menu entry
 				if (menuItem[1] != null) {
 					menuItem[1].setVisibility(View.VISIBLE);
 				}
 			} else {
-				editor.putString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION);
+				//TODO editor.putString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION);
 				if (menuItem[1] != null) {
 					menuItem[1].setVisibility(View.GONE);
 				}
@@ -102,7 +102,7 @@ public class MainActivity extends Activity {
 			editor.apply();
 
 			//Repeat this the same runnable code block again another th specified interval
-			locationHandler.postDelayed(checkForLocation, GM.INTERVAL_LOCATION);
+			locationHandler.postDelayed(checkForLocation, GM.LOCATION.INTERVAL);
 		}
 	};
 	/**
@@ -168,21 +168,21 @@ public class MainActivity extends Activity {
 		}
 
 		switch (section) {
-			case GM.SECTION_HOME:
+			case GM.SECTION.HOME:
 				fragment = new HomeLayout();
 				title = getString(R.string.menu_home);
 				menuText[0].setTypeface(null, Typeface.BOLD);
 				menuImage[0].getLayoutParams().height = 8;
 				break;
 
-			case GM.SECTION_LOCATION:
+			case GM.SECTION.LOCATION:
 				fragment = new LocationLayout();
 				title = getString(R.string.menu_location);
 				menuText[1].setTypeface(null, Typeface.BOLD);
 				menuImage[1].getLayoutParams().height = 8;
 				break;
 
-			case GM.SECTION_LABLANCA:
+			case GM.SECTION.LABLANCA:
 				//Get settings
 				SharedPreferences sharedData = getSharedPreferences(GM.DATA.DATA, Context.MODE_PRIVATE);
 				if (sharedData.getBoolean(GM.DATA.KEY.LABLANCA, GM.DATA.DEFAULT.LABLANCA)) {
@@ -195,39 +195,39 @@ public class MainActivity extends Activity {
 				menuImage[2].getLayoutParams().height = 8;
 				break;
 
-			case GM.SECTION_LABLANCA_SCHEDULE:
+			case GM.SECTION.SCHEDULE:
 				fragment = new ScheduleLayout();
-				bundle.putInt(GM.SCHEDULE, GM.SECTION_LABLANCA_SCHEDULE);
+				bundle.putInt(GM.SCHEDULE.KEY, GM.SCHEDULE.MARGOLARIAK);
 				fragment.setArguments(bundle);
 				title = getString(R.string.menu_lablanca_schedule);
 				menuText[2].setTypeface(null, Typeface.BOLD);
 				menuImage[2].getLayoutParams().height = 8;
 				break;
 
-			case GM.SECTION_LABLANCA_GM_SCHEDULE:
+			case GM.SECTION.GM_SCHEDULE:
 				fragment = new ScheduleLayout();
-				bundle.putInt(GM.SCHEDULE, GM.SECTION_LABLANCA_GM_SCHEDULE);
+				bundle.putInt(GM.SCHEDULE.KEY, GM.SCHEDULE.MARGOLARIAK);
 				fragment.setArguments(bundle);
 				title = getString(R.string.menu_lablanca_gm_schedule);
 				menuText[2].setTypeface(null, Typeface.BOLD);
 				menuImage[2].getLayoutParams().height = 8;
 				break;
 
-			case GM.SECTION_ACTIVITIES:
+			case GM.SECTION.ACTIVITIES:
 				fragment = new ActivityLayout();
 				title = getString(R.string.menu_activities);
 				menuText[3].setTypeface(null, Typeface.BOLD);
 				menuImage[3].getLayoutParams().height = 8;
 				break;
 
-			case GM.SECTION_BLOG:
+			case GM.SECTION.BLOG:
 				fragment = new BlogLayout();
 				title = getString(R.string.menu_blog);
 				menuText[4].setTypeface(null, Typeface.BOLD);
 				menuImage[4].getLayoutParams().height = 8;
 				break;
 
-			case GM.SECTION_GALLERY:
+			case GM.SECTION.GALLERY:
 				fragment = new GalleryLayout();
 				title = getString(R.string.menu_blog);
 				menuText[5].setTypeface(null, Typeface.BOLD);
@@ -263,9 +263,9 @@ public class MainActivity extends Activity {
 	protected void onCreate(Bundle savedInstanceState) {
 
 		//Get intent extras
-		String action = getIntent().getStringExtra(GM.EXTRA_ACTION);
-		String actionText = getIntent().getStringExtra(GM.EXTRA_TEXT);
-		String actionTitle = getIntent().getStringExtra(GM.EXTRA_TITLE);
+		String action = getIntent().getStringExtra(GM.EXTRA.ACTION);
+		String actionText = getIntent().getStringExtra(GM.EXTRA.TEXT);
+		String actionTitle = getIntent().getStringExtra(GM.EXTRA.TITLE);
 
 		//Set an alarm for notifications..
 		//Wait a little
@@ -332,37 +332,37 @@ public class MainActivity extends Activity {
 		menuItem[0].setOnClickListener(new OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				loadSection(GM.SECTION_HOME);
+				loadSection(GM.SECTION.HOME);
 			}
 		});
 		menuItem[1].setOnClickListener(new OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				loadSection(GM.SECTION_LOCATION);
+				loadSection(GM.SECTION.LOCATION);
 			}
 		});
 		menuItem[2].setOnClickListener(new OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				loadSection(GM.SECTION_LABLANCA);
+				loadSection(GM.SECTION.LABLANCA);
 			}
 		});
 		menuItem[3].setOnClickListener(new OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				loadSection(GM.SECTION_ACTIVITIES);
+				loadSection(GM.SECTION.ACTIVITIES);
 			}
 		});
 		menuItem[4].setOnClickListener(new OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				loadSection(GM.SECTION_BLOG);
+				loadSection(GM.SECTION.BLOG);
 			}
 		});
 		menuItem[5].setOnClickListener(new OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				loadSection(GM.SECTION_GALLERY);
+				loadSection(GM.SECTION.GALLERY);
 			}
 		});
 
@@ -376,7 +376,7 @@ public class MainActivity extends Activity {
 		if (sharedData.getString(GM.DATA.KEY.USER, GM.DATA.DEFAULT.USER).length() == GM.DATA.DEFAULT.USER.length()) {
 			SecureRandom random = new SecureRandom();
 			String newCode = new BigInteger(130, random).toString(32).substring(0, 16);
-			dataEditor.putString(GM.USER_CODE, newCode);
+			dataEditor.putString(GM.DATA.KEY.USER, newCode);
 			dataEditor.apply();
 		}
 
@@ -397,7 +397,7 @@ public class MainActivity extends Activity {
 			sync();
 
 			//Load initial section
-			loadSection(GM.SECTION_HOME);
+			loadSection(GM.SECTION.HOME);
 
 			//If the intent had extras (from notifications), do something
 			if (actionText != null) {
@@ -446,7 +446,7 @@ public class MainActivity extends Activity {
 					if (action != null) {
 						switch (action) {
 
-							case GM.EXTRA_ACTION_LABLANCA:
+							case GM.EXTRA.SECTION.LABLANCA:
 
 								//Set up the action button
 								btDialogAction.setVisibility(View.VISIBLE);
@@ -455,15 +455,15 @@ public class MainActivity extends Activity {
 									@Override
 									public void onClick(View v) {
 										dialog.dismiss();
-										loadSection(GM.SECTION_LABLANCA);
+										loadSection(GM.SECTION.LABLANCA);
 									}
 								});
 								break;
 
-							case GM.EXTRA_ACTION_LOCATION:
+							case GM.EXTRA.SECTION.LOCATION:
 
 								//TODO: Read from database
-								if (!sharedData.getString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION).equals(GM.DEFAULT_PREF_GM_LOCATION)) {
+								/*if (!sharedData.getString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION).equals(GM.DEFAULT_PREF_GM_LOCATION)) {
 									//Set up the action button if location is reported
 									btDialogAction.setVisibility(View.VISIBLE);
 									btDialogAction.setText(this.getApplicationContext().getString(R.string.notification_action_location));
@@ -475,10 +475,10 @@ public class MainActivity extends Activity {
 										}
 									});
 
-								}
+								}*/
 								break;
 
-							case GM.EXTRA_ACTION_BLOG:
+							case GM.EXTRA.SECTION.BLOG:
 
 								//Set up the action button
 								btDialogAction.setVisibility(View.VISIBLE);
@@ -487,12 +487,12 @@ public class MainActivity extends Activity {
 									@Override
 									public void onClick(View v) {
 										dialog.dismiss();
-										loadSection(GM.SECTION_BLOG);
+										loadSection(GM.SECTION.BLOG);
 									}
 								});
 								break;
 
-							case GM.EXTRA_ACTION_ACTIVITIES:
+							case GM.EXTRA.SECTION.ACTIVITIES:
 
 								//Set up the action button
 								btDialogAction.setVisibility(View.VISIBLE);
@@ -501,12 +501,12 @@ public class MainActivity extends Activity {
 									@Override
 									public void onClick(View v) {
 										dialog.dismiss();
-										loadSection(GM.SECTION_ACTIVITIES);
+										loadSection(GM.SECTION.ACTIVITIES);
 									}
 								});
 								break;
 
-							case GM.EXTRA_ACTION_GALLERY:
+							case GM.EXTRA.SECTION.GALLERY:
 
 								//Set up the action button
 								btDialogAction.setVisibility(View.VISIBLE);
@@ -515,12 +515,12 @@ public class MainActivity extends Activity {
 									@Override
 									public void onClick(View v) {
 										dialog.dismiss();
-										loadSection(GM.SECTION_GALLERY);
+										loadSection(GM.SECTION.GALLERY);
 									}
 								});
 								break;
 
-							case GM.EXTRA_ACTION_GMSCHEDULE:
+							case GM.EXTRA.SECTION.GMSCHEDULE:
 
 								if (festivals) {
 									//Set up the action button
@@ -530,13 +530,13 @@ public class MainActivity extends Activity {
 										@Override
 										public void onClick(View v) {
 											dialog.dismiss();
-											loadSection(GM.SECTION_LABLANCA_GM_SCHEDULE);
+											loadSection(GM.SECTION.GM_SCHEDULE);
 										}
 									});
 								}
 								break;
 
-							case GM.EXTRA_ACTION_CITYSCHEDULE:
+							case GM.EXTRA.SECTION.SCHEDULE:
 								if (festivals) {
 									//Set up the action button
 									btDialogAction.setVisibility(View.VISIBLE);
@@ -545,7 +545,7 @@ public class MainActivity extends Activity {
 										@Override
 										public void onClick(View v) {
 											dialog.dismiss();
-											loadSection(GM.SECTION_LABLANCA_SCHEDULE);
+											loadSection(GM.SECTION.SCHEDULE);
 										}
 									});
 								}
@@ -587,7 +587,7 @@ public class MainActivity extends Activity {
 		SQLiteDatabase db;
 		try {
 			//Create database
-			db = openOrCreateDatabase(GM.DB_NAME, Activity.MODE_PRIVATE, null);
+			db = openOrCreateDatabase(GM.DB.NAME, Activity.MODE_PRIVATE, null);
 			db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY);
 			db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY_COMMENT);
 			db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY_IMAGE);
@@ -610,7 +610,7 @@ public class MainActivity extends Activity {
 			db.execSQL(GM.DB.QUERY.CREATE.POST_COMMENT);
 			db.execSQL(GM.DB.QUERY.CREATE.POST_IMAGE);
 			db.execSQL(GM.DB.QUERY.CREATE.POST_TAG);
-			db.execSQL(GM.DB.QUERY.CREATE.SETTINGS);
+			//db.execSQL(GM.DB.QUERY.CREATE.SETTINGS);
 			db.execSQL(GM.DB.QUERY.CREATE.SPONSOR);
 			db.execSQL(GM.DB.QUERY.CREATE.VERSION);
 			db.close();
@@ -625,7 +625,7 @@ public class MainActivity extends Activity {
 	private void deleteDatabase() {
 		SQLiteDatabase db;
 		try {
-			getApplicationContext().deleteDatabase(GM.DB_NAME);
+			getApplicationContext().deleteDatabase(GM.DB.NAME);
 		} catch (Exception ex) {
 			Log.e("Error deleting database", ex.toString());
 		}
@@ -688,7 +688,6 @@ public class MainActivity extends Activity {
 			}
 		} catch (Exception ex) {
 			Log.e("Error going back", "Finishing activity: " + ex.toString());
-			Log.e("RUNNABLE", "Finishing callback for location");
 			locationHandler.removeCallbacks(checkForLocation);
 			finish();
 			//super.onBackPressed();

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

@@ -123,7 +123,7 @@ public class PhotoLayout extends Fragment {
 	 */
 	private Integer[] loadPhotos(int id){
 
-		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 
 		//Get album id for the photo
 		Cursor cAlbum = db.rawQuery("SELECT album FROM photo_album WHERE photo = " + id + ";", null);
@@ -156,7 +156,7 @@ public class PhotoLayout extends Fragment {
 		final int photoId = id;
 
 		//Get data from database
-		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 		final Cursor cursor;
 		final String lang = GM.getLang();
 		cursor = db.rawQuery("SELECT id, file, title_" + lang+ " AS title, description_" + lang + " AS description, uploaded, width, height, size FROM photo WHERE id = " + id + ";", null);
@@ -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.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.VIEW).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
 		}
 
 		//Hide or show comments, as needed

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

@@ -103,7 +103,7 @@ class PostComment extends AsyncTask<String, String, Integer> {
             urlParams = urlParams + "&from=app&code=" + userCode;
             byte[] postData       = urlParams.getBytes("UTF-8");
             int    postDataLength = postData.length;
-            String request        = GM.SERVER + "/" + type + "/comment.php";
+            String request        = GM.API.SERVER + "/" + type + "/comment.php";
             url            = new URL( request );
             HttpURLConnection conn= (HttpURLConnection) url.openConnection();
             conn.setDoOutput( true );
@@ -122,7 +122,7 @@ class PostComment extends AsyncTask<String, String, Integer> {
 
             if (code == 200){
                 //Insert into local db
-                SQLiteDatabase db = SQLiteDatabase.openDatabase(context.getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS);
+                SQLiteDatabase db = SQLiteDatabase.openDatabase(context.getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS);
                 String table = "";
                 String item = "";
                 switch (type){

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

@@ -57,7 +57,7 @@ public class PostLayout extends Fragment {
         }
 
         //Get data from database
-        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
         final Cursor cursor;
         String lang = GM.getLang();
         cursor = db.rawQuery("SELECT id, title_" + lang+ " AS title, text_" + lang + " AS text, dtime FROM post WHERE id = " + id + ";", null);
@@ -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.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.PREVIEW).execute();
             }
             images[i].setVisibility(View.VISIBLE);
             i ++;

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

@@ -105,18 +105,18 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 
 		//Get schedule type
 		Bundle bundle = this.getArguments();
-		schedule = bundle.getInt(GM.SCHEDULE, GM.SECTION_LABLANCA_SCHEDULE);
+		schedule = bundle.getInt(GM.SCHEDULE.KEY, GM.SCHEDULE.CITY);
 		
 		//Set the title
-		if (schedule == GM.SECTION_LABLANCA_SCHEDULE)
+		if (schedule == GM.SCHEDULE.CITY)
 			((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_lablanca_schedule));
 		else
 			((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_lablanca_gm_schedule));
 
 		//Populate the dates array
-		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 		Cursor cursor;
-		if (schedule == GM.SECTION_LABLANCA_GM_SCHEDULE) {
+		if (schedule == GM.SCHEDULE.MARGOLARIAK) {
 			cursor = db.rawQuery("SELECT DISTINCT date(start) FROM festival_event WHERE strftime('%Y', start) = '" + year + "' AND strftime('%H', start) > '06' AND gm = 1;", null);
 		}
 		else{
@@ -224,7 +224,7 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 			Log.e("Datetime error", ex.toString());
 		}
 
-		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 
 		String lang = GM.getLang();
 
@@ -252,7 +252,7 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 				tvDayMonth.setText(getString(R.string.schedule_month_august));
 				break;
 		}
-		if (schedule == GM.SECTION_LABLANCA_GM_SCHEDULE) {
+		if (schedule == GM.SCHEDULE.MARGOLARIAK) {
 			Cursor cursorDay = db.rawQuery("SELECT name_" + lang + " FROM festival_day WHERE date(date) = '" + dates[selected] + "';", null);
 			if (cursorDay.getCount() > 0) {
 				cursorDay.moveToFirst();
@@ -278,7 +278,7 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 
 		String query = "SELECT festival_event.id, title_" + lang + ", description_" + lang + ", place, start, end, name_" + lang + ", address_" + lang + ", lat, lon FROM festival_event, place WHERE place = place.id AND start >= '" + dates[selected] + " 06:00:00' AND start < '" + endDate + " 05:59:59' AND ";
 
-		if (schedule == GM.SECTION_LABLANCA_GM_SCHEDULE) {
+		if (schedule == GM.SCHEDULE.MARGOLARIAK) {
 			query = query + "gm = 1 ";
 		} else {
 			query = query + "gm = 0 ";
@@ -327,7 +327,7 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 			}
 
 			//Set icon
-			if (schedule == GM.SECTION_LABLANCA_GM_SCHEDULE) {
+			if (schedule == GM.SCHEDULE.MARGOLARIAK) {
 				ImageView pinPoint = (ImageView) entry.findViewById(R.id.iv_row_schedule_pinpoint);
 				pinPoint.setImageResource(getResources().getIdentifier("com.ivalentin.margolariak:drawable/pinpoint_gm", null, null));
 			}
@@ -399,7 +399,7 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 		Button btClose = (Button) dialog.findViewById(R.id.bt_schedule_close);
 		
 		//Get info about the event
-		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB_NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
+		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 		String lang = GM.getLang();
 		Cursor cursor = db.rawQuery("SELECT festival_event.id, title_" + lang + ", description_" + lang + ", place, start, end, name_" + lang + ", address_" + lang + ", lat, lon, host FROM festival_event, place WHERE place = place.id AND festival_event.id = " + id + ";", null);
 		if (cursor.getCount() > 0){

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

@@ -111,7 +111,7 @@ class Sync extends AsyncTask<Void, Void, Void> {
 			dialog.dismiss();
 
 			//Check db version again
-			SQLiteDatabase db = myContextRef.openOrCreateDatabase(GM.DB_NAME, Activity.MODE_PRIVATE, null);
+			SQLiteDatabase db = myContextRef.openOrCreateDatabase(GM.DB.NAME, Activity.MODE_PRIVATE, null);
 			if (db.isReadOnly()){
 				Log.e("Db ro", "Database is locked and in read only mode. Skipping sync.");
 				return;
@@ -127,7 +127,7 @@ class Sync extends AsyncTask<Void, Void, Void> {
 			db.close();
 
 			//If the database is on it's initial version (i.e: There is no data, new or old)
-			if (dbVersion == GM.DEFAULT_PREF_DB_VERSION){
+			if (true){ //TODO dbVersion == GM.DATA.DEFAULT.DEFAULT_PREF_DB_VERSION){
 
 				Log.e("SYNC", "Full sync failed");
 
@@ -154,7 +154,7 @@ class Sync extends AsyncTask<Void, Void, Void> {
 			}
 			else{
 				Log.d("SYNC", "Full sync finished");
-				activity.loadSection(GM.SECTION_HOME);
+				activity.loadSection(GM.SECTION.HOME);
 			}
 		}
 
@@ -244,15 +244,15 @@ class Sync extends AsyncTask<Void, Void, Void> {
 	private String buildUrl(String user, int version, int foreground, String lang){
 		String url = "";
 		try {
-			url = GM.SERVER + GM.SERVER_SYNC + "?" +
-					GM.SERVER_SYNC_KEY_CLIENT + "=" + URLEncoder.encode(GM.CLIENT, "UTF-8") + "&" +
-					GM.SERVER_SYNC_KEY_USER + "=" + URLEncoder.encode(user, "UTF-8") + "&" +
-					GM.SERVER_SYNC_KEY_ACTION + "=" + URLEncoder.encode(GM.SERVER_SYNC_VALUE_ACTION, "UTF-8") + "&" +
-					GM.SERVER_SYNC_KEY_SECTION + "=" + URLEncoder.encode(GM.SERVER_SYNC_VALUE_SECTION, "UTF-8") + "&" +
-					GM.SERVER_SYNC_KEY_VERSION + "=" + version + "&" +
-					GM.SERVER_SYNC_KEY_FOREGROUND + "=" + foreground + "&" +
-					GM.SERVER_SYNC_KEY_FORMAT + "=" + URLEncoder.encode(GM.SERVER_SYNC_VALUE_FORMAT, "UTF-8") + "&" +
-					GM.SERVER_SYNC_KEY_LANG + "=" + URLEncoder.encode(lang, "UTF-8");
+			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");
 		}
 		catch (java.io.UnsupportedEncodingException ex){
 			Log.e("UTF-8", "Error encoding url for sync \"" + url + "\" - " + ex.toString());
@@ -591,7 +591,7 @@ class Sync extends AsyncTask<Void, Void, Void> {
 		String userCode = preferences.getString(GM.DATA.KEY.USER, GM.DATA.DEFAULT.USER);
 
 		//Get database. Stop if it's locked
-		SQLiteDatabase db = myContextRef.openOrCreateDatabase(GM.DB_NAME, Activity.MODE_PRIVATE, null);
+		SQLiteDatabase db = myContextRef.openOrCreateDatabase(GM.DB.NAME, Activity.MODE_PRIVATE, null);
 		if (db.isReadOnly()){
 			Log.e("SYNC", "Database is locked and in read only mode. Skipping sync.");
 			return null;