浏览代码

Merge branch 'V4'

Iñigo Valentin 8 年之前
父节点
当前提交
8c78600904
共有 100 个文件被更改,包括 3559 次插入4567 次删除
  1. 0 229
      .idea/codeStyleSettings.xml
  2. 2 2
      .idea/gradle.xml
  3. 0 10
      .idea/inspectionProfiles/Project_Default.xml
  4. 0 7
      .idea/inspectionProfiles/profiles_settings.xml
  5. 16 3
      app/build.gradle
  6. 11 19
      app/src/main/AndroidManifest.xml
  7. 362 402
      app/src/main/java/com/ivalentin/margolariak/ActivityFutureLayout.java
  8. 239 237
      app/src/main/java/com/ivalentin/margolariak/ActivityLayout.java
  9. 71 79
      app/src/main/java/com/ivalentin/margolariak/ActivityPastLayout.java
  10. 11 10
      app/src/main/java/com/ivalentin/margolariak/AlarmReceiver.java
  11. 91 100
      app/src/main/java/com/ivalentin/margolariak/AlbumLayout.java
  12. 208 215
      app/src/main/java/com/ivalentin/margolariak/BlogLayout.java
  13. 1 1
      app/src/main/java/com/ivalentin/margolariak/BootReceiver.java
  14. 28 27
      app/src/main/java/com/ivalentin/margolariak/CustomScrollView.java
  15. 1 1
      app/src/main/java/com/ivalentin/margolariak/Distance.java
  16. 46 46
      app/src/main/java/com/ivalentin/margolariak/DownloadImage.java
  17. 8 6
      app/src/main/java/com/ivalentin/margolariak/FetchURL.java
  18. 308 112
      app/src/main/java/com/ivalentin/margolariak/GM.java
  19. 134 139
      app/src/main/java/com/ivalentin/margolariak/GalleryLayout.java
  20. 57 48
      app/src/main/java/com/ivalentin/margolariak/HomeLayout.java
  21. 0 105
      app/src/main/java/com/ivalentin/margolariak/HomeSectionLocation.java
  22. 101 113
      app/src/main/java/com/ivalentin/margolariak/LablancaLayout.java
  23. 2 6
      app/src/main/java/com/ivalentin/margolariak/LablancaNoFestivalsLayout.java
  24. 92 137
      app/src/main/java/com/ivalentin/margolariak/LocationLayout.java
  25. 44 69
      app/src/main/java/com/ivalentin/margolariak/MainActivity.java
  26. 19 12
      app/src/main/java/com/ivalentin/margolariak/PhotoLayout.java
  27. 163 150
      app/src/main/java/com/ivalentin/margolariak/PostComment.java
  28. 134 143
      app/src/main/java/com/ivalentin/margolariak/PostLayout.java
  29. 20 11
      app/src/main/java/com/ivalentin/margolariak/ReceiveLocation.java
  30. 294 276
      app/src/main/java/com/ivalentin/margolariak/ScheduleLayout.java
  31. 8 3
      app/src/main/java/com/ivalentin/margolariak/SettingsActivity.java
  32. 0 179
      app/src/main/java/com/ivalentin/margolariak/SettingsLayout.java
  33. 2 4
      app/src/main/java/com/ivalentin/margolariak/SponsorActivity.java
  34. 141 203
      app/src/main/java/com/ivalentin/margolariak/Sync.java
  35. 12 9
      app/src/main/java/com/ivalentin/margolariak/UsActivity.java
  36. 二进制
      app/src/main/res/drawable-xhdpi/pinpoint_gm.png
  37. 二进制
      app/src/main/res/drawable-xxhdpi/pinpoint_gm.png
  38. 0 14
      app/src/main/res/drawable/album.xml
  39. 二进制
      app/src/main/res/drawable/divider.png
  40. 二进制
      app/src/main/res/drawable/ic_launcher_old.png
  41. 20 0
      app/src/main/res/drawable/map.xml
  42. 二进制
      app/src/main/res/drawable/menu.png
  43. 二进制
      app/src/main/res/drawable/photo_placeholder.png
  44. 二进制
      app/src/main/res/drawable/pinpoint.png
  45. 二进制
      app/src/main/res/drawable/pinpoint_end.png
  46. 二进制
      app/src/main/res/drawable/pinpoint_gm.png
  47. 二进制
      app/src/main/res/drawable/pinpoint_route.png
  48. 二进制
      app/src/main/res/drawable/pinpoint_start.png
  49. 0 15
      app/src/main/res/drawable/row_home_image.xml
  50. 0 18
      app/src/main/res/drawable/titlebar.xml
  51. 二进制
      app/src/main/res/drawable/tutorial_point.png
  52. 二进制
      app/src/main/res/drawable/tutorial_slide.png
  53. 6 18
      app/src/main/res/layout/activity_main.xml
  54. 1 8
      app/src/main/res/layout/activity_settings.xml
  55. 0 4
      app/src/main/res/layout/activity_sponsor.xml
  56. 0 4
      app/src/main/res/layout/activity_us.xml
  57. 0 4
      app/src/main/res/layout/dialog_changelog.xml
  58. 0 2
      app/src/main/res/layout/dialog_notification.xml
  59. 35 13
      app/src/main/res/layout/dialog_schedule.xml
  60. 0 50
      app/src/main/res/layout/dialog_settings.xml
  61. 15 15
      app/src/main/res/layout/dialog_sponsor.xml
  62. 0 2
      app/src/main/res/layout/dialog_sync.xml
  63. 0 2
      app/src/main/res/layout/dialog_sync_failed.xml
  64. 5 9
      app/src/main/res/layout/dialog_us.xml
  65. 0 4
      app/src/main/res/layout/fragment_layout_activities.xml
  66. 0 2
      app/src/main/res/layout/fragment_layout_activity_future.xml
  67. 0 2
      app/src/main/res/layout/fragment_layout_activity_past.xml
  68. 0 2
      app/src/main/res/layout/fragment_layout_album.xml
  69. 0 2
      app/src/main/res/layout/fragment_layout_blog.xml
  70. 0 2
      app/src/main/res/layout/fragment_layout_gallery.xml
  71. 728 749
      app/src/main/res/layout/fragment_layout_home.xml
  72. 1 8
      app/src/main/res/layout/fragment_layout_lablanca.xml
  73. 18 53
      app/src/main/res/layout/fragment_layout_lablanca_nofestivals.xml
  74. 14 9
      app/src/main/res/layout/fragment_layout_location.xml
  75. 0 2
      app/src/main/res/layout/fragment_layout_photo.xml
  76. 0 2
      app/src/main/res/layout/fragment_layout_post.xml
  77. 2 7
      app/src/main/res/layout/fragment_layout_schedule.xml
  78. 0 149
      app/src/main/res/layout/fragment_layout_settings.xml
  79. 8 9
      app/src/main/res/layout/row_activity_future.xml
  80. 6 4
      app/src/main/res/layout/row_activity_past.xml
  81. 5 5
      app/src/main/res/layout/row_activity_schedule.xml
  82. 0 4
      app/src/main/res/layout/row_album.xml
  83. 0 1
      app/src/main/res/layout/row_comment.xml
  84. 0 1
      app/src/main/res/layout/row_festival_price_day.xml
  85. 0 1
      app/src/main/res/layout/row_festival_price_pack.xml
  86. 0 5
      app/src/main/res/layout/row_gallery.xml
  87. 7 6
      app/src/main/res/layout/row_home_activities.xml
  88. 3 1
      app/src/main/res/layout/row_home_blog.xml
  89. 1 6
      app/src/main/res/layout/row_home_schedule.xml
  90. 3 4
      app/src/main/res/layout/row_schedule.xml
  91. 12 43
      app/src/main/res/values-en/strings.xml
  92. 11 37
      app/src/main/res/values-eu-rES/strings.xml
  93. 0 16
      app/src/main/res/values-v11/styles.xml
  94. 0 17
      app/src/main/res/values-v14/styles.xml
  95. 0 10
      app/src/main/res/values-v21/styles.xml
  96. 0 5
      app/src/main/res/values-v24/styles.xml
  97. 12 2
      app/src/main/res/values/color.xml
  98. 16 48
      app/src/main/res/values/strings.xml
  99. 4 20
      app/src/main/res/values/styles.xml
  100. 0 38
      app/src/main/res/xml/preferences.xml

+ 0 - 229
.idea/codeStyleSettings.xml

@@ -1,229 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ProjectCodeStyleSettingsManager">
-    <option name="PER_PROJECT_SETTINGS">
-      <value>
-        <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
-        <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
-        <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
-          <value />
-        </option>
-        <option name="IMPORT_LAYOUT_TABLE">
-          <value>
-            <package name="android" withSubpackages="true" static="false" />
-            <emptyLine />
-            <package name="com" withSubpackages="true" static="false" />
-            <emptyLine />
-            <package name="junit" withSubpackages="true" static="false" />
-            <emptyLine />
-            <package name="net" withSubpackages="true" static="false" />
-            <emptyLine />
-            <package name="org" withSubpackages="true" static="false" />
-            <emptyLine />
-            <package name="java" withSubpackages="true" static="false" />
-            <emptyLine />
-            <package name="javax" withSubpackages="true" static="false" />
-            <emptyLine />
-            <package name="" withSubpackages="true" static="false" />
-            <emptyLine />
-            <package name="" withSubpackages="true" static="true" />
-            <emptyLine />
-          </value>
-        </option>
-        <option name="RIGHT_MARGIN" value="100" />
-        <AndroidXmlCodeStyleSettings>
-          <option name="USE_CUSTOM_SETTINGS" value="true" />
-        </AndroidXmlCodeStyleSettings>
-        <Objective-C-extensions>
-          <option name="GENERATE_INSTANCE_VARIABLES_FOR_PROPERTIES" value="ASK" />
-          <option name="RELEASE_STYLE" value="IVAR" />
-          <option name="TYPE_QUALIFIERS_PLACEMENT" value="BEFORE" />
-          <file>
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
-          </file>
-          <class>
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
-            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
-          </class>
-          <extensions>
-            <pair source="cpp" header="h" />
-            <pair source="c" header="h" />
-          </extensions>
-        </Objective-C-extensions>
-        <XML>
-          <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
-        </XML>
-        <codeStyleSettings language="XML">
-          <option name="FORCE_REARRANGE_MODE" value="1" />
-          <indentOptions>
-            <option name="CONTINUATION_INDENT_SIZE" value="4" />
-          </indentOptions>
-          <arrangement>
-            <rules>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>xmlns:android</NAME>
-                      <XML_NAMESPACE>^$</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>xmlns:.*</NAME>
-                      <XML_NAMESPACE>^$</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                  <order>BY_NAME</order>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>.*:id</NAME>
-                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>.*:name</NAME>
-                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>name</NAME>
-                      <XML_NAMESPACE>^$</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>style</NAME>
-                      <XML_NAMESPACE>^$</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>.*</NAME>
-                      <XML_NAMESPACE>^$</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                  <order>BY_NAME</order>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>.*:layout_width</NAME>
-                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>.*:layout_height</NAME>
-                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>.*:layout_.*</NAME>
-                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                  <order>BY_NAME</order>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>.*:width</NAME>
-                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                  <order>BY_NAME</order>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>.*:height</NAME>
-                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                  <order>BY_NAME</order>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>.*</NAME>
-                      <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                  <order>BY_NAME</order>
-                </rule>
-              </section>
-              <section>
-                <rule>
-                  <match>
-                    <AND>
-                      <NAME>.*</NAME>
-                      <XML_NAMESPACE>.*</XML_NAMESPACE>
-                    </AND>
-                  </match>
-                  <order>BY_NAME</order>
-                </rule>
-              </section>
-            </rules>
-          </arrangement>
-        </codeStyleSettings>
-      </value>
-    </option>
-    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
-  </component>
-</project>

+ 2 - 2
.idea/gradle.xml

@@ -3,13 +3,13 @@
   <component name="GradleSettings">
     <option name="linkedExternalProjectsSettings">
       <GradleProjectSettings>
-        <option name="distributionType" value="LOCAL" />
+        <option name="distributionType" value="DEFAULT_WRAPPED" />
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
-        <option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.14.1" />
         <option name="modules">
           <set>
             <option value="$PROJECT_DIR$" />
             <option value="$PROJECT_DIR$/app" />
+            <option value="$PROJECT_DIR$/osmdroid-android-5.6.5-release" />
           </set>
         </option>
         <option name="resolveModulePerSourceSet" value="false" />

+ 0 - 10
.idea/inspectionProfiles/Project_Default.xml

@@ -1,10 +0,0 @@
-<component name="InspectionProjectProfileManager">
-  <profile version="1.0">
-    <option name="myName" value="Project Default" />
-    <inspection_tool class="AndroidLintRtlCompat" enabled="false" level="ERROR" enabled_by_default="false" />
-    <inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
-      <option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
-      <option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
-    </inspection_tool>
-  </profile>
-</component>

+ 0 - 7
.idea/inspectionProfiles/profiles_settings.xml

@@ -1,7 +0,0 @@
-<component name="InspectionProjectProfileManager">
-  <settings>
-    <option name="PROJECT_PROFILE" value="Project Default" />
-    <option name="USE_PROJECT_PROFILE" value="true" />
-    <version value="1.0" />
-  </settings>
-</component>

+ 16 - 3
app/build.gradle

@@ -2,11 +2,11 @@ apply plugin: 'com.android.application'
 
 android {
     compileSdkVersion 23
-    buildToolsVersion '25.0.0'
+    buildToolsVersion '27.0.3'
 
     defaultConfig {
         applicationId "com.ivalentin.margolariak"
-        minSdkVersion 14
+        minSdkVersion 23
         targetSdkVersion 23
         multiDexEnabled true
     }
@@ -23,10 +23,23 @@ android {
         preDexLibraries = false
         javaMaxHeapSize "2g"
     }
+
+    lintOptions {
+        checkReleaseBuilds false
+    }
 }
 
 dependencies {
     //noinspection GradleDynamicVersion
-    compile 'com.google.android.gms:play-services:+'
     compile 'com.android.support:multidex:1.0.1'
+    compile 'org.osmdroid:osmdroid-android:5.6.5@aar'
 }
+
+
+allprojects {
+    repositories {
+        // The order in which you list these repositories matter.
+        google()
+        jcenter()
+    }
+}

+ 11 - 19
app/src/main/AndroidManifest.xml

@@ -2,8 +2,8 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
           xmlns:tools="http://schemas.android.com/tools"
           package="com.ivalentin.margolariak"
-    android:versionCode="26"
-    android:versionName="3.1" >
+    android:versionCode="27"
+    android:versionName="4" >
 
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
@@ -24,23 +24,15 @@
         android:allowBackup="true"
         android:icon="@drawable/ic_launcher"
         android:label="@string/app_name"
-        android:theme="@style/Theme.AppBaseTheme"
+        android:theme="@style/AppTheme"
         android:supportsRtl="true"
         android:isGame="false"
         android:fullBackupContent="@xml/backup"
         android:hardwareAccelerated="true"
         android:allowClearUserData="true"
-        tools:ignore="UnusedAttribute"
+        tools:ignore="GoogleAppIndexingWarning,UnusedAttribute"
         android:name="android.support.multidex.MultiDexApplication">
-        
-        <meta-data
-    		android:name="com.google.android.gms.version"
-    		android:value="@integer/google_play_services_version" />
-        
-        <meta-data
-    		android:name="com.google.android.geo.API_KEY"
-    		android:value="AIzaSyC6DgCJRiBkYiNUivE0VH9fsTZDbfVDpS0"/>
-        
+
         <activity
             android:name="com.ivalentin.margolariak.MainActivity"
             android:windowSoftInputMode="stateHidden|adjustResize"
@@ -50,7 +42,7 @@
             
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
-				<category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
 
@@ -70,11 +62,11 @@
         
         <receiver
             android:name="com.ivalentin.margolariak.BootReceiver"
-			android:enabled="false">
-		    <intent-filter>
-		        <action android:name="android.intent.action.BOOT_COMPLETED"></action>
-		    </intent-filter>
-		</receiver>
+            android:enabled="false">
+            <intent-filter>
+                <action android:name="android.intent.action.BOOT_COMPLETED"/>
+            </intent-filter>
+        </receiver>
     </application>
 
 </manifest>

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

@@ -1,21 +1,19 @@
 package com.ivalentin.margolariak;
 
-import android.annotation.SuppressLint;
 import android.app.Dialog;
-import android.content.DialogInterface;
-import android.content.pm.PackageManager;
+import android.app.Fragment;
+import android.content.Intent;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
-import android.os.Build;
+import android.graphics.drawable.Drawable;
 import android.os.Bundle;
-import android.app.Fragment;
-import android.support.v4.app.ActivityCompat;
 import android.util.Log;
 import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.Window;
 import android.view.WindowManager;
@@ -24,22 +22,23 @@ import android.widget.Button;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
-
-import com.google.android.gms.maps.CameraUpdate;
-import com.google.android.gms.maps.CameraUpdateFactory;
-import com.google.android.gms.maps.GoogleMap;
-import com.google.android.gms.maps.MapView;
-import com.google.android.gms.maps.MapsInitializer;
-import com.google.android.gms.maps.OnMapReadyCallback;
-import com.google.android.gms.maps.model.LatLng;
-import com.google.android.gms.maps.model.MarkerOptions;
+import android.preference.PreferenceManager;
+import android.net.Uri;
 
 import java.io.File;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
 import java.util.Locale;
+import java.util.ArrayList;
+
+import org.osmdroid.api.IMapController;
+import org.osmdroid.config.Configuration;
+
+import org.osmdroid.util.GeoPoint;
+import org.osmdroid.views.MapView;
+import org.osmdroid.views.overlay.ItemizedIconOverlay;
+import org.osmdroid.views.overlay.OverlayItem;
+import org.osmdroid.views.overlay.Polyline;
 
 /**
  * Fragment to display upcoming activities.
@@ -51,146 +50,150 @@ import java.util.Locale;
  * @see Fragment
  *
  */
-public class ActivityFutureLayout extends Fragment implements OnMapReadyCallback {
-
-	//Map stuff for the dialog
-	private MapView mapView;
-	private GoogleMap map;
-	private LatLng location;
-	private String markerName = "";
-	private final Bundle bund = null;
-	private View v;
-
-	@SuppressWarnings("ResultOfMethodCallIgnored")
-    @SuppressLint("InflateParams")
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
-        //Load the layout
-        View view = inflater.inflate(R.layout.fragment_layout_activity_future, null);
-
-        //Get bundled id
-        Bundle bundle = this.getArguments();
-        int id = bundle.getInt("activity", -1);
-        if (id == -1){
-            Log.e("Activity error", "No such activity: " + id);
-            this.getActivity().onBackPressed();
-        }
-
-        //Get data from database
-        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
-        final Cursor cursor;
+public class ActivityFutureLayout extends Fragment {
+
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+		//Load the layout
+		View view = inflater.inflate(R.layout.fragment_layout_activity_future, container, false);
+
+		//Get bundled id
+		Bundle bundle = this.getArguments();
+		int id = bundle.getInt("activity", -1);
+		if (id == -1){
+			Log.e("ACTIVITY_FUTURE_LAYOUT", "No such activity: " + id);
+			this.getActivity().onBackPressed();
+		}
+
+		//Get data from database
+		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, price, permalink FROM activity WHERE id = " + id + ";", null);
-        cursor.moveToFirst();
-
-        //Get display elements
-        ImageView images[] = new ImageView[5];
-        images[0] = (ImageView) view.findViewById(R.id.iv_activity_future_0);
-        images[1] = (ImageView) view.findViewById(R.id.iv_activity_future_1);
-        images[2] = (ImageView) view.findViewById(R.id.iv_activity_future_2);
-        images[3] = (ImageView) view.findViewById(R.id.iv_activity_future_3);
-        images[4] = (ImageView) view.findViewById(R.id.iv_activity_future_4);
-
-        TextView tvTitle = (TextView) view.findViewById(R.id.tv_activity_future_title);
-        TextView tvDate = (TextView) view.findViewById(R.id.tv_activity_future_date);
-        TextView tvCity = (TextView) view.findViewById(R.id.tv_activity_future_city);
-        TextView tvPrice = (TextView) view.findViewById(R.id.tv_activity_future_price);
-        WebView wvText = (WebView) view.findViewById(R.id.wv_activity_future_text);
-
-        //Set fields
-        tvTitle.setText(cursor.getString(1));
-        ((MainActivity) getActivity()).setSectionTitle(cursor.getString(1));
+		cursor = db.rawQuery("SELECT id, title_" + lang+ " AS title, text_" + lang + " AS text, date, city, price, permalink FROM activity WHERE id = " + id + ";", null);
+		cursor.moveToFirst();
+
+		//Get display elements
+		ImageView images[] = new ImageView[5];
+		images[0] = (ImageView) view.findViewById(R.id.iv_activity_future_0);
+		images[1] = (ImageView) view.findViewById(R.id.iv_activity_future_1);
+		images[2] = (ImageView) view.findViewById(R.id.iv_activity_future_2);
+		images[3] = (ImageView) view.findViewById(R.id.iv_activity_future_3);
+		images[4] = (ImageView) view.findViewById(R.id.iv_activity_future_4);
+
+		TextView tvTitle = (TextView) view.findViewById(R.id.tv_activity_future_title);
+		TextView tvDate = (TextView) view.findViewById(R.id.tv_activity_future_date);
+		TextView tvCity = (TextView) view.findViewById(R.id.tv_activity_future_city);
+		TextView tvPrice = (TextView) view.findViewById(R.id.tv_activity_future_price);
+		WebView wvText = (WebView) view.findViewById(R.id.wv_activity_future_text);
+
+		//Set fields
+		tvTitle.setText(cursor.getString(1));
+		((MainActivity) getActivity()).setSectionTitle(cursor.getString(1));
 		((MainActivity) getActivity()).setShareLink(String.format(getString(R.string.share_with_title), cursor.getString(1)), GM.SHARE.ACTIVITIES + cursor.getString(6));
-		if (Build.VERSION.SDK_INT >= 19) {
-			wvText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
-		}
-		else {
-			wvText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
-		}
+		wvText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+
 		wvText.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
 		//wvText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
-        tvDate.setText(GM.formatDate(cursor.getString(3) + " 00:00:00", lang, true, false, false));
-        tvPrice.setText(String.format(getString(R.string.price), cursor.getInt(5)));
-        tvCity.setText(cursor.getString(4));
+		tvDate.setText(GM.formatDate(cursor.getString(3) + " 00:00:00", lang, true, false, false));
+		tvPrice.setText(String.format(getString(R.string.price), cursor.getInt(5)));
+		tvCity.setText(cursor.getString(4));
 
-        //Get images
-        Cursor imageCursor = db.rawQuery("SELECT image, idx FROM activity_image WHERE activity = " + id + " ORDER BY idx LIMIT 5;", null);
-        int i = 0;
+		//Get images
+		Cursor imageCursor = db.rawQuery("SELECT image, idx FROM activity_image WHERE activity = " + id + " ORDER BY idx LIMIT 5;", null);
+		int i = 0;
 		String image;
-        while (imageCursor.moveToNext()) {
-            image = imageCursor.getString(0);
-
-            //Check if image exists
-            File f;
-            f = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image);
-            if (f.exists()){
-                //If the image exists, set it.
-                Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image);
-                images[i].setImageBitmap(myBitmap);
-            }
-            else {
-                //If not, create directories and download asynchronously
-                File fpath;
-                fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/");
-                //noinspection ResultOfMethodCallIgnored
-                fpath.mkdirs();
-                new DownloadImage(GM.API.SERVER + "/img/actividades/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image, images[i], GM.IMG.SIZE.PREVIEW).execute();
-            }
-            images[i].setVisibility(View.VISIBLE);
-            i ++;
-        }
-        imageCursor.close();
-        cursor.close();
-
-        //Get itinerary
-        Cursor cursorItinerary = db.rawQuery("SELECT activity_itinerary.id, activity_itinerary.name_" + lang + " AS name, description_" + lang + " AS description, start, place.name_" + lang + " AS placename, address_" + lang + " AS address, lat, lon FROM activity_itinerary, place WHERE activity_itinerary.place = place.id AND activity = " + id + ";", null);
-        if (cursorItinerary.getCount() <= 0){
-            LinearLayout sch = (LinearLayout) view.findViewById(R.id.ll_activity_future_schedule);
-            sch.setVisibility(View.GONE);
-        }
-        else{
-            LinearLayout list = (LinearLayout) view.findViewById(R.id.ll_activity_future_schedule_list);
-            LinearLayout entry;
-            LayoutInflater factory = LayoutInflater.from(getActivity());
-            while (cursorItinerary.moveToNext()) {
-                //Create a new row
-                entry = (LinearLayout) factory.inflate(R.layout.row_activity_schedule, null);
-
-                //Set time
-                TextView tvSchTime = (TextView) entry.findViewById(R.id.tv_row_activity_itinerary_time);
-                tvSchTime.setText(cursorItinerary.getString(3).substring(11, 16));
-
-                //Set title
-                TextView tvSchTitle = (TextView) entry.findViewById(R.id.tv_row_activity_itinerary_title);
-                tvSchTitle.setText(cursorItinerary.getString(1));
+		while (imageCursor.moveToNext()) {
+			image = imageCursor.getString(0);
+
+			//Check if image exists
+			File f;
+			f = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image);
+			if (f.exists()){
+				//If the image exists, set it.
+				Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image);
+				images[i].setImageBitmap(myBitmap);
+			}
+			else {
+				//If not, create directories and download asynchronously
+				File fpath;
+				fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/");
+				//noinspection ResultOfMethodCallIgnored
+				fpath.mkdirs();
+				new DownloadImage(GM.API.SERVER + "/img/actividades/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image, images[i], GM.IMG.SIZE.PREVIEW).execute();
+			}
+			images[i].setVisibility(View.VISIBLE);
+			i ++;
+		}
+		imageCursor.close();
+		cursor.close();
+
+		//Get itinerary
+		Cursor cursorItinerary = db.rawQuery("SELECT activity_itinerary.id AS id, activity_itinerary.name_" + lang + " AS name, description_" + lang + " AS description, start, place.name_" + lang + " AS placename, address_" + lang + " AS address, lat, lon, route FROM activity_itinerary, place WHERE activity_itinerary.place = place.id AND activity = " + id + ";", null);
+		/*
+		 * 0: id
+		 * 1: name
+		 * 2: description
+		 * 3: start
+		 * 4: place
+		 * 5: address
+		 * 6: lat
+		 * 7: lon
+		 * 8: route
+		 */
+		if (cursorItinerary.getCount() <= 0){
+			LinearLayout sch = (LinearLayout) view.findViewById(R.id.ll_activity_future_schedule);
+			sch.setVisibility(View.GONE);
+		}
+		else{
+			LinearLayout list = (LinearLayout) view.findViewById(R.id.ll_activity_future_schedule_list);
+			LinearLayout entry;
+			LayoutInflater factory = LayoutInflater.from(getActivity());
+
+			while (cursorItinerary.moveToNext()) {
+				//Create a new row
+				entry = (LinearLayout) factory.inflate(R.layout.row_activity_schedule, list, false);
+
+				//Set time
+				TextView tvSchTime = (TextView) entry.findViewById(R.id.tv_row_activity_itinerary_time);
+				tvSchTime.setText(cursorItinerary.getString(3).substring(11, 16));
+
+				//Set title
+				TextView tvSchTitle = (TextView) entry.findViewById(R.id.tv_row_activity_itinerary_title);
+				tvSchTitle.setText(cursorItinerary.getString(1));
 
 				//Set Id
 				TextView tvSchId = (TextView) entry.findViewById(R.id.tv_row_activity_itinerary_id);
 				tvSchId.setText(cursorItinerary.getString(0));
 
-                //Set description
-                TextView tvSchDescription = (TextView) entry.findViewById(R.id.tv_row_activity_itinerary_description);
-                if (!cursorItinerary.getString(1).equals(cursorItinerary.getString(2))){
-                    tvSchDescription.setVisibility(View.GONE);
-                }
-                else {
-                    tvSchTitle.setText(cursorItinerary.getString(2));
-                }
-
-                //Set place
-                TextView tvSchPlace = (TextView) entry.findViewById(R.id.tv_row_activity_itinerary_place);
-                tvSchPlace.setText(cursorItinerary.getString(4));
-
-                //Set address
-                TextView tvSchAddress = (TextView) entry.findViewById(R.id.tv_row_activity_itinerary_address);
-                if (!cursorItinerary.getString(4).equals(cursorItinerary.getString(5))){
-                    tvSchAddress.setVisibility(View.GONE);
-                }
-                else {
-                    tvSchAddress.setText(cursorItinerary.getString(5));
-                }
+				//Set description
+				TextView tvSchDescription = (TextView) entry.findViewById(R.id.tv_row_activity_itinerary_description);
+				if (cursorItinerary.getString(1).equals(cursorItinerary.getString(2))){
+					tvSchDescription.setVisibility(View.GONE);
+				}
+				else {
+					tvSchDescription.setText(cursorItinerary.getString(2));
+				}
+
+				//Set place
+				TextView tvSchPlace = (TextView) entry.findViewById(R.id.tv_row_activity_itinerary_place);
+				tvSchPlace.setText(cursorItinerary.getString(4));
+
+				// Set route indicator
+				if (cursorItinerary.getString(8) != null && cursorItinerary.getString(8).length() > 0){
+					ImageView ivPinpoint = (ImageView) entry.findViewById(R.id.iv_row_activity_itinerary_pinpoint);
+					ivPinpoint.setImageResource(R.drawable.pinpoint_route);
+				}
+
+				//Set address
+				TextView tvSchAddress = (TextView) entry.findViewById(R.id.tv_row_activity_itinerary_address);
+				if (cursorItinerary.getString(4).equals(cursorItinerary.getString(5))){
+					tvSchAddress.setVisibility(View.GONE);
+				}
+				else {
+					tvSchAddress.setText(cursorItinerary.getString(5));
+				}
 
 				//Set click listener
 				entry.setOnClickListener(new View.OnClickListener() {
@@ -202,283 +205,240 @@ public class ActivityFutureLayout extends Fragment implements OnMapReadyCallback
 					}
 				});
 
-                list.addView(entry);
-            }
-        }
-
-
-        cursorItinerary.close();
-        db.close();
-
-		v = view;
-        return view;
-    }
+				list.addView(entry);
+			}
+		}
 
-    /**
-     * Shows a dialog with info about the selected event.
-     *
-     * @param id The event id
-     */
-    @SuppressWarnings("ConstantConditions")
-	private void showDialog(final int id){
 
-        //Create the dialog
-        final Dialog dialog = new Dialog(getActivity());
-
-        //Set up dialog window
-        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
-        dialog.setContentView(R.layout.dialog_schedule);
-
-        //Date formatters
-        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
-        SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd-", Locale.US);
-        SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm", Locale.US);
-
-        //Set the custom dialog components - text, image and button
-        TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_title);
-        TextView tvDescription = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_description);
-        TextView tvHost = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_host);
-        TextView tvDate = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_date);
-        TextView tvTime = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_time);
-        TextView tvPlace = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_place);
-        TextView tvAddress = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_address);
-        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);
-        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){
-            cursor.moveToNext();
-
-            //Set title
-            tvTitle.setText(cursor.getString(1));
-            markerName = cursor.getString(1);
-
-            //Set description
-            tvDescription.setText(cursor.getString(2));
-
-            //Set host field hidden
-           	tvHost.setVisibility(View.GONE);
-
-            //Set date
-            try{
-                Date day = dateFormat.parse(cursor.getString(4));
-                Date date = new Date();
-                //If the event is today, show "Today" instead of the date
-                if (dayFormat.format(day).equals(dayFormat.format(date)))
-                    tvDate.setText(dialog.getContext().getString(R.string.today));
-
-                else{
-                    Calendar cal = Calendar.getInstance();
-                    cal.setTime(date);
-                    cal.add(Calendar.HOUR_OF_DAY, 24);
-
-                    //If the event is tomorrow, show "Tomorrow" instead of the date
-                    if (dayFormat.format(cal.getTime()).equals(dayFormat.format(date))){
-                        tvDate.setText(dialog.getContext().getString(R.string.tomorrow));
-                    }
-
-                    //Else, show the date
-                    else{
-                        SimpleDateFormat printFormat = new SimpleDateFormat("dd MMMM", Locale.US);
-                        tvDate.setText(printFormat.format(day));
-                    }
-                }
-            }
-            catch (Exception ex){
-                Log.e("Error parsing date", ex.toString());
-            }
-
-            //Set time
-            try{
-                if (cursor.getString(5) == null || cursor.getString(5).length() == 0) {
-                    tvTime.setText(timeFormat.format(dateFormat.parse(cursor.getString(4))));
-                }
-                else {
-                    String time = timeFormat.format(dateFormat.parse(cursor.getString(4))) + " - " + timeFormat.format(dateFormat.parse(cursor.getString(5)));
-                    tvTime.setText(time);
-                }
-            }
-            catch (ParseException ex){
-                Log.e("Error parsing time", ex.toString());
-            }
-
-            //Set the place
-            tvPlace.setText(cursor.getString(6));
-            tvAddress.setText(cursor.getString(7));
-
-            //Set up map
-            location = new LatLng(Double.parseDouble(cursor.getString(8)), Double.parseDouble(cursor.getString(9)));
-            mapView = (MapView) dialog.findViewById(R.id.mv_dialog_schedule_map);
-            mapView.onCreate(bund);
-
-            //Close the db connection
-            cursor.close();
-            db.close();
-
-            //Set close button
-            btClose.setOnClickListener(new View.OnClickListener() {
-                @Override
-                public void onClick(View v) {
-                    dialog.dismiss();
-                }
-            });
-
-            //Actions to take when the dialog is cancelled
-            dialog.setOnCancelListener(new DialogInterface.OnCancelListener(){
-                @Override
-                public void onCancel(DialogInterface dialog) {
-                    if (map != null) {
-						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)) {
-							map.setMyLocationEnabled(false);
-						}
-					}
-                    if (mapView != null){
-                        mapView.onResume();
-                        mapView.onDestroy();
-                    }
-                }
-            });
-
-            //Show the dialog
-            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
-            lp.copyFrom(dialog.getWindow().getAttributes());
-            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
-            lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
-            lp.gravity = Gravity.CENTER;
-            lp.dimAmount = 0.0f;
-            dialog.getWindow().setAttributes(lp);
-
-            //Show dialog
-            dialog.show();
-
-            //Start the map
-            startMap();
-            mapView.onResume();
-            dialog.setOnShowListener(new DialogInterface.OnShowListener(){
-
-                @Override
-                public void onShow(DialogInterface dialog) {
-                    // Gets to GoogleMap from the MapView and does initialization stuff
-                    startMap();
-
-                }
-            });
-
-        }
-    }
+		cursorItinerary.close();
+		db.close();
 
-	/**
-	 * Starts the map in the dialog.
-	 */
-	private void startMap(){
-		mapView.getMapAsync(this);
+		return view;
 	}
 
 	/**
-	 * Called when the fragment is brought back into the foreground.
-	 * Resumes the map and the location manager.
+	 * Shows a dialog with info about the selected event.
 	 *
-	 * @see android.app.Fragment#onResume()
+	 * @param id The event id
 	 */
-	@Override
-	public void onResume() {
-		if (mapView != null)
-			mapView.onResume();
-		if (map != null) {
-			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)) {
-				map.setMyLocationEnabled(true);
+	@SuppressWarnings("ConstantConditions")
+	private void showDialog(final int id){
+
+		//Create the dialog
+		final Dialog dialog = new Dialog(getActivity());
+
+		//Set up dialog window
+		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
+		dialog.setContentView(R.layout.dialog_schedule);
+
+		//Date formatters
+		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
+		SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm", Locale.US);
+
+		//Set the custom dialog components - text, image, buttons, map
+		LinearLayout llPlace = (LinearLayout) dialog.findViewById(R.id.ll_dialog_schedule_place);
+		TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_title);
+		TextView tvDescription = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_description);
+		TextView tvHost = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_host);
+		TextView tvDate = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_date);
+		TextView tvTime = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_time);
+		TextView tvPlace = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_place);
+		TextView tvAddress = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_address);
+		TextView tvOsm = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_osm);
+		Button btClose = (Button) dialog.findViewById(R.id.bt_schedule_close);
+		MapView mapView = (MapView) dialog.findViewById(R.id.mv_dialog_schedule_map);
+
+		// Basic map setup
+		mapView.setMultiTouchControls(true);
+		IMapController mapController = mapView.getController();
+
+		//Get info about the event
+		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 id, name_" + lang + ", description_" + lang + ", place, route, start, end FROM activity_itinerary WHERE id = " + id + " ORDER BY start;", null);
+		if (cursor.getCount() > 0){
+
+			cursor.moveToNext();
+
+			// Get data
+			String title = cursor.getString(1);
+			String description = "";
+			if (!cursor.isNull(2)){
+				description = cursor.getString(2);
+			}
+			int placeId = 0;
+			if (!cursor.isNull(3)){
+				placeId = cursor.getInt(3);
+			}
+			int routeId = 0;
+			if (!cursor.isNull(4)){
+				routeId = cursor.getInt(4);
+			}
+			String strStart = cursor.getString(5);
+			String strEnd = "";
+			if (!cursor.isNull(6)){
+				strEnd = cursor.getString(6);
 			}
-		}
-		super.onResume();
-	}
 
-	/**
-	 * Called when the fragment is destroyed.
-	 * Finishes the map.
-	 *
-	 * @see android.app.Fragment#onDestroy()
-	 */
-	@Override
-	public void onDestroy() {
-		super.onDestroy();
-		if (map != null) {
-			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)) {
-				map.setMyLocationEnabled(false);
+			//Set title
+			tvTitle.setText(title);
+
+			//Set description
+			tvDescription.setText(description);
+
+			//Hide the host and date fields
+		   	tvHost.setVisibility(View.GONE);
+			tvDate.setVisibility(View.GONE);
+
+			//Set time
+			try{
+				if (strEnd.length() == 0) {
+					tvTime.setText(timeFormat.format(dateFormat.parse(strStart)));
+				}
+				else {
+					String time = timeFormat.format(dateFormat.parse(strStart)) + " - " + timeFormat.format(dateFormat.parse(strEnd));
+					tvTime.setText(time);
+				}
+			}
+			catch (ParseException ex){
+				Log.e("ACTIVITY_FUTURE_LAYOUT", "Error parsing time: " + ex.toString());
 			}
-		}
-		if (mapView != null){
-			mapView.onResume();
-			mapView.onDestroy();
-		}
-	}
 
-	/**
-	 * Called when the fragment is paused.
-	 * Finishes the map.
-	 *
-	 * @see android.app.Fragment#onPause()
-	 */
-	@Override
-	public void onPause() {
-		super.onDestroy();
-		if (map != null) {
-			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)) {
-				map.setMyLocationEnabled(false);
+			//Set the place
+			if (routeId != 0){
+				llPlace.setVisibility(View.GONE);
+				Cursor routeCursor = db.rawQuery("SELECT id, c_lat, c_lon, zoom FROM route WHERE id = " + routeId + ";", null);
+				if (routeCursor.moveToNext()) {
+
+					// Read from route_point and draw the route on the map.
+					Cursor pointCursor = db.rawQuery("SELECT lat_o, lon_o, lat_d, lon_d FROM route_point WHERE route = " + routeId + " ORDER BY part;", null);
+					final ArrayList<GeoPoint> points = new ArrayList<>();
+					GeoPoint lastPoint = new GeoPoint(0.0, 0.0);
+					GeoPoint firstPoint = null;
+					while (pointCursor.moveToNext()){
+						if (firstPoint == null){
+							firstPoint = new GeoPoint(pointCursor.getDouble(0), pointCursor.getDouble(1));
+						}
+						points.add(new GeoPoint(pointCursor.getDouble(0), pointCursor.getDouble(1)));
+						lastPoint = new GeoPoint(pointCursor.getDouble(2), pointCursor.getDouble(3));
+					}
+					// For the last one, also take destination
+					points.add(lastPoint);
+
+					pointCursor.close();
+
+					// Center map
+					mapController.setCenter(firstPoint);
+					mapController.setZoom(routeCursor.getInt(3));
+
+					// Create path
+					Polyline line = new Polyline();
+					line.setPoints(points);
+					line.setColor(getResources().getColor(R.color.map_route, null));
+					line.setWidth(30.0f);
+					mapView.getOverlays().add(line);
+
+					// Set markers
+					OverlayItem startOverlay = new OverlayItem(title, title, firstPoint);
+					Drawable startMarker = this.getResources().getDrawable(R.drawable.pinpoint_start, null);
+					startOverlay.setMarker(startMarker);
+					OverlayItem endOverlay = new OverlayItem(title, title, lastPoint);
+					Drawable endMarker = this.getResources().getDrawable(R.drawable.pinpoint_end, null);
+					endOverlay.setMarker(endMarker);
+					final ArrayList<OverlayItem> markers = new ArrayList<>();
+					markers.add(startOverlay);
+					markers.add(endOverlay);
+					ItemizedIconOverlay markersOverlay = new ItemizedIconOverlay<>(markers,
+					  new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
+					        public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
+					                return true;
+					        }
+					        public boolean onItemLongPress(final int index, final OverlayItem item) {
+					                return true;
+					        }
+					  }, getContext());
+					mapView.getOverlays().add(markersOverlay);
+
+				}
+				routeCursor.close();
+
 			}
-		}
-		if (mapView != null){
-			mapView.onPause();
+			else{
+				Cursor placeCursor = db.rawQuery("SELECT name_" + lang + ", address_" + lang + ", lat, lon FROM place WHERE id = " + placeId + ";", null);
+				if (placeCursor.moveToNext()){
+					tvPlace.setText(placeCursor.getString(0));
+					tvAddress.setText(placeCursor.getString(1));
+
+					// Configure map marker
+					mapController.setZoom(17);
+					GeoPoint center = new GeoPoint(placeCursor.getDouble(2), placeCursor.getDouble(3));
+					mapController.setCenter(center);
+					OverlayItem locationOverlayItem = new OverlayItem(title, placeCursor.getString(0), center);
+					Drawable locationMarker = this.getResources().getDrawable(R.drawable.pinpoint, null);
+					locationOverlayItem.setMarker(locationMarker);
+					final ArrayList<OverlayItem> items = new ArrayList<>();
+					items.add(locationOverlayItem);
+					ItemizedIconOverlay locationOverlay = new ItemizedIconOverlay<>(items,
+							new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
+								public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
+									return true;
+								}
+								public boolean onItemLongPress(final int index, final OverlayItem item) {
+									return true;
+								}
+							}, getContext());
+					mapView.getOverlays().add(locationOverlay);
+				}
+				placeCursor.close();
+			}
+
+			//Set up OpenStreetMap attribution
+			tvOsm.setOnClickListener(new OnClickListener() {
+				@Override
+				public void onClick(View view) {
+					Intent i = new Intent(Intent.ACTION_VIEW);
+					i.setData(Uri.parse(GM.URL.OSM_COPYRIGHT));
+					startActivity(i);
+				}
+			});
+
+			//Close the db connection
+			cursor.close();
+			db.close();
+
+			//Set close button
+			btClose.setOnClickListener(new View.OnClickListener() {
+				@Override
+				public void onClick(View v) {
+					dialog.dismiss();
+				}
+			});
+
+			//Show the dialog
+			WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
+			lp.copyFrom(dialog.getWindow().getAttributes());
+			lp.width = WindowManager.LayoutParams.MATCH_PARENT;
+			lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
+			lp.gravity = Gravity.CENTER;
+			lp.dimAmount = 0.0f;
+			dialog.getWindow().setAttributes(lp);
+
+			//Show dialog
+			dialog.show();
+
 		}
 	}
 
 	/**
-	 * Called in a situation of low memory.
+	 * Called when the activity is resumed.
 	 * Lets the map handle this situation.
 	 *
-	 * @see android.app.Fragment#onLowMemory()
+	 * @see android.app.Fragment#onResume()
 	 */
 	@Override
-	public void onLowMemory() {
-		super.onLowMemory();
-		if (mapView != null){
-			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)) {
-				mapView.onResume();
-			}
-			mapView.onLowMemory();
-		}
+	public void onResume() {
+		Configuration.getInstance().load(getContext(), PreferenceManager.getDefaultSharedPreferences(getContext()));
+		super.onResume();
 	}
 
-	/**
-	 * Called when the map is ready to be displayed.
-	 * Sets the map options and a marker for the map.
-	 *
-	 * @param googleMap The map to be shown
-	 *
-	 * @see com.google.android.gms.maps.OnMapReadyCallback#onMapReady(com.google.android.gms.maps.GoogleMap)
-	 */
-	@Override
-	public void onMapReady(GoogleMap googleMap) {
-		this.map = googleMap;
-
-		map.getUiSettings().setMyLocationButtonEnabled(false);
-		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)) {
-			map.setMyLocationEnabled(true);
-		}
-		// Needs to call MapsInitializer before doing any CameraUpdateFactory calls
-		try {
-			MapsInitializer.initialize(this.getActivity());
-			CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(location, 14);
-			map.animateCamera(cameraUpdate);
-		} catch (Exception e) {
-			Log.e("Error initializing maps", e.toString());
-		}
-		//Set GM marker
-		MarkerOptions mo = new MarkerOptions();
-		mo.title(markerName);
-		mo.position(location);
-		map.addMarker(mo);
-
-	}
-}
+}

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

@@ -1,7 +1,6 @@
 package com.ivalentin.margolariak;
 
 
-import android.annotation.SuppressLint;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.graphics.Bitmap;
@@ -11,7 +10,6 @@ import android.app.Fragment;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
 import android.text.Html;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -29,241 +27,245 @@ import java.io.File;
  * @see Fragment
  *
  */
-@SuppressLint("ResultOfMethodCallIgnored")
 public class ActivityLayout extends Fragment{
 
-    /**
-     * Run when the fragment is inflated.
-     * Assigns views, gets the date and does the first call to the {@link #populate} function.
-     *
-     * @param inflater A LayoutInflater to manage views
-     * @param container The container View
-     * @param savedInstanceState Bundle containing the state
-     *
-     * @return The fragment view
-     *
-     * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
-     */
-    @SuppressLint("InflateParams") //Throws unknown error when done properly.
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
-        //Load the layout
-        View view = inflater.inflate(R.layout.fragment_layout_activities, null);
-
-        //Set the title
-        ((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_activities));
-
-        populate(view);
-        return view;
-    }
-
-    /**
-     * Populates the list of activities.
-     * It uses the default layout as parent.
-     */
-    @SuppressWarnings("ResultOfMethodCallIgnored")
-    @SuppressLint("InflateParams") //Throws unknown error when done properly.
-    private void populate(View view){
-        LinearLayout llListFuture = (LinearLayout) view.findViewById(R.id.ll_activities_future_list);
-        LinearLayout llListPast = (LinearLayout) view.findViewById(R.id.ll_activities_past_list);
-        LinearLayout entry;
-
-        //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);
-        final Cursor cursor;
-        String lang = GM.getLang();
-
-        //Get data from the database of the future activities
-        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 DESC;", null);
-        if (cursor.getCount() > 0) {
-            TextView tvNoFuture = (TextView) view.findViewById(R.id.tv_activities_no_future);
-            tvNoFuture.setVisibility(View.GONE);
-
-            //Print rows
-            while (cursor.moveToNext()) {
-                //Create a new row
-                entry = (LinearLayout) factory.inflate(R.layout.row_activity_future, null);
-
-                //Set margins TODO: I dont know why it doesnt read margins from the xml
-                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-                int margin = (int) (9 * getActivity().getResources().getDisplayMetrics().density);
-                layoutParams.setMargins(margin, margin, margin, margin);
-                entry.setLayoutParams(layoutParams);
-
-                //Set title
-                TextView tvTitle = (TextView) entry.findViewById(R.id.tv_row_activity_future_title);
-                tvTitle.setText(cursor.getString(3));
-
-                //Set city
-                TextView tvCity = (TextView) entry.findViewById(R.id.tv_row_activity_future_city);
-                tvCity.setText(cursor.getString(2));
-
-                //Set price
-                TextView tvPrice = (TextView) entry.findViewById(R.id.tv_row_activity_future_price);
-                tvPrice.setText(String.format(getString(R.string.price), cursor.getInt(5)));
-
-                //Set text
-                String text = Html.fromHtml(cursor.getString(4)).toString();
-                TextView tvText = (TextView) entry.findViewById(R.id.tv_row_activity_future_text);
-                tvText.setText(text);
-
-                //Set date
-                TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_activity_future_date);
-                tvDate.setText(GM.formatDate(cursor.getString(1) + " 00:00:00", lang, true, false, false));
-
-                //Set hidden id
-                TextView tvId = (TextView) entry.findViewById(R.id.tv_row_activity_future_hidden);
-                tvId.setText(cursor.getString(0));
-
-                //Get image
-                ImageView iv = (ImageView) entry.findViewById(R.id.iv_row_activity_future);
-                Cursor cursorImage = db.rawQuery("SELECT image FROM activity_image WHERE activity = " + cursor.getString(0) + " ORDER BY idx LIMIT 1;", null);
-                if (cursorImage.getCount() > 0) {
-                    cursorImage.moveToFirst();
-                    String image = cursorImage.getString(0);
-
-                    //Check if image exists
-                    File f;
-                    f = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image);
-                    if (f.exists()) {
-                        //If the image exists, set it.
-                        Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image);
-                        iv.setImageBitmap(myBitmap);
-                    } else {
-                        //If not, create directories and download asynchronously
-                        File fpath;
-                        fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
-                        fpath.mkdirs();
-                        new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
-                    }
-                }
-                cursorImage.close();
-
-                //Set onCLickListener
-                entry.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        //Toast.makeText(getActivity(), "OPENING POST", Toast.LENGTH_LONG).show();
-                        Fragment fragment = new ActivityFutureLayout();
-                        Bundle bundle = new Bundle();
-                        //Pass post id
-                        int id = Integer.parseInt(((TextView) v.findViewById(R.id.tv_row_activity_future_hidden)).getText().toString());
-                        bundle.putInt("activity", id);
-                        fragment.setArguments(bundle);
-
-                        FragmentManager fm = ActivityLayout.this.getActivity().getFragmentManager();
-                        FragmentTransaction ft = fm.beginTransaction();
-
-                        ft.replace(R.id.activity_main_content_fragment, fragment);
-                        ft.addToBackStack("activity_" + id);
-                        ft.commit();
-                    }
-                });
-
-                //Add to the list
-                llListFuture.addView(entry);
-            }
-            cursor.close();
-
-        }
-
-        //Get data from the database of the past activities
-        Cursor cursorPast = db.rawQuery("SELECT id, date, city, title_" + lang + " AS title, text_" + lang + " AS text, after_" + lang + " AS after FROM activity WHERE date < date('now') ORDER BY date DESC;", null);
-
-
-        //Print rows
-        while (cursorPast.moveToNext()) {
-            //Create a new row
-            entry = (LinearLayout) factory.inflate(R.layout.row_activity_past, null);
-
-            //Set margins TODO: I dont know why it doesnt read margins from the xml
-            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-            int margin = (int) (9 * getActivity().getResources().getDisplayMetrics().density);
-            layoutParams.setMargins(margin, margin, margin, margin);
-            entry.setLayoutParams(layoutParams);
-
-            //Set title
-            TextView tvTitle = (TextView) entry.findViewById(R.id.tv_row_activity_past_title);
-            tvTitle.setText(cursorPast.getString(3));
-
-            //Set text
-            String text;
-            if (cursorPast.getString(5) == null){
-                text = Html.fromHtml(cursorPast.getString(4)).toString();
-            }
-            else {
-                if (cursorPast.getString(5) == null || cursorPast.getString(5).length() < 1) {
-                    text = Html.fromHtml(cursorPast.getString(4)).toString();
-                } else {
-                    text = Html.fromHtml(cursorPast.getString(5)).toString();
-                }
-            }
-            TextView tvText = (TextView) entry.findViewById(R.id.tv_row_activity_past_text);
-            tvText.setText(text);
-
-            //Set date
-            TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_activity_past_date);
-            tvDate.setText(GM.formatDate(cursorPast.getString(1) + " 00:00:00", lang, true, true, false));
-
-            //Set hidden id
-            TextView tvId = (TextView) entry.findViewById(R.id.tv_row_activity_past_hidden);
-            tvId.setText(cursorPast.getString(0));
-
-            //Get image
-            ImageView iv = (ImageView) entry.findViewById(R.id.iv_row_activity_past);
-            Cursor cursorImage = db.rawQuery("SELECT image FROM activity_image WHERE activity = " + cursorPast.getString(0) + " ORDER BY idx LIMIT 1;", null);
-            if (cursorImage.getCount() > 0) {
-                cursorImage.moveToFirst();
-                String image = cursorImage.getString(0);
-
-                //Check if image exists
-                File f;
-                f = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image);
-                if (f.exists()) {
-                    //If the image exists, set it.
-                    Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image);
-                    iv.setImageBitmap(myBitmap);
-                } else {
-                    //If not, create directories and download asynchronously
-                    File fpath;
-                    fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
-                    fpath.mkdirs();
-                    new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
-                }
-            }
-            cursorImage.close();
-
-            //Set onCLickListener
-            entry.setOnClickListener(new View.OnClickListener() {
-                @Override
-                public void onClick(View v) {
-                //Toast.makeText(getActivity(), "OPENING POST", Toast.LENGTH_LONG).show();
-                Fragment fragment = new ActivityPastLayout();
-                Bundle bundle = new Bundle();
-                //Pass post id
-                int id = Integer.parseInt(((TextView) v.findViewById(R.id.tv_row_activity_past_hidden)).getText().toString());
-                bundle.putInt("activity", id);
-                fragment.setArguments(bundle);
-
-                FragmentManager fm = ActivityLayout.this.getActivity().getFragmentManager();
-                FragmentTransaction ft = fm.beginTransaction();
-
-                ft.replace(R.id.activity_main_content_fragment, fragment);
-                ft.addToBackStack("activity_" + id);
-                ft.commit();
-                }
-            });
-
-            //Add to the list
-            llListPast.addView(entry);
-        }
-        cursorPast.close();
-        db.close();
-
-
-
-    }
+	/**
+	 * Run when the fragment is inflated.
+	 * Assigns views, gets the date and does the first call to the {@link #populate} function.
+	 *
+	 * @param inflater A LayoutInflater to manage views
+	 * @param container The container View
+	 * @param savedInstanceState Bundle containing the state
+	 *
+	 * @return The fragment view
+	 *
+	 * @see Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
+	 */
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+		//Load the layout
+		View view = inflater.inflate(R.layout.fragment_layout_activities, container, false);
+
+		//Set the title
+		((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_activities));
+
+		populate(view);
+		return view;
+	}
+
+	/**
+	 * Populates the list of activities.
+	 * It uses the default layout as parent.
+	 */
+	private void populate(View view){
+		LinearLayout llListFuture = (LinearLayout) view.findViewById(R.id.ll_activities_future_list);
+		LinearLayout llListPast = (LinearLayout) view.findViewById(R.id.ll_activities_past_list);
+		LinearLayout entry;
+
+		//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);
+		final Cursor cursor;
+		String lang = GM.getLang();
+
+		//Get data from the database of the future activities
+		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 DESC;", null);
+		/*
+		 * 0: id
+		 * 1: date
+		 * 3: city
+		 * 4: title
+		 * 5: text
+		 * 6: price
+		 */
+		if (cursor.getCount() > 0) {
+			TextView tvNoFuture = (TextView) view.findViewById(R.id.tv_activities_no_future);
+			tvNoFuture.setVisibility(View.GONE);
+
+			//Print rows
+			while (cursor.moveToNext()) {
+				//Create a new row
+				entry = (LinearLayout) factory.inflate(R.layout.row_activity_future, llListFuture, false);
+
+				//Set margins
+				LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+				int margin = (int) (9 * getActivity().getResources().getDisplayMetrics().density);
+				layoutParams.setMargins(margin, margin, margin, margin);
+				entry.setLayoutParams(layoutParams);
+
+				//Set title
+				TextView tvTitle = (TextView) entry.findViewById(R.id.tv_row_activity_future_title);
+				tvTitle.setText(cursor.getString(3));
+
+				//Set city
+				TextView tvCity = (TextView) entry.findViewById(R.id.tv_row_activity_future_city);
+				tvCity.setText(cursor.getString(2));
+
+				//Set price
+				TextView tvPrice = (TextView) entry.findViewById(R.id.tv_row_activity_future_price);
+				tvPrice.setText(String.format(getString(R.string.price), cursor.getInt(5)));
+
+				//Set text
+				String text = Html.fromHtml(cursor.getString(4)).toString();
+				TextView tvText = (TextView) entry.findViewById(R.id.tv_row_activity_future_text);
+				tvText.setText(text);
+
+				//Set date
+				TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_activity_future_date);
+				tvDate.setText(GM.formatDate(cursor.getString(1) + " 00:00:00", lang, true, false, false));
+
+				//Set hidden id
+				TextView tvId = (TextView) entry.findViewById(R.id.tv_row_activity_future_hidden);
+				tvId.setText(cursor.getString(0));
+
+				//Get image
+				ImageView iv = (ImageView) entry.findViewById(R.id.iv_row_activity_future);
+				Cursor cursorImage = db.rawQuery("SELECT image FROM activity_image WHERE activity = " + cursor.getString(0) + " ORDER BY idx LIMIT 1;", null);
+				if (cursorImage.getCount() > 0) {
+					cursorImage.moveToFirst();
+					String image = cursorImage.getString(0);
+
+					//Check if image exists
+					File f;
+					f = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image);
+					if (f.exists()) {
+						//If the image exists, set it.
+						Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image);
+						iv.setImageBitmap(myBitmap);
+					}
+					else {
+						//If not, create directories and download asynchronously
+						File fpath;
+						fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
+						fpath.mkdirs();
+						new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
+					}
+				}
+				cursorImage.close();
+
+				//Set onCLickListener
+				entry.setOnClickListener(new View.OnClickListener() {
+					@Override
+					public void onClick(View v) {
+						//Toast.makeText(getActivity(), "OPENING POST", Toast.LENGTH_LONG).show();
+						Fragment fragment = new ActivityFutureLayout();
+						Bundle bundle = new Bundle();
+						//Pass post id
+						int id = Integer.parseInt(((TextView) v.findViewById(R.id.tv_row_activity_future_hidden)).getText().toString());
+						bundle.putInt("activity", id);
+						fragment.setArguments(bundle);
+
+						FragmentManager fm = ActivityLayout.this.getActivity().getFragmentManager();
+						FragmentTransaction ft = fm.beginTransaction();
+
+						ft.replace(R.id.activity_main_content_fragment, fragment);
+						ft.addToBackStack("activity_" + id);
+						ft.commit();
+					}
+				});
+
+				llListFuture.addView(entry);
+			}
+			cursor.close();
+
+		}
+
+		//Get data from the database of the past activities
+		Cursor cursorPast = db.rawQuery("SELECT id, date, city, title_" + lang + " AS title, text_" + lang + " AS text, after_" + lang + " AS after FROM activity WHERE date < date('now') ORDER BY date DESC;", null);
+		/*
+		 * 0: id
+		 * 1: date
+		 * 2: city
+		 * 3: title
+		 * 4: text
+		 * 5: after
+		 */
+
+		//Print rows
+		while (cursorPast.moveToNext()) {
+			//Create a new row
+			entry = (LinearLayout) factory.inflate(R.layout.row_activity_past, llListPast, false);
+
+			//Set margins
+			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+			int margin = (int) (9 * getActivity().getResources().getDisplayMetrics().density);
+			layoutParams.setMargins(margin, margin, margin, margin);
+			entry.setLayoutParams(layoutParams);
+
+			//Set title
+			TextView tvTitle = (TextView) entry.findViewById(R.id.tv_row_activity_past_title);
+			tvTitle.setText(cursorPast.getString(3));
+
+			//Set text
+			String text;
+			if (cursorPast.getString(5) != null && cursorPast.getString(5).length() > 0){
+				text = Html.fromHtml(cursorPast.getString(5)).toString();
+			}
+			else{
+				text = Html.fromHtml(cursorPast.getString(4)).toString();
+			}
+			TextView tvText = (TextView) entry.findViewById(R.id.tv_row_activity_past_text);
+			tvText.setText(text);
+
+			//Set date
+			TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_activity_past_date);
+			tvDate.setText(GM.formatDate(cursorPast.getString(1) + " 00:00:00", lang, true, true, false));
+
+			//Set hidden id
+			TextView tvId = (TextView) entry.findViewById(R.id.tv_row_activity_past_hidden);
+			tvId.setText(cursorPast.getString(0));
+
+			//Get image
+			ImageView iv = (ImageView) entry.findViewById(R.id.iv_row_activity_past);
+			Cursor cursorImage = db.rawQuery("SELECT image FROM activity_image WHERE activity = " + cursorPast.getString(0) + " ORDER BY idx LIMIT 1;", null);
+			if (cursorImage.getCount() > 0) {
+				cursorImage.moveToFirst();
+				String image = cursorImage.getString(0);
+
+				//Check if image exists
+				File f;
+				f = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image);
+				if (f.exists()) {
+					//If the image exists, set it.
+					Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image);
+					iv.setImageBitmap(myBitmap);
+				}
+				else {
+					//If not, create directories and download asynchronously
+					File fpath;
+					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
+					fpath.mkdirs();
+					new DownloadImage(GM.API.SERVER + "/img/actividades/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
+				}
+			}
+			cursorImage.close();
+
+			//Set onCLickListener
+			entry.setOnClickListener(new View.OnClickListener() {
+				@Override
+				public void onClick(View v) {
+				//Toast.makeText(getActivity(), "OPENING POST", Toast.LENGTH_LONG).show();
+				Fragment fragment = new ActivityPastLayout();
+				Bundle bundle = new Bundle();
+				//Pass post id
+				int id = Integer.parseInt(((TextView) v.findViewById(R.id.tv_row_activity_past_hidden)).getText().toString());
+				bundle.putInt("activity", id);
+				fragment.setArguments(bundle);
+
+				FragmentManager fm = ActivityLayout.this.getActivity().getFragmentManager();
+				FragmentTransaction ft = fm.beginTransaction();
+
+				ft.replace(R.id.activity_main_content_fragment, fragment);
+				ft.addToBackStack("activity_" + id);
+				ft.commit();
+				}
+			});
+
+			llListPast.addView(entry);
+		}
+		cursorPast.close();
+		db.close();
+	}
 }

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

@@ -1,11 +1,9 @@
 package com.ivalentin.margolariak;
 
-import android.annotation.SuppressLint;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
-import android.os.Build;
 import android.os.Bundle;
 import android.app.Fragment;
 import android.util.Log;
@@ -27,91 +25,85 @@ import java.io.File;
  * @see Fragment
  *
  */
-
 public class ActivityPastLayout extends Fragment {
 
-	@SuppressWarnings("ResultOfMethodCallIgnored")
-    @SuppressLint("InflateParams")
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
-        //Load the layout
-        View view = inflater.inflate(R.layout.fragment_layout_activity_past, null);
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+		//Load the layout
+		View view = inflater.inflate(R.layout.fragment_layout_activity_past, container, false);
+
+		//Get bundled id
+		Bundle bundle = this.getArguments();
+		int id = bundle.getInt("activity", -1);
+		if (id == -1){
+			Log.e("ACTIVITY_PAST_LAYOUT", "No such activity: " + id);
+			this.getActivity().onBackPressed();
+		}
 
-        //Get bundled id
-        Bundle bundle = this.getArguments();
-        int id = bundle.getInt("activity", -1);
-        if (id == -1){
-            Log.e("Activity error", "No such activity: " + id);
-            this.getActivity().onBackPressed();
-        }
+		//Get data from database
+		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, permalink FROM activity WHERE id = " + id + ";", null);
+		cursor.moveToFirst();
 
-        //Get data from database
-        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, permalink FROM activity WHERE id = " + id + ";", null);
-        cursor.moveToFirst();
+		//Get display elements
+		ImageView images[] = new ImageView[5];
+		images[0] = (ImageView) view.findViewById(R.id.iv_activity_past_0);
+		images[1] = (ImageView) view.findViewById(R.id.iv_activity_past_1);
+		images[2] = (ImageView) view.findViewById(R.id.iv_activity_past_2);
+		images[3] = (ImageView) view.findViewById(R.id.iv_activity_past_3);
+		images[4] = (ImageView) view.findViewById(R.id.iv_activity_past_4);
 
-        //Get display elements
-        ImageView images[] = new ImageView[5];
-        images[0] = (ImageView) view.findViewById(R.id.iv_activity_past_0);
-        images[1] = (ImageView) view.findViewById(R.id.iv_activity_past_1);
-        images[2] = (ImageView) view.findViewById(R.id.iv_activity_past_2);
-        images[3] = (ImageView) view.findViewById(R.id.iv_activity_past_3);
-        images[4] = (ImageView) view.findViewById(R.id.iv_activity_past_4);
+		TextView tvTitle = (TextView) view.findViewById(R.id.tv_activity_past_title);
+		TextView tvDate = (TextView) view.findViewById(R.id.tv_activity_past_date);
+		TextView tvCity = (TextView) view.findViewById(R.id.tv_activity_past_city);
+		WebView wvText = (WebView) view.findViewById(R.id.wv_activity_past_text);
+		wvText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
 
-        TextView tvTitle = (TextView) view.findViewById(R.id.tv_activity_past_title);
-        TextView tvDate = (TextView) view.findViewById(R.id.tv_activity_past_date);
-        TextView tvCity = (TextView) view.findViewById(R.id.tv_activity_past_city);
-        WebView wvText = (WebView) view.findViewById(R.id.wv_activity_past_text);
-        if (Build.VERSION.SDK_INT >= 19) {
-            wvText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
-        }
-        else {
-            wvText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
-        }
 
-        //Set fields
-        tvTitle.setText(cursor.getString(1));
-        ((MainActivity) getActivity()).setSectionTitle(cursor.getString(1));
-        ((MainActivity) getActivity()).setShareLink(String.format(getString(R.string.share_with_title), cursor.getString(1)), GM.SHARE.ACTIVITIES + cursor.getString(6));
-        if (cursor.getString(5) == null || cursor.getString(5).length() < 1) {
-            wvText.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
-        } else {
-            wvText.loadDataWithBaseURL(null, cursor.getString(5), "text/html", "utf-8", null);
-        }
-        tvDate.setText(GM.formatDate(cursor.getString(3) + " 00:00:00", lang, true, true, false));
-        tvCity.setText(cursor.getString(4));
+		//Set fields
+		tvTitle.setText(cursor.getString(1));
+		((MainActivity) getActivity()).setSectionTitle(cursor.getString(1));
+		((MainActivity) getActivity()).setShareLink(String.format(getString(R.string.share_with_title), cursor.getString(1)), GM.SHARE.ACTIVITIES + cursor.getString(6));
+		if (cursor.getString(5) == null || cursor.getString(5).length() < 1) {
+			wvText.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
+		} else {
+			wvText.loadDataWithBaseURL(null, cursor.getString(5), "text/html", "utf-8", null);
+		}
+		tvDate.setText(GM.formatDate(cursor.getString(3) + " 00:00:00", lang, true, true, false));
+		tvCity.setText(cursor.getString(4));
 
-        //Get images
-        Cursor imageCursor = db.rawQuery("SELECT image, idx FROM activity_image WHERE activity = " + id + " ORDER BY idx LIMIT 5;", null);
-        int i = 0;
-        while (imageCursor.moveToNext()) {
-            String image = imageCursor.getString(0);
+		//Get images
+		Cursor imageCursor = db.rawQuery("SELECT image, idx FROM activity_image WHERE activity = " + id + " ORDER BY idx LIMIT 5;", null);
+		int i = 0;
+		while (imageCursor.moveToNext()) {
+			String image = imageCursor.getString(0);
 
-            //Check if image exists
-            File f;
-            f = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image);
-            if (f.exists()){
-                //If the image exists, set it.
-                Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image);
-                images[i].setImageBitmap(myBitmap);
-            }
-            else {
-                //If not, create directories and download asynchronously
-                File fpath;
-                fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/");
-                fpath.mkdirs();
-                new DownloadImage(GM.API.SERVER + "/img/actividades/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image, images[i], GM.IMG.SIZE.PREVIEW).execute();
-             }
-            images[i].setVisibility(View.VISIBLE);
-            i ++;
-        }
-        imageCursor.close();
+			//Check if image exists
+			File f;
+			f = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image);
+			if (f.exists()){
+				//If the image exists, set it.
+				Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image);
+				images[i].setImageBitmap(myBitmap);
+			}
+			else {
+				//If not, create directories and download asynchronously
+				File fpath;
+				fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/");
+				fpath.mkdirs();
+				new DownloadImage(GM.API.SERVER + "/img/actividades/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/actividades/preview/" + image, images[i], GM.IMG.SIZE.PREVIEW).execute();
+			 }
+			images[i].setVisibility(View.VISIBLE);
+			i ++;
+		}
+		imageCursor.close();
 
-        cursor.close();
-        db.close();
-        return view;
-    }
-}
+		cursor.close();
+		db.close();
+		return view;
+	}
+}

+ 11 - 10
app/src/main/java/com/ivalentin/margolariak/AlarmReceiver.java

@@ -2,8 +2,10 @@ package com.ivalentin.margolariak;
 
 import android.app.Activity;
 import android.app.AlarmManager;
+import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
+import android.app.TaskStackBuilder;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -14,8 +16,6 @@ import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteDatabaseLockedException;
 import android.graphics.BitmapFactory;
 import android.media.RingtoneManager;
-import android.support.v4.app.NotificationCompat;
-import android.support.v4.app.TaskStackBuilder;
 import android.content.BroadcastReceiver;
 import android.util.Log;
 
@@ -54,7 +54,7 @@ public class AlarmReceiver extends BroadcastReceiver {
 			try{
 				fu = new FetchURL();
 				fu.Run(GM.API.SERVER + GM.API.NOTIFICATION.PATH);
-				Log.d("NOTIFICATIONS", "Fetched notifications");
+				Log.d("ALARM_RECEIVER", "Fetched notifications");
 
 				//Parse info
 				String o = fu.getOutput().toString();
@@ -64,13 +64,13 @@ public class AlarmReceiver extends BroadcastReceiver {
 				try {
 					db = context.openOrCreateDatabase(GM.DB.NAME, Activity.MODE_PRIVATE, null);
 					if (db.isReadOnly()) {
-						Log.e("NOTIFICATIONS", "Database is locked and in read only mode. Not reading new notifications now, but I'll try to sync.");
+						Log.e("ALARM_RECEIVER", "Database is locked and in read only mode. Not reading new notifications now, but I'll try to sync.");
 						new Sync(context).execute(); // Sync before exiting.
 						return;
 					}
 				}
 				catch(SQLiteDatabaseLockedException ex){
-					Log.e("NOTIFICATIONS", "Database is locked and in read only mode. Not reading new notifications now, but I'll try to sync.");
+					Log.e("ALARM_RECEIVER", "Database is locked and in read only mode. Not reading new notifications now, but I'll try to sync.");
 					new Sync(context).execute(); // Sync before exiting.
 					return;
 				}
@@ -138,7 +138,7 @@ public class AlarmReceiver extends BroadcastReceiver {
 						TaskStackBuilder stackBuilder;
 
 						//Send the notification.
-						NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
+						Notification.Builder mBuilder = new Notification.Builder(context)
 								.setSmallIcon(R.drawable.ic_notification)
 								.setContentTitle(title)
 								.setAutoCancel(true)
@@ -181,10 +181,10 @@ public class AlarmReceiver extends BroadcastReceiver {
 
 			}
 			catch(NumberFormatException ex) {
-				Log.e("NOTIFICATION", "Error parsing remote file: " + ex.toString());
+				Log.e("ALARM_RECEIVER", "Notification: Error parsing remote file: " + ex.toString());
 			}
 			catch (Exception ex){
-				Log.e("NOTIFICATION", "Error fetching notifications: " + ex.toString());
+				Log.e("ALARM_RECEIVER", "Notification: Error fetching notifications: " + ex.toString());
 			}
     	}
 
@@ -198,7 +198,7 @@ public class AlarmReceiver extends BroadcastReceiver {
 		 * @param in String to be decoded.
 		 * @return Decoded string.
 		 */
-		static final String decode(final String in){
+		static String decode(final String in){
 			String working = in;
 			int index = working.indexOf("\\u");
 			while(index > -1){
@@ -218,7 +218,8 @@ public class AlarmReceiver extends BroadcastReceiver {
 		}
 
     /**
-     * Sets a repeating alarm. 
+     * Sets a repeating alarm. o
+
      * When the alarm fires, the app broadcasts an Intent to this WakefulBroadcastReceiver.
      * @param context The context of the app
      */

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

@@ -1,9 +1,7 @@
 package com.ivalentin.margolariak;
 
-import android.annotation.SuppressLint;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
-import android.os.Build;
 import android.os.Bundle;
 import android.app.Fragment;
 import android.app.FragmentManager;
@@ -32,73 +30,66 @@ import java.io.File;
  */
 public class AlbumLayout extends Fragment {
 
-	@SuppressWarnings("ResultOfMethodCallIgnored")
-    @SuppressLint("InflateParams") //Throws unknown error when done properly.
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
-        //Load the layout
-        View view = inflater.inflate(R.layout.fragment_layout_album, null);
+		//Load the layout
+		View view = inflater.inflate(R.layout.fragment_layout_album, container, false);
 
-        //Get bundled id
-        Bundle bundle = this.getArguments();
-        int id = bundle.getInt("album", -1);
-        if (id == -1){
-			Log.e("Album error", "No such album: " + id);
+		//Get bundled id
+		Bundle bundle = this.getArguments();
+		int id = bundle.getInt("album", -1);
+		if (id == -1){
+			Log.e("ALBUM_LAYOUT", "No such album: " + id);
 			this.getActivity().onBackPressed();
-        }
+		}
 
-        //Get data from database
-        SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
-        final Cursor cursor;
+		//Get data from database
+		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, description_" + lang + " AS description, permalink FROM album WHERE id = " + id + ";", null);
-        cursor.moveToFirst();
+		cursor = db.rawQuery("SELECT id, title_" + lang + " AS title, description_" + lang + " AS description, permalink FROM album WHERE id = " + id + ";", null);
+		cursor.moveToFirst();
 
-        //Set album elements
-        TextView tvTitle = (TextView) view.findViewById(R.id.tv_album_title);
-        WebView tvDescription = (WebView) view.findViewById(R.id.wv_album_description);
+		//Set album elements
+		TextView tvTitle = (TextView) view.findViewById(R.id.tv_album_title);
+		WebView tvDescription = (WebView) view.findViewById(R.id.wv_album_description);
 
-		if (Build.VERSION.SDK_INT >= 19) {
-			tvDescription.setLayerType(View.LAYER_TYPE_HARDWARE, null);
-		}
-		else {
-			tvDescription.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
-		}
+		tvDescription.setLayerType(View.LAYER_TYPE_HARDWARE, null);
 
-        tvTitle.setText(cursor.getString(1));
+		tvTitle.setText(cursor.getString(1));
 		((MainActivity) getActivity()).setSectionTitle(cursor.getString(1));
 		((MainActivity) getActivity()).setShareLink(String.format(getString(R.string.share_with_title), cursor.getString(1)), GM.SHARE.GALLERY + cursor.getString(3));
 
 		final String albumName = cursor.getString(1);
 		final String albumPerm = cursor.getString(3);
-        if (cursor.getString(2) == null || cursor.getString(2).length() < 1){
-            tvDescription.setVisibility(View.GONE);
-        }
-        else {
-            tvDescription.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
-        }
+		if (cursor.getString(2) == null || cursor.getString(2).length() < 1){
+			tvDescription.setVisibility(View.GONE);
+		}
+		else {
+			tvDescription.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
+		}
 		cursor.close();
 
 
-        //Assign elements
-        LinearLayout llList = (LinearLayout) view.findViewById(R.id.ll_album_list);
-        LinearLayout entry;
+		//Assign elements
+		LinearLayout llList = (LinearLayout) view.findViewById(R.id.ll_album_list);
+		LinearLayout entry;
 
-        //An inflater
-        LayoutInflater factory = LayoutInflater.from(getActivity());
+		//An inflater
+		LayoutInflater factory = LayoutInflater.from(getActivity());
 
-        String image;
-        Cursor imageCursor = db.rawQuery("SELECT id, title_" + lang + " AS title, file, width, height FROM photo, photo_album WHERE photo = id AND album = " + id + " ORDER BY uploaded DESC;", null);
-        while (imageCursor.moveToNext()){
-            //Create a new row
-            entry = (LinearLayout) factory.inflate(R.layout.row_album, null);
+		String image;
+		Cursor imageCursor = db.rawQuery("SELECT id, title_" + lang + " AS title, file, width, height FROM photo, photo_album WHERE photo = id AND album = " + id + " ORDER BY uploaded DESC;", null);
+		while (imageCursor.moveToNext()){
+			//Create a new row
+			entry = (LinearLayout) factory.inflate(R.layout.row_album, llList, false);
 
 			//Set left and right layouts
 			LinearLayout left = (LinearLayout) entry.findViewById(R.id.ll_row_album_left);
 
-            //Set title
-            TextView tvTitleLeft = (TextView) entry.findViewById(R.id.tv_row_album_title_left);
+			//Set title
+			TextView tvTitleLeft = (TextView) entry.findViewById(R.id.tv_row_album_title_left);
 
 			if (imageCursor.getString(1) != null && imageCursor.getString(1).length() > 0) {
 				tvTitleLeft.setText(imageCursor.getString(1));
@@ -107,34 +98,34 @@ public class AlbumLayout extends Fragment {
 				tvTitleLeft.setVisibility(View.GONE);
 			}
 
-            //Set id
-            TextView tvHiddenLeft = (TextView) entry.findViewById(R.id.tv_row_album_hidden_left);
-            tvHiddenLeft.setText(imageCursor.getString(0));
+			//Set id
+			TextView tvHiddenLeft = (TextView) entry.findViewById(R.id.tv_row_album_hidden_left);
+			tvHiddenLeft.setText(imageCursor.getString(0));
 
-            //Set image
-            ImageView ivLeft = (ImageView) entry.findViewById(R.id.iv_row_album_left);
-            image = imageCursor.getString(2);
+			//Set image
+			ImageView ivLeft = (ImageView) entry.findViewById(R.id.iv_row_album_left);
+			image = imageCursor.getString(2);
 
-            //Check if image exists
-            File f;
-            f = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image);
-            if (f.exists()){
-                //If the image exists, set it.
+			//Check if image exists
+			File f;
+			f = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image);
+			if (f.exists()){
+				//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.SIZE.PREVIEW));
 				}
 				catch (Exception ex){
-					Log.e("Bitmap error", "Not loading image " + image + ": " + ex.toString());
+					Log.e("ALBUM_LAYOUT", "Bitmap error. Not loading image " + image + ": " + ex.toString());
 				}
-            }
-            else {
-                //If not, create directories and download asynchronously
-                File fpath;
-                fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/");
-                fpath.mkdirs();
+			}
+			else {
+				//If not, create directories and download asynchronously
+				File fpath;
+				fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/");
+				fpath.mkdirs();
 				new DownloadImage(GM.API.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivLeft, GM.IMG.SIZE.PREVIEW).execute();
-            }
+			}
 
 			//Count comments
 			Cursor cursorComments = db.rawQuery("SELECT id FROM photo_comment WHERE photo = " + imageCursor.getString(0) + ";", null);
@@ -164,15 +155,15 @@ public class AlbumLayout extends Fragment {
 				ft.commit();
 				}
 			});
-            
-            //If odd pass, to the right line
-            if (imageCursor.moveToNext()){
+			
+			//If odd pass, to the right line
+			if (imageCursor.moveToNext()){
 
-                LinearLayout right = (LinearLayout) entry.findViewById(R.id.ll_row_album_right);
-                right.setVisibility(View.VISIBLE);
+				LinearLayout right = (LinearLayout) entry.findViewById(R.id.ll_row_album_right);
+				right.setVisibility(View.VISIBLE);
 
-                //Set title
-                TextView tvTitleRight = (TextView) entry.findViewById(R.id.tv_row_album_title_right);
+				//Set title
+				TextView tvTitleRight = (TextView) entry.findViewById(R.id.tv_row_album_title_right);
 				if (imageCursor.getString(1) != null && imageCursor.getString(1).length() > 0) {
 					tvTitleRight.setText(imageCursor.getString(1));
 				}
@@ -180,32 +171,32 @@ public class AlbumLayout extends Fragment {
 					tvTitleRight.setVisibility(View.GONE);
 				}
 
-                //Set id
-                TextView tvHiddenRight = (TextView) entry.findViewById(R.id.tv_row_album_hidden_right);
-                tvHiddenRight.setText(imageCursor.getString(0));
-
-                //Set image
-                ImageView ivRight = (ImageView) entry.findViewById(R.id.iv_row_album_right);
-                image = imageCursor.getString(2);
-                //Check if image exists
-                f = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image);
-                if (f.exists()){
-                    //If the image exists, set it.
+				//Set id
+				TextView tvHiddenRight = (TextView) entry.findViewById(R.id.tv_row_album_hidden_right);
+				tvHiddenRight.setText(imageCursor.getString(0));
+
+				//Set image
+				ImageView ivRight = (ImageView) entry.findViewById(R.id.iv_row_album_right);
+				image = imageCursor.getString(2);
+				//Check if image exists
+				f = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image);
+				if (f.exists()){
+					//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.SIZE.PREVIEW));
 					}
 					catch (Exception ex){
-						Log.e("Bitmap error", "Not loading image " + image + ": " + ex.toString());
+						Log.e("ALBUM_LAYOUT", "Bitmap error. Not loading image " + image + ": " + ex.toString());
 					}
-                }
-                else {
-                    //If not, create directories and download asynchronously
-                    File fpath;
-                    fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/");
-                    fpath.mkdirs();
+				}
+				else {
+					//If not, create directories and download asynchronously
+					File fpath;
+					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/");
+					fpath.mkdirs();
 					new DownloadImage(GM.API.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivRight, GM.IMG.SIZE.PREVIEW).execute();
-                }
+				}
 
 				//Count comments
 				cursorComments = db.rawQuery("SELECT id FROM photo_comment WHERE photo = " + imageCursor.getString(0) + ";", null);
@@ -233,13 +224,13 @@ public class AlbumLayout extends Fragment {
 					ft.commit();
 					}
 				});
-            }
+			}
 
-            llList.addView(entry);
-        }
+			llList.addView(entry);
+		}
 
-        imageCursor.close();
-        db.close();
-        return view;
-    }
-}
+		imageCursor.close();
+		db.close();
+		return view;
+	}
+}

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

@@ -1,7 +1,6 @@
 package com.ivalentin.margolariak;
 
 
-import android.annotation.SuppressLint;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.graphics.Bitmap;
@@ -31,218 +30,212 @@ import java.io.File;
  */
 public class BlogLayout extends Fragment{
 
-    //Main View
-    private View view;
-
-    private int offset = 0;
-    private int totalPost = 0;
-
-    /**
-     * Run when the fragment is inflated.
-     * Assigns views, gets the date and does the first call to the {@link #populate} function.
-     *
-     * @param inflater A LayoutInflater to manage views
-     * @param container The container View
-     * @param savedInstanceState Bundle containing the state
-     *
-     * @return The fragment view
-     *
-     * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
-     */
-    @SuppressLint("InflateParams")
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
-        //Load the layout
-        view = inflater.inflate(R.layout.fragment_layout_blog, null);
-
-        //Set the title
-        ((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);
-        Cursor cursor = db.rawQuery("SELECT id FROM post;", null);
-        totalPost = cursor.getCount();
-        cursor.close();
-        db.close();
-
-        //Assign pager buttons
-        final Button btnPrevious = (Button) view.findViewById(R.id.bt_blog_previous);
-        final Button btnNext = (Button) view.findViewById(R.id.bt_blog_next);
-
-        btnPrevious.setOnClickListener(new View.OnClickListener() {
-           @Override
-           public void onClick(View v) {
-               offset -= 5;
-               btnNext.setVisibility(View.VISIBLE);
-               populate(offset);
-               if (offset == 0){
-                   v.setVisibility(View.INVISIBLE);
-               }
-           }
-        });
-
-        btnNext.setOnClickListener(new View.OnClickListener() {
-           @Override
-           public void onClick(View v) {
-               offset += 5;
-               btnPrevious.setVisibility(View.VISIBLE);
-               populate(offset);
-               if (offset >= totalPost - 5){
-                   v.setVisibility(View.INVISIBLE);
-               }
-           }
-        });
-
-        populate(offset);
-
-        return view;
-    }
-
-    /**
-     * Called when the fragment is brought back into the foreground.
-     * Shows or hides the pager buttons.
-     *
-     * @see android.app.Fragment#onResume()
-     */
-    @Override
-    @SuppressLint("InflateParams")
-    @SuppressWarnings("ResultOfMethodCallIgnored")
-    public void onResume(){
-        //Assign pager buttons
-        Button btnPrevious = (Button) view.findViewById(R.id.bt_blog_previous);
-        Button btnNext = (Button) view.findViewById(R.id.bt_blog_next);
-        if (offset == 0){
-            btnPrevious.setVisibility(View.INVISIBLE);
-        }
-        else{
-            btnPrevious.setVisibility(View.VISIBLE);
-        }
-        if (offset >= totalPost - 5){
-            btnNext.setVisibility(View.INVISIBLE);
-        }
-        else{
-            btnNext.setVisibility(View.VISIBLE);
-        }
-        super.onResume();
-    }
-
-    /**
-     * Populates the list of activities around.
-     * It uses the default layout as parent.
-     */
-    @SuppressLint("InflateParams")
-    @SuppressWarnings("ResultOfMethodCallIgnored")
-    private void populate(int offset){
-
-        //Assign elements
-        LinearLayout llList = (LinearLayout) view.findViewById(R.id.ll_blog_list);
-        LinearLayout entry;
-
-        //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);
-        final Cursor cursor;
-        String lang = GM.getLang();
-
-        //Get data from the database
-        cursor = db.rawQuery("SELECT id, title_" + lang+ " AS title, text_" + lang + " AS text, dtime FROM post ORDER BY dtime DESC LIMIT 5 OFFSET " + offset + ";", null);
-
-        //Clear the list
-        llList.removeAllViews();
-
-        //Loop
-        while (cursor.moveToNext()){
-
-            //Create a new row
-            entry = (LinearLayout) factory.inflate(R.layout.row_blog, null);
-
-            //Set margins TODO: I dont know why it doesnt read margins from the xml
-            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-            int margin = (int) (9 * getActivity().getResources().getDisplayMetrics().density);
-            layoutParams.setMargins(margin, margin, margin, margin);
-            entry.setLayoutParams(layoutParams);
-
-            //Set title
-            TextView tvTitle = (TextView) entry.findViewById(R.id.tv_row_blog_title);
-            tvTitle.setText(cursor.getString(1));
-
-            //Set text
-            String text = Html.fromHtml(cursor.getString(2)).toString();
-            TextView tvText = (TextView) entry.findViewById(R.id.tv_row_blog_text);
-            tvText.setText(text);
-
-            //Set date
-            TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_blog_date);
-            tvDate.setText(GM.formatDate(cursor.getString(3), lang, true, true, false));
-
-            //Set hidden id
-            TextView tvId = (TextView) entry.findViewById(R.id.tv_row_blog_hidden);
-            tvId.setText(cursor.getString(0));
-
-            //Get image
-            ImageView iv = (ImageView) entry.findViewById(R.id.iv_row_blog_image);
-            Cursor cursorImage = db.rawQuery("SELECT image FROM post_image WHERE post = " + cursor.getString(0) +" ORDER BY idx LIMIT 1;", null);
-            if (cursorImage.getCount() > 0){
-                cursorImage.moveToFirst();
-                String image = cursorImage.getString(0);
-
-                //Check if image exists
-                File f;
-                f = new File(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image);
-                if (f.exists()){
-                    //If the image exists, set it.
-                    Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image);
-                    iv.setImageBitmap(myBitmap);
-                }
-                else {
-                    //If not, create directories and download asynchronously
-                    File fpath;
-                    fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/");
-                    fpath.mkdirs();
-                    new DownloadImage(GM.API.SERVER + "/img/blog/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
-                }
-            }
-            else{
-                iv.setVisibility(View.GONE);
-            }
-            cursorImage.close();
-
-            //Count comments
-            Cursor cursorComment = db.rawQuery("SELECT * FROM post_comment WHERE post = " + cursor.getString(0) +";", null);
-            TextView tvDetails = (TextView) entry.findViewById(R.id.tv_row_blog_details);
-            tvDetails.setText(String.valueOf(cursorComment.getCount()));
-            cursorComment.close();
-
-            //Set onCLickListener
-            entry.setOnClickListener(new View.OnClickListener(){
-                @Override
-                public void onClick(View v) {
-                //Toast.makeText(getActivity(), "OPENING POST", Toast.LENGTH_LONG).show();
-                Fragment fragment = new PostLayout();
-                Bundle bundle = new Bundle();
-                //Pass post id
-                int id = Integer.parseInt(((TextView) v.findViewById(R.id.tv_row_blog_hidden)).getText().toString());
-                bundle.putInt("post", id);
-                fragment.setArguments(bundle);
-
-                FragmentManager fm = BlogLayout.this.getActivity().getFragmentManager();
-                FragmentTransaction ft = fm.beginTransaction();
-
-                ft.replace(R.id.activity_main_content_fragment, fragment);
-                ft.addToBackStack("post_" + id);
-                ft.commit();
-                }
-            });
-
-            //Add to the list
-            llList.addView(entry);
-        }
-
-        //Close the database
-        cursor.close();
-        db.close();
-
-    }
+	//Main View
+	private View view;
+
+	private int offset = 0;
+	private int totalPost = 0;
+
+	/**
+	 * Run when the fragment is inflated.
+	 * Assigns views, gets the date and does the first call to the {@link #populate} function.
+	 *
+	 * @param inflater A LayoutInflater to manage views
+	 * @param container The container View
+	 * @param savedInstanceState Bundle containing the state
+	 *
+	 * @return The fragment view
+	 *
+	 * @see Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
+	 */
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+		//Load the layout
+		view = inflater.inflate(R.layout.fragment_layout_blog, container, false);
+
+		//Set the title
+		((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);
+		Cursor cursor = db.rawQuery("SELECT id FROM post;", null);
+		totalPost = cursor.getCount();
+		cursor.close();
+		db.close();
+
+		//Assign pager buttons
+		final Button btnPrevious = (Button) view.findViewById(R.id.bt_blog_previous);
+		final Button btnNext = (Button) view.findViewById(R.id.bt_blog_next);
+
+		btnPrevious.setOnClickListener(new View.OnClickListener() {
+		   @Override
+		   public void onClick(View v) {
+			   offset -= 5;
+			   btnNext.setVisibility(View.VISIBLE);
+			   populate(offset);
+			   if (offset == 0){
+				   v.setVisibility(View.INVISIBLE);
+			   }
+		   }
+		});
+
+		btnNext.setOnClickListener(new View.OnClickListener() {
+		   @Override
+		   public void onClick(View v) {
+			   offset += 5;
+			   btnPrevious.setVisibility(View.VISIBLE);
+			   populate(offset);
+			   if (offset >= totalPost - 5){
+				   v.setVisibility(View.INVISIBLE);
+			   }
+		   }
+		});
+
+		populate(offset);
+
+		return view;
+	}
+
+	/**
+	 * Called when the fragment is brought back into the foreground.
+	 * Shows or hides the pager buttons.
+	 *
+	 * @see android.app.Fragment#onResume()
+	 */
+	@Override
+	public void onResume(){
+		//Assign pager buttons
+		Button btnPrevious = (Button) view.findViewById(R.id.bt_blog_previous);
+		Button btnNext = (Button) view.findViewById(R.id.bt_blog_next);
+		if (offset == 0){
+			btnPrevious.setVisibility(View.INVISIBLE);
+		}
+		else{
+			btnPrevious.setVisibility(View.VISIBLE);
+		}
+		if (offset >= totalPost - 5){
+			btnNext.setVisibility(View.INVISIBLE);
+		}
+		else{
+			btnNext.setVisibility(View.VISIBLE);
+		}
+		super.onResume();
+	}
+
+	/**
+	 * Populates the list of activities around.
+	 * It uses the default layout as parent.
+	 */
+	private void populate(int offset){
+
+		//Assign elements
+		LinearLayout llList = (LinearLayout) view.findViewById(R.id.ll_blog_list);
+		LinearLayout entry;
+
+		//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);
+		final Cursor cursor;
+		String lang = GM.getLang();
+
+		//Get data from the database
+		cursor = db.rawQuery("SELECT id, title_" + lang+ " AS title, text_" + lang + " AS text, dtime FROM post ORDER BY dtime DESC LIMIT 5 OFFSET " + offset + ";", null);
+
+		//Clear the list
+		llList.removeAllViews();
+
+		//Loop
+		while (cursor.moveToNext()){
+
+			//Create a new row
+			entry = (LinearLayout) factory.inflate(R.layout.row_blog, llList, false);
+
+			//Set margins
+			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+			int margin = (int) (9 * getActivity().getResources().getDisplayMetrics().density);
+			layoutParams.setMargins(margin, margin, margin, margin);
+			entry.setLayoutParams(layoutParams);
+
+			//Set title
+			TextView tvTitle = (TextView) entry.findViewById(R.id.tv_row_blog_title);
+			tvTitle.setText(cursor.getString(1));
+
+			//Set text
+			String text = Html.fromHtml(cursor.getString(2)).toString();
+			TextView tvText = (TextView) entry.findViewById(R.id.tv_row_blog_text);
+			tvText.setText(text);
+
+			//Set date
+			TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_blog_date);
+			tvDate.setText(GM.formatDate(cursor.getString(3), lang, true, true, false));
+
+			//Set hidden id
+			TextView tvId = (TextView) entry.findViewById(R.id.tv_row_blog_hidden);
+			tvId.setText(cursor.getString(0));
+
+			//Get image
+			ImageView iv = (ImageView) entry.findViewById(R.id.iv_row_blog_image);
+			Cursor cursorImage = db.rawQuery("SELECT image FROM post_image WHERE post = " + cursor.getString(0) +" ORDER BY idx LIMIT 1;", null);
+			if (cursorImage.getCount() > 0){
+				cursorImage.moveToFirst();
+				String image = cursorImage.getString(0);
+
+				//Check if image exists
+				File f;
+				f = new File(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image);
+				if (f.exists()){
+					//If the image exists, set it.
+					Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image);
+					iv.setImageBitmap(myBitmap);
+				}
+				else {
+					//If not, create directories and download asynchronously
+					File fpath;
+					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/");
+					fpath.mkdirs();
+					new DownloadImage(GM.API.SERVER + "/img/blog/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/miniature/" + image, iv, GM.IMG.SIZE.MINIATURE).execute();
+				}
+			}
+			else{
+				iv.setVisibility(View.GONE);
+			}
+			cursorImage.close();
+
+			//Count comments
+			Cursor cursorComment = db.rawQuery("SELECT * FROM post_comment WHERE post = " + cursor.getString(0) +";", null);
+			TextView tvDetails = (TextView) entry.findViewById(R.id.tv_row_blog_details);
+			tvDetails.setText(String.valueOf(cursorComment.getCount()));
+			cursorComment.close();
+
+			//Set onCLickListener
+			entry.setOnClickListener(new View.OnClickListener(){
+				@Override
+				public void onClick(View v) {
+				//Toast.makeText(getActivity(), "OPENING POST", Toast.LENGTH_LONG).show();
+				Fragment fragment = new PostLayout();
+				Bundle bundle = new Bundle();
+				//Pass post id
+				int id = Integer.parseInt(((TextView) v.findViewById(R.id.tv_row_blog_hidden)).getText().toString());
+				bundle.putInt("post", id);
+				fragment.setArguments(bundle);
+
+				FragmentManager fm = BlogLayout.this.getActivity().getFragmentManager();
+				FragmentTransaction ft = fm.beginTransaction();
+
+				ft.replace(R.id.activity_main_content_fragment, fragment);
+				ft.addToBackStack("post_" + id);
+				ft.commit();
+				}
+			});
+
+			llList.addView(entry);
+		}
+
+		//Close the database
+		cursor.close();
+		db.close();
+
+	}
 }

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

@@ -7,7 +7,7 @@ import android.content.Intent;
 /**
  * Broadcast receiver that receives the BOOT_COMPLETED event and sets an alarm.
  * 
- * @see @android.content.BroadCastReceiver
+ * @see BroadcastReceiver
  * 
  * @author Iñigo Valentin
  *

+ 28 - 27
app/src/main/java/com/ivalentin/margolariak/CustomScrollView.java

@@ -1,6 +1,5 @@
 package com.ivalentin.margolariak;
 
-import android.annotation.SuppressLint;
 import android.content.Context;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
@@ -16,37 +15,40 @@ import android.widget.ScrollView;
  *
  */
 public class CustomScrollView extends ScrollView{
-	
+
 	/**
-     * Constructor.
-     * 
-     * @param context The context of the app or Activity.
-     */
+	 * Constructor.
+	 * 
+	 * @param context The context of the app or Activity.
+	 */
 	public CustomScrollView(Context context) {
 		super(context);
 	}
-	
+
+
 	/**
-     * Constructor.
-     * 
-     * @param context The context of the app or Activity.
-     * @param attrs Attributes.
-     */
+	 * Constructor.
+	 * 
+	 * @param context The context of the app or Activity.
+	 * @param attrs Attributes.
+	 */
 	public CustomScrollView(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
+		super(context, attrs);
+	}
+
+
+	/**
+	 * Constructor.
+	 * 
+	 * @param context The context of the app or Activity.
+	 * @param attrs Attributes.
+	 * @param defStyle Default style.
+	 */
+	public CustomScrollView(Context context, AttributeSet attrs, int defStyle) {
+		super(context, attrs, defStyle);
+	}
+
 
-    /**
-     * Constructor.
-     * 
-     * @param context The context of the app or Activity.
-     * @param attrs Attributes.
-     * @param defStyle Default style.
-     */
-    public CustomScrollView(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-    }
-	
 	/**
 	 * Overrides the default onTouchListener. 
 	 * 
@@ -59,9 +61,8 @@ public class CustomScrollView extends ScrollView{
 	 * 
 	 * @return True if the app handles the motion (i.e. to slide), false otherwise (normal event)
 	 */
-	@SuppressLint("ClickableViewAccessibility") //Disturbs the sliding process
 	@Override
-    public boolean onTouchEvent(MotionEvent ev) {
+	public boolean onTouchEvent(MotionEvent ev) {
 		int width = this.getWidth();
 		super.onTouchEvent(ev);
 		return ev.getX() >= (float) width / 10;

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

@@ -22,7 +22,7 @@ final class Distance {
 	 *
 	 * @return The distance between the points
 	 */
-	public static double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
+	static double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
 		double theta = lon1 - lon2;
 		double dist = Math.sin(deg2rad(lat1)) * Math.sin(deg2rad(lat2)) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.cos(deg2rad(theta));
 		dist = Math.acos(dist);

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

@@ -22,11 +22,12 @@ import java.net.URLConnection;
  */
 class DownloadImage extends AsyncTask<Void, Void, Void> {
 
-    private final String file;
-    private final String path;
-    private final ImageView iv;
+	private final String file;
+	private final String path;
+	private final ImageView iv;
 	private final int size;
 
+
 	/**
 	 * Constructor.
 	 *
@@ -37,63 +38,62 @@ class DownloadImage extends AsyncTask<Void, Void, Void> {
 	 *
 	 * @see android.widget.ImageView
 	 */
-    public DownloadImage(String file, String path, ImageView iv, int size) {
-        super();
-        this.file = file;
-        this.path = path;
-        this.iv = iv;
+	public DownloadImage(String file, String path, ImageView iv, int size) {
+		super();
+		this.file = file;
+		this.path = path;
+		this.iv = iv;
 		this.size = size;
-    }
+	}
 
-    /**
-     * Downloading file in background thread.
-	 */
-    @Override
-    protected Void doInBackground(Void... v) {
-        int count;
-        try {
 
-            URL url = new URL(file);
+	/**
+	 * Downloading file in background thread.
+	 */
+	@Override
+	protected Void doInBackground(Void... v) {
+		int count;
+		try {
 
-            URLConnection conection = url.openConnection();
-            conection.connect();
+			URL url = new URL(file);
 
-            // input stream to read file - with 8k buffer
-            InputStream input = new BufferedInputStream(url.openStream(), 8192);
+			URLConnection conection = url.openConnection();
+			conection.connect();
 
-            // Output stream to write file
-            OutputStream output = new FileOutputStream(path);
-            byte data[] = new byte[1024];
+			// input stream to read file - with 8k buffer
+			InputStream input = new BufferedInputStream(url.openStream(), 8192);
 
-            while ((count = input.read(data)) != -1) {
+			// Output stream to write file
+			OutputStream output = new FileOutputStream(path);
+			byte data[] = new byte[1024];
 
-                // writing data to file
-                output.write(data, 0, count);
+			while ((count = input.read(data)) != -1) {
 
-            }
+				// writing data to file
+				output.write(data, 0, count);
 
-            // flushing output
-            output.flush();
+			}
 
-            // closing streams
-            output.close();
-            input.close();
+			// flushing output
+			output.flush();
 
-        } catch (Exception e) {
-            Log.e("Error downloading: ", e.getMessage());
-        }
+			// closing streams
+			output.close();
+			input.close();
 
-        return null;
-    }
+		} catch (Exception e) {
+			Log.e("DOWNLOAD_IMAGE", "Error downloading: " + e.getMessage());
+		}
 
+		return null;
+	}
 
 
-    /**
-     * After completing background task, set the image on the ImageView.
-     */
-    @Override
-    protected void onPostExecute(Void v) {
-        Log.d("File downloaded", path);
+	/**
+	 * After completing background task, set the image on the ImageView.
+	 */
+	@Override
+	protected void onPostExecute(Void v) {
 		try {
 			File file = new File(path);
 			iv.setImageBitmap(GM.decodeSampledBitmapFromFile(file.getAbsolutePath(), size));
@@ -102,6 +102,6 @@ class DownloadImage extends AsyncTask<Void, Void, Void> {
 		catch(Exception ex){
 			Log.e("Bitmap error", "Not loading image " + path + ": " + ex.toString());
 		}
-    }
+	}
 
-}
+}

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

@@ -17,24 +17,26 @@ class FetchURL {
 	//List of strings that will contain the output, line by line
 	private List<String> output;
 	private String url;
-  
+
+
 	/**
 	 * Constructor.
 	 */
-	public FetchURL(){
+	FetchURL(){
 		output = new ArrayList<>();
 	}
-  
+
+
 	/**
 	 * Returns the content of the fetched page.
 	 * 
 	 * @return A List of strings containing the lines of the web page.
 	 */
-	public List<String> getOutput(){
+	List<String> getOutput(){
 		return output;
 	}
-  
-		
+
+
 	/**
 	 * Actually fetches the web page.
 	 * 

+ 308 - 112
app/src/main/java/com/ivalentin/margolariak/GM.java

@@ -12,7 +12,7 @@ import java.util.Locale;
 
 /**
  * Final class that contains useful static values to be used across the app.
- * 
+ *
  * @author Iñigo Valentin
  *
  */
@@ -26,13 +26,159 @@ final class GM {
 		/**
 		 * Name of the database.
 		 */
-		static final String NAME = "gm";
+		static final String NAME = "gmv3";
 
 		/**
 		 * Initial version of the database.
 		 */
 		static final int INITIAL_VERSION = 0;
 
+		/**
+		 * Names of the tables of the database.
+		 */
+		final class TABLE {
+
+			/**
+			 * Name of the table "activity".
+			 */
+			static final String ACTIVITY = "activity";
+
+			/**
+			 * Name of the table "activity_comment".
+			 */
+			static final String ACTIVITY_COMMENT = "activity_comment";
+
+			/**
+			 * Name of the table "activity_image".
+			 */
+			static final String ACTIVITY_IMAGE = "activity_image";
+
+			/**
+			 * Name of the table "activity_itinerary".
+			 */
+			static final String ACTIVITY_ITINERARY = "activity_itinerary";
+
+			/**
+			 * Name of the table "activity_tag".
+			 */
+			static final String ACTIVITY_TAG = "activity_tag";
+
+			/**
+			 * Name of the table "album".
+			 */
+			static final String ALBUM = "album";
+
+			/**
+			 * Name of the table "festival".
+			 */
+			static final String FESTIVAL = "festival";
+
+			/**
+			 * Name of the table "festival_day".
+			 */
+			static final String FESTIVAL_DAY = "festival_day";
+
+			/**
+			 * Name of the table "festival_event_city".
+			 */
+			static final String FESTIVAL_EVENT_CITY = "festival_event_city";
+
+			/**
+			 * Name of the table "festival_event_gm".
+			 */
+			static final String FESTIVAL_EVENT_GM = "festival_event_gm";
+
+			/**
+			 * Name of the table "festival_event_image".
+			 */
+			static final String FESTIVAL_EVENT_IMAGE = "festival_event_image";
+
+			/**
+			 * Name of the table "festival_offer".
+			 */
+			static final String FESTIVAL_OFFER = "festival_offer";
+
+			/**
+			 * Name of the table "location".
+			 */
+			static final String LOCATION = "location";
+
+			/**
+			 * Name of the table "notification".
+			 */
+			static final String NOTIFICATION = "notification";
+
+			/**
+			 * Name of the table "people".
+			 */
+			static final String PEOPLE = "people";
+
+			/**
+			 * Name of the table "photo".
+			 */
+			static final String PHOTO = "photo";
+
+			/**
+			 * Name of the table "photo_album".
+			 */
+			static final String PHOTO_ALBUM = "photo_album";
+
+			/**
+			 * Name of the table "photo_comment".
+			 */
+			static final String PHOTO_COMMENT = "photo_comment";
+
+			/**
+			 * Name of the table "place".
+			 */
+			static final String PLACE = "place";
+
+			/**
+			 * Name of the table "post".
+			 */
+			static final String POST = "post";
+
+			/**
+			 * Name of the table "post_comment".
+			 */
+			static final String POST_COMMENT = "post_comment";
+
+			/**
+			 * Name of the table "post_image".
+			 */
+			static final String POST_IMAGE = "post_image";
+
+			/**
+			 * Name of the table "post_tag".
+			 */
+			static final String POST_TAG = "post_tag";
+
+			/**
+			 * Name of the table "route".
+			 */
+			static final String ROUTE = "route";
+
+			/**
+			 * Name of the table "route_point".
+			 */
+			static final String ROUTE_POINT = "route_point";
+
+			/**
+			 * Name of the table "settings".
+			 */
+			static final String SETTINGS = "settings";
+
+			/**
+			 * Name of the table "sponsor".
+			 */
+			static final String SPONSOR = "sponsor";
+
+			/**
+			 * Name of the table "version".
+			 */
+			static final String VERSION = "version";
+		}
+
 		/**
 		 * Column types
 		 */
@@ -82,7 +228,7 @@ final class GM {
 				/**
 				 * 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);";
+				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, route INT);";
 
 				/**
 				 * Creates the table "activity_tag" on the database.
@@ -102,12 +248,17 @@ final class GM {
 				/**
 				 * 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);";
+				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, people INT, max_people INT);";
+
+				/**
+				 * Creates the table "festival_event_city" on the database.
+				 */
+				static final String FESTIVAL_EVENT_CITY = "CREATE TABLE IF NOT EXISTS festival_event_city (id INT, title_es VARCHAR, title_en VARCHAR, title_eu VARCHAR, description_es VARCHAR, description_en VARCHAR, description_eu VARCHAR, host INT, sponsor INT, place INT, route INT, start DATETIME, end DATETIME, interest INT);";
 
 				/**
-				 * Creates the table "festival_event" on the database.
+				 * Creates the table "festival_event_gm" 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);";
+				static final String FESTIVAL_EVENT_GM = "CREATE TABLE IF NOT EXISTS festival_event_gm (id INT, title_es VARCHAR, title_en VARCHAR, title_eu VARCHAR, description_es VARCHAR, description_en VARCHAR, description_eu VARCHAR, host INT, sponsor INT, place INT, route INT, start DATETIME, end DATETIME, interest INT);";
 
 				/**
 				 * Creates the table "festival_event_image" on the database.
@@ -174,6 +325,16 @@ final class GM {
 				 */
 				static final String POST_TAG = "CREATE TABLE IF NOT EXISTS post_tag (post INT, tag VARCHAR);";
 
+				/**
+				 * Creates the table "route" on the database.
+				 */
+				static final String ROUTE = "CREATE TABLE IF NOT EXISTS route (id INT, name VARCHAR, mins INT, c_lat DOUBLE, c_lon DOUBLE, zoom INT);";
+
+				/**
+				 * Creates the table "route_point" on the database.
+				 */
+				static final String ROUTE_POINT = "CREATE TABLE IF NOT EXISTS route_point (id INT, route INT, part INT, lat_o DOUBLE, lon_o DOUBLE, lat_d DOUBLE, lon_d DOUBLE, mins INT, visible INT);";
+
 				/**
 				 * Creates the table "settings" on the database.
 				 */
@@ -236,9 +397,14 @@ final class GM {
 				static final String FESTIVAL_DAY = "DROP TABLE festival_day;";
 
 				/**
-				 * Deletes the table "festival_event" from the database.
+				 * Deletes the table "festival_event_city" from the database.
+				 */
+				static final String FESTIVAL_EVENT_CITY = "DROP TABLE festival_event_city;";
+
+				/**
+				 * Deletes the table "festival_event_gm" from the database.
 				 */
-				static final String FESTIVAL_EVENT = "DROP TABLE festival_event;";
+				static final String FESTIVAL_EVENT_GM = "DROP TABLE festival_event_gm;";
 
 				/**
 				 * Deletes the table "festival_event_image" from the database.
@@ -305,6 +471,16 @@ final class GM {
 				 */
 				static final String POST_TAG = "DROP TABLE post_tag;";
 
+				/**
+				 * Deletes the table "route" from the database.
+				 */
+				static final String ROUTE = "DROP TABLE route;";
+
+				/**
+				 * Deletes the table "route_point" from the database.
+				 */
+				static final String ROUTE_POINT = "DROP TABLE route_point;";
+
 				/**
 				 * Deletes the table "settings" from the database.
 				 */
@@ -368,12 +544,17 @@ final class GM {
 				static final String FESTIVAL_DAY = "DELETE FROM festival_day;";
 
 				/**
-				 * Empties the table "festival_event".
+				 * Empties the table "festival_event_city".
 				 */
-				static final String FESTIVAL_EVENT = "DELETE FROM festival_event;";
+				static final String FESTIVAL_EVENT_CITY = "DELETE FROM festival_event_city;";
+
+				/**
+				 * Empties the table "festival_event_gm".
+                 */
+				static final String FESTIVAL_EVENT_GM = "DELETE FROM festival_event_gm;";
 
 				/**
-				 * Empties the table "festival_event".
+				 * Empties the table "festival_event_image".
 				 */
 				static final String FESTIVAL_EVENT_IMAGE = "DELETE FROM festival_event_image;";
 
@@ -437,6 +618,16 @@ final class GM {
 				 */
 				static final String POST_TAG = "DELETE FROM post_tag;";
 
+				/**
+				 * Empties the table "route".
+				 */
+				static final String ROUTE = "DELETE FROM route;";
+
+				/**
+				 * Empties the table "route_point".
+				 */
+				static final String ROUTE_POINT = "DELETE FROM route_point;";
+
 				/**
 				 * Empties the table "settings".
 				 */
@@ -500,9 +691,14 @@ final class GM {
 				static final String FESTIVAL_DAY = GM.DB.QUERY.DROP.FESTIVAL_DAY + GM.DB.QUERY.CREATE.FESTIVAL_DAY;
 
 				/**
-				 * Deletes and then recreates the table "festival_event".
+				 * Deletes and then recreates the table "festival_event_city".
+				 */
+				static final String FESTIVAL_EVENT_CITY = GM.DB.QUERY.DROP.FESTIVAL_EVENT_CITY + GM.DB.QUERY.CREATE.FESTIVAL_EVENT_CITY;
+
+				/**
+				 * Deletes and then recreates the table "festival_event_gm".
 				 */
-				static final String FESTIVAL_EVENT = GM.DB.QUERY.DROP.FESTIVAL_EVENT + GM.DB.QUERY.CREATE.FESTIVAL_EVENT;
+				static final String FESTIVAL_EVENT_GM = GM.DB.QUERY.DROP.FESTIVAL_EVENT_GM + GM.DB.QUERY.CREATE.FESTIVAL_EVENT_GM;
 
 				/**
 				 * Deletes and then recreates the table "festival_event_image".
@@ -569,6 +765,16 @@ final class GM {
 				 */
 				static final String POST_TAG = GM.DB.QUERY.DROP.POST_TAG + GM.DB.QUERY.CREATE.POST_TAG;
 
+				/**
+				 * Deletes and then recreates the table "route".
+				 */
+				static final String ROUTE = GM.DB.QUERY.DROP.ROUTE + GM.DB.QUERY.CREATE.ROUTE;
+
+				/**
+				 * Deletes and then recreates the table "route_point".
+				 */
+				static final String ROUTE_PONT = GM.DB.QUERY.DROP.ROUTE_POINT + GM.DB.QUERY.CREATE.ROUTE_POINT;
+
 				/**
 				 * Deletes and then recreates the table "settings".
 				 */
@@ -714,6 +920,11 @@ final class GM {
 		 */
 		static final String GITHUB = "https://github.com/GasteizkoMargolariak/GasteizkoMargolariakApp";
 
+		/**
+		 * URL of the Open Street Maps copyright.
+		 */
+		static final String OSM_COPYRIGHT = "https://www.openstreetmap.org/copyright";
+
 		/**
 		 * URL of the server.
 		 */
@@ -736,14 +947,25 @@ final class GM {
 		static final String SERVER = URL.SERVER;
 
 		/**
-		 * Utilities for the Sync V1 API.
+		 * Utilities for the Sync V3 API.
 		 */
 		static final class SYNC {
 
 			/**
 			 * Path to the API.
 			 */
-			static final String PATH = "/API/v1/sync.php";
+			static final class PATH {
+
+				/**
+				 * Path to the fast sync API.
+				 */
+				static final String FAST= "/API/v3/fastsync.php";
+
+				/**
+				 * Path to the regular sync API.
+				 */
+				static final String COMPLETE= "/API/v3/sync.php";
+			}
 
 			/**
 			 * Keys fotr the API parameters.
@@ -760,101 +982,34 @@ final class GM {
 				 */
 				static final String USER = "user";
 
-				/**
-				 * Key for the action to perform with the API ("sync" or "version").
-				 */
-				static final String ACTION = "action";
-
-				/**
-				 * Key for the section to sync.
-				 */
-				static final String SECTION = "section";
-
-				/**
-				 * Key for the current version of the database to send to the API.
-				 */
-				static final String VERSION = "version";
-
 				/**
 				 * Key to indicate to the API if the sync is being performed on the foreground.
 				 */
 				static final String FOREGROUND = "foreground";
 
-				/**
-				 * Key to indicate the format of the data for the API to send.
-				 */
-				static final String FORMAT = "format";
-
-				/**
-				 * Key to indicate the language to the API.
-				 */
-				static final String LANG = "lang";
 			}
-
-			/**
-			 * Values for the parameters.
-			 */
-			 static final class VALUE {
-
-				/**
-				 * Value for the ACTION key.
-				 */
-				static final String ACTION = "sync";
-
-				/**
-				 * Value for the SECTION key,
-				 */
-				 static final String SECTION = "all";
-
-				/**
-				 * Value for the FORMAT key.
-				 */
-				static final String FORMAT = "json";
-			 }
 		}
 
 		/**
-		 * Utilities for the Location V1 API.
+		 * Utilities for the Location V3 API.
 		 */
 		static final class LOCATION {
 
 			/**
 			 * Path to the API.
 			 */
-			static final String PATH = "/API/v1/location.php";
-
-			/**
-			 * Keys fotr the API parameters.
-			 */
-			static final class KEY {
-
-				/**
-				 * Key to indicate the format of the data for the API to send.
-				 */
-				static final String FORMAT = "format";
-			}
-
-			/**
-			 * Values for the parameters.
-			 */
-			static final class VALUE {
-
-				/**
-				 * Value for the FORMAT key.
-				 */
-				static final String FORMAT = "json";
-			}
+			static final String PATH = "/API/v3/location.php";
 		}
 
 		/**
-		 * Utilities for the Notifications V1 API.
+		 * Utilities for the Notifications V3 API.
 		 */
 		static final class NOTIFICATION {
 
 			/**
 			 * Path to the API.
 			 */
-			static final String PATH = "/API/v1/notifications.php";
+			static final String PATH = "/API/v3/notifications.php";
 
 			/**
 			 * Keys fotr the API parameters.
@@ -875,37 +1030,42 @@ final class GM {
 				 * Key for the action to perform with the API ("sync" or "version").
 				 */
 				static final String TARGET = "target";
-
-				/**
-				 * Key to indicate the format of the data for the API to send.
-				 */
-				static final String FORMAT = "format";
-			}
-
-			/**
-			 * Values for the parameters.
-			 */
-			static final class VALUE {
-
-				/**
-				 * Value for the FORMAT key.
-				 */
-				static final String FORMAT = "json";
 			}
 		}
 
 		/**
-		 * Utilities for the COMMENT V1 API.
+		 * Utilities for posting comment
 		 */
 		static final class COMMENT {
 
 			/**
 			 * Path to the API.
 			 */
-			static final String PATH = "/API/v1/comment.php";
+			static final String PATH = "/API/v3/comment.php";
 
 			/**
-			 * Keys fotr the API parameters.
+			 * Sections where comments can be posted
+			 */
+			static final class TYPE {
+
+				/**
+				 * Comment in a blog post.
+				 */
+				static final String BLOG = "post";
+
+				/**
+				 * Comment in an activity.
+				 */
+				static final String ACTIVITIES = "activity";
+
+				/**
+				 * Comment in a photo.
+				 */
+				static final String GALLERY = "photo";
+			}
+
+			/**
+			 * Keys for the API parameters.
 			 */
 			static final class KEY {
 
@@ -920,12 +1080,12 @@ final class GM {
 				static final String USER = "user";
 
 				/**
-				 * Key for the action to perform with the API ("sync" or "version").
+				 * Key to indicate the section.
 				 */
-				static final String TARGET = "target";
+				static final String TYPE = "target";
 
 				/**
-				 * Key to indicate the format of the data for the API to send.
+				 * Key to indicate the entry ID.
 				 */
 				static final String ID = "id";
 
@@ -939,6 +1099,11 @@ final class GM {
 				 */
 				static final String TEXT = "text";
 
+				/**
+				 * Key to indicate the text language.
+				 */
+				static final String LANGUAGE = "lang";
+
 			}
 		}
 
@@ -950,7 +1115,13 @@ final class GM {
 	static final class PERMISSION {
 
 		/**
-		 * Code for the location permission request
+		 * Code for the storage persmission request.
+		 */
+
+		static final int STORAGE = 0;
+
+		/**
+		 * Code for the location permission request.
 		 */
 		static final int LOCATION = 1;
 	}
@@ -1184,6 +1355,32 @@ final class GM {
 		static final String GALLERY = HOME + "/galeria/";
 	}
 
+	/**
+	 * Text encoding.
+	 */
+	static final String ENCODING = "UTF-8";
+
+	/**
+	 * Valid languages.
+	 */
+	static final class LANGUAGE{
+
+		/**
+		 * Spanish
+		 */
+		static final String ES = "es";
+
+		/**
+		 * English
+		 */
+		static final String EN = "en";
+
+		/**
+		 * Basque
+		 */
+		static final String EU = "eu";
+	}
+
 	/**
 	 * Gets the language code for sql queries.
 	 * Only three values can be returned: es, eu, en.
@@ -1215,9 +1412,8 @@ final class GM {
 	 * @param includeYear Also returns the year.
 	 * @param includeTime Also returns the hour and minute.
 	 *
-	 * @return The fragment view
+	 * @return The formatted date.
 	 *
-	 * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
 	 */
 	static String formatDate(String dateString, String lang, boolean includeDay, boolean includeYear, boolean includeTime){
 
@@ -1299,7 +1495,7 @@ final class GM {
 			}
 		}
 		catch(Exception ex){
-			Log.e("Date format error", ex.toString());
+			Log.e("GM", "Date format error: " + ex.toString());
 		}
 
 		return output;

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

@@ -1,7 +1,6 @@
 package com.ivalentin.margolariak;
 
 
-import android.annotation.SuppressLint;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.graphics.Bitmap;
@@ -30,152 +29,148 @@ import java.util.Random;
  */
 public class GalleryLayout extends Fragment{
 
-    /**
-     * Run when the fragment is inflated.
-     * Assigns views, gets the date and does the first call to the {@link @populate()} function.
-     *
-     * @param inflater A LayoutInflater to manage views
-     * @param container The container View
-     * @param savedInstanceState Bundle containing the state
-     *
-     * @return The fragment view
-     *
-     * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
-     */
-    @SuppressLint("InflateParams") //Throws unknown error when done properly.
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
-        //Load the layout
-        View view = inflater.inflate(R.layout.fragment_layout_gallery, null);
-
-        //Set the title
-        ((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_gallery));
-
-        populate(view);
-
-        return view;
-    }
-
-    /**
-     * Populates the list of activities around.
-     * It uses the default layout as parent.
-     */
-    @SuppressLint("InflateParams") //Throws unknown error when done properly.
-    @SuppressWarnings("ResultOfMethodCallIgnored")
-    private void populate(View view){
-
-        //Assign elements
-        LinearLayout llList = (LinearLayout) view.findViewById(R.id.ll_gallery_album_list);
-        LinearLayout entry;
-
-        //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);
-        final Cursor cursor;
+	/**
+	 * Run when the fragment is inflated.
+	 * Assigns views, gets the date and does the first call to the {@link @populate()} function.
+	 *
+	 * @param inflater A LayoutInflater to manage views
+	 * @param container The container View
+	 * @param savedInstanceState Bundle containing the state
+	 *
+	 * @return The fragment view
+	 *
+	 * @see Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
+	 */
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+		//Load the layout
+		View view = inflater.inflate(R.layout.fragment_layout_gallery, container, false);
+
+		//Set the title
+		((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_gallery));
+
+		populate(view);
+
+		return view;
+	}
+
+	/**
+	 * Populates the list of activities around.
+	 * It uses the default layout as parent.
+	 */
+	private void populate(View view){
+
+		//Assign elements
+		LinearLayout llList = (LinearLayout) view.findViewById(R.id.ll_gallery_album_list);
+		LinearLayout entry;
+
+		//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);
+		final Cursor cursor;
 		String lang = GM.getLang();
 
-        //Get data from the database
-        cursor = db.rawQuery("SELECT DISTINCT album.id AS id, album.title_" + lang + " AS name FROM photo, album, photo_album WHERE photo.id = photo AND album.id = album ORDER BY uploaded DESC;", null);
+		//Get data from the database
+		cursor = db.rawQuery("SELECT DISTINCT album.id AS id, album.title_" + lang + " AS name FROM photo, album, photo_album WHERE photo.id = photo AND album.id = album ORDER BY uploaded DESC;", null);
 
-        //Loop
-        while (cursor.moveToNext()){
+		//Loop
+		while (cursor.moveToNext()){
 
-            //Create a new row
-            entry = (LinearLayout) factory.inflate(R.layout.row_gallery, null);
+			//Create a new row
+			entry = (LinearLayout) factory.inflate(R.layout.row_gallery, llList, false);
 
-            //Set margins TODO: I dont know why it doesnt read margins from the xml
-            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+			//Set margins
+			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
 			int margin = (int) (9 * getActivity().getResources().getDisplayMetrics().density);
-            layoutParams.setMargins(margin, margin, margin, margin);
-            entry.setLayoutParams(layoutParams);
-
-            //Set title
-            TextView tvTitle = (TextView) entry.findViewById(R.id.tv_row_gallery_title);
-            tvTitle.setText(cursor.getString(1));
-
-            //Set hidden id
-            TextView tvId = (TextView) entry.findViewById(R.id.tv_row_gallery_hidden);
-            tvId.setText(cursor.getString(0));
-
-            //Get images
-            ImageView preview[] = new ImageView[4];
-            preview[0] = (ImageView) entry.findViewById(R.id.iv_row_gallery_0);
-            preview[1] = (ImageView) entry.findViewById(R.id.iv_row_gallery_1);
-            preview[2] = (ImageView) entry.findViewById(R.id.iv_row_gallery_2);
-            preview[3] = (ImageView) entry.findViewById(R.id.iv_row_gallery_3);
-
-            //Get db rows
-            Cursor cursorImage = db.rawQuery("SELECT id, file, width, height FROM photo, photo_album WHERE photo = id AND album = " + cursor.getString(0) + " ORDER BY random() LIMIT 4;", null);
-
-            //Loop
-            int i = 0;
-            Random r;
-            while (cursorImage.moveToNext()){
-                String image = cursorImage.getString(1);
-
-                //Check if image exists
-                File f;
-                f = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/" + image);
-                if (f.exists()){
-                    //If the image exists, set it.
-                    Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/" + image);
-                    preview[i].setImageBitmap(myBitmap);
-                }
-                else {
-                    //If not, create directories and download asynchronously
-                    File fpath;
-                    fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/");
-                    fpath.mkdirs();
-                    new DownloadImage(GM.API.SERVER + "/img/galeria/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/" + image, preview[i], GM.IMG.SIZE.MINIATURE).execute();
-                }
-
-                //Rotate the image
-                r = new Random();
-                int rot = r.nextInt(31) - 15;
-                preview[i].setRotation(rot);
-
-                i ++;
-            }
-
-            //Set photo counter
+			layoutParams.setMargins(margin, margin, margin, margin);
+			entry.setLayoutParams(layoutParams);
+
+			//Set title
+			TextView tvTitle = (TextView) entry.findViewById(R.id.tv_row_gallery_title);
+			tvTitle.setText(cursor.getString(1));
+
+			//Set hidden id
+			TextView tvId = (TextView) entry.findViewById(R.id.tv_row_gallery_hidden);
+			tvId.setText(cursor.getString(0));
+
+			//Get images
+			ImageView preview[] = new ImageView[4];
+			preview[0] = (ImageView) entry.findViewById(R.id.iv_row_gallery_0);
+			preview[1] = (ImageView) entry.findViewById(R.id.iv_row_gallery_1);
+			preview[2] = (ImageView) entry.findViewById(R.id.iv_row_gallery_2);
+			preview[3] = (ImageView) entry.findViewById(R.id.iv_row_gallery_3);
+
+			//Get db rows
+			Cursor cursorImage = db.rawQuery("SELECT id, file, width, height FROM photo, photo_album WHERE photo = id AND album = " + cursor.getString(0) + " ORDER BY random() LIMIT 4;", null);
+
+			//Loop
+			int i = 0;
+			Random r;
+			while (cursorImage.moveToNext()){
+				String image = cursorImage.getString(1);
+
+				//Check if image exists
+				File f;
+				f = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/" + image);
+				if (f.exists()){
+					//If the image exists, set it.
+					Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/" + image);
+					preview[i].setImageBitmap(myBitmap);
+				}
+				else {
+					//If not, create directories and download asynchronously
+					File fpath;
+					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/");
+					fpath.mkdirs();
+					new DownloadImage(GM.API.SERVER + "/img/galeria/miniature/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/" + image, preview[i], GM.IMG.SIZE.MINIATURE).execute();
+				}
+
+				//Rotate the image
+				r = new Random();
+				int rot = r.nextInt(31) - 15;
+				preview[i].setRotation(rot);
+
+				i ++;
+			}
+
+			//Set photo counter
 			Cursor cursorCounter = db.rawQuery("SELECT id FROM photo, photo_album WHERE photo = id AND album = " + cursor.getString(0) + ";", null);
-            TextView tvPhotoCounter = (TextView) entry.findViewById(R.id.tv_row_gallery_counter);
-            tvPhotoCounter.setText(getResources().getQuantityString(R.plurals.gallery_photo_count, cursorCounter.getCount(), cursorCounter.getCount()));
+			TextView tvPhotoCounter = (TextView) entry.findViewById(R.id.tv_row_gallery_counter);
+			tvPhotoCounter.setText(getResources().getQuantityString(R.plurals.gallery_photo_count, cursorCounter.getCount(), cursorCounter.getCount()));
 
 			//Close cursors
 			cursorCounter.close();
-            cursorImage.close();
-
-            //Set onCLickListener
-            entry.setOnClickListener(new View.OnClickListener(){
-                @Override
-                public void onClick(View v) {
-                Fragment fragment = new AlbumLayout();
-                Bundle bundle = new Bundle();
-
-                //Pass post id
-                int id = Integer.parseInt(((TextView) v.findViewById(R.id.tv_row_gallery_hidden)).getText().toString());
-                bundle.putInt("album", id);
-                fragment.setArguments(bundle);
-
-                FragmentManager fm = GalleryLayout.this.getActivity().getFragmentManager();
-                FragmentTransaction ft = fm.beginTransaction();
-
-                ft.replace(R.id.activity_main_content_fragment, fragment);
-                ft.addToBackStack("album_" + id);
-                ft.commit();
-                }
-            });
-
-            //Add to the list
-            llList.addView(entry);
-        }
-
-        //Close database
-        cursor.close();
-        db.close();
-
-    }
+			cursorImage.close();
+
+			//Set onCLickListener
+			entry.setOnClickListener(new View.OnClickListener(){
+				@Override
+				public void onClick(View v) {
+				Fragment fragment = new AlbumLayout();
+				Bundle bundle = new Bundle();
+
+				//Pass post id
+				int id = Integer.parseInt(((TextView) v.findViewById(R.id.tv_row_gallery_hidden)).getText().toString());
+				bundle.putInt("album", id);
+				fragment.setArguments(bundle);
+
+				FragmentManager fm = GalleryLayout.this.getActivity().getFragmentManager();
+				FragmentTransaction ft = fm.beginTransaction();
+
+				ft.replace(R.id.activity_main_content_fragment, fragment);
+				ft.addToBackStack("album_" + id);
+				ft.commit();
+				}
+			});
+
+			llList.addView(entry);
+		}
+
+		//Close database
+		cursor.close();
+		db.close();
+
+	}
 }

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

@@ -6,7 +6,6 @@ import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Locale;
 
-import android.annotation.SuppressLint;
 import android.Manifest;
 import android.app.Activity;
 import android.content.Context;
@@ -26,7 +25,6 @@ import android.net.Uri;
 import android.os.Bundle;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
-import android.support.v4.app.ActivityCompat;
 import android.text.Html;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -49,7 +47,6 @@ import android.widget.Toast;
  * @see Fragment
  *
  */
-@SuppressWarnings("UnusedReturnValue")
 public class HomeLayout extends Fragment implements LocationListener {
 
 	//The location manager
@@ -62,6 +59,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 
 	private View view;
 
+
 	/**
 	 * Run when the fragment is inflated.
 	 * Assigns views, gets the date and does the first call to the {//@link populate function}.
@@ -74,21 +72,25 @@ public class HomeLayout extends Fragment implements LocationListener {
 	 *
 	 * @see android.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
 	 */
-	@SuppressLint("InflateParams") //Throws unknown error when done properly.
 	@Override
 	public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
 
 		//Load the layout.
-		view = inflater.inflate(R.layout.fragment_layout_home, null);
+		view = inflater.inflate(R.layout.fragment_layout_home, container, false);
+
+		//Request storage permissions if not set
+		if (!checkStoragePermission()) {
+			requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, GM.PERMISSION.STORAGE);
+		}
 
 		//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);
+		if (!checkLocationPermission()) {
+			requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, GM.PERMISSION.LOCATION);
 		}
 
 		//Set Location manager
 		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)) {
+		if (checkLocationPermission()) {
 			locationManager.requestLocationUpdates(locationManager.getBestProvider(new Criteria(), true), GM.LOCATION.ACCURACY.TIME, GM.LOCATION.ACCURACY.SPACE, this);
 			onLocationChanged(locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER));
 		}
@@ -109,10 +111,6 @@ public class HomeLayout extends Fragment implements LocationListener {
 		//Set up the gallery section
 		setUpGallery(view);
 
-		//Asynchronously set up location section
-		//This will trigger onLocationChanged, that will trigger setUpLocation
-		new HomeSectionLocation(view).execute();
-
 		//Set up schedule sections
 		setUpSchedule(1, view);
 		setUpSchedule(0, view);
@@ -129,7 +127,6 @@ public class HomeLayout extends Fragment implements LocationListener {
 	 *
 	 * @return The number of entries shown.
 	 */
-	@SuppressLint("InflateParams")
 	private int setUpSchedule(int gm, View view) {
 		int count = 0;
 
@@ -182,7 +179,12 @@ public class HomeLayout extends Fragment implements LocationListener {
 		calendarEnd = calendar;
 		calendarEnd.add(Calendar.MINUTE, -40);
 		endString = dateFormat.format(calendarEnd.getTime());
-		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 <= '" + nowString + "' AND end > '" + nowString + "') OR (start > '" + endString + "' AND start < '" + nowString + "')) AND gm = " + gm + " ORDER BY start LIMIT 2";
+		if (gm == 1) {
+			query = "SELECT festival_event_gm.id, title_" + lang + ", description_" + lang + ", place, start, end, name_" + lang + ", address_" + lang + ", lat, lon FROM festival_event_gm, place WHERE place = place.id AND ((start <= '" + nowString + "' AND end > '" + nowString + "') OR (start > '" + endString + "' AND start < '" + nowString + "')) ORDER BY start LIMIT 2";
+		}
+		else{
+			query = "SELECT festival_event_city.id, title_" + lang + ", description_" + lang + ", place, start, end, name_" + lang + ", address_" + lang + ", lat, lon FROM festival_event_city, place WHERE place = place.id AND ((start <= '" + nowString + "' AND end > '" + nowString + "') OR (start > '" + endString + "' AND start < '" + nowString + "')) ORDER BY start LIMIT 2";
+		}
 
 		//Execute query and loop
 		Cursor cursorNow = db.rawQuery(query, null);
@@ -192,7 +194,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		while (cursorNow.moveToNext()) {
 			count++;
 
-			entry = (LinearLayout) factory.inflate(R.layout.row_home_schedule, null);
+			entry = (LinearLayout) factory.inflate(R.layout.row_home_schedule, listNow, false);
 
 			//Set id
 			tvRowId = (TextView) entry.findViewById(R.id.tv_row_home_schedule_id);
@@ -216,16 +218,20 @@ public class HomeLayout extends Fragment implements LocationListener {
 			tvRowTime = (TextView) entry.findViewById(R.id.tv_row_home_schedule_time);
 			tvRowTime.setVisibility(View.GONE);
 
-			//Add the view
 			listNow.addView(entry);
 		}
 		cursorNow.close();
 
-		//Prepare query for upcaming events
+		//Prepare query for upcoming events
 		calendarEnd = calendar;
 		calendarEnd.add(Calendar.MINUTE, 320);
 		endString = dateFormat.format(calendarEnd.getTime());
-		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 > '" + nowString + "' AND start < '" + endString + "' AND gm = " + gm + " ORDER BY start LIMIT 2";
+		if (gm == 1) {
+			query = "SELECT festival_event_gm.id, title_" + lang + ", description_" + lang + ", place, start, end, name_" + lang + ", address_" + lang + ", lat, lon FROM festival_event_gm, place WHERE place = place.id AND start > '" + nowString + "' AND start < '" + endString + "' ORDER BY start LIMIT 2";
+		}
+		else{
+			query = "SELECT festival_event_city.id, title_" + lang + ", description_" + lang + ", place, start, end, name_" + lang + ", address_" + lang + ", lat, lon FROM festival_event_city, place WHERE place = place.id AND start > '" + nowString + "' AND start < '" + endString + "' ORDER BY start LIMIT 2";
+		}
 
 		//Execute query and loop
 		Cursor cursorNext = db.rawQuery(query, null);
@@ -235,7 +241,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		while (cursorNext.moveToNext()) {
 			count++;
 
-			entry = (LinearLayout) factory.inflate(R.layout.row_home_schedule, null);
+			entry = (LinearLayout) factory.inflate(R.layout.row_home_schedule, listNext, false);
 
 			//Set id
 			tvRowId = (TextView) entry.findViewById(R.id.tv_row_home_schedule_id);
@@ -261,7 +267,6 @@ public class HomeLayout extends Fragment implements LocationListener {
 			String tm = cursorNext.getString(4).substring(cursorNext.getString(4).length() - 8, cursorNext.getString(4).length() - 3);
 			tvRowTime.setText(tm);
 
-			//Add the view
 			listNext.addView(entry);
 		}
 		cursorNext.close();
@@ -396,7 +401,6 @@ public class HomeLayout extends Fragment implements LocationListener {
 	 *
 	 * @return True if the section has been shown, false otherwise.
 	 */
-	@SuppressWarnings("ResultOfMethodCallIgnored")
 	private boolean setUpLablanca(View view) {
 		SharedPreferences preferences = view.getContext().getSharedPreferences(GM.DATA.DATA, Context.MODE_PRIVATE);
 		Boolean set = false;
@@ -422,10 +426,6 @@ public class HomeLayout extends Fragment implements LocationListener {
 				cursor.moveToFirst();
 				llSection.setVisibility(View.VISIBLE);
 
-				//Enable menu entries
-				//this.getActivity().findViewById(R.id.menu_lablanca_gm_schedule).setVisibility(View.VISIBLE);
-				//this.getActivity().findViewById(R.id.menu_lablanca_schedule).setVisibility(View.VISIBLE);
-
 				//Set text
 				String text = Html.fromHtml(cursor.getString(0)).toString();
 				String shortText = text.substring(0, 80);
@@ -508,7 +508,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 			}
 		}
 		catch (Exception ex){
-			Log.e("Location", "Couldn't set up home location section: " + ex.toString());
+			Log.e("HOME_LAYOUT", "Couldn't set up home location section: " + ex.toString());
 		}
 
 		return false;
@@ -521,7 +521,6 @@ public class HomeLayout extends Fragment implements LocationListener {
 	 *
 	 * @return The number of entries shown
 	 */
-	@SuppressWarnings("ResultOfMethodCallIgnored")
 	private int setUpGallery(View view) {
 		int counter = 0;
 
@@ -606,12 +605,10 @@ public class HomeLayout extends Fragment implements LocationListener {
 	/**
 	 * Populates the Past Activities section of the home screen.
 	 * Makes the section visible and adds two rows with the two last activities.
-	 * Tapping them takes to the post, tapping anywhere else, to the blog section.
+	 * Tapping them takes to the activity, tapping anywhere else, to the activities section.
 	 *
 	 * @return The number of entries shown
 	 */
-	@SuppressLint("InflateParams") //Throws unknown error when done properly.
-	@SuppressWarnings("ResultOfMethodCallIgnored")
 	private int setUpPastActivities(View view) {
 		int counter = 0;
 		String lang = GM.getLang();
@@ -641,7 +638,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		//Print rows
 		while (cursor.moveToNext()) {
 			//Create a new row
-			entry = (LinearLayout) factory.inflate(R.layout.row_home_activities, null);
+			entry = (LinearLayout) factory.inflate(R.layout.row_home_activities, llList, false);
 
 			//Set margins
 			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
@@ -725,7 +722,6 @@ public class HomeLayout extends Fragment implements LocationListener {
 				}
 			});
 
-			//Add to the list
 			llList.addView(entry);
 			counter++;
 		}
@@ -741,12 +737,10 @@ public class HomeLayout extends Fragment implements LocationListener {
 	 * Populates the Future activities section of the home screen.
 	 * If there are future activities, makes the section visible.
 	 * Adds two rows with the two next activities.
-	 * Tapping them takes to the post, tapping anywhere else, to the blog section.
+	 * Tapping them takes to the activity, tapping anywhere else, to the activities section.
 	 *
 	 * @return The number of entries shown
 	 */
-	@SuppressLint("InflateParams") //Throws unknown error when done properly.
-	@SuppressWarnings("ResultOfMethodCallIgnored")
 	private int setUpFutureActivities(View view) {
 		int counter = 0;
 		String lang = GM.getLang();
@@ -779,7 +773,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 			//Print rows
 			while (cursor.moveToNext()) {
 				//Create a new row
-				entry = (LinearLayout) factory.inflate(R.layout.row_home_activities, null);
+				entry = (LinearLayout) factory.inflate(R.layout.row_home_activities, llList, false);
 
 				//Set margins
 				LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
@@ -856,7 +850,6 @@ public class HomeLayout extends Fragment implements LocationListener {
 					}
 				});
 
-				//Add to the list
 				llList.addView(entry);
 				counter++;
 			}
@@ -875,8 +868,6 @@ public class HomeLayout extends Fragment implements LocationListener {
 	 *
 	 * @return The number of entries shown
 	 */
-	@SuppressLint("InflateParams") //Throws unknown error when done properly.
-	@SuppressWarnings("ResultOfMethodCallIgnored")
 	private int setUpBlog(View view) {
 		int counter = 0;
 		String lang = GM.getLang();
@@ -906,7 +897,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		while (cursor.moveToNext()) {
 
 			//Create a new row
-			entry = (LinearLayout) factory.inflate(R.layout.row_home_blog, null);
+			entry = (LinearLayout) factory.inflate(R.layout.row_home_blog, llList, false);
 
 			//Set margins
 			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
@@ -975,7 +966,6 @@ public class HomeLayout extends Fragment implements LocationListener {
 				}
 			});
 
-			//Add to the list
 			llList.addView(entry);
 
 			counter++;
@@ -1051,12 +1041,13 @@ public class HomeLayout extends Fragment implements LocationListener {
 	 */
 	@Override
 	public void onPause() {
-		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)) {
+		if (checkLocationPermission()) {
 			locationManager.removeUpdates(this);
 		}
 		super.onPause();
 	}
 
+
 	/**
 	 * Called when the fragment is destroyed.
 	 * Stops the location manager
@@ -1065,27 +1056,45 @@ public class HomeLayout extends Fragment implements LocationListener {
 	@Override
 	public void onDestroy() {
 		try {
-			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)) {
+			if (checkLocationPermission()) {
 				locationManager.removeUpdates(this);
 			}
 		}
 		catch (Exception ex){
-			Log.e("Location manager", "Unable to stop location manager on destroy: " + ex.toString());
+			Log.e("HOME_LAYOUT", "Unable to stop location manager on destroy: " + ex.toString());
 		}
 		super.onDestroy();
 	}
-	
+
+
 	/**
-	 * Called when the fragment is brought back into the foreground. 
+	 * Called when the fragment is brought back into the foreground.
 	 * Resumes the map and the location manager.
-	 * 
+	 *
 	 * @see android.app.Fragment#onResume()
 	 */
 	@Override
 	public void onResume(){
-		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)) {
+		if (checkLocationPermission()) {
 			locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);
 		}
 		super.onResume();
 	}
+
+
+	/**
+	 * Checks app permission to write device storage, user for OSM cache.
+	 * @return true if the permission has been granted, false otherwise.
+	 */
+        private boolean checkStoragePermission(){
+                return getContext().checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
+        }
+
+	/**
+	 * Checks app permission to access the user location.
+	 * @return true if the permission has been granted, false otherwise.
+	 */
+	private boolean checkLocationPermission(){
+		return getContext().checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && getContext().checkSelfPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
+	}
 }

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

@@ -1,105 +0,0 @@
-package com.ivalentin.margolariak;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.os.AsyncTask;
-import android.util.Log;
-import android.view.View;
-import android.widget.LinearLayout;
-
-import com.google.android.gms.maps.model.LatLng;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Locale;
-
-/**
- * Async task to download images on the fly.
- * The remote image file, the local path, and the ImageView where the image will be loaded are set on the constructor.
- *
- * @author Iñigo Valentin
- *
- */
-class HomeSectionLocation extends AsyncTask<Void, Void, Void> {
-
-	private boolean isLocationReported;
-	private LatLng coord;
-	private final View view;
-
-	/**
-	 * Constructor.
-	 *
-	 * @param v Application top view.
-	 *
-	 * @see android.widget.ImageView
-	 */
-	public HomeSectionLocation(View v) {
-		super();
-		this.view = v;
-	}
-
-	/**
-	 * Downloading file in background thread.
-	 */
-	@Override
-	protected Void doInBackground(Void... v) {
-
-		String o = "";
-
-		try {
-
-			FetchURL fu = new FetchURL();
-			fu.Run(GM.API.SERVER + "/app/location.php");
-			//All the info
-			o = fu.getOutput().toString();
-
-		} catch (Exception e) {
-			Log.e("Location error: ", e.getMessage());
-		}
-
-		if (o.contains("<reporting>1</reporting>")){
-			isLocationReported = true;
-			String latString = o.substring(o.indexOf("<lat>") + 5, o.indexOf("</lat>"));
-			String lonString = o.substring(o.indexOf("<lon>") + 5, o.indexOf("</lon>"));
-			coord = new LatLng(Double.parseDouble(latString), Double.parseDouble(lonString));
-		}
-
-		return null;
-	}
-
-
-
-	/**
-	 * After completing background task, set the image on the ImageView.
-	 */
-	@Override
-	protected void onPostExecute(Void v) {
-		if (isLocationReported){
-
-			//TODO: Do this on a db table
-			/*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();*/
-
-			//Show menu entry
-			//LinearLayout menuEntry = (LinearLayout) activity.findViewById(R.id.rl_menu_location);
-			//menuEntry.setVisibility(View.VISIBLE);
-
-			//Set up home view section
-			LinearLayout section = (LinearLayout) view.findViewById(R.id.ll_home_section_location);
-			section.setVisibility(View.VISIBLE);
-			section.setOnClickListener(new View.OnClickListener(){
-				@Override
-				public void onClick(View v) {
-					((MainActivity) v.getContext()).loadSection(GM.SECTION.LOCATION);
-				}
-			});
-
-		}
-	}
-
-}

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

@@ -1,14 +1,11 @@
 package com.ivalentin.margolariak;
 
-import android.annotation.SuppressLint;
 import android.app.Fragment;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
-import android.os.Build;
 import android.os.Bundle;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -19,11 +16,7 @@ import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
 import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
 
 /**
  * Fragment opened for La Blanca sections while the festivals are not close.
@@ -45,12 +38,10 @@ public class LablancaLayout extends Fragment {
 	 * @see android.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
 	 */
 	@Override
-	@SuppressLint({"InflateParams", "SwitchIntDef"})
-	@SuppressWarnings("ResultOfMethodCallIgnored")
 	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
 		//Load the layout
-		View view = inflater.inflate(R.layout.fragment_layout_lablanca, null);
+		View view = inflater.inflate(R.layout.fragment_layout_lablanca, container, false);
 
 		//Set the title
 		((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_lablanca));
@@ -60,127 +51,124 @@ public class LablancaLayout extends Fragment {
 		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);
 		Cursor cursor = db.rawQuery("SELECT text_" + lang + ", img FROM festival WHERE year = " + year + ";", null);
-		cursor.moveToFirst();
 
-		//Set text
-		WebView headerText = (WebView) view.findViewById(R.id.wv_lablanca_header);
+		if (cursor.getCount() > 0) {
+			cursor.moveToFirst();
 
-		if (Build.VERSION.SDK_INT >= 19) {
-			headerText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
-		}
-		else {
-			headerText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
-		}
-
-		headerText.loadDataWithBaseURL(null, cursor.getString(0), "text/html", "utf-8", null);
-
-		//Set image
-		ImageView headerImage = (ImageView) view.findViewById(R.id.iv_lablanca_header);
-		String image = cursor.getString(1);
-		if (image != null && image.length() > 0){
+			//Set text
+			WebView headerText = (WebView) view.findViewById(R.id.wv_lablanca_header);
 
-			//Check if image exists
-			File f;
-			f = new File(this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image);
-			if (f.exists()) {
-				//If the image exists, set it.
-				Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image);
-				headerImage.setImageBitmap(myBitmap);
+			headerText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+			headerText.loadDataWithBaseURL(null, cursor.getString(0), "text/html", "utf-8", null);
+
+			//Set image
+			ImageView headerImage = (ImageView) view.findViewById(R.id.iv_lablanca_header);
+			String image = cursor.getString(1);
+			if (image != null && image.length() > 0) {
+
+				//Check if image exists
+				File f;
+				f = new File(this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image);
+				if (f.exists()) {
+					//If the image exists, set it.
+					Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image);
+					headerImage.setImageBitmap(myBitmap);
+				} else {
+					//If not, create directories and download asynchronously
+					File fpath;
+					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/");
+					fpath.mkdirs();
+					new DownloadImage(GM.API.SERVER + "/img/fiestas/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image, headerImage, GM.IMG.SIZE.PREVIEW).execute();
+				}
 			} else {
-				//If not, create directories and download asynchronously
-				File fpath;
-				fpath = new File(this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/");
-				fpath.mkdirs();
-				new DownloadImage(GM.API.SERVER + "/img/fiestas/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image, headerImage, GM.IMG.SIZE.PREVIEW).execute();
+				headerImage.setVisibility(View.GONE);
 			}
-		}
-		else{
-			headerImage.setVisibility(View.GONE);
-		}
 
-		//Get prices for single days
-		Cursor cursorDays = db.rawQuery("SELECT date, name_" + lang + ", price FROM festival_day WHERE strftime('%Y', date) = '" + year + "' ORDER BY date;", null);
-		LinearLayout list = (LinearLayout) view.findViewById(R.id.ll_lablanca_prices_days_list);
-		LinearLayout entry;
-		LayoutInflater factory = LayoutInflater.from(getActivity());
-		while (cursorDays.moveToNext()){
-
-			//Create a new row
-			entry = (LinearLayout) factory.inflate(R.layout.row_festival_price_day, null);
-
-			//Set margins
-			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-			layoutParams.setMargins(10, 10, 10, 25);
-			entry.setLayoutParams(layoutParams);
-
-			//Set title
-			TextView tvName = (TextView) entry.findViewById(R.id.tv_row_festival_price_day_name);
-			tvName.setText(cursorDays.getString(1));
-
-			//Set price
-			TextView tvPrice = (TextView) entry.findViewById(R.id.tv_row_festival_price_day_price);
-			String price = cursorDays.getString(2) + " " + getString(R.string.eur);
-			tvPrice.setText(price);
-
-			//Set date
-			TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_festival_price_day_date);
-			tvDate.setText(GM.formatDate(cursorDays.getString(0) + " 00:00:00", lang, false, false, false));
-			/*DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
-			Date date;
-			try {
-				date = format.parse(cursorDays.getString(0));
-				Calendar calendar = Calendar.getInstance();
-				calendar.setTime(date);
-				int day = calendar.get(Calendar.DAY_OF_MONTH);
-				int month = calendar.get(Calendar.MONTH);
-				switch (month){
-					case 6:
-						tvDate.setText(String.format(getString(R.string.lablanca_date_july), String.valueOf(day)));
-						break;
-					case 7:
-						tvDate.setText(String.format(getString(R.string.lablanca_date_august), String.valueOf(day)));
-						break;
+			//Get prices for single days
+			Cursor cursorDays = db.rawQuery("SELECT date, name_" + lang + ", price FROM festival_day WHERE strftime('%Y', date) = '" + year + "' ORDER BY date;", null);
+			LinearLayout list = (LinearLayout) view.findViewById(R.id.ll_lablanca_prices_days_list);
+			LinearLayout entry;
+			LayoutInflater factory = LayoutInflater.from(getActivity());
+			while (cursorDays.moveToNext()) {
+
+				//Create a new row
+				entry = (LinearLayout) factory.inflate(R.layout.row_festival_price_day, list, false);
+
+				//Set margins
+				LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+				layoutParams.setMargins(10, 10, 10, 25);
+				entry.setLayoutParams(layoutParams);
+
+				//Set title
+				TextView tvName = (TextView) entry.findViewById(R.id.tv_row_festival_price_day_name);
+				tvName.setText(cursorDays.getString(1));
+
+				//Set price
+				TextView tvPrice = (TextView) entry.findViewById(R.id.tv_row_festival_price_day_price);
+				String price = cursorDays.getString(2) + " " + getString(R.string.eur);
+				tvPrice.setText(price);
+
+				//Set date
+				TextView tvDate = (TextView) entry.findViewById(R.id.tv_row_festival_price_day_date);
+				tvDate.setText(GM.formatDate(cursorDays.getString(0) + " 00:00:00", lang, false, false, false));
+				/*DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
+				Date date;
+				try {
+					date = format.parse(cursorDays.getString(0));
+					Calendar calendar = Calendar.getInstance();
+					calendar.setTime(date);
+					int day = calendar.get(Calendar.DAY_OF_MONTH);
+					int month = calendar.get(Calendar.MONTH);
+					switch (month){
+						case 6:
+							tvDate.setText(String.format(getString(R.string.lablanca_date_july), String.valueOf(day)));
+							break;
+						case 7:
+							tvDate.setText(String.format(getString(R.string.lablanca_date_august), String.valueOf(day)));
+							break;
+					}
 				}
+				catch(Exception ex){
+					Log.e("Date format error", ex.toString());
+				}*/
+
+				list.addView(entry);
 			}
-			catch(Exception ex){
-				Log.e("Date format error", ex.toString());
-			}*/
 
-			list.addView(entry);
-		}
+			//Get prices for single days
+			Cursor cursorPacks = db.rawQuery("SELECT name_" + lang + ", description_" + lang + ", price FROM festival_offer WHERE year = " + year + " ORDER BY days;", null);
+			list = (LinearLayout) view.findViewById(R.id.ll_lablanca_prices_packs_list);
+			while (cursorPacks.moveToNext()) {
 
-		//Get prices for single days
-		Cursor cursorPacks = db.rawQuery("SELECT name_" + lang + ", description_" + lang + ", price FROM festival_offer WHERE year = " + year + " ORDER BY days;", null);
-		list = (LinearLayout) view.findViewById(R.id.ll_lablanca_prices_packs_list);
-		while (cursorPacks.moveToNext()){
+				//Create a new row
+				entry = (LinearLayout) factory.inflate(R.layout.row_festival_price_pack, list, false);
 
-			//Create a new row
-			entry = (LinearLayout) factory.inflate(R.layout.row_festival_price_pack, null);
+				//Set margins
+				LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+				layoutParams.setMargins(10, 10, 10, 25);
+				entry.setLayoutParams(layoutParams);
 
-			//Set margins
-			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-			layoutParams.setMargins(10, 10, 10, 25);
-			entry.setLayoutParams(layoutParams);
+				//Set title
+				TextView tvName = (TextView) entry.findViewById(R.id.tv_row_festival_price_pack_name);
+				tvName.setText(cursorPacks.getString(0));
 
-			//Set title
-			TextView tvName = (TextView) entry.findViewById(R.id.tv_row_festival_price_pack_name);
-			tvName.setText(cursorPacks.getString(0));
+				//Set text
+				TextView tvText = (TextView) entry.findViewById(R.id.tv_row_festival_price_pack_text);
+				tvText.setText(cursorPacks.getString(1));
 
-			//Set text
-			TextView tvText = (TextView) entry.findViewById(R.id.tv_row_festival_price_pack_text);
-			tvText.setText(cursorPacks.getString(1));
+				//Set price
+				TextView tvPrice = (TextView) entry.findViewById(R.id.tv_row_festival_price_pack_price);
+				String price = cursorPacks.getString(2) + " " + getString(R.string.eur);
+				tvPrice.setText(price);
 
-			//Set price
-			TextView tvPrice = (TextView) entry.findViewById(R.id.tv_row_festival_price_pack_price);
-			String price = cursorPacks.getString(2) + " " + getString(R.string.eur);
-			tvPrice.setText(price);
+				list.addView(entry);
+			}
 
-			list.addView(entry);
+			cursorDays.close();
+			cursorPacks.close();
 		}
 
 		cursor.close();
-		cursorDays.close();
-		cursorPacks.close();
 		db.close();
 
 		//Set listeners for the schedule buttons.
@@ -203,4 +191,4 @@ public class LablancaLayout extends Fragment {
 
 		return view;
 	}
-}
+}

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

@@ -1,13 +1,10 @@
 package com.ivalentin.margolariak;
 
-import android.annotation.SuppressLint;
 import android.app.Fragment;
 import android.os.Bundle;
-import android.text.Html;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.TextView;
 
 /**
  * Fragment openen for La Blanca sections while the festivals are not close.
@@ -26,14 +23,13 @@ public class LablancaNoFestivalsLayout extends Fragment {
 	 * @param container          The container View
 	 * @param savedInstanceState Bundle containing the state
 	 * @return The fragment view
-	 * @see android.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
+	 * @see Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
 	 */
 	@Override
-	@SuppressLint("InflateParams")
 	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
 		//Load the layout
-		View view = inflater.inflate(R.layout.fragment_layout_lablanca_nofestivals, null);
+		View view = inflater.inflate(R.layout.fragment_layout_lablanca_nofestivals, container, false);
 
 		//Set the title
 		((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_lablanca));

+ 92 - 137
app/src/main/java/com/ivalentin/margolariak/LocationLayout.java

@@ -1,83 +1,79 @@
 package com.ivalentin.margolariak;
 
 import java.util.Locale;
-
-import com.google.android.gms.maps.CameraUpdateFactory;
-import com.google.android.gms.maps.GoogleMap;
-import com.google.android.gms.maps.MapView;
-import com.google.android.gms.maps.MapsInitializer;
-import com.google.android.gms.maps.OnMapReadyCallback;
-import com.google.android.gms.maps.model.BitmapDescriptorFactory;
-import com.google.android.gms.maps.model.LatLng;
-import com.google.android.gms.maps.model.Marker;
-import com.google.android.gms.maps.model.MarkerOptions;
+import java.util.ArrayList;
 
 import android.app.Activity;
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
-import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.Bundle;
 import android.app.Fragment;
 import android.os.Handler;
-import android.support.v4.app.ActivityCompat;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.TextView;
+import android.graphics.drawable.Drawable;
+
+import org.osmdroid.api.IMapController;
+
+import org.osmdroid.util.GeoPoint;
+import org.osmdroid.views.MapView;
+import org.osmdroid.views.overlay.ItemizedIconOverlay;
+import org.osmdroid.views.overlay.OverlayItem;
 
 /**
- * Section that shows a map with the location of Gasteizko Margolariak. 
- * If no recent report location, it will explain that and will show the 
- * next scheduled activity. 
+ * Section that shows a map with the location of Gasteizko Margolariak.
  *
  * @author Iñigo Valentin
  *
  * @see Fragment
- * @see OnMapReadyCallback
  *
  */
-public class LocationLayout extends Fragment implements OnMapReadyCallback, LocationListener {
+public class LocationLayout extends Fragment implements LocationListener {
 
-	//The map view
+	//The map view stuff
 	private MapView mapView;
-	GoogleMap gMap;
+	private Drawable locationMarker;
 
+	// The location manager
 	private LocationManager locationManager;
 
 	//Locations for the user and Gasteizko Margolariak
-	private LatLng gmLocation;
+	private GeoPoint gmLocation;
 
 	//The main View
 	private View v;
 
-	private double lat, lon;
-
-	//Map marker
-	Marker gmMarker;
-	MarkerOptions moGm = new MarkerOptions();
-
+	// Handler to refresh the location.
 	private final Handler markerHandler = new Handler();
-
 	private final Runnable resetMarker = new Runnable() {
 		@Override
 		public void run() {
 
-			if (gmMarker != null) {
-				gmMarker.remove();
+			if (mapView != null) {
 				if (refreshLocation()) {
-					gmMarker.setPosition(new LatLng(lat, lon));
-					gmLocation = new LatLng(lat, lon);
-					//moGm = new MarkerOptions();
-					moGm.title(v.getContext().getString(R.string.app_name));
-					moGm.position(gmLocation);
-					moGm.icon(BitmapDescriptorFactory.fromResource(R.drawable.pinpoint_gm));
-					gmMarker = gMap.addMarker(moGm);
+					
+					OverlayItem locationOverlayItem = new OverlayItem("Gasteizko Margolariak", "", gmLocation);
+					locationOverlayItem.setMarker(locationMarker);
+					final ArrayList<OverlayItem> items = new ArrayList<>();
+					items.add(locationOverlayItem);
+					ItemizedIconOverlay locationOverlay = new ItemizedIconOverlay<>(items,
+							new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
+								public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
+									return true;
+								}
+								public boolean onItemLongPress(final int index, final OverlayItem item) {
+									return true;
+								}
+							}, getContext());
+					mapView.getOverlays().add(locationOverlay);
 				}
 			}
 			markerHandler.postDelayed(resetMarker, GM.LOCATION.INTERVAL);
@@ -92,7 +88,7 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 	 * @param container The container View
 	 * @param savedInstanceState Bundle containing the state
 	 *
-	 * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
+	 * @see Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
 	 */
 	@Override
 	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
@@ -102,7 +98,8 @@ 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)){
+		if (checkLocationPermission()){
+			locationManager.requestSingleUpdate(LocationManager.GPS_PROVIDER, this, null);
 			locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, GM.LOCATION.ACCURACY.TIME, GM.LOCATION.ACCURACY.SPACE, this);
 		}
 
@@ -115,16 +112,19 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 		//Periodically check map
 		markerHandler.post(resetMarker);
 
-		mapView = (MapView) v.findViewById(R.id.mapview);
-		mapView.onCreate(savedInstanceState);
-
-		// Gets to GoogleMap from the MapView and does initialization stuff
-		mapView.getMapAsync(this);
+		// Set up the map
+		this.mapView = (MapView) v.findViewById(R.id.mapview);
+		this.mapView.setMultiTouchControls(true);
+		IMapController mapController = mapView.getController();
+		mapController.setZoom(17);
+		mapController.setCenter(gmLocation);
+		this.locationMarker = this.getResources().getDrawable(R.drawable.pinpoint, null);
 
 		//Return the view
 		return v;
 	}
 
+
 	/**
 	 * Called when the fragment is bought back to the foreground. 
 	 * Ensures that the map is displayed then, and activates the location manager.
@@ -133,17 +133,14 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 	 */
 	@Override
 	public void onResume() {
-		if (mapView != null) {
-			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)){
+		if (checkLocationPermission()){
 			locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, GM.LOCATION.ACCURACY.TIME, GM.LOCATION.ACCURACY.SPACE, this);
 		}
 		super.onResume();
-
 		markerHandler.post(resetMarker);
 	}
 
+
 	/**
 	 * Called when the fragment is paused.
 	 * Stops the location manager
@@ -151,7 +148,7 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 	 */
 	@Override
 	public void onPause(){
-		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)) {
+		if (checkLocationPermission()) {
 			locationManager.removeUpdates(this);
 		}
 		super.onPause();
@@ -159,44 +156,26 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 		markerHandler.removeCallbacks(resetMarker);
 	}
 
+
 	/**
 	 * Called when the fragment is destroyed. 
 	 * Ensures that the map is destroyed then.
 	 * 
-	 * @see android.support.v4.app.Fragment#onDestroy()
+	 * @see Fragment#onDestroy()
 	 */
 	@Override
 	public void onDestroy() {
 		super.onDestroy();
-		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)) {
+		if (checkLocationPermission()) {
 			locationManager.removeUpdates(this);
 		}
 
-		if (mapView != null){
-			mapView.onResume();
-			mapView.onDestroy();
-		}
-
 		markerHandler.removeCallbacks(resetMarker);
 	}
 
-	/**
-	 * Called in a situation of low memory. 
-	 * It let's the mapView handle the situation.
-	 * 
-	 * @see android.support.v4.app.Fragment#onLowMemory()
-	 */
-	@Override
-	public void onLowMemory() {
-		super.onLowMemory();
-		if (mapView != null){
-			mapView.onResume();
-			mapView.onLowMemory();
-		}
-	}
 
 	/**
-	 * Refresh the global variables "lat" and "lon".
+	 * Refresh the location of Gasteizko Margolariak, by updating the class attribute gmLocation.
 	 *
 	 * Uses the most recent data in the database, if they are not older than 10 minutes.
 	 *
@@ -214,77 +193,42 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 		}
 		else {
 			cursor.moveToFirst();
-			lat = cursor.getDouble(0);
-			lon = cursor.getDouble(1);
+			gmLocation = new GeoPoint(cursor.getDouble(0), cursor.getDouble(1));
 			cursor.close();
 			db.close();
 			return true;
 		}
-
 	}
 
+
 	/**
-	 * Called when the map is ready to be used. 
-	 * Initializes it and sets the Gasteizko Margolariak marker.
-	 * 
-	 * @param googleMap the map
-	 * 
-	 * @see com.google.android.gms.maps.OnMapReadyCallback#onMapReady(com.google.android.gms.maps.GoogleMap)
+	 * Recalculates the distance between the user and Gasteizko Margolariak.
+	 * Prints the distance to a TextView.
+	 *
+	 * @param userLocation The new user location.
+	 *
+	 * @see android.location.LocationListener#onLocationChanged(android.location.Location)
 	 */
-	@Override
-	public void onMapReady(GoogleMap googleMap) {
-
-		gMap = googleMap;
-
-		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)) {
-			googleMap.setMyLocationEnabled(true);
-		}
-		
-		googleMap.getUiSettings().setMyLocationButtonEnabled(false);
-		// Needs to call MapsInitializer before doing any CameraUpdateFactory calls
-		try {
-			MapsInitializer.initialize(this.getActivity());
-		} catch (Exception e) {
-			Log.e("Error initializing maps", e.toString());
-		}
-
-		//If there is a location, set it
-		if (refreshLocation()) {
-
-			//Set the marker
-			gmLocation = new LatLng(lat, lon);
-			moGm.title(v.getContext().getString(R.string.app_name));
-			moGm.position(gmLocation);
-			moGm.icon(BitmapDescriptorFactory.fromResource(R.drawable.pinpoint_gm));
-			gmMarker = googleMap.addMarker(moGm);
-			googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lon), 14.0f));
-		}
-
-		//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);
-			onLocationChanged(locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER));
-		}
-	}
-
-
-	private void calCulateDistance(Location userLocation){
+	private void calculateDistance(Location userLocation){
 		TextView text = (TextView) v.findViewById(R.id.tv_location_distance);
-		try {
-			Double distance = Distance.calculateDistance(userLocation.getLatitude(), userLocation.getLongitude(), lat, lon);
-			if (distance <= 2) {
-				distance = 1000 * distance;
-				text.setText(String.format(getString(R.string.home_section_location_text_short), distance.intValue(), (int) (0.012 * distance.intValue())));
-			} else {
-				text.setText(String.format(getString(R.string.home_section_location_text_long), String.format(Locale.US, "%.02f", distance)));
+		if (userLocation != null){
+			try {
+				Double distance = Distance.calculateDistance(userLocation.getLatitude(), userLocation.getLongitude(), gmLocation.getLatitude(), gmLocation.getLongitude());
+				if (distance <= 2) {
+					distance = 1000 * distance;
+					text.setText(String.format(getString(R.string.home_section_location_text_short), distance.intValue(), (int) (0.012 * distance.intValue())));
+				} else {
+					text.setText(String.format(getString(R.string.home_section_location_text_long), String.format(Locale.US, "%.02f", distance)));
+				}
+			}
+			catch(Exception ex){
+				Log.e("LOCATION_LAYOUT", "Distance error: " + ex.toString());
+				text.setText("");
 			}
-		}
-		catch(Exception ex){
-			Log.e("Distance error", ex.toString());
-			text.setText("");
 		}
 	}
 
+
 	/**
 	 * Called when the user location changes.
 	 * Recalculates the list of around events and calls updateLocation() to
@@ -296,11 +240,24 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 	 */
 	@Override
 	public void onLocationChanged(Location location) {
-		calCulateDistance(location);
+		calculateDistance(location);
 	}
 
+
+	/**
+	 * Checks app permission to access the user location.
+	 * @return true if the permission has been granted, false otherwise.
+	 *
+	 * @see android.app.Fragment#onResume()
+	 */
+	private boolean checkLocationPermission(){
+		return getContext().checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && getContext().checkSelfPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
+	}
+
+
 	/**
 	 * Called when the location provider changes it's state.
+	 * Does nothing.
 	 *
 	 * @param provider The name of the provider
 	 * @param status Status code of the provider
@@ -309,27 +266,26 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 	 * @see android.location.LocationListener#onStatusChanged(java.lang.String, int, android.os.Bundle)
 	 */
 	@Override
-	public void onStatusChanged(String provider, int status, Bundle extras) {
-		//populateAround();
+		public void onStatusChanged(String provider, int status, Bundle extras) {
 	}
 
 
 	/**
 	 * Called when a location provider is enabled.
-	 * Recalculates the list of events.
+	 * Does nothing.
 	 *
 	 * @param provider The name of the provider
 	 *
 	 * @see android.location.LocationListener#onProviderEnabled(java.lang.String)
 	 */
 	@Override
-	public void onProviderEnabled(String provider) {
-		//populateAround();
+		public void onProviderEnabled(String provider) {
 	}
 
+
 	/**
 	 * Called when a location provider is disabled.
-	 * Recalculates the list of events.
+	 * Does nothing.
 	 *
 	 * @param provider The name of the provider
 	 *
@@ -337,6 +293,5 @@ public class LocationLayout extends Fragment implements OnMapReadyCallback, Loca
 	 */
 	@Override
 	public void onProviderDisabled(String provider) {
-		//populateAround();
 	}
 }

+ 44 - 69
app/src/main/java/com/ivalentin/margolariak/MainActivity.java

@@ -16,9 +16,7 @@ import android.graphics.Color;
 import android.graphics.Typeface;
 import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
-import android.net.Uri;
 import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.Gravity;
@@ -38,11 +36,6 @@ import android.widget.RelativeLayout;
 import android.widget.TextView;
 import android.os.Handler;
 
-import com.google.android.gms.appindexing.Action;
-import com.google.android.gms.appindexing.AppIndex;
-import com.google.android.gms.appindexing.Thing;
-import com.google.android.gms.common.api.GoogleApiClient;
-
 /**
  * The main Activity of the app. It's actually the only content activity, and it loads other fragments.
  *
@@ -58,6 +51,7 @@ public class MainActivity extends Activity {
 
 	//Handler to periodically check for location updates
 	private final Handler locationHandler = new Handler();
+
 	// Code to check for location updates
 	private MainActivity activity = this;
 	private final Runnable checkForLocation = new Runnable() {
@@ -71,16 +65,11 @@ public class MainActivity extends Activity {
 		}
 	};
 
-	/**
-	 * ATTENTION: This was auto-generated to implement the App Indexing API.
-	 * See https://g.co/AppIndexing/AndroidStudio for more information.
-	 */
-	private GoogleApiClient client;
-
 	// Shareable URL
 	private String shareURL = GM.SHARE.HOME;
 	private String shareTitle = "";
 
+
 	/**
 	 * Sets the displayed section url and localized title.
 	 * Thy can be retrieved later with getShareLink() to share the URL.
@@ -95,6 +84,7 @@ public class MainActivity extends Activity {
 		shareURL = url;
 	}
 
+
 	/**
 	 * Returns the url of the current sections and a title.
 	 * To be used with the share option.
@@ -105,6 +95,7 @@ public class MainActivity extends Activity {
 		return(new String[]{shareTitle, shareURL});
 	}
 
+
 	/**
 	 * Enables o disables the location section.
 	 *
@@ -127,6 +118,7 @@ public class MainActivity extends Activity {
 		}
 	}
 
+
 	/**
 	 * Opens and closes the app menu.
 	 * Not referenced in code.
@@ -296,10 +288,12 @@ public class MainActivity extends Activity {
 		ft.addToBackStack(title);
 		ft.commit();
 		setSectionTitle(title);
+
 		//Set the shareable url
 		setShareLink(shareTitle, shareURL);
 	}
 
+
 	/**
 	 * Sets the title of the current section.
 	 *
@@ -310,13 +304,13 @@ public class MainActivity extends Activity {
 		tvTitle.setText(title);
 	}
 
+
 	/**
 	 * Runs when the activity is created.
 	 *
 	 * @param savedInstanceState Saved state of the activity.
 	 * @see Activity#onCreate(Bundle)
 	 */
-	@SuppressWarnings("deprecation, ConstantConditions")
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
 
@@ -345,7 +339,7 @@ public class MainActivity extends Activity {
 						}
 					});
 				} catch (InterruptedException e) {
-					Log.e("Sleep interrupted", e.toString());
+					Log.e("MAIN_ACTIVITY", "Sleep interrupted: " +  e.toString());
 				}
 			}
 		};
@@ -441,7 +435,7 @@ public class MainActivity extends Activity {
 
 		//If the database has just been updated, recreate the database
 		if (sharedData.getInt(GM.DATA.KEY.PREVIOUS_APP_VERSION, GM.DATA.DEFAULT.PREVIOUS_APP_VERSION) < BuildConfig.VERSION_CODE) {
-			Log.d("UPDATE", "App updated from version " + sharedData.getInt(GM.DATA.KEY.PREVIOUS_APP_VERSION, GM.DATA.DEFAULT.PREVIOUS_APP_VERSION) + " to " + BuildConfig.VERSION_CODE + ". Forcing a new sync...");
+			Log.d("MAIN_ACTIVITY", "App updated from version " + sharedData.getInt(GM.DATA.KEY.PREVIOUS_APP_VERSION, GM.DATA.DEFAULT.PREVIOUS_APP_VERSION) + " to " + BuildConfig.VERSION_CODE + ". Forcing a new sync...");
 			deleteDatabase();
 			dataEditor.putInt(GM.DATA.KEY.PREVIOUS_APP_VERSION, BuildConfig.VERSION_CODE);
 			dataEditor.apply();
@@ -487,7 +481,7 @@ public class MainActivity extends Activity {
 					});
 
 					//Set the icon
-					dialogIcon = getResources().getDrawable(R.drawable.ic_launcher);
+					dialogIcon = getResources().getDrawable(R.drawable.ic_launcher, null);
 					if (dialogIcon != null) {
 						dialogIcon.setBounds(0, 0, (int) (tvDialogTitle.getTextSize() * 1.4), (int) (tvDialogTitle.getTextSize() * 1.4));
 					}
@@ -618,7 +612,13 @@ public class MainActivity extends Activity {
 
 					//Set dialog parameters
 					WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
-					lp.copyFrom(dialog.getWindow().getAttributes());
+					try {
+						//noinspection ConstantConditions
+						lp.copyFrom(dialog.getWindow().getAttributes());
+					}
+					catch (NullPointerException e){
+						Log.e("MAIN_ACTIVITY", "Error setting dialog parameters: " + e.toString());
+					}
 					lp.width = WindowManager.LayoutParams.MATCH_PARENT;
 					lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
 					lp.gravity = Gravity.CENTER;
@@ -632,12 +632,9 @@ public class MainActivity extends Activity {
 				}
 			}
 		}
-
-		// ATTENTION: This was auto-generated to implement the App Indexing API.
-		// See https://g.co/AppIndexing/AndroidStudio for more information.
-		client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
 	}
 
+
 	/**
 	 * Creates the app database and fills it with the hard coded, default data.
 	 */
@@ -654,7 +651,8 @@ public class MainActivity extends Activity {
 			db.execSQL(GM.DB.QUERY.CREATE.ALBUM);
 			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL);
 			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL_DAY);
-			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL_EVENT);
+			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL_EVENT_CITY);
+			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL_EVENT_GM);
 			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL_EVENT_IMAGE);
 			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL_OFFER);
 			db.execSQL(GM.DB.QUERY.CREATE.LOCATION);
@@ -668,15 +666,17 @@ 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.ROUTE);
+			db.execSQL(GM.DB.QUERY.CREATE.ROUTE_POINT);
 			db.execSQL(GM.DB.QUERY.CREATE.SPONSOR);
 			db.execSQL(GM.DB.QUERY.CREATE.VERSION);
 			db.close();
 		} catch (Exception ex) {
-			Log.e("Error creating database", ex.toString());
+			Log.e("MAIN_ACTIVITY", "Error creating database: " + ex.toString());
 		}
 	}
 
+
 	/**
 	 * Creates the app database and fills it with the hard coded, default data.
 	 */
@@ -684,10 +684,11 @@ public class MainActivity extends Activity {
 		try {
 			getApplicationContext().deleteDatabase(GM.DB.NAME);
 		} catch (Exception ex) {
-			Log.e("Error deleting database", ex.toString());
+			Log.e("MAIN_ACTIVITY", "Error deleting database: " + ex.toString());
 		}
 	}
 
+
 	/**
 	 * Performs a full sync against the remote database.
 	 */
@@ -697,6 +698,7 @@ public class MainActivity extends Activity {
 		new Sync(this, pbSync, ivSync).execute();
 	}
 
+
 	/**
 	 * Asks the activity to performa a sync.
 	 * Intended to be called from any screen.
@@ -705,12 +707,12 @@ public class MainActivity extends Activity {
 		new Sync(this).execute();
 	}
 
+
 	/**
 	 * Perform an initial sync before the app can be used.
 	 * A dialog will block the UI.
 	 * It is intended to be used only when the database is empty.
 	 */
-	@SuppressWarnings("ConstantConditions")
 	private void initialSync() {
 		//Create a dialog
 		Dialog dialog = new Dialog(this);
@@ -722,8 +724,13 @@ public class MainActivity extends Activity {
 
 		//Set dialog parameters
 		WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
-		lp.copyFrom(dialog.getWindow().getAttributes());
-		lp.width = WindowManager.LayoutParams.MATCH_PARENT;
+		try {
+			//noinspection ConstantConditions
+			lp.copyFrom(dialog.getWindow().getAttributes());
+		}
+		catch (NullPointerException e){
+			Log.e("MAIN_ACTIVITY", "Error setting dialog parameters: " + e.toString());
+		}		lp.width = WindowManager.LayoutParams.MATCH_PARENT;
 		lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
 		lp.gravity = Gravity.CENTER;
 		dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
@@ -735,17 +742,17 @@ public class MainActivity extends Activity {
 		new Sync(this, pbSync, ivSync, dialog, this).execute();
 	}
 
+
 	/**
 	 * Overrides onBackPressed().
 	 * Used to show the previous fragment instead of finishing the app.
 	 *
-	 * @see AppCompatActivity#onBackPressed()
+	 * @see Activity#onBackPressed()
 	 */
 	@Override
 	public void onBackPressed() {
 		try {
 			FragmentManager fm = getFragmentManager();
-			Log.d("BACK", "StackEntryCount " + fm.getBackStackEntryCount());
 			if (fm.getBackStackEntryCount() > 1) {
 				fm.popBackStack();
 			} else {
@@ -753,17 +760,17 @@ public class MainActivity extends Activity {
 				super.onBackPressed();
 			}
 		} catch (Exception ex) {
-			Log.e("Error going back", "Finishing activity: " + ex.toString());
+			Log.e("MAIN_ACTIVITY", "Error going back. Finishing activity: " + ex.toString());
 			locationHandler.removeCallbacks(checkForLocation);
 			finish();
-			//super.onBackPressed();
 		}
 
 	}
 
+
 	/**
 	 * Overrides onKeyUp().
-	 * Used to toggle the menu whent the key is pressed.
+	 * Used to toggle the menu when the key is pressed.
 	 *
 	 * @see Activity#onKeyUp(int, KeyEvent)
 	 */
@@ -776,6 +783,7 @@ public class MainActivity extends Activity {
 		return super.onKeyUp(keyCode, event);
 	}
 
+
 	/**
 	 * Overrides onResume().
 	 * Resumes the location handler to check for location regularly.
@@ -788,6 +796,7 @@ public class MainActivity extends Activity {
 		super.onResume();
 	}
 
+
 	/**
 	 * Overrides onPause().
 	 * Stops the location handler to check for location regularly.
@@ -800,6 +809,7 @@ public class MainActivity extends Activity {
 		super.onPause();
 	}
 
+
 	/**
 	 * Overrides onDestroy().
 	 * Stops the location handler to check for location regularly.
@@ -812,39 +822,4 @@ public class MainActivity extends Activity {
 		super.onDestroy();
 	}
 
-	/**
-	 * ATTENTION: This was auto-generated to implement the App Indexing API.
-	 * See https://g.co/AppIndexing/AndroidStudio for more information.
-	 */
-	public Action getIndexApiAction() {
-		Thing object = new Thing.Builder()
-				.setName("Main Page") // TODO: Define a title for the content shown.
-				// TODO: Make sure this auto-generated URL is correct.
-				.setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]"))
-				.build();
-		return new Action.Builder(Action.TYPE_VIEW)
-				.setObject(object)
-				.setActionStatus(Action.STATUS_TYPE_COMPLETED)
-				.build();
-	}
-
-	@Override
-	public void onStart() {
-		super.onStart();
-
-		// ATTENTION: This was auto-generated to implement the App Indexing API.
-		// See https://g.co/AppIndexing/AndroidStudio for more information.
-		client.connect();
-		AppIndex.AppIndexApi.start(client, getIndexApiAction());
-	}
-
-	@Override
-	public void onStop() {
-		super.onStop();
-
-		// ATTENTION: This was auto-generated to implement the App Indexing API.
-		// See https://g.co/AppIndexing/AndroidStudio for more information.
-		AppIndex.AppIndexApi.end(client, getIndexApiAction());
-		client.disconnect();
-	}
 }

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

@@ -1,6 +1,5 @@
 package com.ivalentin.margolariak;
 
-import android.annotation.SuppressLint;
 import android.app.Fragment;
 import android.content.Context;
 import android.database.Cursor;
@@ -22,6 +21,7 @@ import android.widget.Toast;
 
 import java.io.File;
 
+
 /**
  * Section that shows a photo of the gallery, with details and comments.
  * Contains info from almost every other section.
@@ -37,28 +37,27 @@ public class PhotoLayout extends Fragment {
 	private View view;
 
 	private String albumName;
-	private String albumPerm;
 
 	private Integer photos[];
 	private int position;
 
 	private Context context;
 
-	@SuppressLint("InflateParams") //Throws unknown error when done properly.
+
 	@Override
 	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
 		//Load the layout
-		view = inflater.inflate(R.layout.fragment_layout_photo, null);
+		view = inflater.inflate(R.layout.fragment_layout_photo, container, false);
 		context = view.getContext();
 
 		//Get bundled id
 		Bundle bundle = this.getArguments();
 		albumName = bundle.getString("albumName", "");
-		albumPerm = bundle.getString("albumPerm", "");
+		String albumPerm = bundle.getString("albumPerm", "");
 		int id = bundle.getInt("photo", -1);
 		if (id == -1) {
-			Log.e("Photo error", "No such photo: " + id);
+			Log.e("PHOTO_LAYOUT", "No such photo: " + id);
 			this.getActivity().onBackPressed();
 		}
 
@@ -95,6 +94,7 @@ public class PhotoLayout extends Fragment {
 		return view;
 	}
 
+
 	/**
 	 * Given a photo id array and a photo id, tells the position of the photo in the array.
 	 *
@@ -119,6 +119,7 @@ public class PhotoLayout extends Fragment {
 		return i;
 	}
 
+
 	/**
 	 * Given a photo, builds an ordered array with the ids of all photos in the same album.
 	 *
@@ -149,12 +150,20 @@ public class PhotoLayout extends Fragment {
 		return list;
 	}
 
+	/**
+	 * Retrieves data from the database and populates the layout.
+	 * @param id Photo id.
+	 */
 	private void populate(int id){
 		populate(id, view);
 	}
 
-	@SuppressLint("InflateParams") //Throws unknown error when done properly.
-	@SuppressWarnings("ResultOfMethodCallIgnored")
+
+	/**
+	 * Retrieves data from the database and populates the layout.
+	 * @param id Photo id.
+	 * @param v Parent view.
+	 */
 	private void populate(int id, View v){
 
 		final int photoId = id;
@@ -231,8 +240,6 @@ public class PhotoLayout extends Fragment {
 			btNext.setVisibility(View.VISIBLE);
 		}
 
-
-
 		//Get comments
 		Cursor commentCursor = db.rawQuery("SELECT text, dtime, username FROM photo_comment WHERE photo = " + id + ";", null);
 		tvComments.setText(String.format(getResources().getQuantityString(R.plurals.comment_comments, commentCursor.getCount()), commentCursor.getCount()));
@@ -242,7 +249,7 @@ public class PhotoLayout extends Fragment {
 		LayoutInflater factory = LayoutInflater.from(getActivity());
 		llCommentList.removeAllViews();
 		while (commentCursor.moveToNext()) {
-			entry = (LinearLayout) factory.inflate(R.layout.row_comment, null);
+			entry = (LinearLayout) factory.inflate(R.layout.row_comment, llCommentList, false);
 
 			//Set user
 			TextView tvUser = (TextView) entry.findViewById(R.id.tv_row_comment_user);
@@ -289,4 +296,4 @@ public class PhotoLayout extends Fragment {
 		cursor.close();
 		db.close();
 	}
-}
+}

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

@@ -1,10 +1,7 @@
 package com.ivalentin.margolariak;
 
-import android.annotation.SuppressLint;
-import android.app.Activity;
 import android.content.Context;
 import android.content.SharedPreferences;
-import android.database.sqlite.SQLiteDatabase;
 import android.os.AsyncTask;
 import android.text.format.DateFormat;
 import android.util.Log;
@@ -25,178 +22,194 @@ import java.net.URL;
 import java.net.URLEncoder;
 import java.util.Date;
 
+
+/**
+ * Posts a comment for an entry.
+ */
 class PostComment extends AsyncTask<String, String, Integer> {
 
-    //Elements passed from fragments
-    private final String type, user, text, language;
-    private String userCode;
-    private final LinearLayout list, form;
-    private final int id;
-    private final Context context;
-
-    //Elements calculated here
-    private Button btSend;
-    private ProgressBar pb;
-
-    private int code = 404;
-
-    PostComment(String type, String user, String text, String language, int id, LinearLayout form, LinearLayout list, Context context) {
-        super();
-        this.type = type;
-        this.user = user;
-        this.text = text;
-        this.form = form;
-        this.list = list;
-        this.language = language;
-        this.id = id;
-        this.context = context;
-
-    }
-
-    /**
-     * Before starting background thread
-     * */
-    @Override
-    protected void onPreExecute() {
-        super.onPreExecute();
-        btSend = (Button) form.findViewById(R.id.bt_comment_send);
-        pb = (ProgressBar) form.findViewById(R.id.pb_comment);
-        btSend.setVisibility(View.GONE);
-        pb.setVisibility(View.VISIBLE);
-
-        //Get user code
-        SharedPreferences sharedData = context.getSharedPreferences(GM.DATA.DATA, Context.MODE_PRIVATE);
-        userCode = sharedData.getString(GM.DATA.KEY.USER, GM.DATA.DEFAULT.USER);
-    }
-
-    /**
-     * Downloading file in background thread
-     * */
-    @Override
-    @SuppressWarnings("deprecation")
-    protected Integer doInBackground(String... f_url) {
-        URL url;
-        String urlParams;
-        try {
-
-            urlParams = "username=" + URLEncoder.encode(user) + "&text=" + URLEncoder.encode(text);
-            urlParams = urlParams + "&id=" + id;
-            switch (type) {
-                case "blog":
-                    urlParams = urlParams + "&target=post";
-                    break;
-                case "galeria":
-                    urlParams = urlParams + "&target=photo";
-                    break;
-                case "actividades":
-                    urlParams = urlParams + "&target=activity";
-                    break;
-                default:
-                    Log.e("Comment error", "Unknown section: " + type);
-                    return -1;
-            }
-            switch (language) {
-                case "es":
-                    urlParams = urlParams + "&lang=es";
-                    break;
-                case "eu":
-                    urlParams = urlParams + "&lang=eu";
-                    break;
-                default:
-                    urlParams = urlParams + "&lang=en";
-            }
-            urlParams = urlParams + "&client=" + GM.API.CLIENT + "&user=" + userCode;
-
-            String uri = GM.API.SERVER + GM.API.COMMENT.PATH + "?" + urlParams;
-            url = new URL(uri);
-			Log.e("URI", uri);
-
-            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
-
-            code = urlConnection.getResponseCode();
-
-            switch (code) {
-                case 400:    //Client error: Bad request
-                    Log.e("COMMENT", "The server returned a 400 code (Client Error: Bad request) for the url \"" + uri + "\"");
+	//Elements passed from fragments
+	private final String type, user, text, language;
+	private String userCode;
+	private final LinearLayout list, form;
+	private final int id;
+	private final Context context;
+
+	//Elements calculated here
+	private Button btSend;
+	private ProgressBar pb;
+
+	private int code = 404;
+
+	/**
+	 * Post a comment for an entry.
+	 * @param type Type of the entry to comment. @see GM.COMMENT.TYPE
+	 * @param user Username.
+	 * @param text Comment text.
+	 * @param language Comment language.
+	 * @param id ID of the entry to post the comment on.
+	 * @param form Layout containing the comment form.
+	 * @param list Layout containing the list of comments for the entry.
+	 * @param context App context.
+	 */
+	PostComment(String type, String user, String text, String language, int id, LinearLayout form, LinearLayout list, Context context) {
+		super();
+		this.type = type;
+		this.user = user;
+		this.text = text;
+		this.form = form;
+		this.list = list;
+		this.language = language;
+		this.id = id;
+		this.context = context;
+
+	}
+
+
+	/**
+	 * Before starting background thread
+	 */
+	@Override
+	protected void onPreExecute() {
+		super.onPreExecute();
+		btSend = (Button) form.findViewById(R.id.bt_comment_send);
+		pb = (ProgressBar) form.findViewById(R.id.pb_comment);
+		btSend.setVisibility(View.GONE);
+		pb.setVisibility(View.VISIBLE);
+
+		//Get user code
+		SharedPreferences sharedData = context.getSharedPreferences(GM.DATA.DATA, Context.MODE_PRIVATE);
+		userCode = sharedData.getString(GM.DATA.KEY.USER, GM.DATA.DEFAULT.USER);
+	}
+
+
+	/**
+	 * Send request to the server
+	 * @param f_url API URL.
+	 * @return 0 for success, something else for error.
+	 */
+	@Override
+	protected Integer doInBackground(String... f_url) {
+		URL url;
+		String urlParams;
+		try {
+
+			urlParams = GM.API.COMMENT.KEY.USERNAME + "=" + URLEncoder.encode(user,GM.ENCODING) + "&" + GM.API.COMMENT.KEY.TEXT + "=" + URLEncoder.encode(text, GM.ENCODING);
+			urlParams = urlParams + "&id=" + id;
+			switch (type) {
+				case GM.API.COMMENT.TYPE.BLOG:
+					urlParams = urlParams + "&" + GM.API.COMMENT.KEY.TYPE + "=" + GM.API.COMMENT.TYPE.BLOG;
+					break;
+				case GM.API.COMMENT.TYPE.GALLERY:
+					urlParams = urlParams + "&" + GM.API.COMMENT.KEY.TYPE + "=" + GM.API.COMMENT.TYPE.GALLERY;
+					break;
+				case GM.API.COMMENT.TYPE.ACTIVITIES:
+					urlParams = urlParams + "&" + GM.API.COMMENT.KEY.TYPE + "=" + GM.API.COMMENT.TYPE.ACTIVITIES;
+					break;
+				default:
+					Log.e("POST_COMMENT", "Unknown section: " + type);
+					return -1;
+			}
+			switch (language) {
+				case GM.LANGUAGE.EN:
+					urlParams = urlParams + "&" + GM.API.COMMENT.KEY.LANGUAGE + "=" + GM.LANGUAGE.EN;
+					break;
+				case GM.LANGUAGE.EU:
+					urlParams = urlParams + "&" + GM.API.COMMENT.KEY.LANGUAGE + "=" + GM.LANGUAGE.EU;
+					break;
+				case GM.LANGUAGE.ES:
+					urlParams = urlParams + "&" + GM.API.COMMENT.KEY.LANGUAGE + "=" + GM.LANGUAGE.ES;
+					break;
+				default:
+					urlParams = urlParams + "&" + GM.API.COMMENT.KEY.LANGUAGE + "=" + GM.LANGUAGE.ES;
+			}
+			urlParams = urlParams + "&" + GM.API.COMMENT.KEY.CLIENT + "=" + GM.API.CLIENT + "&" + GM.API.COMMENT.KEY.USER + "=" + userCode;
+
+			String uri = GM.API.SERVER + GM.API.COMMENT.PATH + "?" + urlParams;
+			url = new URL(uri);
+
+			HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
+
+			code = urlConnection.getResponseCode();
+
+			switch (code) {
+				case 400: //Client error: Bad request
+					Log.e("POST_COMMENT", "The server returned a 400 code (Client Error: Bad request) for the url \"" + uri + "\"");
 					return(-400);
-                case 403:    //Client error: Forbidden
-                    Log.e("COMMENT", "The server returned a 403 code (Client Error: Forbidden) for the url \"" + uri + "\"");
+				case 403: //Client error: Forbidden
+					Log.e("POST_COMMENT", "The server returned a 403 code (Client Error: Forbidden) for the url \"" + uri + "\"");
 					return(-403);
-                case 200:    //Success: OK
-                    Log.d("COMMENT", "The server returned a 200 code (Success: OK) for the url \"" + uri + "\".");
+				case 200: //Success: OK
+					Log.d("POST_COMMENT", "The server returned a 200 code (Success: OK) for the url \"" + uri + "\".");
 					break;
 				default:
-					Log.e("COMMENT", "The server returned a " + code + " code for the url \"" + uri + "\".");
+					Log.e("POST_COMMENT", "The server returned a " + code + " code for the url \"" + uri + "\".");
 					return(-6);
-            }
+			}
 
-        }
+		}
 		catch (UnsupportedEncodingException e) {
-            Log.e("COMMENT", "Unable to post comment (UnsupportedEncodingException): " + e.toString());
+			Log.e("POST_COMMENT", "Unable to post comment (UnsupportedEncodingException): " + e.toString());
 			return -2;
-        }
+		}
 		catch (ProtocolException e) {
-            Log.e("COMMENT", "Unable to post comment (ProtocolException): " + e.toString());
+			Log.e("POST_COMMENT", "Unable to post comment (ProtocolException): " + e.toString());
 			return -3;
-        }
+		}
 		catch (MalformedURLException e) {
-            Log.e("COMMENT", "Unable to post comment (MalformedURLException): " + e.toString());
+			Log.e("POST_COMMENT", "Unable to post comment (MalformedURLException): " + e.toString());
 			return -4;
-        }
+		}
 		catch (IOException e) {
-            Log.e("COMMENT", "Unable to post comment (IOException): " + e.toString());
+			Log.e("POST_COMMENT", "Unable to post comment (IOException): " + e.toString());
 			return -5;
-        }
+		}
 		catch (Exception e) {
-            Log.e("COMMENT", "Unable to post comment: " + e.toString());
+			Log.e("POST_COMMENT", "Unable to post comment: " + e.toString());
 			return -1;
-        }
+		}
 
 		return 0;
-    }
-
+	}
 
 
-    /**
-     * After completing background task
-     */
-    @SuppressLint("InflateParams") //Throws unknown error when done properly.
-    @Override
-    protected void onPostExecute(Integer a) {
+	/**
+	 * When the comment is posted, update the comment list and clean the comment form.
+	 * @param a Unused.
+	 */
+	@Override
+	protected void onPostExecute(Integer a) {
 
-        if (code == 200) {
-            //Clear form
-            EditText formText = (EditText) form.findViewById(R.id.et_comment_text);
-            EditText formUser = (EditText) form.findViewById(R.id.et_comment_name);
-            formUser.setText("");
-            formText.setText("");
-
-            //TODO: Update counter
+		if (code == 200) {
+			//Clear form
+			EditText formText = (EditText) form.findViewById(R.id.et_comment_text);
+			EditText formUser = (EditText) form.findViewById(R.id.et_comment_name);
+			formUser.setText("");
+			formText.setText("");
 
 			//Perform a sync
 			((MainActivity) context).bgSync();
 
-
-            //Insert comment in list
-            LayoutInflater factory = LayoutInflater.from(context);
-            LinearLayout entry = (LinearLayout) factory.inflate(R.layout.row_comment, null);
-
-            //Set user
-            TextView tvUser = (TextView) entry.findViewById(R.id.tv_row_comment_user);
-            tvUser.setText(user);
-            Date d = new Date();
-            String date = DateFormat.format("yyyy-MM-dd hh:mm:ss", d.getTime()).toString();
-            TextView tvCDate = (TextView) entry.findViewById(R.id.tv_row_comment_date);
-            tvCDate.setText(GM.formatDate(date, language, true, true, true));
-            TextView tvText = (TextView) entry.findViewById(R.id.tv_row_comment_text);
-            tvText.setText(text);
-
-            //Add to the list
-            list.addView(entry);
-        }
-
-        //Show button again
-        btSend.setVisibility(View.VISIBLE);
-        pb.setVisibility(View.GONE);
-    }
+			//Insert comment in list
+			LayoutInflater factory = LayoutInflater.from(context);
+			LinearLayout entry = (LinearLayout) factory.inflate(R.layout.row_comment, list, false);
+
+			//Set user
+			TextView tvUser = (TextView) entry.findViewById(R.id.tv_row_comment_user);
+			tvUser.setText(user);
+			Date d = new Date();
+			String date = DateFormat.format("yyyy-MM-dd hh:mm:ss", d.getTime()).toString();
+			TextView tvCDate = (TextView) entry.findViewById(R.id.tv_row_comment_date);
+			tvCDate.setText(GM.formatDate(date, language, true, true, true));
+			TextView tvText = (TextView) entry.findViewById(R.id.tv_row_comment_text);
+			tvText.setText(text);
+
+			//Add to the list
+			list.addView(entry);
+		}
+
+		//Show button again
+		btSend.setVisibility(View.VISIBLE);
+		pb.setVisibility(View.GONE);
+	}
 }

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

@@ -1,12 +1,10 @@
 package com.ivalentin.margolariak;
 
-import android.annotation.SuppressLint;
 import android.content.Context;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
-import android.os.Build;
 import android.os.Bundle;
 import android.app.Fragment;
 import android.util.Log;
@@ -34,145 +32,138 @@ import java.io.File;
  */
 public class PostLayout extends Fragment {
 
-    //Main View
-    private View view;
-
-    private Context context;
-
-    @SuppressLint("InflateParams") //Throws unknown error when done properly.
-    @SuppressWarnings("ResultOfMethodCallIgnored")
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-
-        //Load the layout
-        view = inflater.inflate(R.layout.fragment_layout_post, null);
-        context = view.getContext();
-
-        //Get bundled id
-        Bundle bundle = this.getArguments();
-        final int id = bundle.getInt("post", -1);
-        if (id == -1){
-            Log.e("Post error", "No such post: " + id);
-            this.getActivity().onBackPressed();
-        }
-
-        //Get data from database
-        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, permalink FROM post WHERE id = " + id + ";", null);
-        cursor.moveToFirst();
-
-        //Get display elements
-        ImageView images[] = new ImageView[5];
-        images[0] = (ImageView) view.findViewById(R.id.iv_post_0);
-        images[1] = (ImageView) view.findViewById(R.id.iv_post_1);
-        images[2] = (ImageView) view.findViewById(R.id.iv_post_2);
-        images[3] = (ImageView) view.findViewById(R.id.iv_post_3);
-        images[4] = (ImageView) view.findViewById(R.id.iv_post_4);
-
-        TextView tvTitle = (TextView) view.findViewById(R.id.tv_post_title);
-        TextView tvDate = (TextView) view.findViewById(R.id.tv_post_date);
-        final TextView tvComments = (TextView) view.findViewById(R.id.tv_comments);
-        WebView wvText = (WebView) view.findViewById(R.id.wv_post_text);
-
-        if (Build.VERSION.SDK_INT >= 19) {
-            wvText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
-        }
-        else {
-            wvText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
-        }
-
-        LinearLayout llCommentList = (LinearLayout) view.findViewById(R.id.ll_comment_list);
-
-        //Set fields
-        tvTitle.setText(cursor.getString(1));
-        ((MainActivity) getActivity()).setSectionTitle(cursor.getString(1));
-        ((MainActivity) getActivity()).setShareLink(String.format(getString(R.string.share_with_title), cursor.getString(1)), GM.SHARE.BLOG + cursor.getString(4));
-        wvText.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
-        tvDate.setText(GM.formatDate(cursor.getString(3), lang, true, true, true));
-
-        //Get images
-        Cursor imageCursor = db.rawQuery("SELECT image, idx FROM post_image WHERE post = " + id + " ORDER BY idx LIMIT 5;", null);
-        int i = 0;
-        while (imageCursor.moveToNext()) {
-            String image = imageCursor.getString(0);
-
-            //Check if image exists
-            File f;
-            f = new File(this.getActivity().getFilesDir().toString() + "/img/blog/preview/" + image);
-            if (f.exists()){
-                //If the image exists, set it.
-                Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/blog/preview/" + image);
-                images[i].setImageBitmap(myBitmap);
-            }
-            else {
-                //If not, create directories and download asynchronously
-                File fpath;
-                fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/preview/");
-                fpath.mkdirs();
+	//Main View
+	private View view;
+
+	private Context context;
+
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+		//Load the layout
+		view = inflater.inflate(R.layout.fragment_layout_post, container, false);
+		context = view.getContext();
+
+		//Get bundled id
+		Bundle bundle = this.getArguments();
+		final int id = bundle.getInt("post", -1);
+		if (id == -1){
+			Log.e("POST_LAYOUT", "No such post: " + id);
+			this.getActivity().onBackPressed();
+		}
+
+		//Get data from database
+		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, permalink FROM post WHERE id = " + id + ";", null);
+		cursor.moveToFirst();
+
+		//Get display elements
+		ImageView images[] = new ImageView[5];
+		images[0] = (ImageView) view.findViewById(R.id.iv_post_0);
+		images[1] = (ImageView) view.findViewById(R.id.iv_post_1);
+		images[2] = (ImageView) view.findViewById(R.id.iv_post_2);
+		images[3] = (ImageView) view.findViewById(R.id.iv_post_3);
+		images[4] = (ImageView) view.findViewById(R.id.iv_post_4);
+
+		TextView tvTitle = (TextView) view.findViewById(R.id.tv_post_title);
+		TextView tvDate = (TextView) view.findViewById(R.id.tv_post_date);
+		final TextView tvComments = (TextView) view.findViewById(R.id.tv_comments);
+		WebView wvText = (WebView) view.findViewById(R.id.wv_post_text);
+
+		wvText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+
+		LinearLayout llCommentList = (LinearLayout) view.findViewById(R.id.ll_comment_list);
+
+		//Set fields
+		tvTitle.setText(cursor.getString(1));
+		((MainActivity) getActivity()).setSectionTitle(cursor.getString(1));
+		((MainActivity) getActivity()).setShareLink(String.format(getString(R.string.share_with_title), cursor.getString(1)), GM.SHARE.BLOG + cursor.getString(4));
+		wvText.loadDataWithBaseURL(null, cursor.getString(2), "text/html", "utf-8", null);
+		tvDate.setText(GM.formatDate(cursor.getString(3), lang, true, true, true));
+
+		//Get images
+		Cursor imageCursor = db.rawQuery("SELECT image, idx FROM post_image WHERE post = " + id + " ORDER BY idx LIMIT 5;", null);
+		int i = 0;
+		while (imageCursor.moveToNext()) {
+			String image = imageCursor.getString(0);
+
+			//Check if image exists
+			File f;
+			f = new File(this.getActivity().getFilesDir().toString() + "/img/blog/preview/" + image);
+			if (f.exists()){
+				//If the image exists, set it.
+				Bitmap myBitmap = BitmapFactory.decodeFile(this.getActivity().getFilesDir().toString() + "/img/blog/preview/" + image);
+				images[i].setImageBitmap(myBitmap);
+			}
+			else {
+				//If not, create directories and download asynchronously
+				File fpath;
+				fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/preview/");
+				fpath.mkdirs();
 				new DownloadImage(GM.API.SERVER + "/img/blog/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/blog/preview/" + image, images[i], GM.IMG.SIZE.PREVIEW).execute();
-            }
-            images[i].setVisibility(View.VISIBLE);
-            i ++;
-        }
-        imageCursor.close();
-
-        //Get comments
-        Cursor commentCursor = db.rawQuery("SELECT text, dtime, username FROM post_comment WHERE post = " + id + ";", null);
-        tvComments.setText(String.format(getResources().getQuantityString(R.plurals.comment_comments, commentCursor.getCount()), commentCursor.getCount()));
-        //final int commentCount = commentCursor.getCount();
-        cursor.moveToFirst();
-        LinearLayout entry;
-        LayoutInflater factory = LayoutInflater.from(getActivity());
-        while (commentCursor.moveToNext()) {
-            entry = (LinearLayout) factory.inflate(R.layout.row_comment, null);
-
-            //Set user
-            TextView tvUser = (TextView) entry.findViewById(R.id.tv_row_comment_user);
-            tvUser.setText(commentCursor.getString(2));
-            TextView tvCDate = (TextView) entry.findViewById(R.id.tv_row_comment_date);
-            tvCDate.setText(GM.formatDate(commentCursor.getString(1), lang, true, true, true));
-            TextView tvText = (TextView) entry.findViewById(R.id.tv_row_comment_text);
-            tvText.setText(commentCursor.getString(0));
-
-            //Add to the list
-            llCommentList.addView(entry);
-        }
-        commentCursor.close();
-
-        //Set up comment form
-        final EditText etCommentText = (EditText) view.findViewById(R.id.et_comment_text);
-        final EditText etCommentName = (EditText) view.findViewById(R.id.et_comment_name);
-        Button btSendComment = (Button) view.findViewById(R.id.bt_comment_send);
-
-        btSendComment.setOnClickListener(new View.OnClickListener(){
-            @Override
-            public void onClick(View v) {
-                String user = etCommentName.getText().toString();
-                String text = etCommentText.getText().toString();
-                if (user.length() < 1){
-                    Toast.makeText(getActivity(), getString(R.string.comment_toast_user), Toast.LENGTH_LONG).show();
-                    etCommentName.requestFocus();
-                    return;
-                }
-                if (text.length() < 1){
-                    Toast.makeText(getActivity(), getString(R.string.comment_toast_text), Toast.LENGTH_LONG).show();
-                    etCommentText.requestFocus();
-                    return;
-                }
-
-                //Start async task
-                LinearLayout form = (LinearLayout) view.findViewById(R.id.ll_new_comment);
-                LinearLayout list = (LinearLayout) view.findViewById(R.id.ll_comment_list);
-                String lang = GM.getLang();
-                new PostComment("blog", user, text, lang, id, form, list, context).execute();
-
-            }
-        });
-
-        cursor.close();
-        db.close();
-        return view;
-    }
-}
+			}
+			images[i].setVisibility(View.VISIBLE);
+			i ++;
+		}
+		imageCursor.close();
+
+		//Get comments
+		Cursor commentCursor = db.rawQuery("SELECT text, dtime, username FROM post_comment WHERE post = " + id + ";", null);
+		tvComments.setText(String.format(getResources().getQuantityString(R.plurals.comment_comments, commentCursor.getCount()), commentCursor.getCount()));
+		//final int commentCount = commentCursor.getCount();
+		cursor.moveToFirst();
+		LinearLayout entry;
+		LayoutInflater factory = LayoutInflater.from(getActivity());
+		while (commentCursor.moveToNext()) {
+			entry = (LinearLayout) factory.inflate(R.layout.row_comment, llCommentList, false);
+
+			//Set user
+			TextView tvUser = (TextView) entry.findViewById(R.id.tv_row_comment_user);
+			tvUser.setText(commentCursor.getString(2));
+			TextView tvCDate = (TextView) entry.findViewById(R.id.tv_row_comment_date);
+			tvCDate.setText(GM.formatDate(commentCursor.getString(1), lang, true, true, true));
+			TextView tvText = (TextView) entry.findViewById(R.id.tv_row_comment_text);
+			tvText.setText(commentCursor.getString(0));
+
+			//Add to the list
+			llCommentList.addView(entry);
+		}
+		commentCursor.close();
+
+		//Set up comment form
+		final EditText etCommentText = (EditText) view.findViewById(R.id.et_comment_text);
+		final EditText etCommentName = (EditText) view.findViewById(R.id.et_comment_name);
+		Button btSendComment = (Button) view.findViewById(R.id.bt_comment_send);
+
+		btSendComment.setOnClickListener(new View.OnClickListener(){
+			@Override
+			public void onClick(View v) {
+				String user = etCommentName.getText().toString();
+				String text = etCommentText.getText().toString();
+				if (user.length() < 1){
+					Toast.makeText(getActivity(), getString(R.string.comment_toast_user), Toast.LENGTH_LONG).show();
+					etCommentName.requestFocus();
+					return;
+				}
+				if (text.length() < 1){
+					Toast.makeText(getActivity(), getString(R.string.comment_toast_text), Toast.LENGTH_LONG).show();
+					etCommentText.requestFocus();
+					return;
+				}
+
+				//Start async task
+				LinearLayout form = (LinearLayout) view.findViewById(R.id.ll_new_comment);
+				LinearLayout list = (LinearLayout) view.findViewById(R.id.ll_comment_list);
+				String lang = GM.getLang();
+				new PostComment("blog", user, text, lang, id, form, list, context).execute();
+
+			}
+		});
+
+		cursor.close();
+		db.close();
+		return view;
+	}
+}

+ 20 - 11
app/src/main/java/com/ivalentin/margolariak/ReceiveLocation.java

@@ -46,14 +46,14 @@ class ReceiveLocation extends AsyncTask<Void, Void, Void> {
 
 			int httpCode = urlConnection.getResponseCode();
 			switch (httpCode) {
-				case 400:	//Client error: Bad request
-					Log.e("LOCATION", "The server returned a 400 code (Client Error: Bad request) for the url \"" + uri + "\"");
+				case 400: //Client error: Bad request
+					Log.e("RECEIVE_LOCATION", "The server returned a 400 code (Client Error: Bad request) for the url \"" + uri + "\"");
 					break;
-				case 204:	//Success: No content
-					Log.d("LOCATION", "The server returned a 204 code (Success: No content) for the url \"" + uri + "\". Not getting location...");
+				case 204: //Success: No content
+					Log.d("RECEIVE_LOCATION", "The server returned a 204 code (Success: No content) for the url \"" + uri + "\". Not getting location...");
 					break;
-				case 200:	//Success: OK
-					Log.d("LOCATION", "The server returned a 200 code (Success: OK) for the url \"" + uri + "\". Now getting location...");
+				case 200: //Success: OK
+					Log.d("RECEIVE_LOCATION", "The server returned a 200 code (Success: OK) for the url \"" + uri + "\". Now getting location...");
 					BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
 					StringBuilder sb = new StringBuilder();
 					String o;
@@ -66,10 +66,14 @@ class ReceiveLocation extends AsyncTask<Void, Void, Void> {
 					String lat = strLocation.substring(strLocation.indexOf("\"lat\":\"") + 7, strLocation.indexOf("\"", strLocation.indexOf("\"lat\":\"") + 8));
 					String lon = strLocation.substring(strLocation.indexOf("\"lon\":\"") + 7, strLocation.indexOf("\"", strLocation.indexOf("\"lon\":\"") + 8));
 					String dtime = strLocation.substring(strLocation.indexOf("\"dtime\":\"") + 9, strLocation.indexOf("\"", strLocation.indexOf("\"dtime\":\"") + 10));
-					Log.d("LOCATION", "Found location [" +lat + ", " + lon + "] sent " + dtime);
+					Log.d("RECEIVE_LOCATION", "Found location [" +lat + ", " + lon + "] sent " + dtime);
 
 					//Insert into the database
 					SQLiteDatabase db = activity.openOrCreateDatabase(GM.DB.NAME, Activity.MODE_PRIVATE, null);
+					if (db.isReadOnly()){
+						Log.e("RECEIVE_LOCATION", "Database is in read only mode. Skipping.");
+						return null;
+					}
 					db.execSQL("INSERT INTO location VALUES ('" + dtime + "', " + lat + ", " + lon + ")");
 					db.close();
 
@@ -78,10 +82,15 @@ class ReceiveLocation extends AsyncTask<Void, Void, Void> {
 			}
 
 
-		} catch (MalformedURLException e) {
-			Log.e("LOCATION", "Unable to get location, malformed URL: " + e.toString());
-		} catch (IOException e) {
-			Log.e("LOCATION", "Unable to get location, IO exception: " + e.toString());
+		}
+		catch (MalformedURLException e) {
+			Log.e("RECEIVE_LOCATION", "Unable to get location, malformed URL: " + e.toString());
+		}
+		catch (IOException e) {
+			Log.e("RECEIVE_LOCATION", "Unable to get location, IO exception: " + e.toString());
+		}
+		catch (Exception e) {
+			Log.e("RECEIVE_LOCATION", "Unable to get location, unknown exception: " + e.toString());
 		}
 
 

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

@@ -3,30 +3,22 @@ package com.ivalentin.margolariak;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.Locale;
 
-import com.google.android.gms.maps.CameraUpdate;
-import com.google.android.gms.maps.CameraUpdateFactory;
-import com.google.android.gms.maps.GoogleMap;
-import com.google.android.gms.maps.MapView;
-import com.google.android.gms.maps.MapsInitializer;
-import com.google.android.gms.maps.OnMapReadyCallback;
-import com.google.android.gms.maps.model.LatLng;
-import com.google.android.gms.maps.model.MarkerOptions;
-
-import android.annotation.SuppressLint;
 import android.app.Dialog;
 import android.content.DialogInterface;
 import android.content.DialogInterface.OnCancelListener;
-import android.content.DialogInterface.OnShowListener;
-import android.content.pm.PackageManager;
+import android.content.Intent;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
 import android.os.Bundle;
 import android.app.Fragment;
-import android.support.v4.app.ActivityCompat;
+import android.preference.PreferenceManager;
 import android.text.Editable;
 import android.text.TextWatcher;
 import android.util.Log;
@@ -44,59 +36,52 @@ import android.widget.LinearLayout;
 import android.widget.ScrollView;
 import android.widget.TextView;
 
+import org.osmdroid.api.IMapController;
+import org.osmdroid.config.Configuration;
+
+import org.osmdroid.util.GeoPoint;
+import org.osmdroid.views.MapView;
+import org.osmdroid.views.overlay.ItemizedIconOverlay;
+import org.osmdroid.views.overlay.OverlayItem;
+import org.osmdroid.views.overlay.Polyline;
+
 /**
  * Fragment to be inflated showing the festivals schedule.
  * Contains a date selector and a ScrollView with all the activities for the day.
- * 
+ *
  * @author Inigo Valentin
  *
  */
-public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
-
-	private Bundle bund;
+public class ScheduleLayout extends Fragment{
 
 	private final String dates[] = new String[40];
 	private int dateCount = 0;
 	private int selected = 0;
-
-	//Indicates official schedule
-	private int schedule;
-
-	//Map stuff for the dialog
-	private MapView mapView;
-	private GoogleMap map;
-	private LatLng location;
-	private View view;
-	private String markerName = "";
 	
+	private View view;
+
 	/**
 	 * Run when the fragment is inflated.
 	 * Assigns views, gets the date and does the first call to the populateSchedule function.
-	 * 
+	 *
 	 * @param inflater A LayoutInflater to manage views
 	 * @param container The container View
 	 * @param savedInstanceState Bundle containing the state
-	 * 
-	 * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
+	 *
+	 * @see Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
 	 */
-	@SuppressLint("InflateParams") //Throws unknown error when done properly.
 	@Override
 	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
 		Calendar calendar = Calendar.getInstance();
 		String year = Integer.toString(calendar.get(Calendar.YEAR));
 
-
-		//Set bundle for the map
-		bund = savedInstanceState;
-		
 		//Load the layout
-		view = inflater.inflate(R.layout.fragment_layout_schedule, null);
+		view = inflater.inflate(R.layout.fragment_layout_schedule, container, false);
 		view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
 			@Override
 			public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
 				CustomScrollView sv = (CustomScrollView) v.findViewById(R.id.sv_schedule);
-				Log.d("SV", "INVALIDATED");
 				sv.invalidate();
 			}
 		});
@@ -104,8 +89,8 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 		//Get schedule type
 		TextView title = (TextView) view.findViewById(R.id.tv_schedule_type);
 		Bundle bundle = this.getArguments();
-		schedule = bundle.getInt(GM.SCHEDULE.KEY, GM.SCHEDULE.CITY);
-		
+		final int schedule = bundle.getInt(GM.SCHEDULE.KEY, GM.SCHEDULE.CITY);
+
 		//Set the title
 		if (schedule == GM.SCHEDULE.CITY) {
 			((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_lablanca_schedule));
@@ -121,10 +106,10 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
 		Cursor cursor;
 		if (schedule == GM.SCHEDULE.MARGOLARIAK) {
-			cursor = db.rawQuery("SELECT DISTINCT date(start) AS daydate FROM festival_event WHERE strftime('%Y', start) = '" + year + "' AND strftime('%H', start) > '06' AND gm = 1 ORDER BY daydate;", null);
+			cursor = db.rawQuery("SELECT DISTINCT date(start) AS daydate FROM festival_event_gm WHERE strftime('%Y', start) = '" + year + "' AND strftime('%H', start) > '06' ORDER BY daydate;", null);
 		}
 		else{
-			cursor = db.rawQuery("SELECT DISTINCT date(start) AS daydate FROM festival_event WHERE strftime('%Y', start) = '" + year + "' AND strftime('%H', start) > '06' AND gm = 0 ORDER BY daydate;", null);
+			cursor = db.rawQuery("SELECT DISTINCT date(start) AS daydate FROM festival_event_city WHERE strftime('%Y', start) = '" + year + "' AND strftime('%H', start) > '06' ORDER BY daydate;", null);
 		}
 
 
@@ -152,17 +137,17 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 			@Override
 			public void onClick(View v) {
 				selected --;
-				populateSchedule();
+				populateSchedule(schedule);
 			}
 		});
 		btR.setOnClickListener(new OnClickListener() {
 			@Override
 			public void onClick(View v) {
 				selected ++;
-				populateSchedule();
+				populateSchedule(schedule);
 			}
 		});
-		
+
 		//Assign the filter text
 		EditText etFilter = (EditText) view.findViewById(R.id.et_schedule_filter);
 		etFilter.addTextChangedListener(new TextWatcher() {
@@ -176,25 +161,24 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 	        @Override
 	        public void onTextChanged(CharSequence s, int start, int before, int count) {
 	        	//Repopulate when the text is changed
-	        	populateSchedule();
-	          
+	        	populateSchedule(schedule);
 	        }
 		});
-		
+
 		//Populate the activity list
-		populateSchedule();
-		
+		populateSchedule(schedule);
+
 		//Return the fragment view
 		return view;
 	}
 
 	/**
-	 * Populates the list of activities with the ones n the selected day.
-	 * 
+	 * Populates the list of activities with the ones in the selected day.
+	 *
+	 * @param schedule GM.SCHEDULE.GM or GM.SCHEDULE.CITY
 	 */
-	@SuppressLint({"InflateParams", "SwitchIntDef"})
 	//Views are added from a loop: I can't specify the parent when inflating.
-	private int populateSchedule() {
+	private int populateSchedule(final int schedule) {
 
 		int eventCount = 0;
 
@@ -225,7 +209,7 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 		try {
 			calendar.setTime(dateFormat.parse(dates[selected] + " 06:00:00"));
 		} catch (Exception ex) {
-			Log.e("Datetime error", ex.toString());
+			Log.e("SCHEDULE_LAYOUT", "Datetime error: " + ex.toString());
 		}
 
 		SQLiteDatabase db = SQLiteDatabase.openDatabase(getActivity().getDatabasePath(GM.DB.NAME).getAbsolutePath(), null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READONLY);
@@ -248,13 +232,14 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 
 
 		tvDayNumber.setText(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
-		switch (calendar.get(Calendar.MONTH)) {
-			case 6:
-				tvDayMonth.setText(getString(R.string.schedule_month_july));
-				break;
-			case 7:
-				tvDayMonth.setText(getString(R.string.schedule_month_august));
-				break;
+		int i = calendar.get(Calendar.MONTH);
+		if (i == Calendar.JULY) {
+			tvDayMonth.setText(getString(R.string.schedule_month_july));
+
+		}
+		else if (i == Calendar.AUGUST) {
+			tvDayMonth.setText(getString(R.string.schedule_month_august));
+
 		}
 		if (schedule == GM.SCHEDULE.MARGOLARIAK) {
 			Cursor cursorDay = db.rawQuery("SELECT name_" + lang + " FROM festival_day WHERE date(date) = '" + dates[selected] + "';", null);
@@ -274,24 +259,38 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 		try {
 			c.setTime(sdf.parse(dates[selected]));
 		} catch (Exception ex) {
-			Log.e("Date parsing error", ex.toString());
+			Log.e("SCHEDULE_LAYOUT", "Date parsing error: " + ex.toString());
 			return eventCount;
 		}
 		c.add(Calendar.DATE, 1);  // number of days to add
 		String endDate = sdf.format(c.getTime());
 
-		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 ";
+		String query;
 
 		if (schedule == GM.SCHEDULE.MARGOLARIAK) {
-			query = query + "gm = 1 ";
-		} else {
-			query = query + "gm = 0 ";
+			query = "SELECT festival_event_gm.id AS id, title_" + lang + " AS title, description_" + lang + " AS description, place AS place_id, start, end, name_" + lang + " AS place, address_" + lang + " AS address, lat, lon, route FROM festival_event_gm, place WHERE place = place.id AND start >= '" + dates[selected] + " 06:00:00' AND start < '" + endDate + " 05:59:59'";
+		}
+		else {
+			query = "SELECT festival_event_city.id AS id, title_" + lang + " AS title, description_" + lang + " AS description, place AS place_id, start, end, name_" + lang + " AS place, address_" + lang + " AS address, lat, lon, route FROM festival_event_city, place WHERE place = place.id AND start >= '" + dates[selected] + " 06:00:00' AND start < '" + endDate + " 05:59:59'";
 		}
 		if (filter.length() > 0) {
 			query = query + "AND (title_" + lang + " like '%" + filter + "%' OR description_" + lang + " like '%" + filter + "%' OR name_" + lang + " like '%" + filter + "%' OR address_" + lang + " like '%" + filter + "%') ";
 		}
 		query = query + " ORDER BY start;";
 		Cursor cursor = db.rawQuery(query, null);
+		/*
+		 * 0: id
+		 * 1: title
+		 * 2: description
+		 * 3: place_id
+		 * 4: start
+		 * 5: end
+		 * 6: place
+		 * 7: address
+		 * 8: lat
+		 * 9: lon
+		 * 10: route
+		 */
 
 		//Clear the list
 		list = (LinearLayout) view.findViewById(R.id.ll_schedule_list);
@@ -300,7 +299,7 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 		while (cursor.moveToNext()) {
 			eventCount++;
 
-			entry = (LinearLayout) factory.inflate(R.layout.row_schedule, null);
+			entry = (LinearLayout) factory.inflate(R.layout.row_schedule, list, false);
 
 			//Set id
 			tvRowId = (TextView) entry.findViewById(R.id.tv_row_schedule_id);
@@ -314,7 +313,8 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 			tvRowDesc = (TextView) entry.findViewById(R.id.tv_row_schedule_description);
 			if (cursor.getString(2) == null || cursor.getString(2).length() <= 0 || cursor.getString(2).equals(cursor.getString(1))) {
 				tvRowDesc.setVisibility(View.GONE);
-			} else {
+			}
+			else {
 				tvRowDesc.setText(cursor.getString(2));
 			}
 
@@ -324,19 +324,19 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 
 			//Set address
 			tvRowAddress = (TextView) entry.findViewById(R.id.tv_row_schedule_address);
-			if (cursor.getString(7) == null || cursor.getString(7).length() <= 0 || cursor.getString(7).equals(cursor.getString(6))) {
+			if (cursor.getString(7) == null || cursor.getString(7).length() <= 0 || cursor.getString(7).equalsIgnoreCase(cursor.getString(6))) {
 				tvRowAddress.setVisibility(View.GONE);
-			} else {
+			}
+			else {
 				tvRowAddress.setText(cursor.getString(7));
 			}
 
 			//Set icon
-			if (schedule == GM.SCHEDULE.MARGOLARIAK) {
+			if (cursor.getString(10) != null){
 				ImageView pinPoint = (ImageView) entry.findViewById(R.id.iv_row_schedule_pinpoint);
-				pinPoint.setImageResource(getResources().getIdentifier("com.ivalentin.margolariak:drawable/pinpoint_gm", null, null));
+				pinPoint.setImageResource(R.drawable.pinpoint_route);
 			}
 
-
 			//Set time
 			tvRowTime = (TextView) entry.findViewById(R.id.tv_row_schedule_time);
 			String tm = cursor.getString(4).substring(cursor.getString(4).length() - 8, cursor.getString(4).length() - 3);
@@ -348,7 +348,7 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 				public void onClick(View v) {
 					TextView tvId = (TextView) v.findViewById(R.id.tv_row_schedule_id);
 					int id = Integer.parseInt(tvId.getText().toString());
-					showDialog(id);
+					showDialog(id, schedule);
 				}
 			});
 
@@ -365,65 +365,107 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 			sw.scrollTo(0, 0);
 		}
 		catch(Exception ex){
-			Log.e("Schedule scroll", "Culdnt get scrollview to scroll: " + ex.toString());
+			Log.e("SCHEDULE_LAYOUT", "Culdn't get scrollview to scroll: " + ex.toString());
 		}
 
 		return eventCount;
 
 	}
-	
+
 	/**
 	 * Shows a dialog with info about the selected event.
-	 * 
+	 *
 	 * @param id The event id
+	 * @param schedule GM.SCHEDULE.GM or GM.SCHEDULE.CITY
 	 */
-	@SuppressWarnings("ConstantConditions")
-	private void showDialog(final int id){
-		
+	private void showDialog(final int id, final int schedule){
+
 		//Create the dialog
 		final Dialog dialog = new Dialog(getActivity());
-		
+
 		//Set up dialog window
 		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
 		dialog.setContentView(R.layout.dialog_schedule);
-		
+
 		//Date formatters
 		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
 		SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd-", Locale.US);
 		SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm", Locale.US);
- 
+
 		//Set the custom dialog components - text, image and button
 		TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_title);
 		TextView tvDescription = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_description);
 		TextView tvHost = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_host);
+		TextView tvSponsor = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_sponsor);
 		TextView tvDate = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_date);
 		TextView tvTime = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_time);
+		LinearLayout llPlace = (LinearLayout) dialog.findViewById(R.id.ll_dialog_schedule_place);
 		TextView tvPlace = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_place);
 		TextView tvAddress = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_address);
 		Button btClose = (Button) dialog.findViewById(R.id.bt_schedule_close);
-		
+		TextView tvOsm = (TextView) dialog.findViewById(R.id.tv_dialog_schedule_osm);
+		MapView mapView = (MapView) dialog.findViewById(R.id.mv_dialog_schedule_map);
+
+		// Basic map configuration
+		mapView.setMultiTouchControls(true);
+		IMapController mapController = mapView.getController();
+
 		//Get info about the event
 		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);
+		Cursor cursor;
+		if (schedule == GM.SCHEDULE.MARGOLARIAK){
+			//cursor = db.rawQuery("SELECT festival_event_gm.id, title_" + lang + ", description_" + lang + ", place, route, start, end, name_" + lang + ", address_" + lang + ", lat, lon, host, sponsor FROM festival_event_gm, place WHERE place = place.id AND festival_event_gm.id = " + id + ";", null);
+			cursor = db.rawQuery("SELECT id, title_" + lang + ", description_" + lang + ", place, route, start, end, host, sponsor FROM festival_event_gm WHERE id = " + id + ";", null);
+		}
+		else{
+			//cursor = db.rawQuery("SELECT festival_event_city.id, title_" + lang + ", description_" + lang + ", place, route, start, end, name_" + lang + ", address_" + lang + ", lat, lon, host, sponsor FROM, sponsor festival_event_city, place WHERE place = place.id AND festival_event_city.id = " + id + ";", null);
+			cursor = db.rawQuery("SELECT id, title_" + lang + ", description_" + lang + ", place, route, start, end, host, sponsor FROM festival_event_city WHERE id = " + id + ";", null);
+		}
 		if (cursor.getCount() > 0){
 			cursor.moveToNext();
-		
+
+			String title = cursor.getString(1);
+			String description = "";
+			if (!cursor.isNull(2)){
+				description = cursor.getString(2);
+			}
+			String strStart = cursor.getString(5);
+			String strEnd = "";
+			if (!cursor.isNull(6)){
+				strEnd = cursor.getString(6);
+			}
+			int placeId = 0;
+			if (!cursor.isNull(3)){
+				placeId = cursor.getInt(3);
+			}
+			int routeId = 0;
+			if (!cursor.isNull(4)){
+				routeId = cursor.getInt(4);
+			}
+			int hostId = 0;
+			if (!cursor.isNull(7)){
+				hostId = cursor.getInt(7);
+			}
+			int sponsorId = 0;
+			if (!cursor.isNull(8)){
+				sponsorId = cursor.getInt(8);
+			}
+
 			//Set title
-			tvTitle.setText(cursor.getString(1));
-			markerName = cursor.getString(1);
-			
+			tvTitle.setText(title);
+
 			//Set description
-			if (cursor.getString(2) != null && cursor.getString(2).length() > 0) {
-				tvDescription.setText(cursor.getString(2));
+			if (description.length() > 0) {
+				tvDescription.setText(description);
 			}
 			else{
 				tvDescription.setVisibility(View.GONE);
 			}
-			
+
 			//Set host
-			if (cursor.getString(10) != null){
-				Cursor hostCursor = db.rawQuery("SELECT name_" + lang + " FROM people WHERE id = " + cursor.getString(10) + ";", null);
+			if (hostId != 0){
+				Cursor hostCursor = db.rawQuery("SELECT name_" + lang + " FROM people WHERE id = " + hostId + ";", null);
 				if (hostCursor.moveToNext()){
 					tvHost.setVisibility(View.VISIBLE);
 					tvHost.setText(String.format(getString(R.string.schedule_host), hostCursor.getString(0)));
@@ -432,28 +474,41 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 			}
 			else{
 				tvHost.setVisibility(View.GONE);
-			}				
-			
+			}
+
+			//Set sponsor
+			if (sponsorId != 0){
+				Cursor sponsorCursor = db.rawQuery("SELECT name_" + lang + " FROM people WHERE id = " + sponsorId + ";", null);
+				if (sponsorCursor.moveToNext()){
+					tvSponsor.setVisibility(View.VISIBLE);
+					tvSponsor.setText(String.format(getString(R.string.schedule_sponsor), sponsorCursor.getString(0)));
+				}
+				sponsorCursor.close();
+			}
+			else{
+					tvSponsor.setVisibility(View.GONE);
+			}
+
+
 			//Set date
 			try{
-				Date day = dateFormat.parse(cursor.getString(4));
+				Date day = dateFormat.parse(strStart);
 				Date date = new Date();
 				//If the event is today, show "Today" instead of the date
 				if (dayFormat.format(day).equals(dayFormat.format(date)))
 					tvDate.setText(dialog.getContext().getString(R.string.today));
-				
 				else{
 					Calendar cal = Calendar.getInstance();
-				    cal.setTime(date);
-				    cal.add(Calendar.HOUR_OF_DAY, 24);
-				    
-				    //If the event is tomorrow, show "Tomorrow" instead of the date
-				    if (dayFormat.format(cal.getTime()).equals(dayFormat.format(date))){
-				    	tvDate.setText(dialog.getContext().getString(R.string.tomorrow));
-				    }
-					
-				    //Else, show the date
-				    else{
+					cal.setTime(date);
+					cal.add(Calendar.HOUR_OF_DAY, 24);
+
+					//If the event is tomorrow, show "Tomorrow" instead of the date
+					if (dayFormat.format(cal.getTime()).equals(dayFormat.format(date))){
+						tvDate.setText(dialog.getContext().getString(R.string.tomorrow));
+					}
+
+					//Else, show the date
+					else{
 						SimpleDateFormat printFormat;
 						switch (lang){
 							case "en":
@@ -476,63 +531,153 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 				}
 			}
 			catch (Exception ex){
-				Log.e("Error parsing date", ex.toString());
+				Log.e("SCHEDULE_LAYOUT", "Error parsing date: " + ex.toString());
 			}
-			
+
 			//Set time
 			try{
-				if (cursor.getString(5) == null || cursor.getString(5).length() == 0) {
-					tvTime.setText(timeFormat.format(dateFormat.parse(cursor.getString(4))));
+				if (strEnd.length() == 0) {
+					tvTime.setText(timeFormat.format(dateFormat.parse(strStart)));
 				}
 				else {
-					String time = timeFormat.format(dateFormat.parse(cursor.getString(4))) + " - " + timeFormat.format(dateFormat.parse(cursor.getString(5)));
+					String time = timeFormat.format(dateFormat.parse(strStart)) + " - " + timeFormat.format(dateFormat.parse(strEnd));
 					tvTime.setText(time);
 				}
 			}
 			catch (ParseException ex){
-				Log.e("Error parsing time", ex.toString());
+				Log.e("SCHEDULE_LAYOUT", "Error parsing time: " + ex.toString());
 			}
-			
+
+
+
+
 			//Set the place
-			tvPlace.setText(cursor.getString(6));
-			tvAddress.setText(cursor.getString(7));
-			
-			//Set up map
-			location = new LatLng(Double.parseDouble(cursor.getString(8)), Double.parseDouble(cursor.getString(9)));
-			mapView = (MapView) dialog.findViewById(R.id.mv_dialog_schedule_map);
-			mapView.onCreate(bund);
-			
+			if (routeId != 0){
+				llPlace.setVisibility(View.GONE);
+				Cursor routeCursor = db.rawQuery("SELECT id, c_lat, c_lon, zoom FROM route WHERE id = " + routeId + ";", null);
+				if (routeCursor.moveToNext()) {
+
+					// Read from route_point and draw the route on the map.
+					Cursor pointCursor = db.rawQuery("SELECT lat_o, lon_o, lat_d, lon_d FROM route_point WHERE route = " + routeId + " ORDER BY part;", null);
+					final ArrayList<GeoPoint> points = new ArrayList<>();
+					GeoPoint lastPoint = new GeoPoint(0.0, 0.0);
+					GeoPoint firstPoint = null;
+					while (pointCursor.moveToNext()){
+						points.add(new GeoPoint(pointCursor.getDouble(0), pointCursor.getDouble(1)));
+						lastPoint = new GeoPoint(pointCursor.getDouble(2), pointCursor.getDouble(3));
+						if (firstPoint == null){
+							firstPoint = new GeoPoint(pointCursor.getDouble(0), pointCursor.getDouble(1));
+						}
+					}
+					// For the last one, also take destination
+					points.add(lastPoint);
+
+					pointCursor.close();
+
+					// Center map
+					mapController.setCenter(firstPoint);
+					mapController.setZoom(routeCursor.getInt(3));
+
+					// Create path
+					Polyline line = new Polyline();
+					line.setPoints(points);
+					line.setColor(getResources().getColor(R.color.map_route, null));
+					line.setWidth(30.0f);
+					mapView.getOverlays().add(line);
+
+					// Set markers
+					OverlayItem startOverlay = new OverlayItem(title, title, firstPoint);
+					Drawable startMarker = this.getResources().getDrawable(R.drawable.pinpoint_start, null);
+					startOverlay.setMarker(startMarker);
+					OverlayItem endOverlay = new OverlayItem(title, title, lastPoint);
+					Drawable endMarker = this.getResources().getDrawable(R.drawable.pinpoint_end, null);
+					endOverlay.setMarker(endMarker);
+					final ArrayList<OverlayItem> markers = new ArrayList<>();
+					markers.add(startOverlay);
+					markers.add(endOverlay);
+                                        ItemizedIconOverlay markersOverlay = new ItemizedIconOverlay<>(markers,
+					  new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
+					  	public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
+							return true;
+						}
+						public boolean onItemLongPress(final int index, final OverlayItem item) {
+							return true;
+						}
+					  }, getContext());
+					mapView.getOverlays().add(markersOverlay);
+
+				}
+				routeCursor.close();
+
+			}
+			else{
+				Cursor placeCursor = db.rawQuery("SELECT name_" + lang + ", address_" + lang + ", lat, lon FROM place WHERE id = " + placeId + ";", null);
+				if (placeCursor.moveToNext()){
+					tvPlace.setText(placeCursor.getString(0));
+					tvAddress.setText(placeCursor.getString(1));
+
+					// Configure map marker
+					mapController.setZoom(17);
+					GeoPoint center = new GeoPoint(placeCursor.getDouble(2), placeCursor.getDouble(3));
+					mapController.setCenter(center);
+					OverlayItem locationOverlayItem = new OverlayItem(title, placeCursor.getString(0), center);
+					Drawable locationMarker = this.getResources().getDrawable(R.drawable.pinpoint, null);
+					locationOverlayItem.setMarker(locationMarker);
+					final ArrayList<OverlayItem> items = new ArrayList<>();
+					items.add(locationOverlayItem);
+					ItemizedIconOverlay locationOverlay = new ItemizedIconOverlay<>(items,
+							new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
+								public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
+									return true;
+								}
+								public boolean onItemLongPress(final int index, final OverlayItem item) {
+									return true;
+								}
+							}, getContext());
+					mapView.getOverlays().add(locationOverlay);
+				}
+				placeCursor.close();
+			}
+
+			//Set up OpenStreetMap attribution
+			tvOsm.setOnClickListener(new OnClickListener() {
+				@Override
+				public void onClick(View view) {
+					Intent i = new Intent(Intent.ACTION_VIEW);
+					i.setData(Uri.parse(GM.URL.OSM_COPYRIGHT));
+					startActivity(i);
+				}
+			});
+
+
 			//Close the db connection
 			cursor.close();
 			db.close();
-			
-			//Set close button			
-        	btClose.setOnClickListener(new OnClickListener() {
-    			@Override
-    			public void onClick(View v) {
-    				dialog.dismiss();
-    			}
-    		});
-			
+
+			//Set close button
+	        	btClose.setOnClickListener(new OnClickListener() {
+	    			@Override
+	    			public void onClick(View v) {
+    					dialog.dismiss();
+    				}
+    			});
+
 			//Actions to take when the dialog is cancelled
 			dialog.setOnCancelListener(new OnCancelListener(){
 				@Override
 				public void onCancel(DialogInterface dialog) {
-					if (map != null) {
-						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)) {
-							map.setMyLocationEnabled(false);
-						}
-					}
-					if (mapView != null){
-    					mapView.onResume();
-    					mapView.onDestroy();
-    				}					
 				}
 			});
-			
+
 			//Show the dialog
 			WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
-			lp.copyFrom(dialog.getWindow().getAttributes());
+			try {
+				//noinspection ConstantConditions
+				lp.copyFrom(dialog.getWindow().getAttributes());
+			}
+			catch(NullPointerException e){
+				Log.e("SCHEDULE_LAYOUT", "Error setting dialog parameters: " + e.toString());
+			}
 			lp.width = WindowManager.LayoutParams.MATCH_PARENT;
 			lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
 			lp.gravity = Gravity.CENTER;
@@ -541,148 +686,21 @@ public class ScheduleLayout extends Fragment implements OnMapReadyCallback{
 
 			//Show dialog
 			dialog.show();
-			
-			//Start the map
-			startMap();
-			mapView.onResume();
-			dialog.setOnShowListener(new OnShowListener(){
 
-				@Override
-				public void onShow(DialogInterface dialog) {
-					// Gets to GoogleMap from the MapView and does initialization stuff
-					startMap();
-					
-				}
-			});		
-			
 		}
 	}
-	
-	/**
-	 * Starts the map in the dialog.
-	 */
-	private void startMap(){
-		mapView.getMapAsync(this);
-	}
-	
-	/**
-	 * Called when the fragment is brought back into the foreground. 
-	 * Resumes the map and the location manager.
-	 * 
-	 * @see android.app.Fragment#onResume()
-	 */
-	@Override
-	public void onResume() {
-		if (mapView != null)
-			mapView.onResume();
-		if (map != null) {
-			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)) {
-				map.setMyLocationEnabled(true);
-			}
-		}
-		super.onResume();
-	}
 
-	/**
-	 * Called when the fragment is destroyed. 
-	 * Finishes the map. 
-	 * 
-	 * @see android.app.Fragment#onDestroy()
-	 */
-	@Override
-	public void onDestroy() {
-		super.onDestroy();
-		if (map != null) {
-			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)) {
-				map.setMyLocationEnabled(false);
-			}
-		}
-		if (mapView != null){
-			try{
-				mapView.onResume();
-				mapView.onDestroy();
-			}
-			catch(Exception e){
-				Log.e("Error destroying mapview: ", e.toString());
-			}
-		}
-	}
-	
-	/**
-	 * Called when the fragment is paused. 
-	 * Finishes the map. 
-	 * 
-	 * @see android.app.Fragment#onPause()
-	 */
-	@Override
-	public void onPause() {
-		super.onDestroy();
-		if (map != null) {
-			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)) {
-				try{
-					map.setMyLocationEnabled(false);
-				}
-				catch(Exception e){
-					Log.e("Error pausing map: ", e.toString());
-				}
-			}
-		}
-		if (mapView != null){
-			try{
-				mapView.onPause();
-			}
-			catch(Exception e){
-				Log.e("Error pausing mapview: ", e.toString());
-			}
-		}
-	}
 
 	/**
-	 * Called in a situation of low memory.
+	 * Called when the activity is resumed.
 	 * Lets the map handle this situation.
-	 * 
-	 * @see android.app.Fragment#onLowMemory()
+	 *
+	 * @see android.app.Fragment#onResume()
 	 */
 	@Override
-	public void onLowMemory() {
-		super.onLowMemory();
-		if (mapView != null){
-			mapView.onResume();
-			mapView.onLowMemory();
-		}
+	public void onResume() {
+		Configuration.getInstance().load(getContext(), PreferenceManager.getDefaultSharedPreferences(getContext()));
+		super.onResume();
 	}
 
-	/**
-	 * Called when the map is ready to be displayed. 
-	 * Sets the map options and a marker for the map.
-	 * 
-	 * @param googleMap The map to be shown
-	 * 
-	 * @see com.google.android.gms.maps.OnMapReadyCallback#onMapReady(com.google.android.gms.maps.GoogleMap)
-	 */
-	@Override
-	public void onMapReady(GoogleMap googleMap) {
-		this.map = googleMap;
-		
-		map.getUiSettings().setMyLocationButtonEnabled(false);
-		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)) {
-			map.setMyLocationEnabled(true);
-		}
-		// Needs to call MapsInitializer before doing any CameraUpdateFactory calls
-		try {
-			MapsInitializer.initialize(this.getActivity());
-			CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(location, 14);
-			map.animateCamera(cameraUpdate);
-		}
-		catch (Exception e) {
-			Log.e("Error initializing maps", e.toString());
-		}
-		//Set GM marker
-		MarkerOptions mo = new MarkerOptions();
-		mo.title(markerName);
-		mo.position(location);
-		map.addMarker(mo);
-		
-	}
-		
 }

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

@@ -45,7 +45,7 @@ public class SettingsActivity extends Activity {
 	 *
 	 * @see Activity#onCreate(Bundle)
 	 */
-	@SuppressLint("CommitPrefEdits") // apply() is called in other methods
+	@SuppressLint("CommitPrefEdits")
 	@Override
 	public void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
@@ -249,7 +249,6 @@ public class SettingsActivity extends Activity {
 		//Set the web view
 		WebView wv = (WebView) dialog.findViewById(R.id.wv_changelog);
 		wv.getSettings().setAllowContentAccess(true);
-		Log.e("URL", "file:///android_assets/changelog_" + GM.getLang() + ".html");
 		wv.loadUrl("file:///android_asset/changelog_" + GM.getLang() + ".html");
 
 		//Set close button
@@ -263,7 +262,13 @@ public class SettingsActivity extends Activity {
 
 		//Prep the dialog
 		WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
-		lp.copyFrom(dialog.getWindow().getAttributes());
+		try {
+			//noinspection ConstantConditions
+			lp.copyFrom(dialog.getWindow().getAttributes());
+		}
+		catch (NullPointerException e){
+			Log.e("SETTINGS_ACTIVITY", "Error setting the dialog attributes: " + e.toString());
+		}
 		lp.width = WindowManager.LayoutParams.MATCH_PARENT;
 		lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
 		lp.gravity = Gravity.CENTER;

+ 0 - 179
app/src/main/java/com/ivalentin/margolariak/SettingsLayout.java

@@ -1,179 +0,0 @@
-package com.ivalentin.margolariak;
-
-import android.annotation.SuppressLint;
-import android.app.Dialog;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.os.Build;
-import android.os.Bundle;
-import android.app.Fragment;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.view.Window;
-import android.view.WindowManager;
-import android.webkit.WebView;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-/**
- * Section that allow the user to change the app settings.
- * 
- * @author Inigo Valentin
- *
- */
-public class SettingsLayout extends Fragment{
-
-	/**
-	 * Run when the fragment is inflated.
-	 * Assigns the view and the click listeners. 
-	 * 
-	 * @param inflater A LayoutInflater to manage views
-	 * @param container The container View
-	 * @param savedInstanceState Bundle containing the state
-	 * 
-	 * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
-	 */
-	@SuppressLint("InflateParams") //Throws unknown error when done properly.
-	@Override
-	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-		
-		//Load the layout
-		final View view = inflater.inflate(R.layout.fragment_layout_settings, null);
-		
-		//Set the title
-		((MainActivity) getActivity()).setSectionTitle(view.getContext().getString(R.string.menu_settings));
-		
-		//Get views.
-		RelativeLayout rlNotification = (RelativeLayout) view.findViewById(R.id.rl_settings_notifications);
-		final CheckBox cbNotification = (CheckBox) view.findViewById(R.id.cb_settings_notifications);
-		final TextView tvNotification = (TextView) view.findViewById(R.id.tv_settings_notifications_summary);
-		TextView tvLicense = (TextView) view.findViewById(R.id.tv_setting_license);
-		TextView tvPrivacy = (TextView) view.findViewById(R.id.tv_setting_privacy);
-		TextView tvAbout = (TextView) view.findViewById(R.id.tv_setting_about);
-		TextView tvTransparency = (TextView) view.findViewById(R.id.tv_setting_transparency);
-
-
-		//Set initial state of the notification  settings
-		SharedPreferences settings = view.getContext().getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
-		if (settings.getBoolean(GM.PREFERENCES.KEY.NOTIFICATIONS, GM.PREFERENCES.DEFAULT.NOTIFICATIONS)){
-			cbNotification.setChecked(true);
-			tvNotification.setText(view.getContext().getString(R.string.settings_notification_on));
-		}
-		else{
-			cbNotification.setChecked(false);
-			tvNotification.setText(view.getContext().getString(R.string.settings_notification_off));
-		}
-
-		//Set click listener for "Notification" preference
-		rlNotification.setOnClickListener(new OnClickListener(){
-			@Override
-			public void onClick(View v) {
-				if (cbNotification.isChecked()){
-					cbNotification.setChecked(false);
-					tvNotification.setText(view.getContext().getString(R.string.settings_notification_off));
-					SharedPreferences preferences = view.getContext().getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
-					SharedPreferences.Editor editor = preferences.edit();
-					editor.putBoolean(GM.PREFERENCES.KEY.NOTIFICATIONS, false);
-					editor.apply();
-				}
-				else{
-					cbNotification.setChecked(true);
-					tvNotification.setText(view.getContext().getString(R.string.settings_notification_on));
-					SharedPreferences preferences = view.getContext().getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
-					SharedPreferences.Editor editor = preferences.edit();
-					editor.putBoolean(GM.PREFERENCES.KEY.NOTIFICATIONS, true);
-					editor.apply();
-				}
-			}
-			
-		});
-
-		//Set listener for the other buttons
-		tvLicense.setOnClickListener(new OnClickListener() {
-			@Override
-			public void onClick(View v) {
-				String title = v.getResources().getString(R.string.settings_license);
-				String text = v.getResources().getString(R.string.settings_license_content);
-				showDialog(title, text);
-			}
-		});
-		tvPrivacy.setOnClickListener(new OnClickListener() {
-			@Override
-			public void onClick(View v) {
-				String title = v.getResources().getString(R.string.settings_privacy);
-				String text = v.getResources().getString(R.string.settings_privacy_content);
-				showDialog(title, text);
-			}
-		});
-		tvAbout.setOnClickListener(new OnClickListener() {
-			@Override
-			public void onClick(View v) {
-				String title = v.getResources().getString(R.string.settings_about);
-				String text = v.getResources().getString(R.string.settings_about_content);
-				showDialog(title, text);
-			}
-		});
-		tvTransparency.setOnClickListener(new OnClickListener() {
-			@Override
-			public void onClick(View v) {
-				String title = v.getResources().getString(R.string.settings_transparency);
-				String text = v.getResources().getString(R.string.settings_transparency_content);
-				showDialog(title, text);
-			}
-		});
-
-		return view;
-	}
-
-	private void showDialog(String title, String text){
-		//Create the dialog
-		final Dialog dialog = new Dialog(getActivity());
-
-		//Set up dialog window
-		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
-		dialog.setContentView(R.layout.dialog_settings);
-
-		//Set the custom dialog components - text, image and button
-		TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_dialog_settings_title);
-		WebView wvText = (WebView) dialog.findViewById(R.id.wv_dialog_settings_text);
-
-		if (Build.VERSION.SDK_INT >= 19) {
-			wvText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
-		}
-		else {
-			wvText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
-		}
-
-		Button btClose = (Button) dialog.findViewById(R.id.bt_dialog_settings_close);
-
-		//Set text
-		tvTitle.setText(title);
-		wvText.loadDataWithBaseURL(null, text, "text/html", "utf-8", null);
-
-		//Set close button
-		btClose.setOnClickListener(new OnClickListener() {
-			@Override
-			public void onClick(View v) {
-				dialog.dismiss();
-			}
-		});
-
-		//Set parameters
-		WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
-		lp.copyFrom(dialog.getWindow().getAttributes());
-		lp.width = WindowManager.LayoutParams.MATCH_PARENT;
-		lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
-		lp.gravity = Gravity.CENTER;
-		lp.dimAmount = 0.4f;
-		dialog.getWindow().setAttributes(lp);
-
-		//Show dialog
-		dialog.show();
-
-	}
-}

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

@@ -1,6 +1,5 @@
 package com.ivalentin.margolariak;
 
-import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.app.Dialog;
 import android.content.Intent;
@@ -39,7 +38,6 @@ public class SponsorActivity extends Activity {
 	 * @param savedInstanceState Saved state of the activity.
 	 * @see Activity#onCreate(Bundle)
 	 */
-	@SuppressLint("InflateParams")
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
 
@@ -64,9 +62,9 @@ public class SponsorActivity extends Activity {
 
 		while (cursor.moveToNext()) {
 			//Create a new row
-			entry = (LinearLayout) factory.inflate(R.layout.row_sponsor, null);
+			entry = (LinearLayout) factory.inflate(R.layout.row_sponsor, llList, false);
 
-			//Set margins TODO: I don't know why it doesnt read margins from the xml
+			//Set margins
 			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
 			int margin = (int) (9 * getResources().getDisplayMetrics().density);
 			layoutParams.setMargins(margin, margin, margin, margin);

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

@@ -8,6 +8,7 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLEncoder;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.regex.Pattern;
@@ -124,7 +125,7 @@ class Sync extends AsyncTask<Void, Void, Void> {
 			//Check db version again
 			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.");
+				Log.e("SYNC", "Database is in read only mode. Skipping sync.");
 				return;
 			}
 
@@ -238,9 +239,10 @@ class Sync extends AsyncTask<Void, Void, Void> {
     }
 
 	@Override
-	/**
-	 * Called when the AsyncTask is updated.
-	 * Used to change text in the sync window.
+	/*
+	  Called when the AsyncTask is updated.
+	  Used to change text in the sync window.
+	  @param progress Unused.
 	 */
 	protected void onProgressUpdate(Void...progress) {
 		if (doProgress){
@@ -256,103 +258,53 @@ class Sync extends AsyncTask<Void, Void, Void> {
 	 * Creates the URL required to performa a sync. Uses static data and data passed as arguments.
 	 *
 	 * @param user A unique user identifier.
-	 * @param version The db version of the client.
 	 * @param foreground 1 if the sync is done while the app is running, 0 otherwise.
-	 * @param lang Two letter language identifier.
 	 *
 	 * @return The URL that will be used for syncing.
 	 */
-	private String buildUrl(String user, int version, int foreground, String lang){
+	private String buildUrl(SQLiteDatabase db, String user, int foreground){
 		String url = "";
 		try {
-			url = GM.API.SERVER + GM.API.SYNC.PATH + "?" +
-					GM.API.SYNC.KEY.CLIENT + "=" + URLEncoder.encode(GM.API.CLIENT, "UTF-8") + "&" +
-					GM.API.SYNC.KEY.USER + "=" + URLEncoder.encode(user, "UTF-8") + "&" +
-					GM.API.SYNC.KEY.ACTION + "=" + URLEncoder.encode(GM.API.SYNC.VALUE.ACTION, "UTF-8") + "&" +
-					GM.API.SYNC.KEY.SECTION + "=" + URLEncoder.encode(GM.API.SYNC.VALUE.SECTION, "UTF-8") + "&" +
-					GM.API.SYNC.KEY.VERSION + "=" + version + "&" +
-					GM.API.SYNC.KEY.FOREGROUND + "=" + foreground + "&" +
-					GM.API.SYNC.KEY.FORMAT + "=" + URLEncoder.encode(GM.API.SYNC.VALUE.FORMAT, "UTF-8") + "&" +
-					GM.API.SYNC.KEY.LANG + "=" + URLEncoder.encode(lang, "UTF-8");
+
+			// Common parameters
+			url = GM.API.SERVER + GM.API.SYNC.PATH.COMPLETE + "?" +
+			  GM.API.SYNC.KEY.CLIENT + "=" + URLEncoder.encode(GM.API.CLIENT, "UTF-8") + "&" +
+			  GM.API.SYNC.KEY.USER + "=" + URLEncoder.encode(user, "UTF-8") + "&" +
+			  GM.API.SYNC.KEY.FOREGROUND + "=" + foreground;
+
+			// Versions of the tables
+			Cursor cursor;
+
+			// Check if the table "versions" exists.
+			cursor = db.rawQuery("SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name = '" + GM.DB.TABLE.VERSION + "'", null);
+			if(cursor.getCount() > 0) {
+				cursor = db.rawQuery("SELECT section, version FROM version;", null);
+
+				// Get table list
+				String tables[] = {GM.DB.TABLE.ACTIVITY,             GM.DB.TABLE.ACTIVITY_COMMENT,    GM.DB.TABLE.ACTIVITY_IMAGE,
+				                   GM.DB.TABLE.ACTIVITY_ITINERARY,   GM.DB.TABLE.ACTIVITY_TAG,        GM.DB.TABLE.ALBUM,
+				                   GM.DB.TABLE.ALBUM,                GM.DB.TABLE.FESTIVAL,            GM.DB.TABLE.FESTIVAL_DAY,
+				                   GM.DB.TABLE.FESTIVAL_DAY,         GM.DB.TABLE.FESTIVAL_EVENT_CITY, GM.DB.TABLE.FESTIVAL_EVENT_GM,
+				                   GM.DB.TABLE.FESTIVAL_EVENT_IMAGE, GM.DB.TABLE.FESTIVAL_OFFER,      GM.DB.TABLE.PEOPLE,
+				                   GM.DB.TABLE.PHOTO,                GM.DB.TABLE.PHOTO_ALBUM,         GM.DB.TABLE.PHOTO_COMMENT,
+				                   GM.DB.TABLE.PLACE,                GM.DB.TABLE.POST,                GM.DB.TABLE.POST_COMMENT,
+				                   GM.DB.TABLE.POST_IMAGE,           GM.DB.TABLE.POST_TAG,            GM.DB.TABLE.ROUTE,
+				                   GM.DB.TABLE.ROUTE_POINT,          GM.DB.TABLE.SETTINGS,            GM.DB.TABLE.SPONSOR};
+				List<String> tableList = Arrays.asList(tables);
+				while (cursor.moveToNext()) {
+					if(tableList.contains(cursor.getString(0))){
+						url = url + "&" + cursor.getString(0) + "=" + cursor.getString(1);
+					}
+				}
+			}
+			cursor.close();
 		}
 		catch (java.io.UnsupportedEncodingException ex){
-			Log.e("UTF-8", "Error encoding url for sync \"" + url + "\" - " + ex.toString());
+			Log.e("SYNC", "Error encoding url for sync \"" + url + "\" - " + ex.toString());
 		}
 		return url;
 	}
 
-	/**
-	 * Recreates the database, dropping and then creating all the tables containing
-	 * data. "location" and "notification" tables are untouched.
-	 *
-	 * @param db A database connection.
-	 *
-	 * @return False if there were errors, true otherwise.
-	 */
-	@SuppressWarnings("unused")
-	private boolean recreateDb(SQLiteDatabase db) {
-		boolean result = true;
-		try {
-			db.beginTransactionNonExclusive();
-			db.execSQL(GM.DB.QUERY.DROP.ACTIVITY);
-			db.execSQL(GM.DB.QUERY.DROP.ACTIVITY_COMMENT);
-			db.execSQL(GM.DB.QUERY.DROP.ACTIVITY_IMAGE);
-			db.execSQL(GM.DB.QUERY.DROP.ACTIVITY_ITINERARY);
-			db.execSQL(GM.DB.QUERY.DROP.ACTIVITY_TAG);
-			db.execSQL(GM.DB.QUERY.DROP.ALBUM);
-			db.execSQL(GM.DB.QUERY.DROP.FESTIVAL);
-			db.execSQL(GM.DB.QUERY.DROP.FESTIVAL_DAY);
-			db.execSQL(GM.DB.QUERY.DROP.FESTIVAL_EVENT);
-			db.execSQL(GM.DB.QUERY.DROP.FESTIVAL_EVENT_IMAGE);
-			db.execSQL(GM.DB.QUERY.DROP.FESTIVAL_OFFER);
-			db.execSQL(GM.DB.QUERY.DROP.PEOPLE);
-			db.execSQL(GM.DB.QUERY.DROP.PHOTO);
-			db.execSQL(GM.DB.QUERY.DROP.PHOTO_ALBUM);
-			db.execSQL(GM.DB.QUERY.DROP.PHOTO_COMMENT);
-			db.execSQL(GM.DB.QUERY.DROP.PLACE);
-			db.execSQL(GM.DB.QUERY.DROP.POST);
-			db.execSQL(GM.DB.QUERY.DROP.POST_COMMENT);
-			db.execSQL(GM.DB.QUERY.DROP.POST_IMAGE);
-			db.execSQL(GM.DB.QUERY.DROP.POST_TAG);
-			db.execSQL(GM.DB.QUERY.DROP.SETTINGS);
-			db.execSQL(GM.DB.QUERY.DROP.SPONSOR);
-			db.execSQL(GM.DB.QUERY.DROP.VERSION);
-			db.setTransactionSuccessful();
-			db.endTransaction();
-			publishProgress();
-			db.beginTransactionNonExclusive();
-			db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY);
-			db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY_COMMENT);
-			db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY_IMAGE);
-			db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY_ITINERARY);
-			db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY_TAG);
-			db.execSQL(GM.DB.QUERY.CREATE.ALBUM);
-			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL);
-			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL_DAY);
-			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL_EVENT);
-			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL_EVENT_IMAGE);
-			db.execSQL(GM.DB.QUERY.CREATE.FESTIVAL_OFFER);
-			db.execSQL(GM.DB.QUERY.CREATE.PEOPLE);
-			db.execSQL(GM.DB.QUERY.CREATE.PHOTO);
-			db.execSQL(GM.DB.QUERY.CREATE.PHOTO_ALBUM);
-			db.execSQL(GM.DB.QUERY.CREATE.PHOTO_COMMENT);
-			db.execSQL(GM.DB.QUERY.CREATE.PLACE);
-			db.execSQL(GM.DB.QUERY.CREATE.POST);
-			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.SPONSOR);
-			db.execSQL(GM.DB.QUERY.CREATE.VERSION);
-			db.setTransactionSuccessful();
-			db.endTransaction();
-		}
-		catch (Exception ex) {
-			result = false;
-			Log.e("SYNC", "Error recreating the database: " + ex.toString());
-		}
-		return result;
-	}
 
 	/**
 	 * Finds out the type of a column of a table in the database.
@@ -390,84 +342,31 @@ class Sync extends AsyncTask<Void, Void, Void> {
 	 * Uses a custom JSON parser.
 	 *
 	 * @param db Database store the data.
-	 * @param versions List of strings with data about the versions.
-	 *
-	 * @return False if there were errors, true otherwise.
-	 */
-	private boolean saveVersions(SQLiteDatabase db, String versions){
-		String str = versions;
-		String key;
-		boolean result = true;
-		int value;
-		int totalVersions = 0;
-
-		//If I ever have a database with more than 99 public sections (not tables), I'll have to change this. Also, ask for a raise.
-		int[] values = new int[99];
-		String[] keys = new String[99];
-		try {
-			while (str.indexOf("{") > 0){
-				key = str.substring(str.indexOf("{\"") + 2, str.indexOf("\":"));
-				str = str.substring(str.indexOf("\":\"") + 3);
-				value = Integer.parseInt(str.substring(0, str.indexOf("\"")));
-				str = str.substring(str.indexOf("}") + 1);
-				keys[totalVersions] = key;
-				values[totalVersions] = value;
-				totalVersions ++;
-				publishProgress();
-			}
-			if (totalVersions > 0 && totalVersions < 99){
-				db.execSQL(GM.DB.QUERY.CREATE.VERSION);
-				db.execSQL(GM.DB.QUERY.EMPTY.VERSION);
-				for (int i = 0; i < totalVersions; i ++){
-					if (!"all".equals(keys[i])) {
-						db.execSQL("INSERT INTO version VALUES ('" + keys[i] + "', " + values[i] + ");");
-					}
-				}
-			}
-			else{
-				result = false;
-			}
-
-		}
-		catch (Exception ex){
-			result = false;
-			Log.e("SYNC", "Error saving the remote db versions: " + ex.toString());
-		}
-		return result;
-	}
-
-	/**
-	 * Stores version data for each section in the database.
-	 * Uses a custom JSON parser.
-	 *
-	 * @param db Database store the data.
-	 * @param data List of strings in json format with the tables.
+	 * @param data JSON formated string with the information for the database.
 	 *
 	 * @return False if there were errors, true otherwise.
 	 */
 	private boolean saveData(SQLiteDatabase db, String data){
-		String str;
-		String key;
-		String value;
+
+		String str = data;
+		String name;
+		String content;
 		boolean result = true;
 		try{
-			str = data.substring(data.indexOf("[") + 1, data.lastIndexOf("]"));
 			while (str.indexOf("}") > 0){
 				try {
-					key = str.substring(str.indexOf("\"") + 1, str.indexOf("\"", str.indexOf(":") - 1));
-					value = str.substring(str.indexOf("[") + 1, str.indexOf("]"));
-					str = str.substring(str.indexOf("]") + 1);
+					name = str.substring(str.indexOf("\"") + 1, str.indexOf(":") -1);
+					content = str.substring(str.indexOf("[{"), str.indexOf("}]") + 2);
 
-					if (!saveTable(db, key, value)){
+					if (!saveTable(db, name, content)){
 						//Finish the loop if there is an error
 						return false;
 					}
 
-					str = str.substring(str.indexOf("}") + 1);
+					str = str.substring(str.indexOf("}]") + 2);
 				}
 				catch (Exception ex){
 					//End of string
-					Log.d("SYNC", "End of data string:" + ex.toString());
 					str = "";
 				}
 				publishProgress();
@@ -497,7 +396,6 @@ class Sync extends AsyncTask<Void, Void, Void> {
 			if (settings.contains("\"name\":\"comments\",\"value\":\"")){
 				value = settings.substring(settings.indexOf("\"name\":\"comments\",\"value\":\"") + 27, settings.indexOf("\"name\":\"comments\",\"value\":\"") + 28);
 				if ("0".equals(value) || "1".equals(value)){
-					Log.d("SYNC", "Setting found: comments = " + value);
 					if ("0".equals(value)) {
 						editor.putBoolean(GM.DATA.KEY.COMMENTS, false);
 					}
@@ -509,7 +407,6 @@ class Sync extends AsyncTask<Void, Void, Void> {
 			if (settings.contains("\"name\":\"festivals\",\"value\":\"")){
 				value = settings.substring(settings.indexOf("\"name\":\"festivals\",\"value\":\"") + 28, settings.indexOf("\"name\":\"festivals\",\"value\":\"") + 29);
 				if ("0".equals(value) || "1".equals(value)){
-					Log.d("SYNC", "Setting found: lablanca = " + value);
 					if ("0".equals(value)) {
 						editor.putBoolean(GM.DATA.KEY.LABLANCA, false);
 					}
@@ -521,7 +418,6 @@ class Sync extends AsyncTask<Void, Void, Void> {
 			if (settings.contains("\"name\":\"photos\",\"value\":\"")){
 				value = settings.substring(settings.indexOf("\"name\":\"photos\",\"value\":\"") + 25, settings.indexOf("\"name\":\"photos\",\"value\":\"") + 26);
 				if ("0".equals(value) || "1".equals(value)){
-					Log.d("SYNC" ,"Setting found: photos = " + value);
 					if ("0".equals(value)) {
 						editor.putBoolean(GM.DATA.KEY.PHOTOS, false);
 					}
@@ -544,6 +440,63 @@ class Sync extends AsyncTask<Void, Void, Void> {
 	}
 
 
+	/**
+	 * Stores the new contents of the table 'version' into the database.
+	 * Uses a custom JSON parser.
+	 *
+	 * @param db Database to store the data.
+	 * @param data String in JSON format with the data of the table.
+	 * @return False if there were errors, true otherwise.
+	 */
+	private boolean saveTableVersion(SQLiteDatabase db, String data) {
+
+		String section, row, version;
+		String str = data;
+		Cursor cursor;
+		List<String> queries = new ArrayList<>();
+
+		//Process each row
+		while (str.contains("{\"") && str.contains("\"}")) {
+			row = str.substring(str.indexOf("{\""), str.indexOf("\"}") + 2);
+			try {
+
+				section = row.substring(row.indexOf("\"section\"") + 11, row.indexOf(",") + -1);
+				version = row.substring(row.indexOf("\"version\"") + 11, row.lastIndexOf("\""));
+				// Check if the value already exists in the database.
+				cursor = db.rawQuery("SELECT section FROM version WHERE version = '" + section + "';", null);
+				if (cursor.getCount() == 0) {
+					queries.add("INSERT INTO version (section, version) VALUES ('" + section + "', " + version + ");");
+				} else {
+					queries.add("UPDATE version SET version = " + version + " WHERE section  ='" + section + "';");
+				}
+				cursor.close();
+			}
+			catch (Exception ex) {
+				Log.e("SYNC", "Error parsing special table 'version': " + ex.toString());
+				return false;
+			}
+
+			//Process str for the next loop pass.
+			str = str.substring(str.indexOf("\"}") + 2);
+
+			publishProgress();
+		}
+
+		//If I get to this point, there were no errors, and I can safely execute the queries
+		try {
+			int totalQueries = queries.size();
+			for (int i = 0; i < totalQueries; i++) {
+				db.execSQL(queries.get(i));
+			}
+		} catch (Exception ex) {
+			Log.e("SYNC", "Error inserting data from special table 'version' into the local db: " + ex.toString());
+
+			//I don't put a 'return false;' here because I dont want to loose the whole table for just one row.
+		}
+
+		return true;
+	}
+
 
 	/**
 	 * Stores a table data into the database.
@@ -556,12 +509,17 @@ class Sync extends AsyncTask<Void, Void, Void> {
 	 */
 	private boolean saveTable(SQLiteDatabase db, String table, String data) {
 
-		//If settings table, do something else
-		if ("settings".equals(table)){
+		//If table, do something else
+		if (GM.DB.TABLE.SETTINGS.equals(table)){
 			Log.d("SYNC", "Got the settings table. Special treatment...");
 			return saveSettings(data);
 		}
 
+		if (GM.DB.TABLE.VERSION.equals(table)){
+			Log.d("SYNC", "Got the version table. Special treatment...");
+			return saveTableVersion(db, data);
+		}
+
 		int type, i;
 		JSONObject jsonObj;
 		String[] values = new String[99];
@@ -574,8 +532,16 @@ class Sync extends AsyncTask<Void, Void, Void> {
 		queries.add("DELETE FROM " + table + ";");
 
 		//Process each row
-		while (str.contains("{\"") && str.contains("\"}")) {
-			row = str.substring(str.indexOf("{\""), str.indexOf("\"}") + 2);
+		str = str.replace(":null", ":\"null\"");
+
+		while (str.contains("{\"") && (str.contains("\"}") || str.contains("null}"))) {
+			if (str.contains("\"}")) {
+				row = str.substring(str.indexOf("{\""), str.indexOf("\"}") + 2);
+			}
+			else{
+				row = str.substring(str.indexOf("{\""), str.indexOf("null}") + 5);
+			}
+
 			i = 0;
 
 			try {
@@ -605,8 +571,8 @@ class Sync extends AsyncTask<Void, Void, Void> {
 				//Loop trough values
 				for (int j = 0; j < i; j++) {
 
-					//If the value is empty, I don't care what type is it, it will be 'null'.
-					if (values[j].length() == 0) {
+					//If the value is empty or null, I don't care what type is it, it will be 'null'.
+					if (values[j].length() == 0 || "null".equalsIgnoreCase(values[j])) {
 						val = "null";
 						q = q + val + ", ";
 					}
@@ -619,7 +585,7 @@ class Sync extends AsyncTask<Void, Void, Void> {
 							case GM.DB.COLUMN.INT:
 
 								//Check that is really a number to prevent injection.
-								if (Pattern.matches("\\-?\\d+", values[j]))
+								if (Pattern.matches("-?\\d+", values[j]))
 									q = q + values[j] + ", ";
 								else{
 									//If its not and actually number, just insert null to avoid problems.
@@ -692,32 +658,19 @@ class Sync extends AsyncTask<Void, Void, Void> {
 		try {
 			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.");
+				Log.e("SYNC", "Database is in read only mode. Skipping sync.");
 				return null;
 			}
 		}
 		catch(SQLiteDatabaseLockedException ex){
-			Log.e("SYNC", "Database is locked and in read only mode. Skipping sync.");
+			Log.e("SYNC", "Database is locked . Skipping sync: " + ex.toString());
 			return null;
 		}
 
 		publishProgress();
 
-		//Get database version
-		Cursor cursor;
-		int dbVersion = 0;
-		try{
-			cursor = db.rawQuery("SELECT sum(version) AS v FROM version;", null);
-			cursor.moveToFirst();
-			dbVersion = cursor.getInt(0);
-			cursor.close();
-		}
-		catch (Exception e){
-			Log.e("SYNC", "Unable to read from table 'version': " + e.toString());
-		}
-
 		URL url;
-		String uri = buildUrl(userCode, dbVersion, fg, GM.getLang());
+		String uri = buildUrl(db, userCode, fg);
 		try {
 			url = new URL(uri);
 
@@ -746,35 +699,24 @@ class Sync extends AsyncTask<Void, Void, Void> {
 
 					//Get the string with the sync json. (The whole page)
 					String strSync = sb.toString();
-					strSync = strSync.replace(":null", ":\"\"");
-
-					//Get the JSON object from the string.
-					JSONObject jsonSync = new JSONObject(strSync);
-					jsonSync = new JSONObject(jsonSync.get("sync").toString().substring(1, jsonSync.get("sync").toString().length() - 1));
-
-					//Get the string wit the versions in JSON format.
-					String strVersion = jsonSync.get("version").toString();
-
-					//Handmade parser, because with:
-					//String strData = jsonSync.get("data").toString();
-					//I get an error: "No value for data"
-					String strData = strSync.substring(1, strSync.length() - 1);
-					strData = strData.substring(strData.indexOf("{\"data\":"));
-
 					publishProgress();
 
 					//If the data is correctly parsed and stored, commit changes to the database.
-					db.beginTransactionNonExclusive();
+					try {
+						db.beginTransactionNonExclusive();
 
 
-					if (saveVersions(db, strVersion) && saveData(db, strData)){
-						db.setTransactionSuccessful();
-						Log.d("SYNC", "The sync process finished correctly. Changes to the database will be commited");
+						if (saveData(db, strSync)) {
+							db.setTransactionSuccessful();
+							Log.d("SYNC", "The sync process finished correctly. Changes to the database will be commited");
+						} else {
+							Log.e("SYNC", "The sync process did not finish correctly. Any changes made to the database will be reverted");
+						}
+						db.endTransaction();
 					}
-					else{
-						Log.e("SYNC", "The sync process did not finish correctly. Any changes made to the database will be reverted");
+					catch(SQLiteDatabaseLockedException ex){
+						Log.e("SYNC", "Database is locked . Ending sync now: " + ex.toString());
 					}
-					db.endTransaction();
 
 					break;
 				default:
@@ -794,10 +736,6 @@ class Sync extends AsyncTask<Void, Void, Void> {
 			Log.e("SYNC", "IOException for URL (" + uri + "): " + e.toString());
 			e.printStackTrace();
 		}
-		catch (org.json.JSONException e) {
-			Log.e("SYNC", "JSONException for URL (" + uri + "): " + e.toString());
-			e.printStackTrace();
-		}
 
 		db.close();
 		return null;

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

@@ -1,10 +1,10 @@
 package com.ivalentin.margolariak;
 
-import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.app.Dialog;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
+import android.util.Log;
 import android.view.Gravity;
 import android.view.View;
 import android.view.Window;
@@ -14,7 +14,6 @@ import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
-import java.io.File;
 
 /**
  * Activity with info about Gasteizko margolariak.
@@ -32,7 +31,6 @@ public class UsActivity extends Activity {
 	 * @param savedInstanceState Saved state of the activity.
 	 * @see Activity#onCreate(Bundle)
 	 */
-	@SuppressLint("InflateParams")
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
 
@@ -53,25 +51,25 @@ public class UsActivity extends Activity {
 		llCuadrilla.setOnClickListener(new View.OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				openDialog(getString(R.string.us_cuadrilla), getString(R.string.us_cuadrilla_content), getResources().getDrawable(R.drawable.us_cuadrilla));
+				openDialog(getString(R.string.us_cuadrilla), getString(R.string.us_cuadrilla_content), getResources().getDrawable(R.drawable.us_cuadrilla, null));
 			}
 		});
 		llAssociation.setOnClickListener(new View.OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				openDialog(getString(R.string.us_association), getString(R.string.us_association_content), getResources().getDrawable(R.drawable.us_asociacion));
+				openDialog(getString(R.string.us_association), getString(R.string.us_association_content), getResources().getDrawable(R.drawable.us_asociacion, null));
 			}
 		});
 		llActivities.setOnClickListener(new View.OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				openDialog(getString(R.string.us_activities), getString(R.string.us_activities_content), getResources().getDrawable(R.drawable.us_activities));
+				openDialog(getString(R.string.us_activities), getString(R.string.us_activities_content), getResources().getDrawable(R.drawable.us_activities, null));
 			}
 		});
 		llTransparency.setOnClickListener(new View.OnClickListener() {
 			@Override
 			public void onClick(View v) {
-				openDialog(getString(R.string.us_transparency), getString(R.string.us_transparency_content), getResources().getDrawable(R.drawable.us_transparency));
+				openDialog(getString(R.string.us_transparency), getString(R.string.us_transparency_content), getResources().getDrawable(R.drawable.us_transparency, null));
 			}
 		});
 
@@ -84,7 +82,6 @@ public class UsActivity extends Activity {
 	 * @param text The dialog text.
 	 * @param img The dialog image.
 	 */
-	@SuppressWarnings("ConstantConditions")
 	private void openDialog(final String title, final String text, final Drawable img){
 
 		//Create the dialog
@@ -117,7 +114,13 @@ public class UsActivity extends Activity {
 
 		//Show the dialog
 		WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
-		lp.copyFrom(dialog.getWindow().getAttributes());
+		try {
+			//noinspection ConstantConditions
+			lp.copyFrom(dialog.getWindow().getAttributes());
+		}
+		catch (NullPointerException e){
+			Log.e("SETTINGS_ACTIVITY", "Error setting the dialog attributes: " + e.toString());
+		}
 		lp.width = WindowManager.LayoutParams.MATCH_PARENT;
 		lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
 		lp.gravity = Gravity.CENTER;

二进制
app/src/main/res/drawable-xhdpi/pinpoint_gm.png


二进制
app/src/main/res/drawable-xxhdpi/pinpoint_gm.png


+ 0 - 14
app/src/main/res/drawable/album.xml

@@ -1,14 +0,0 @@
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
-    android:shape="rectangle" >
-
-    <stroke
-        android:width="2dp"
-        android:color="@color/album_border" />
-    <solid android:color="@color/album_background" />
-    <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
-        android:topLeftRadius="7dp" android:topRightRadius="7dp"/>
-    <padding android:left="8dp"
-        android:top="8dp"
-        android:right="8dp"
-        android:bottom="8dp" />
-</shape>

二进制
app/src/main/res/drawable/divider.png


二进制
app/src/main/res/drawable/ic_launcher_old.png


+ 20 - 0
app/src/main/res/drawable/map.xml

@@ -0,0 +1,20 @@
+<shape 
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle" >
+
+    <stroke
+        android:width="3dp"
+        android:color="@color/map_border" />
+    <solid android:color="@color/map_background" />
+    <corners
+        android:bottomRightRadius="7dp"
+        android:bottomLeftRadius="7dp"
+        android:topLeftRadius="7dp"
+        android:topRightRadius="7dp"/>
+    <padding
+        android:left="5dp"
+        android:top="5dp"
+        android:right="5dp"
+        android:bottom="5dp" />
+
+</shape>

二进制
app/src/main/res/drawable/menu.png


二进制
app/src/main/res/drawable/photo_placeholder.png


二进制
app/src/main/res/drawable/pinpoint.png


二进制
app/src/main/res/drawable/pinpoint_end.png


二进制
app/src/main/res/drawable/pinpoint_gm.png


二进制
app/src/main/res/drawable/pinpoint_route.png


二进制
app/src/main/res/drawable/pinpoint_start.png


+ 0 - 15
app/src/main/res/drawable/row_home_image.xml

@@ -1,15 +0,0 @@
-<shape
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:shape="rectangle" >
-
-    <stroke
-        android:width="1dp"
-        android:color="@color/image_border" />
-
-    <corners
-        android:bottomRightRadius="2dp"
-        android:bottomLeftRadius="2dp"
-        android:topLeftRadius="2dp"
-        android:topRightRadius="2dp"/>
-
-</shape>

+ 0 - 18
app/src/main/res/drawable/titlebar.xml

@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Shape for the title bar -->
-
-<selector
-    xmlns:android="http://schemas.android.com/apk/res/android">
-	<item>
-	    <shape>
-	        <gradient
-	            android:angle="90"
-	            android:centerY="10%"
-	            android:centerX="0.1"
-	            android:startColor="@color/background_bar_gradient"
-	            android:endColor="@color/background_bar"
-	            android:type="linear" />
-	    </shape>
-	</item>
-</selector>

二进制
app/src/main/res/drawable/tutorial_point.png


二进制
app/src/main/res/drawable/tutorial_slide.png


+ 6 - 18
app/src/main/res/layout/activity_main.xml

@@ -1,6 +1,5 @@
 <LinearLayout
 	xmlns:android="http://schemas.android.com/apk/res/android"
-	xmlns:app="http://schemas.android.com/apk/res-auto"
 	xmlns:tools="http://schemas.android.com/tools"
 	android:layout_width="match_parent"
 	android:layout_height="fill_parent"
@@ -66,15 +65,16 @@
 		<ImageButton
 			android:id="@+id/bt_menu"
 			android:layout_width="wrap_content"
-			android:layout_height="match_parent"
+			android:layout_height="wrap_content"
 			android:layout_weight=".2"
-			android:adjustViewBounds="false"
+			android:adjustViewBounds="true"
 			android:background="#00000000"
-			android:contentDescription="@string/tutorial_menu"
+			android:contentDescription="@string/menu_settings"
 			android:cropToPadding="false"
+			android:maxHeight="45dp"
+			android:maxWidth="45dp"
 			android:onClick="showMenu"
-			android:src="@drawable/ic_group_expand_00"
-			app:srcCompat="@drawable/ic_group_expand_00"/>
+			android:src="@android:drawable/ic_menu_more"/>
 
 		<ProgressBar
 			android:id="@+id/pb_sync"
@@ -131,8 +131,6 @@
 					android:layout_height="7dp"
 					android:layout_alignParentBottom="true"
 					android:layout_alignParentEnd="false"
-					android:layout_alignParentLeft="false"
-					android:layout_alignParentRight="false"
 					android:layout_alignParentStart="false"
 					android:layout_gravity="bottom"
 					android:alpha="1"
@@ -166,8 +164,6 @@
 					android:layout_height="3dp"
 					android:layout_alignParentBottom="true"
 					android:layout_alignParentEnd="false"
-					android:layout_alignParentLeft="false"
-					android:layout_alignParentRight="false"
 					android:layout_alignParentStart="false"
 					android:layout_gravity="bottom"
 					android:alpha="1"
@@ -200,8 +196,6 @@
 					android:layout_height="3dp"
 					android:layout_alignParentBottom="true"
 					android:layout_alignParentEnd="false"
-					android:layout_alignParentLeft="false"
-					android:layout_alignParentRight="false"
 					android:layout_alignParentStart="false"
 					android:layout_gravity="bottom"
 					android:alpha="1"
@@ -234,8 +228,6 @@
 					android:layout_height="3dp"
 					android:layout_alignParentBottom="true"
 					android:layout_alignParentEnd="false"
-					android:layout_alignParentLeft="false"
-					android:layout_alignParentRight="false"
 					android:layout_alignParentStart="false"
 					android:layout_gravity="bottom"
 					android:alpha="1"
@@ -268,8 +260,6 @@
 					android:layout_height="3dp"
 					android:layout_alignParentBottom="true"
 					android:layout_alignParentEnd="false"
-					android:layout_alignParentLeft="false"
-					android:layout_alignParentRight="false"
 					android:layout_alignParentStart="false"
 					android:layout_gravity="bottom"
 					android:alpha="1"
@@ -302,8 +292,6 @@
 					android:layout_height="3dp"
 					android:layout_alignParentBottom="true"
 					android:layout_alignParentEnd="false"
-					android:layout_alignParentLeft="false"
-					android:layout_alignParentRight="false"
 					android:layout_alignParentStart="false"
 					android:layout_gravity="bottom"
 					android:alpha="1"

+ 1 - 8
app/src/main/res/layout/activity_settings.xml

@@ -1,6 +1,5 @@
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="fill_parent"
@@ -63,8 +62,7 @@
             android:background="#00000000"
             android:contentDescription="@android:string/yes"
             android:onClick="finish"
-            android:src="@android:drawable/ic_menu_revert"
-            app:srcCompat="@android:drawable/ic_menu_revert"/>
+            android:src="@android:drawable/ic_menu_revert"/>
 
     </LinearLayout>
 
@@ -126,7 +124,6 @@
                         android:textColor="@android:color/black"
                         android:layout_marginTop="4dp"
                         android:layout_marginStart="10dp"
-                        android:layout_marginLeft="10dp"
                         android:textStyle="italic"
                         android:alpha="0.8"/>
                 </LinearLayout>
@@ -185,7 +182,6 @@
                         android:textColor="@android:color/black"
                         android:layout_marginTop="4dp"
                         android:layout_marginStart="10dp"
-                        android:layout_marginLeft="10dp"
                         android:textStyle="italic"
                         android:alpha="0.8"/>
                 </LinearLayout>
@@ -242,7 +238,6 @@
                     android:textColor="@android:color/black"
                     android:layout_marginTop="4dp"
                     android:layout_marginStart="10dp"
-                    android:layout_marginLeft="10dp"
                     android:layout_weight=".15"
                     android:textStyle="italic"
                     android:alpha="0.8"/>
@@ -282,7 +277,6 @@
                     android:textColor="@android:color/black"
                     android:layout_marginTop="4dp"
                     android:layout_marginStart="10dp"
-                    android:layout_marginLeft="10dp"
                     android:layout_weight=".15"
                     android:textStyle="italic"
                     android:alpha="0.8"/>
@@ -324,7 +318,6 @@
                     android:textColor="@android:color/black"
                     android:layout_marginTop="4dp"
                     android:layout_marginStart="10dp"
-                    android:layout_marginLeft="10dp"
                     android:layout_weight=".15"
                     android:textStyle="italic"
                     android:alpha="0.8"/>

+ 0 - 4
app/src/main/res/layout/activity_sponsor.xml

@@ -1,6 +1,5 @@
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="fill_parent"
@@ -64,7 +63,6 @@
             android:contentDescription="@android:string/yes"
             android:layout_weight=".2"
             android:id="@+id/bt_back"
-            app:srcCompat="@android:drawable/ic_menu_revert"
             android:background="#00000000"/>
 
     </LinearLayout>
@@ -98,8 +96,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:textColor="@color/section_title"/>

+ 0 - 4
app/src/main/res/layout/activity_us.xml

@@ -1,6 +1,5 @@
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="fill_parent"
@@ -63,7 +62,6 @@
             android:contentDescription="@android:string/yes"
             android:layout_weight=".2"
             android:id="@+id/bt_back"
-            app:srcCompat="@android:drawable/ic_menu_revert"
             android:background="#00000000"/>
 
     </LinearLayout>
@@ -96,8 +94,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:textColor="@color/section_title"/>

+ 0 - 4
app/src/main/res/layout/dialog_changelog.xml

@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
@@ -24,8 +23,6 @@
         android:textColor="@color/section_title"
         android:paddingBottom="4dp"
         android:paddingEnd="10dp"
-        android:paddingLeft="20dp"
-        android:paddingRight="10dp"
         android:paddingStart="20dp"
         android:paddingTop="4dp"
         android:background="@drawable/section_title"
@@ -61,7 +58,6 @@
         android:layout_marginRight="25dp"
         android:layout_marginStart="25dp"
         android:layout_marginTop="5dp"
-        android:layout_weight=".5"
         android:background="@drawable/button_selector"
         android:minHeight="40dp"
         android:textColor="@color/input_button_color"

+ 0 - 2
app/src/main/res/layout/dialog_notification.xml

@@ -21,8 +21,6 @@
         android:background="@drawable/section_title"
         android:paddingBottom="4dp"
         android:paddingEnd="10dp"
-        android:paddingLeft="20dp"
-        android:paddingRight="10dp"
         android:paddingStart="20dp"
         android:paddingTop="4dp"
         android:textColor="@color/section_title"/>

+ 35 - 13
app/src/main/res/layout/dialog_schedule.xml

@@ -54,8 +54,6 @@
             android:background="@drawable/section_title"
             android:paddingBottom="4dp"
             android:paddingEnd="10dp"
-            android:paddingLeft="20dp"
-            android:paddingRight="10dp"
             android:paddingStart="20dp"
             android:paddingTop="4dp"
             android:textAppearance="?android:attr/textAppearanceLarge"
@@ -89,7 +87,6 @@
                     android:id="@+id/tv_dialog_schedule_time"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_marginLeft="10dp"
                     android:layout_marginStart="10dp"
                     android:textAppearance="?android:attr/textAppearanceMedium"
                     android:textColor="@color/entry_title"
@@ -108,13 +105,22 @@
                 android:id="@+id/tv_dialog_schedule_host"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginLeft="15dp"
+                android:layout_marginStart="15dp"
+                android:textAppearance="@android:style/TextAppearance.Small"
+                android:textStyle="italic"
+                android:visibility="gone"/>
+
+            <TextView
+                android:id="@+id/tv_dialog_schedule_sponsor"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
                 android:layout_marginStart="15dp"
                 android:textAppearance="@android:style/TextAppearance.Small"
                 android:textStyle="italic"
                 android:visibility="gone"/>
 
             <LinearLayout
+                android:id="@+id/ll_dialog_schedule_place"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_margin="15dp"
@@ -134,7 +140,6 @@
                 <LinearLayout
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:layout_marginLeft="10dp"
                     android:layout_marginStart="10dp"
                     android:orientation="vertical">
 
@@ -158,18 +163,35 @@
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:layout_margin="20dp"
+                android:orientation="vertical"
                 android:padding="3dp">
 
-                <com.google.android.gms.maps.MapView
-                    android:id="@+id/mv_dialog_schedule_map"
-                    android:layout_width="fill_parent"
-                    android:layout_height="fill_parent"
-                    android:background="@android:color/black"
-                    android:padding="1dp">
-                </com.google.android.gms.maps.MapView>
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_weight=".95"
+                    android:background="@drawable/map"
+                    android:padding="3dp">
+
+                    <org.osmdroid.views.MapView
+                        android:id="@+id/mv_dialog_schedule_map"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"/>
+
+                </LinearLayout>
+
+                <TextView
+                    android:id="@+id/tv_dialog_schedule_osm"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/schedule_osm"
+                    android:textAlignment="textEnd"
+                    android:textAppearance="@android:style/TextAppearance.Small"
+                    android:textColor="@color/input_border"/>
+
             </LinearLayout>
         </LinearLayout>
 
     </LinearLayout>
 
-</RelativeLayout>
+</RelativeLayout>

+ 0 - 50
app/src/main/res/layout/dialog_settings.xml

@@ -1,50 +0,0 @@
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:background="@drawable/section"
-    android:orientation="vertical"
-    android:padding="7dp" >
-
-    <TextView
-        android:id="@+id/tv_dialog_settings_title"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:ellipsize="end"
-        android:maxLines="2"
-        android:textAppearance="@android:style/TextAppearance.Large"
-        android:textStyle="bold"/>
-
-    <ScrollView
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content">
-
-        <LinearLayout
-            android:layout_width="fill_parent"
-            android:layout_height="match_parent"
-            android:orientation="vertical"
-            android:background="@drawable/entry"
-            android:padding="7dp"
-            tools:ignore="ScrollViewSize">
-
-            <WebView
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:id="@+id/wv_dialog_settings_text"/>
-
-        </LinearLayout>
-    </ScrollView>
-
-    <Button
-        android:id="@+id/bt_dialog_settings_close"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_margin="10dp"
-        android:background="@drawable/button_selector"
-        android:text="@string/notification_close"
-        android:textColor="@color/input_text_color"
-        android:textStyle="bold"
-        android:layout_gravity="center_horizontal"/>
-
-</LinearLayout>

+ 15 - 15
app/src/main/res/layout/dialog_sponsor.xml

@@ -1,6 +1,6 @@
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"
@@ -16,12 +16,9 @@
         android:background="@drawable/section_title"
         android:paddingBottom="4dp"
         android:paddingEnd="10dp"
-        android:paddingLeft="20dp"
-        android:paddingRight="10dp"
         android:paddingStart="20dp"
         android:paddingTop="4dp"
-        android:textColor="@color/section_title"
-        android:layout_alignParentTop="true"/>
+        android:textColor="@color/section_title"/>
 
     <LinearLayout
         android:layout_width="match_parent"
@@ -29,16 +26,16 @@
         android:orientation="vertical"
         android:background="@drawable/entry"
         android:layout_margin="8dp"
-        android:padding="7dp"
-        >
+        android:padding="7dp">
 
         <ImageView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            app:srcCompat="@drawable/photo_placeholder_thumb"
+            android:src="@drawable/photo_placeholder_thumb"
             android:id="@+id/iv_dialog_sponsor_image"
             android:maxHeight="140dp"
-            android:adjustViewBounds="true"/>
+            android:adjustViewBounds="true"
+            android:contentDescription="@string/pop_menu_sponsors"/>
 
         <TextView
             android:id="@+id/tv_dialog_sponsor_text"
@@ -56,7 +53,8 @@
                 android:orientation="horizontal"
                 android:layout_width="wrap_content"
                 android:layout_height="match_parent"
-                android:id="@+id/ll_dialog_sponsor_url">
+                android:id="@+id/ll_dialog_sponsor_url"
+                tools:ignore="UseCompoundDrawables">
 
                 <ImageView
                     android:layout_width="30dp"
@@ -68,6 +66,7 @@
                     android:layout_marginEnd="15dp"
                     android:layout_marginTop="20dp"
                     android:adjustViewBounds="true"
+                    android:contentDescription="@string/sponsors_url"
                     android:src="@drawable/web"/>
 
                 <TextView
@@ -76,7 +75,7 @@
                     android:id="@+id/tv_dialog_sponsor_url"
                     android:layout_weight="1"
                     android:gravity="center_vertical"
-                    android:layout_width="match_parent"
+                    android:layout_width="0dp"
                     android:textColor="@color/background_menu"
                     android:textSize="16sp"
                     android:textStyle="normal|bold"/>
@@ -86,7 +85,8 @@
                 android:orientation="horizontal"
                 android:layout_width="wrap_content"
                 android:layout_height="match_parent"
-                android:id="@+id/ll_dialog_sponsor_address">
+                android:id="@+id/ll_dialog_sponsor_address"
+                tools:ignore="UseCompoundDrawables">
 
                 <ImageView
                     android:layout_width="30dp"
@@ -98,6 +98,7 @@
                     android:layout_marginLeft="15dp"
                     android:layout_marginEnd="15dp"
                     android:layout_marginTop="20dp"
+                    android:contentDescription="@string/sponsors_url"
                     android:src="@drawable/pinpoint"/>
 
                 <TextView
@@ -105,7 +106,7 @@
                     android:id="@+id/tv_dialog_sponsor_address"
                     android:layout_weight="1"
                     android:gravity="center_vertical"
-                    android:layout_width="match_parent"
+                    android:layout_width="0dp"
                     android:textStyle="normal|bold"
                     android:textSize="16sp"
                     android:textColor="@color/background_menu"/>
@@ -122,7 +123,6 @@
         android:text="@string/notification_close"
         android:textColor="@color/input_text_color"
         android:textStyle="bold"
-        android:layout_alignParentBottom="true"
         android:layout_height="50dp"/>
 
-</LinearLayout>
+</LinearLayout>

+ 0 - 2
app/src/main/res/layout/dialog_sync.xml

@@ -16,8 +16,6 @@
         android:background="@drawable/section_title"
         android:paddingBottom="4dp"
         android:paddingEnd="10dp"
-        android:paddingLeft="20dp"
-        android:paddingRight="10dp"
         android:paddingStart="20dp"
         android:paddingTop="4dp"
         android:textColor="@color/section_title"/>

+ 0 - 2
app/src/main/res/layout/dialog_sync_failed.xml

@@ -17,8 +17,6 @@
         android:background="@drawable/section_title"
         android:paddingBottom="4dp"
         android:paddingEnd="10dp"
-        android:paddingLeft="20dp"
-        android:paddingRight="10dp"
         android:paddingStart="20dp"
         android:paddingTop="4dp"
         android:textColor="@color/section_title"/>

+ 5 - 9
app/src/main/res/layout/dialog_us.xml

@@ -16,12 +16,9 @@
         android:background="@drawable/section_title"
         android:paddingBottom="4dp"
         android:paddingEnd="10dp"
-        android:paddingLeft="20dp"
-        android:paddingRight="10dp"
         android:paddingStart="20dp"
         android:paddingTop="4dp"
-        android:textColor="@color/section_title"
-        android:layout_alignParentTop="true"/>
+        android:textColor="@color/section_title"/>
 
     <LinearLayout
         android:layout_width="match_parent"
@@ -29,8 +26,7 @@
         android:orientation="vertical"
         android:background="@drawable/entry"
         android:layout_margin="8dp"
-        android:padding="7dp"
-        >
+        android:padding="7dp">
 
         <ImageView
             android:id="@+id/iv_dialog_us_image"
@@ -39,7 +35,8 @@
             android:adjustViewBounds="true"
             android:maxHeight="140dp"
             android:minHeight="100dp"
-            app:srcCompat="@drawable/photo_placeholder_thumb"/>
+            android:src="@drawable/photo_placeholder_thumb"
+            android:contentDescription="@string/app_name"/>
 
         <TextView
             android:id="@+id/tv_dialog_us_text"
@@ -58,7 +55,6 @@
         android:text="@string/notification_close"
         android:textColor="@color/input_text_color"
         android:textStyle="bold"
-        android:layout_alignParentBottom="true"
         android:layout_height="50dp"/>
 
-</LinearLayout>
+</LinearLayout>

+ 0 - 4
app/src/main/res/layout/fragment_layout_activities.xml

@@ -29,8 +29,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:textColor="@color/section_title"/>
@@ -62,8 +60,6 @@
             android:background="@drawable/section_title"
             android:paddingBottom="4dp"
             android:paddingEnd="10dp"
-            android:paddingLeft="20dp"
-            android:paddingRight="10dp"
             android:paddingStart="20dp"
             android:paddingTop="4dp"
             android:textColor="@color/section_title"

+ 0 - 2
app/src/main/res/layout/fragment_layout_activity_future.xml

@@ -30,8 +30,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:textColor="@color/section_title"/>

+ 0 - 2
app/src/main/res/layout/fragment_layout_activity_past.xml

@@ -30,8 +30,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:textColor="@color/section_title"/>

+ 0 - 2
app/src/main/res/layout/fragment_layout_album.xml

@@ -22,8 +22,6 @@
             android:background="@drawable/section_title"
             android:paddingBottom="4dp"
             android:paddingEnd="10dp"
-            android:paddingLeft="20dp"
-            android:paddingRight="10dp"
             android:paddingStart="20dp"
             android:paddingTop="4dp"
             android:textColor="@color/section_title"

+ 0 - 2
app/src/main/res/layout/fragment_layout_blog.xml

@@ -29,8 +29,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:textColor="@color/section_title"/>

+ 0 - 2
app/src/main/res/layout/fragment_layout_gallery.xml

@@ -65,8 +65,6 @@
             android:background="@drawable/section_title"
             android:paddingBottom="4dp"
             android:paddingEnd="10dp"
-            android:paddingLeft="20dp"
-            android:paddingRight="10dp"
             android:paddingStart="20dp"
             android:paddingTop="4dp"
             android:textColor="@color/section_title"

+ 728 - 749
app/src/main/res/layout/fragment_layout_home.xml

@@ -1,772 +1,751 @@
 <com.ivalentin.margolariak.CustomScrollView
-	xmlns:android="http://schemas.android.com/apk/res/android"
-	xmlns:app="http://schemas.android.com/apk/res-auto"
-	xmlns:tools="http://schemas.android.com/tools"
-	android:id="@+id/sh_home_layout"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/sh_home_layout"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content" >
 
     <LinearLayout
-		android:layout_width="fill_parent"
-		android:layout_height="wrap_content"
-		android:orientation="vertical"
-		android:background="@color/background_app">
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:background="@color/background_app">
     
-	    <LinearLayout
-			android:id="@+id/ll_home_section_location"
-			android:layout_width="match_parent"
-			android:layout_height="wrap_content"
-			android:orientation="vertical"
-			android:background="@drawable/section"
-			android:layout_margin="10dp"
-			android:visibility="gone">
-
-			<TextView
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:text="@string/home_section_location"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				tools:layout_width="match_parent"
-				android:background="@drawable/section_title"
-				android:paddingBottom="4dp"
-				android:paddingEnd="10dp"
-				android:paddingLeft="20dp"
-				android:paddingRight="10dp"
-				android:paddingStart="20dp"
-				android:paddingTop="4dp"
-				android:textColor="@color/section_title"/>
-
-			<LinearLayout
-				android:id="@+id/ll_home_section_location_content"
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:orientation="vertical"
-				android:background="@drawable/entry"
-				android:padding="7dp"
-				android:layout_margin="8dp">
-
-				<TextView
-					android:layout_width="match_parent"
-					android:layout_height="wrap_content"
-					android:textAppearance="?android:attr/textAppearanceMedium"
-					android:textColor="@color/entry_title"
-					android:textStyle="bold"
-					android:text="@string/home_section_location_text_0"/>
-
-				<LinearLayout
-					android:orientation="horizontal"
-					android:layout_width="match_parent"
-					android:layout_height="match_parent"
-					android:gravity="center_horizontal"
-					android:layout_marginTop="10dp"
-					android:layout_marginBottom="10dp"
-					tools:ignore="UseCompoundDrawables">
-
-					<ImageView
-						android:layout_width="wrap_content"
-						android:layout_height="wrap_content"
-						android:contentDescription="@string/app_cdesc"
-						android:src="@drawable/pinpoint_gm"
-						android:layout_margin="7dp"
-						android:layout_gravity="center_vertical"/>
-
-					<TextView
-						android:layout_width="wrap_content"
-						android:layout_height="wrap_content"
-						android:textAppearance="@android:style/TextAppearance.Medium"
-						android:text="@string/home_section_location_text_calculating"
-						android:id="@+id/tv_home_section_location_distance"
-						android:layout_gravity="center_vertical"
-						android:layout_margin="7dp"/>
-				</LinearLayout>
-			</LinearLayout>
-
-		</LinearLayout>
-
-		<LinearLayout
-			android:id="@+id/ll_home_section_lablanca"
-			android:layout_width="match_parent"
-			android:layout_height="wrap_content"
-			android:layout_margin="10dp"
-			android:background="@drawable/section"
-			android:orientation="vertical"
-			android:visibility="gone">
-
-			<TextView
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:background="@drawable/section_title"
-				android:paddingBottom="4dp"
-				android:paddingEnd="10dp"
-				android:paddingLeft="20dp"
-				android:paddingRight="10dp"
-				android:paddingStart="20dp"
-				android:paddingTop="4dp"
-				android:text="@string/lablanca_title"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textColor="@color/section_title"
-				android:textStyle="bold"/>
-
-			<LinearLayout
-				android:layout_width="match_parent"
-				android:layout_height="match_parent"
-				android:layout_margin="8dp"
-				android:background="@drawable/entry"
-				android:minHeight="175dp"
-				android:orientation="horizontal"
-				android:padding="7dp">
-
-				<ImageView
-					android:id="@+id/iv_home_section_lablanca_image"
-					android:layout_width="match_parent"
-					android:layout_height="wrap_content"
-					android:layout_margin="3dp"
-					android:layout_weight=".7"
-					android:adjustViewBounds="true"
-					android:contentDescription="@string/app_cdesc"
-					android:maxWidth="130dp"
-					android:minHeight="105dp"/>
-
-				<LinearLayout
-					android:layout_width="match_parent"
-					android:layout_height="match_parent"
-					android:layout_weight=".3"
-					android:orientation="vertical"
-					>
-
-					<TextView
-						android:id="@+id/tv_home_section_lablanca_text"
-						android:layout_width="match_parent"
-						android:layout_height="80dp"
-						android:maxLines="4"
-						android:padding="7dp"
-						android:textAppearance="@android:style/TextAppearance.Medium"/>
-
-					<ImageView
-						android:id="@+id/imageView6"
-						android:layout_width="match_parent"
-						android:layout_height="40dp"
-						android:layout_marginTop="-40dp"
-						android:background="@drawable/gradient_v_white"/>
-
-					<Button
-						android:id="@+id/bt_home_gm"
-						android:layout_width="match_parent"
-						android:layout_height="50dp"
-						android:layout_marginBottom="40dp"
-						android:layout_marginLeft="7dp"
-						android:layout_marginStart="7dp"
-						android:layout_marginTop="10dp"
-						android:background="@drawable/button_selector"
-						android:text="@string/lablanca_schedule_gm"
-						android:textColor="@color/input_button_color"
-						android:textStyle="bold"/>
-				</LinearLayout>
-
-			</LinearLayout>
-
-		</LinearLayout>
-
-		<LinearLayout
-			android:id="@+id/ll_home_section_gmschedule"
-			android:layout_width="fill_parent"
-			android:layout_height="wrap_content"
-			android:orientation="vertical"
-			android:background="@drawable/section"
-			android:layout_margin="10dp"
-			android:visibility="gone">
-
-			<TextView
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:text="@string/home_section_gmschedule"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				tools:layout_width="match_parent"
-				android:background="@drawable/section_title"
-				android:paddingBottom="4dp"
-				android:paddingEnd="10dp"
-				android:paddingLeft="20dp"
-				android:paddingRight="10dp"
-				android:paddingStart="20dp"
-				android:paddingTop="4dp"
-				android:textColor="@color/section_title"/>
-
-			<LinearLayout
-				android:orientation="vertical"
-				android:layout_width="match_parent"
-				android:layout_height="match_parent"
-				android:background="@drawable/entry"
-				android:id="@+id/ll_home_section_gmschedule_now_content"
-				android:padding="7dp"
-				android:layout_margin="8dp">
-
-				<TextView
-					android:layout_width="match_parent"
-					android:layout_height="wrap_content"
-					android:textAppearance="?android:attr/textAppearanceMedium"
-					android:textColor="@color/entry_title"
-					android:textStyle="bold"
-					android:text="@string/schedule_now"/>
-
-				<LinearLayout
-					android:id="@+id/ll_home_section_gmschedule_now_list"
-					android:layout_width="match_parent"
-					android:layout_height="wrap_content"
-					android:orientation="vertical"
-					android:padding="7dp">
-
-				</LinearLayout>
-
-			</LinearLayout>
-
-			<LinearLayout
-				android:orientation="vertical"
-				android:layout_width="match_parent"
-				android:layout_height="match_parent"
-				android:background="@drawable/entry"
-				android:id="@+id/ll_home_section_gmschedule_later_content"
-				android:padding="7dp"
-				android:layout_margin="8dp">
-
-				<TextView
-					android:layout_width="match_parent"
-					android:layout_height="wrap_content"
-					android:textAppearance="?android:attr/textAppearanceMedium"
-					android:textColor="@color/entry_title"
-					android:textStyle="bold"
-					android:text="@string/schedule_later"/>
-
-				<LinearLayout
-					android:id="@+id/ll_home_section_gmschedule_later_list"
-					android:layout_width="match_parent"
-					android:layout_height="wrap_content"
-					android:orientation="vertical"
-					android:padding="7dp">
-
-				</LinearLayout>
-
-			</LinearLayout>
-
-		</LinearLayout>
-
-		<LinearLayout
-			android:id="@+id/ll_home_section_cityschedule"
-			android:layout_width="fill_parent"
-			android:layout_height="wrap_content"
-			android:orientation="vertical"
-			android:background="@drawable/section"
-			android:layout_margin="10dp"
-			android:visibility="gone">
-
-			<TextView
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:text="@string/home_section_cityschedule"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				tools:layout_width="match_parent"
-				android:background="@drawable/section_title"
-				android:paddingBottom="4dp"
-				android:paddingEnd="10dp"
-				android:paddingLeft="20dp"
-				android:paddingRight="10dp"
-				android:paddingStart="20dp"
-				android:paddingTop="4dp"
-				android:textColor="@color/section_title"/>
-
-			<LinearLayout
-				android:orientation="vertical"
-				android:layout_width="match_parent"
-				android:layout_height="match_parent"
-				android:background="@drawable/entry"
-				android:id="@+id/ll_home_section_cityschedule_now_content"
-				android:padding="7dp"
-				android:layout_margin="8dp">
-
-				<TextView
-					android:layout_width="match_parent"
-					android:layout_height="wrap_content"
-					android:textAppearance="?android:attr/textAppearanceMedium"
-					android:textColor="@color/entry_title"
-					android:textStyle="bold"
+        <LinearLayout
+            android:id="@+id/ll_home_section_location"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:background="@drawable/section"
+            android:layout_margin="10dp"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/home_section_location"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:textStyle="bold"
+                tools:layout_width="match_parent"
+                android:background="@drawable/section_title"
+                android:paddingBottom="4dp"
+                android:paddingEnd="10dp"
+                android:paddingStart="20dp"
+                android:paddingTop="4dp"
+                android:textColor="@color/section_title"/>
+
+            <LinearLayout
+                android:id="@+id/ll_home_section_location_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:background="@drawable/entry"
+                android:padding="7dp"
+                android:layout_margin="8dp">
+
+                <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:textColor="@color/entry_title"
+                    android:textStyle="bold"
+                    android:text="@string/home_section_location_text_0"/>
+
+                <LinearLayout
+                    android:orientation="horizontal"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:gravity="center_horizontal"
+                    android:layout_marginTop="10dp"
+                    android:layout_marginBottom="10dp"
+                    tools:ignore="UseCompoundDrawables">
+
+                    <ImageView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:contentDescription="@string/app_cdesc"
+                        android:src="@drawable/pinpoint"
+                        android:layout_margin="7dp"
+                        android:layout_gravity="center_vertical"/>
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:textAppearance="@android:style/TextAppearance.Medium"
+                        android:text="@string/home_section_location_text_calculating"
+                        android:id="@+id/tv_home_section_location_distance"
+                        android:layout_gravity="center_vertical"
+                        android:layout_margin="7dp"/>
+                </LinearLayout>
+            </LinearLayout>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_home_section_lablanca"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_margin="10dp"
+            android:background="@drawable/section"
+            android:orientation="vertical"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="@drawable/section_title"
+                android:paddingBottom="4dp"
+                android:paddingEnd="10dp"
+                android:paddingStart="20dp"
+                android:paddingTop="4dp"
+                android:text="@string/lablanca_title"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:textColor="@color/section_title"
+                android:textStyle="bold"/>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_margin="8dp"
+                android:background="@drawable/entry"
+                android:minHeight="175dp"
+                android:orientation="horizontal"
+                android:padding="7dp">
+
+                <ImageView
+                    android:id="@+id/iv_home_section_lablanca_image"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_margin="3dp"
+                    android:layout_weight=".7"
+                    android:adjustViewBounds="true"
+                    android:contentDescription="@string/app_cdesc"
+                    android:maxWidth="130dp"
+                    android:minHeight="105dp"/>
+
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:layout_weight=".3"
+                    android:orientation="vertical"
+                    >
+
+                    <TextView
+                        android:id="@+id/tv_home_section_lablanca_text"
+                        android:layout_width="match_parent"
+                        android:layout_height="80dp"
+                        android:maxLines="4"
+                        android:padding="7dp"
+                        android:textAppearance="@android:style/TextAppearance.Medium"/>
+
+                    <ImageView
+                        android:id="@+id/imageView6"
+                        android:layout_width="match_parent"
+                        android:layout_height="40dp"
+                        android:layout_marginTop="-40dp"
+                        android:importantForAccessibility="no"
+                        android:background="@drawable/gradient_v_white"/>
+
+                    <Button
+                        android:id="@+id/bt_home_gm"
+                        android:layout_width="match_parent"
+                        android:layout_height="50dp"
+                        android:layout_marginBottom="40dp"
+                        android:layout_marginStart="7dp"
+                        android:layout_marginTop="10dp"
+                        android:background="@drawable/button_selector"
+                        android:text="@string/lablanca_schedule_gm"
+                        android:textColor="@color/input_button_color"
+                        android:textStyle="bold"/>
+                </LinearLayout>
+
+            </LinearLayout>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_home_section_gmschedule"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:background="@drawable/section"
+            android:layout_margin="10dp"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/home_section_gmschedule"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:textStyle="bold"
+                tools:layout_width="match_parent"
+                android:background="@drawable/section_title"
+                android:paddingBottom="4dp"
+                android:paddingEnd="10dp"
+                android:paddingStart="20dp"
+                android:paddingTop="4dp"
+                android:textColor="@color/section_title"/>
+
+            <LinearLayout
+                android:orientation="vertical"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@drawable/entry"
+                android:id="@+id/ll_home_section_gmschedule_now_content"
+                android:padding="7dp"
+                android:layout_margin="8dp">
+
+                <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:textColor="@color/entry_title"
+                    android:textStyle="bold"
                     android:text="@string/schedule_now"/>
 
-				<LinearLayout
+                <LinearLayout
+                    android:id="@+id/ll_home_section_gmschedule_now_list"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="vertical"
+                    android:padding="7dp">
+
+                </LinearLayout>
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:orientation="vertical"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@drawable/entry"
+                android:id="@+id/ll_home_section_gmschedule_later_content"
+                android:padding="7dp"
+                android:layout_margin="8dp">
+
+                <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:textColor="@color/entry_title"
+                    android:textStyle="bold"
+                    android:text="@string/schedule_later"/>
+
+                <LinearLayout
+                    android:id="@+id/ll_home_section_gmschedule_later_list"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="vertical"
+                    android:padding="7dp">
+
+                </LinearLayout>
+
+            </LinearLayout>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_home_section_cityschedule"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:background="@drawable/section"
+            android:layout_margin="10dp"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/home_section_cityschedule"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:textStyle="bold"
+                tools:layout_width="match_parent"
+                android:background="@drawable/section_title"
+                android:paddingBottom="4dp"
+                android:paddingEnd="10dp"
+                android:paddingStart="20dp"
+                android:paddingTop="4dp"
+                android:textColor="@color/section_title"/>
+
+            <LinearLayout
+                android:orientation="vertical"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@drawable/entry"
+                android:id="@+id/ll_home_section_cityschedule_now_content"
+                android:padding="7dp"
+                android:layout_margin="8dp">
+
+                <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:textColor="@color/entry_title"
+                    android:textStyle="bold"
+                    android:text="@string/schedule_now"/>
+
+                <LinearLayout
                     android:id="@+id/ll_home_section_cityschedule_now_list"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-					android:orientation="vertical"
-					android:padding="7dp">
+                    android:orientation="vertical"
+                    android:padding="7dp">
+
+                </LinearLayout>
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:orientation="vertical"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@drawable/entry"
+                android:id="@+id/ll_home_section_cityschedule_later_content"
+                android:padding="7dp"
+                android:layout_margin="8dp">
+
+                <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:textColor="@color/entry_title"
+                    android:textStyle="bold"
+                    android:text="@string/schedule_later"/>
+
+                <LinearLayout
+                    android:id="@+id/ll_home_section_cityschedule_later_list"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="vertical"
+                    android:padding="7dp">
 
                 </LinearLayout>
 
-			</LinearLayout>
-
-			<LinearLayout
-				android:orientation="vertical"
-				android:layout_width="match_parent"
-				android:layout_height="match_parent"
-				android:background="@drawable/entry"
-				android:id="@+id/ll_home_section_cityschedule_later_content"
-				android:padding="7dp"
-				android:layout_margin="8dp">
-
-				<TextView
-					android:layout_width="match_parent"
-					android:layout_height="wrap_content"
-					android:textAppearance="?android:attr/textAppearanceMedium"
-					android:textColor="@color/entry_title"
-					android:textStyle="bold"
-					android:text="@string/schedule_later"/>
-
-				<LinearLayout
-					android:id="@+id/ll_home_section_cityschedule_later_list"
-					android:layout_width="match_parent"
-					android:layout_height="wrap_content"
-					android:orientation="vertical"
-					android:padding="7dp">
-
-				</LinearLayout>
-
-			</LinearLayout>
-
-		</LinearLayout>
-
-		<LinearLayout
-			android:id="@+id/ll_home_section_around"
-			android:layout_width="fill_parent"
-			android:layout_height="wrap_content"
-			android:orientation="vertical"
-			android:background="@drawable/section"
-			android:layout_margin="10dp"
-			android:visibility="gone">
-
-			<TextView
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:text="@string/home_section_around"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				tools:layout_width="match_parent"
-				android:background="@drawable/section_title"
-				android:paddingBottom="4dp"
-				android:paddingEnd="10dp"
-				android:paddingLeft="20dp"
-				android:paddingRight="10dp"
-				android:paddingStart="20dp"
-				android:paddingTop="4dp"
-				android:textColor="@color/section_title"/>
-
-			<LinearLayout
-				android:id="@+id/ll_home_section_around_content"
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:layout_margin="8dp"
-				android:orientation="vertical"
-				android:background="@drawable/entry"
-				>
-
-			</LinearLayout>
-
-		</LinearLayout>
-
-		<LinearLayout
-			android:id="@+id/ll_home_section_activities_future"
-			android:layout_width="fill_parent"
-			android:layout_height="wrap_content"
-			android:orientation="vertical"
-			android:background="@drawable/section"
-			android:layout_margin="10dp"
-			android:visibility="gone">
-
-			<TextView
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:text="@string/home_section_activities_future"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				tools:layout_width="match_parent"
-				android:background="@drawable/section_title"
-				android:paddingBottom="4dp"
-				android:paddingEnd="10dp"
-				android:paddingLeft="20dp"
-				android:paddingRight="10dp"
-				android:paddingStart="20dp"
-				android:paddingTop="4dp"
-				android:textColor="@color/section_title"/>
-
-			<LinearLayout
-				android:id="@+id/ll_home_section_activities_future_content"
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:layout_margin="8dp"
-				android:orientation="vertical">
-
-			</LinearLayout>
-
-		</LinearLayout>
-
-		<LinearLayout
-			android:id="@+id/ll_home_section_blog"
-			android:layout_width="fill_parent"
-			android:layout_height="wrap_content"
-			android:orientation="vertical"
-			android:background="@drawable/section"
-			android:layout_margin="10dp">
-
-			<TextView
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:text="@string/home_section_blog"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				tools:layout_width="match_parent"
-				android:background="@drawable/section_title"
-				android:paddingBottom="4dp"
-				android:paddingEnd="10dp"
-				android:paddingLeft="20dp"
-				android:paddingRight="10dp"
-				android:paddingStart="20dp"
-				android:paddingTop="4dp"
-				android:textColor="@color/section_title"/>
-
-			<LinearLayout
-				android:id="@+id/ll_home_section_blog_content"
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:orientation="vertical"
-				android:layout_margin="8dp">
-
-			</LinearLayout>
-
-		</LinearLayout>
-
-		<LinearLayout
-			android:id="@+id/ll_home_section_gallery"
-			android:layout_width="fill_parent"
-			android:layout_height="wrap_content"
-			android:orientation="vertical"
-			android:background="@drawable/section"
-			android:layout_margin="10dp">
-
-			<TextView
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:text="@string/home_section_gallery"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				tools:layout_width="match_parent"
-				android:background="@drawable/section_title"
-				android:paddingBottom="4dp"
-				android:paddingEnd="10dp"
-				android:paddingLeft="20dp"
-				android:paddingRight="10dp"
-				android:paddingStart="20dp"
-				android:paddingTop="4dp"
-				android:textColor="@color/section_title"/>
-
-			<LinearLayout
-				android:id="@+id/ll_home_section_gallery_content"
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:layout_margin="10dp"
-				android:orientation="vertical"
-				android:background="@drawable/entry"
-				android:padding="7dp">
-
-				<LinearLayout
-					android:baselineAligned="true"
+            </LinearLayout>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_home_section_around"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:background="@drawable/section"
+            android:layout_margin="10dp"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/home_section_around"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:textStyle="bold"
+                tools:layout_width="match_parent"
+                android:background="@drawable/section_title"
+                android:paddingBottom="4dp"
+                android:paddingEnd="10dp"
+                android:paddingStart="20dp"
+                android:paddingTop="4dp"
+                android:textColor="@color/section_title"/>
+
+            <LinearLayout
+                android:id="@+id/ll_home_section_around_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="8dp"
+                android:orientation="vertical"
+                android:background="@drawable/entry"
+                >
+
+            </LinearLayout>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_home_section_activities_future"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:background="@drawable/section"
+            android:layout_margin="10dp"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/home_section_activities_future"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:textStyle="bold"
+                tools:layout_width="match_parent"
+                android:background="@drawable/section_title"
+                android:paddingBottom="4dp"
+                android:paddingEnd="10dp"
+                android:paddingStart="20dp"
+                android:paddingTop="4dp"
+                android:textColor="@color/section_title"/>
+
+            <LinearLayout
+                android:id="@+id/ll_home_section_activities_future_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="8dp"
+                android:orientation="vertical">
+
+            </LinearLayout>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_home_section_blog"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:background="@drawable/section"
+            android:layout_margin="10dp">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/home_section_blog"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:textStyle="bold"
+                tools:layout_width="match_parent"
+                android:background="@drawable/section_title"
+                android:paddingBottom="4dp"
+                android:paddingEnd="10dp"
+                android:paddingStart="20dp"
+                android:paddingTop="4dp"
+                android:textColor="@color/section_title"/>
+
+            <LinearLayout
+                android:id="@+id/ll_home_section_blog_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:layout_margin="8dp">
+
+            </LinearLayout>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_home_section_gallery"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:background="@drawable/section"
+            android:layout_margin="10dp">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/home_section_gallery"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:textStyle="bold"
+                tools:layout_width="match_parent"
+                android:background="@drawable/section_title"
+                android:paddingBottom="4dp"
+                android:paddingEnd="10dp"
+                android:paddingStart="20dp"
+                android:paddingTop="4dp"
+                android:textColor="@color/section_title"/>
+
+            <LinearLayout
+                android:id="@+id/ll_home_section_gallery_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="10dp"
+                android:orientation="vertical"
+                android:background="@drawable/entry"
+                android:padding="7dp">
+
+                <LinearLayout
+                    android:baselineAligned="true"
                     android:orientation="horizontal"
                     android:layout_width="match_parent"
                     android:layout_height="match_parent">
 
-					<LinearLayout
-						android:orientation="horizontal"
-						android:layout_width="fill_parent"
-						android:layout_height="match_parent"
-						android:layout_weight=".5"
-						android:gravity="center_vertical|center_horizontal">
-
-						<ImageView
-							android:layout_width="wrap_content"
-							android:layout_height="wrap_content"
-							android:id="@+id/iv_home_section_gallery_0"
-							android:contentDescription="@string/app_cdesc"
-							android:layout_margin="3dp"
-							android:padding="0.5dp"
-							android:background="@color/image_border"
-							android:adjustViewBounds="true"
-							/>
-					</LinearLayout>
-
-					<LinearLayout
-						android:orientation="horizontal"
-						android:layout_width="fill_parent"
-						android:layout_height="match_parent"
-						android:layout_weight=".5"
-						android:gravity="center_vertical|center_horizontal">
-
-						<ImageView
-							android:layout_width="wrap_content"
-							android:layout_height="wrap_content"
-							android:id="@+id/iv_home_section_gallery_1"
-							android:contentDescription="@string/app_cdesc"
-							android:layout_margin="3dp"
-							android:background="@color/image_border"
-							android:padding="0.5dp"
-							android:adjustViewBounds="true"
-							/>
-					</LinearLayout>
-
-				</LinearLayout>
-
-				<LinearLayout
-					android:baselineAligned="false"
-					android:orientation="horizontal"
-					android:layout_width="match_parent"
-					android:layout_height="match_parent" >
-
-					<LinearLayout
-						android:orientation="horizontal"
-						android:layout_width="fill_parent"
-						android:layout_height="match_parent"
-						android:layout_weight=".5"
-						android:gravity="center_vertical|center_horizontal">
-
-						<ImageView
-							android:layout_width="wrap_content"
-							android:layout_height="wrap_content"
-							android:id="@+id/iv_home_section_gallery_2"
-							android:contentDescription="@string/app_cdesc"
-							android:layout_margin="3dp"
-							android:padding="0.5dp"
-							android:background="@color/image_border"
-							android:adjustViewBounds="true"
-							/>
-					</LinearLayout>
-
-					<LinearLayout
-						android:orientation="horizontal"
-						android:layout_width="fill_parent"
-						android:layout_height="match_parent"
-						android:layout_weight=".5"
-						android:gravity="center_vertical|center_horizontal">
-
-						<ImageView
-							android:layout_width="wrap_content"
-							android:layout_height="wrap_content"
-							android:id="@+id/iv_home_section_gallery_3"
-							android:contentDescription="@string/app_cdesc"
-							android:layout_margin="3dp"
-							android:background="@color/image_border"
-							android:padding="0.5dp"
-							android:adjustViewBounds="true"
-							/>
-					</LinearLayout>
-
-				</LinearLayout>
-
-				<TextView
+                    <LinearLayout
+                        android:orientation="horizontal"
+                        android:layout_width="fill_parent"
+                        android:layout_height="match_parent"
+                        android:layout_weight=".5"
+                        android:gravity="center_vertical|center_horizontal">
+
+                        <ImageView
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:id="@+id/iv_home_section_gallery_0"
+                            android:contentDescription="@string/app_cdesc"
+                            android:layout_margin="3dp"
+                            android:padding="0.5dp"
+                            android:background="@color/image_border"
+                            android:adjustViewBounds="true"
+                            />
+                    </LinearLayout>
+
+                    <LinearLayout
+                        android:orientation="horizontal"
+                        android:layout_width="fill_parent"
+                        android:layout_height="match_parent"
+                        android:layout_weight=".5"
+                        android:gravity="center_vertical|center_horizontal">
+
+                        <ImageView
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:id="@+id/iv_home_section_gallery_1"
+                            android:contentDescription="@string/app_cdesc"
+                            android:layout_margin="3dp"
+                            android:background="@color/image_border"
+                            android:padding="0.5dp"
+                            android:adjustViewBounds="true"
+                            />
+                    </LinearLayout>
+
+                </LinearLayout>
+
+                <LinearLayout
+                    android:baselineAligned="false"
+                    android:orientation="horizontal"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent" >
+
+                    <LinearLayout
+                        android:orientation="horizontal"
+                        android:layout_width="fill_parent"
+                        android:layout_height="match_parent"
+                        android:layout_weight=".5"
+                        android:gravity="center_vertical|center_horizontal">
+
+                        <ImageView
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:id="@+id/iv_home_section_gallery_2"
+                            android:contentDescription="@string/app_cdesc"
+                            android:layout_margin="3dp"
+                            android:padding="0.5dp"
+                            android:background="@color/image_border"
+                            android:adjustViewBounds="true"
+                            />
+                    </LinearLayout>
+
+                    <LinearLayout
+                        android:orientation="horizontal"
+                        android:layout_width="fill_parent"
+                        android:layout_height="match_parent"
+                        android:layout_weight=".5"
+                        android:gravity="center_vertical|center_horizontal">
+
+                        <ImageView
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:id="@+id/iv_home_section_gallery_3"
+                            android:contentDescription="@string/app_cdesc"
+                            android:layout_margin="3dp"
+                            android:background="@color/image_border"
+                            android:padding="0.5dp"
+                            android:adjustViewBounds="true"
+                            />
+                    </LinearLayout>
+
+                </LinearLayout>
+
+                <TextView
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:textAppearance="?android:attr/textAppearanceMedium"
                     android:text="Medium Text"
                     android:id="@+id/tv_home_section_gallery_hidden_0"
-					android:visibility="gone" />
-				<TextView
-					android:layout_width="wrap_content"
-					android:layout_height="wrap_content"
-					android:textAppearance="?android:attr/textAppearanceMedium"
-					android:text="Medium Text"
-					android:id="@+id/tv_home_section_gallery_hidden_1"
-					android:visibility="gone" />
-				<TextView
-					android:layout_width="wrap_content"
-					android:layout_height="wrap_content"
-					android:textAppearance="?android:attr/textAppearanceMedium"
-					android:text="Medium Text"
-					android:id="@+id/tv_home_section_gallery_hidden_2"
-					android:visibility="gone" />
-				<TextView
-					android:layout_width="wrap_content"
-					android:layout_height="wrap_content"
-					android:textAppearance="?android:attr/textAppearanceMedium"
-					android:text="Medium Text"
-					android:id="@+id/tv_home_section_gallery_hidden_3"
-					android:visibility="gone" />
-			</LinearLayout>
-
-		</LinearLayout>
-
-		<LinearLayout
-			android:id="@+id/ll_home_section_activities_past"
-			android:layout_width="fill_parent"
-			android:layout_height="wrap_content"
-			android:orientation="vertical"
-			android:background="@drawable/section"
-			android:layout_margin="10dp"
-			android:visibility="gone">
-
-			<TextView
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:text="@string/home_section_activities_past"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				tools:layout_width="match_parent"
-				android:background="@drawable/section_title"
-				android:paddingBottom="4dp"
-				android:paddingEnd="10dp"
-				android:paddingLeft="20dp"
-				android:paddingRight="10dp"
-				android:paddingStart="20dp"
-				android:paddingTop="4dp"
-				android:textColor="@color/section_title"/>
-
-			<LinearLayout
-				android:id="@+id/ll_home_section_activities_past_content"
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:orientation="vertical"
-				android:layout_margin="8dp">
-
-			</LinearLayout>
-
-		</LinearLayout>
-
-		<LinearLayout
-			android:id="@+id/ll_home_section_social"
-			android:layout_width="fill_parent"
-			android:layout_height="wrap_content"
-			android:orientation="vertical"
-			android:background="@drawable/section"
-			android:layout_margin="10dp">
-
-			<TextView
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:text="@string/home_section_social"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:textStyle="bold"
-				tools:layout_width="match_parent"
-				android:background="@drawable/section_title"
-				android:paddingBottom="4dp"
-				android:paddingEnd="10dp"
-				android:paddingLeft="20dp"
-				android:paddingRight="10dp"
-				android:paddingStart="20dp"
-				android:paddingTop="4dp"
-				android:textColor="@color/section_title"/>
-
-			<LinearLayout
-				android:id="@+id/ll_home_section_social_content"
-				android:layout_width="match_parent"
-				android:layout_height="wrap_content"
-				android:layout_margin="8dp"
-				android:orientation="vertical"
-				android:background="@drawable/entry"
-				android:padding="7dp">
-
-				<LinearLayout
-					android:layout_width="fill_parent"
-					android:layout_height="wrap_content"
-					android:gravity="center_horizontal" >
-
-					<ImageView
-						android:id="@+id/iv_home_section_social_phone"
-						android:layout_width="wrap_content"
-						android:layout_height="wrap_content"
-						android:layout_margin="5dp"
-						android:adjustViewBounds="true"
-						android:contentDescription="@string/social_phone"
-						android:maxWidth="60dp"
-						android:src="@drawable/social_phone"/>
-
-					<ImageView
-						android:id="@+id/iv_home_section_social_mail"
-						android:layout_width="wrap_content"
-						android:layout_height="wrap_content"
-						android:layout_margin="5dp"
-						android:adjustViewBounds="true"
-						android:contentDescription="@string/social_mail"
-						android:maxWidth="60dp"
-						android:src="@drawable/social_mail" />
-
-					<ImageView
-						android:id="@+id/iv_home_section_social_whatsapp"
-						android:layout_width="wrap_content"
-						android:layout_height="wrap_content"
-						android:layout_margin="5dp"
-						android:adjustViewBounds="true"
-						android:contentDescription="@string/social_whatsapp"
-						android:maxWidth="60dp"
-						android:src="@drawable/social_whatsapp" />
-
-					<ImageView
-						android:id="@+id/iv_home_section_social_facebook"
-						android:layout_width="wrap_content"
-						android:layout_height="wrap_content"
-						android:layout_margin="5dp"
-						android:adjustViewBounds="true"
-						android:contentDescription="@string/social_facebook"
-						android:maxWidth="60dp"
-						android:src="@drawable/social_facebook" />
-				</LinearLayout>
-
-				<LinearLayout
-					android:layout_width="fill_parent"
-					android:layout_height="wrap_content"
-					android:gravity="center_horizontal" >
-
-					<ImageView
-						android:id="@+id/iv_home_section_social_twitter"
-						android:layout_width="wrap_content"
-						android:layout_height="wrap_content"
-						android:layout_margin="5dp"
-						android:adjustViewBounds="true"
-						android:contentDescription="@string/social_twitter"
-						android:maxWidth="60dp"
-						android:src="@drawable/social_twitter" />
-
-					<ImageView
-						android:id="@+id/iv_home_section_social_googleplus"
-						android:layout_width="wrap_content"
-						android:layout_height="wrap_content"
-						android:layout_margin="5dp"
-						android:adjustViewBounds="true"
-						android:contentDescription="@string/social_googleplus"
-						android:maxWidth="60dp"
-						android:src="@drawable/social_googleplus" />
-
-					<ImageView
-						android:id="@+id/iv_home_section_social_youtube"
-						android:layout_width="wrap_content"
-						android:layout_height="wrap_content"
-						android:layout_margin="5dp"
-						android:adjustViewBounds="true"
-						android:contentDescription="@string/social_youtube"
-						android:maxWidth="60dp"
-						android:src="@drawable/social_youtube" />
-
-					<ImageView
-						android:id="@+id/iv_home_section_social_instagram"
-						android:layout_width="wrap_content"
-						android:layout_height="wrap_content"
-						android:layout_margin="5dp"
-						android:adjustViewBounds="true"
-						android:contentDescription="@string/social_instagram"
-						android:maxWidth="60dp"
-						android:src="@drawable/social_instagram" />
-
-				</LinearLayout>
-
-			</LinearLayout>
-
-		</LinearLayout>
-
-
-	</LinearLayout>
-
-</com.ivalentin.margolariak.CustomScrollView>
+                    android:visibility="gone" />
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:text="Medium Text"
+                    android:id="@+id/tv_home_section_gallery_hidden_1"
+                    android:visibility="gone" />
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:text="Medium Text"
+                    android:id="@+id/tv_home_section_gallery_hidden_2"
+                    android:visibility="gone" />
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:text="Medium Text"
+                    android:id="@+id/tv_home_section_gallery_hidden_3"
+                    android:visibility="gone" />
+            </LinearLayout>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_home_section_activities_past"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:background="@drawable/section"
+            android:layout_margin="10dp"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/home_section_activities_past"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:textStyle="bold"
+                tools:layout_width="match_parent"
+                android:background="@drawable/section_title"
+                android:paddingBottom="4dp"
+                android:paddingEnd="10dp"
+                android:paddingStart="20dp"
+                android:paddingTop="4dp"
+                android:textColor="@color/section_title"/>
+
+            <LinearLayout
+                android:id="@+id/ll_home_section_activities_past_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:layout_margin="8dp">
+
+            </LinearLayout>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_home_section_social"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:background="@drawable/section"
+            android:layout_margin="10dp">
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/home_section_social"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:textStyle="bold"
+                tools:layout_width="match_parent"
+                android:background="@drawable/section_title"
+                android:paddingBottom="4dp"
+                android:paddingEnd="10dp"
+                android:paddingStart="20dp"
+                android:paddingTop="4dp"
+                android:textColor="@color/section_title"/>
+
+            <LinearLayout
+                android:id="@+id/ll_home_section_social_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="8dp"
+                android:orientation="vertical"
+                android:background="@drawable/entry"
+                android:padding="7dp">
+
+                <LinearLayout
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:gravity="center_horizontal" >
+
+                    <ImageView
+                        android:id="@+id/iv_home_section_social_phone"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_margin="5dp"
+                        android:adjustViewBounds="true"
+                        android:contentDescription="@string/social_phone"
+                        android:maxWidth="60dp"
+                        android:src="@drawable/social_phone"/>
+
+                    <ImageView
+                        android:id="@+id/iv_home_section_social_mail"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_margin="5dp"
+                        android:adjustViewBounds="true"
+                        android:contentDescription="@string/social_mail"
+                        android:maxWidth="60dp"
+                        android:src="@drawable/social_mail" />
+
+                    <ImageView
+                        android:id="@+id/iv_home_section_social_whatsapp"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_margin="5dp"
+                        android:adjustViewBounds="true"
+                        android:contentDescription="@string/social_whatsapp"
+                        android:maxWidth="60dp"
+                        android:src="@drawable/social_whatsapp" />
+
+                    <ImageView
+                        android:id="@+id/iv_home_section_social_facebook"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_margin="5dp"
+                        android:adjustViewBounds="true"
+                        android:contentDescription="@string/social_facebook"
+                        android:maxWidth="60dp"
+                        android:src="@drawable/social_facebook" />
+                </LinearLayout>
+
+                <LinearLayout
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:gravity="center_horizontal" >
+
+                    <ImageView
+                        android:id="@+id/iv_home_section_social_twitter"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_margin="5dp"
+                        android:adjustViewBounds="true"
+                        android:contentDescription="@string/social_twitter"
+                        android:maxWidth="60dp"
+                        android:src="@drawable/social_twitter" />
+
+                    <ImageView
+                        android:id="@+id/iv_home_section_social_googleplus"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_margin="5dp"
+                        android:adjustViewBounds="true"
+                        android:contentDescription="@string/social_googleplus"
+                        android:maxWidth="60dp"
+                        android:src="@drawable/social_googleplus" />
+
+                    <ImageView
+                        android:id="@+id/iv_home_section_social_youtube"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_margin="5dp"
+                        android:adjustViewBounds="true"
+                        android:contentDescription="@string/social_youtube"
+                        android:maxWidth="60dp"
+                        android:src="@drawable/social_youtube" />
+
+                    <ImageView
+                        android:id="@+id/iv_home_section_social_instagram"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_margin="5dp"
+                        android:adjustViewBounds="true"
+                        android:contentDescription="@string/social_instagram"
+                        android:maxWidth="60dp"
+                        android:src="@drawable/social_instagram" />
+
+                </LinearLayout>
+
+            </LinearLayout>
+
+        </LinearLayout>
+
+
+    </LinearLayout>
+
+</com.ivalentin.margolariak.CustomScrollView>

+ 1 - 8
app/src/main/res/layout/fragment_layout_lablanca.xml

@@ -11,8 +11,7 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_margin="10dp"
-        android:orientation="vertical"
-        >
+        android:orientation="vertical">
 
         <LinearLayout
             android:layout_width="match_parent"
@@ -26,8 +25,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:text="@string/lablanca_title"
@@ -79,8 +76,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:text="@string/lablanca_schedule"
@@ -139,8 +134,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:text="@string/lablanca_prices"

+ 18 - 53
app/src/main/res/layout/fragment_layout_lablanca_nofestivals.xml

@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <com.ivalentin.margolariak.CustomScrollView
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
@@ -19,7 +18,7 @@
             android:layout_height="wrap_content"
             android:background="@drawable/section"
             android:orientation="vertical"
-            >
+            tools:ignore="UselessParent">
 
             <TextView
                 android:id="@+id/textView4"
@@ -28,8 +27,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:text="@string/lablanca_title"
@@ -61,7 +58,6 @@
                     android:orientation="horizontal">
 
                     <ImageView
-                        android:id="@+id/imageView4"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:layout_marginEnd="10dp"
@@ -73,8 +69,8 @@
                         android:baselineAlignBottom="true"
                         android:minHeight="15dp"
                         android:minWidth="15dp"
-                        android:src="@drawable/ul"
-                        app:srcCompat="@drawable/ul"/>
+                        android:importantForAccessibility="no"
+                        android:src="@drawable/ul"/>
 
                     <LinearLayout
                         android:layout_width="wrap_content"
@@ -82,7 +78,6 @@
                         android:orientation="vertical">
 
                         <TextView
-                            android:id="@+id/textView2"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
                             android:text="@string/lablanca_nofestivals_1_title"
@@ -91,10 +86,8 @@
                             android:textStyle="bold"/>
 
                         <TextView
-                            android:id="@+id/textView3"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
-                            android:layout_marginLeft="10dp"
                             android:layout_marginStart="10dp"
                             android:text="@string/lablanca_nofestivals_1"
                             android:textAppearance="@android:style/TextAppearance.Medium"/>
@@ -108,7 +101,6 @@
                     android:orientation="horizontal">
 
                     <ImageView
-                        android:id="@+id/imageView4"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:layout_marginEnd="10dp"
@@ -118,10 +110,10 @@
                         android:layout_marginTop="5dp"
                         android:adjustViewBounds="false"
                         android:baselineAlignBottom="false"
+                        android:importantForAccessibility="no"
                         android:minHeight="15dp"
                         android:minWidth="15dp"
-                        android:src="@drawable/ul"
-                        app:srcCompat="@drawable/ul"/>
+                        android:src="@drawable/ul"/>
 
                     <LinearLayout
                         android:layout_width="wrap_content"
@@ -129,7 +121,6 @@
                         android:orientation="vertical">
 
                         <TextView
-                            android:id="@+id/textView2"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
                             android:text="@string/lablanca_nofestivals_2_title"
@@ -138,10 +129,8 @@
                             android:textStyle="bold"/>
 
                         <TextView
-                            android:id="@+id/textView3"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
-                            android:layout_marginLeft="10dp"
                             android:layout_marginStart="10dp"
                             android:text="@string/lablanca_nofestivals_2"
                             android:textAppearance="@android:style/TextAppearance.Medium"/>
@@ -156,7 +145,6 @@
                     android:orientation="horizontal">
 
                     <ImageView
-                        android:id="@+id/imageView4"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:layout_marginEnd="10dp"
@@ -166,10 +154,10 @@
                         android:layout_marginTop="5dp"
                         android:adjustViewBounds="false"
                         android:baselineAlignBottom="false"
+                        android:importantForAccessibility="no"
                         android:minHeight="15dp"
                         android:minWidth="15dp"
-                        android:src="@drawable/ul"
-                        app:srcCompat="@drawable/ul"/>
+                        android:src="@drawable/ul"/>
 
                     <LinearLayout
                         android:layout_width="wrap_content"
@@ -177,7 +165,6 @@
                         android:orientation="vertical">
 
                         <TextView
-                            android:id="@+id/textView2"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
                             android:text="@string/lablanca_nofestivals_3_title"
@@ -186,10 +173,8 @@
                             android:textStyle="bold"/>
 
                         <TextView
-                            android:id="@+id/textView3"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
-                            android:layout_marginLeft="10dp"
                             android:layout_marginStart="10dp"
                             android:text="@string/lablanca_nofestivals_3"
                             android:textAppearance="@android:style/TextAppearance.Medium"/>
@@ -203,7 +188,6 @@
                     android:orientation="horizontal">
 
                     <ImageView
-                        android:id="@+id/imageView4"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:layout_marginEnd="10dp"
@@ -213,10 +197,10 @@
                         android:layout_marginTop="5dp"
                         android:adjustViewBounds="false"
                         android:baselineAlignBottom="false"
+                        android:importantForAccessibility="no"
                         android:minHeight="15dp"
                         android:minWidth="15dp"
-                        android:src="@drawable/ul"
-                        app:srcCompat="@drawable/ul"/>
+                        android:src="@drawable/ul"/>
 
                     <LinearLayout
                         android:layout_width="wrap_content"
@@ -224,7 +208,6 @@
                         android:orientation="vertical">
 
                         <TextView
-                            android:id="@+id/textView2"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
                             android:text="@string/lablanca_nofestivals_4_title"
@@ -233,10 +216,8 @@
                             android:textStyle="bold"/>
 
                         <TextView
-                            android:id="@+id/textView3"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
-                            android:layout_marginLeft="10dp"
                             android:layout_marginStart="10dp"
                             android:text="@string/lablanca_nofestivals_4"
                             android:textAppearance="@android:style/TextAppearance.Medium"/>
@@ -250,7 +231,6 @@
                     android:orientation="horizontal">
 
                     <ImageView
-                        android:id="@+id/imageView4"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:layout_marginEnd="10dp"
@@ -260,10 +240,10 @@
                         android:layout_marginTop="5dp"
                         android:adjustViewBounds="false"
                         android:baselineAlignBottom="false"
+                        android:importantForAccessibility="no"
                         android:minHeight="15dp"
                         android:minWidth="15dp"
-                        android:src="@drawable/ul"
-                        app:srcCompat="@drawable/ul"/>
+                        android:src="@drawable/ul"/>
 
                     <LinearLayout
                         android:layout_width="wrap_content"
@@ -271,7 +251,6 @@
                         android:orientation="vertical">
 
                         <TextView
-                            android:id="@+id/textView2"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
                             android:text="@string/lablanca_nofestivals_5_title"
@@ -280,10 +259,8 @@
                             android:textStyle="bold"/>
 
                         <TextView
-                            android:id="@+id/textView3"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
-                            android:layout_marginLeft="10dp"
                             android:layout_marginStart="10dp"
                             android:text="@string/lablanca_nofestivals_5"
                             android:textAppearance="@android:style/TextAppearance.Medium"/>
@@ -297,7 +274,6 @@
                     android:orientation="horizontal">
 
                     <ImageView
-                        android:id="@+id/imageView4"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:layout_marginEnd="10dp"
@@ -307,10 +283,10 @@
                         android:layout_marginTop="5dp"
                         android:adjustViewBounds="false"
                         android:baselineAlignBottom="false"
+                        android:importantForAccessibility="no"
                         android:minHeight="15dp"
                         android:minWidth="15dp"
-                        android:src="@drawable/ul"
-                        app:srcCompat="@drawable/ul"/>
+                        android:src="@drawable/ul"/>
 
                     <LinearLayout
                         android:layout_width="wrap_content"
@@ -318,7 +294,6 @@
                         android:orientation="vertical">
 
                         <TextView
-                            android:id="@+id/textView2"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
                             android:text="@string/lablanca_nofestivals_6_title"
@@ -327,10 +302,8 @@
                             android:textStyle="bold"/>
 
                         <TextView
-                            android:id="@+id/textView3"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
-                            android:layout_marginLeft="10dp"
                             android:layout_marginStart="10dp"
                             android:text="@string/lablanca_nofestivals_6"
                             android:textAppearance="@android:style/TextAppearance.Medium"/>
@@ -344,7 +317,6 @@
                     android:orientation="horizontal">
 
                     <ImageView
-                        android:id="@+id/imageView4"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:layout_marginEnd="10dp"
@@ -354,10 +326,10 @@
                         android:layout_marginTop="5dp"
                         android:adjustViewBounds="false"
                         android:baselineAlignBottom="false"
+                        android:importantForAccessibility="no"
                         android:minHeight="15dp"
                         android:minWidth="15dp"
-                        android:src="@drawable/ul"
-                        app:srcCompat="@drawable/ul"/>
+                        android:src="@drawable/ul"/>
 
                     <LinearLayout
                         android:layout_width="wrap_content"
@@ -365,7 +337,6 @@
                         android:orientation="vertical">
 
                         <TextView
-                            android:id="@+id/textView2"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
                             android:text="@string/lablanca_nofestivals_7_title"
@@ -374,10 +345,8 @@
                             android:textStyle="bold"/>
 
                         <TextView
-                            android:id="@+id/textView3"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
-                            android:layout_marginLeft="10dp"
                             android:layout_marginStart="10dp"
                             android:text="@string/lablanca_nofestivals_7"
                             android:textAppearance="@android:style/TextAppearance.Medium"/>
@@ -391,7 +360,6 @@
                     android:orientation="horizontal">
 
                     <ImageView
-                        android:id="@+id/imageView4"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:layout_marginEnd="10dp"
@@ -401,10 +369,10 @@
                         android:layout_marginTop="5dp"
                         android:adjustViewBounds="false"
                         android:baselineAlignBottom="false"
+                        android:importantForAccessibility="no"
                         android:minHeight="15dp"
                         android:minWidth="15dp"
-                        android:src="@drawable/ul"
-                        app:srcCompat="@drawable/ul"/>
+                        android:src="@drawable/ul"/>
 
                     <LinearLayout
                         android:layout_width="wrap_content"
@@ -412,7 +380,6 @@
                         android:orientation="vertical">
 
                         <TextView
-                            android:id="@+id/textView2"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
                             android:text="@string/lablanca_nofestivals_8_title"
@@ -421,10 +388,8 @@
                             android:textStyle="bold"/>
 
                         <TextView
-                            android:id="@+id/textView3"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
-                            android:layout_marginLeft="10dp"
                             android:layout_marginStart="10dp"
                             android:text="@string/lablanca_nofestivals_8"
                             android:textAppearance="@android:style/TextAppearance.Medium"/>
@@ -440,4 +405,4 @@
 
 
 
-</com.ivalentin.margolariak.CustomScrollView>
+</com.ivalentin.margolariak.CustomScrollView>

+ 14 - 9
app/src/main/res/layout/fragment_layout_location.xml

@@ -20,8 +20,6 @@
 			android:background="@drawable/section_title"
 			android:paddingBottom="4dp"
 			android:paddingEnd="10dp"
-			android:paddingLeft="20dp"
-			android:paddingRight="10dp"
 			android:paddingStart="20dp"
 			android:paddingTop="4dp"
 			android:text="@string/menu_location"
@@ -52,14 +50,21 @@
 				android:layout_height="wrap_content"
 				android:layout_margin="10dp"
 				android:text="@string/home_section_location_text_calculating"
-				android:textAppearance="?android:attr/textAppearanceSmall"/>
+				android:textAppearance="?android:attr/textAppearanceMedium"/>
 
-			<com.google.android.gms.maps.MapView
-				android:id="@+id/mapview"
-				android:layout_width="fill_parent"
-				android:layout_height="fill_parent"
-				android:layout_margin="7dp"
-				android:minHeight="150dp"/>
+			<LinearLayout
+				android:layout_width="match_parent"
+				android:layout_height="0dp"
+				android:layout_weight=".95"
+				android:background="@drawable/map"
+				android:padding="3dp">
+
+				<org.osmdroid.views.MapView
+					android:id="@+id/mapview"
+					android:layout_width="match_parent"
+					android:layout_height="match_parent"/>
+
+			</LinearLayout>
 		</LinearLayout>
 
 	</LinearLayout>

+ 0 - 2
app/src/main/res/layout/fragment_layout_photo.xml

@@ -28,8 +28,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:textColor="@color/section_title"/>

+ 0 - 2
app/src/main/res/layout/fragment_layout_post.xml

@@ -32,8 +32,6 @@
                 android:background="@drawable/section_title"
                 android:paddingBottom="4dp"
                 android:paddingEnd="10dp"
-                android:paddingLeft="20dp"
-                android:paddingRight="10dp"
                 android:paddingStart="20dp"
                 android:paddingTop="4dp"
                 android:textColor="@color/section_title"/>

+ 2 - 7
app/src/main/res/layout/fragment_layout_schedule.xml

@@ -23,8 +23,6 @@
             android:background="@drawable/section_title"
             android:paddingBottom="4dp"
             android:paddingEnd="10dp"
-            android:paddingLeft="20dp"
-            android:paddingRight="10dp"
             android:paddingStart="20dp"
             android:paddingTop="4dp"
             android:text="@string/lablanca_schedule_gm"
@@ -80,8 +78,6 @@
                             android:layout_width="wrap_content"
                             android:layout_height="wrap_content"
                             android:paddingEnd="0dp"
-                            android:paddingLeft="13dp"
-                            android:paddingRight="0dp"
                             android:paddingStart="13dp"
                             android:textSize="20sp"
                             android:textStyle="italic"/>
@@ -109,7 +105,7 @@
             <EditText
                 android:id="@+id/et_schedule_filter"
                 android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
+                android:layout_height="0dp"
                 android:layout_marginEnd="10dp"
                 android:layout_marginLeft="10dp"
                 android:layout_marginRight="10dp"
@@ -140,8 +136,7 @@
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:layout_margin="0dp"
-                android:orientation="vertical"
-                >
+                android:orientation="vertical">
 
                 <LinearLayout
                     android:id="@+id/ll_schedule_list"

+ 0 - 149
app/src/main/res/layout/fragment_layout_settings.xml

@@ -1,149 +0,0 @@
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:orientation="vertical"
-    android:layout_width="fill_parent"
-    android:background="@color/background_app"
-    android:layout_height="fill_parent"
-    tools:ignore="Overdraw">
-
-    <com.ivalentin.margolariak.CustomScrollView
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content">
-
-        <LinearLayout
-            android:orientation="vertical"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content">
-
-            <RelativeLayout
-                android:id="@+id/rl_settings_notifications"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:paddingLeft="10dp"
-                android:paddingTop="15dp"
-                android:paddingRight="10dp"
-                android:paddingBottom="15dp">
-
-                <TextView
-                    android:id="@+id/tv_settings_notifications"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_alignParentLeft="true"
-                    android:layout_alignParentStart="true"
-                    android:layout_alignParentTop="true"
-                    android:text="@string/settings_notification"
-                    android:textAppearance="@android:style/TextAppearance.Large"
-                    tools:ignore="RelativeOverlap"/>
-
-                <TextView
-                    android:id="@+id/tv_settings_notifications_summary"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_alignParentLeft="true"
-                    android:layout_alignParentStart="true"
-                    android:layout_below="@id/tv_settings_notifications"
-                    android:text="@string/settings_notification_off"
-                    android:textAppearance="@android:style/TextAppearance.Small" />
-
-                <CheckBox
-                    android:id="@+id/cb_settings_notifications"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_alignParentEnd="true"
-                    android:layout_alignParentRight="true"
-                    android:layout_centerVertical="true"
-                    android:clickable="false" />
-
-            </RelativeLayout>
-
-            <TextView
-                android:layout_width="fill_parent"
-                android:layout_height="1dp"
-                android:background="@color/background_separator"
-                android:textAppearance="?android:attr/textAppearanceSmall"
-                android:layout_marginLeft="15dp"
-                android:layout_marginRight="15dp"/>
-
-            <TextView
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:textAppearance="?android:attr/textAppearanceLarge"
-                android:text="@string/settings_license"
-                android:id="@+id/tv_setting_license"
-                android:paddingLeft="10dp"
-                android:paddingTop="20dp"
-                android:paddingRight="10dp"
-                android:paddingBottom="20dp"/>
-
-            <TextView
-                android:layout_width="fill_parent"
-                android:layout_height="1dp"
-                android:background="@color/background_separator"
-                android:textAppearance="?android:attr/textAppearanceSmall"
-                android:layout_marginLeft="15dp"
-                android:layout_marginRight="15dp"/>
-
-            <TextView
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:textAppearance="?android:attr/textAppearanceLarge"
-                android:text="@string/settings_privacy"
-                android:id="@+id/tv_setting_privacy"
-                android:paddingLeft="10dp"
-                android:paddingTop="20dp"
-                android:paddingRight="10dp"
-                android:paddingBottom="20dp"/>
-
-            <TextView
-                android:layout_width="fill_parent"
-                android:layout_height="1dp"
-                android:background="@color/background_separator"
-                android:textAppearance="?android:attr/textAppearanceSmall"
-                android:layout_marginLeft="15dp"
-                android:layout_marginRight="15dp"
-                />
-
-            <TextView
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:textAppearance="?android:attr/textAppearanceLarge"
-                android:text="@string/settings_about"
-                android:id="@+id/tv_setting_about"
-                android:paddingLeft="10dp"
-                android:paddingTop="20dp"
-                android:paddingRight="10dp"
-                android:paddingBottom="20dp"/>
-
-            <TextView
-                android:layout_width="fill_parent"
-                android:layout_height="1dp"
-                android:background="@color/background_separator"
-                android:textAppearance="?android:attr/textAppearanceSmall"
-                android:layout_marginLeft="15dp"
-                android:layout_marginRight="15dp"
-                />
-
-            <TextView
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:textAppearance="?android:attr/textAppearanceLarge"
-                android:text="@string/settings_transparency"
-                android:id="@+id/tv_setting_transparency"
-                android:paddingLeft="10dp"
-                android:paddingTop="20dp"
-                android:paddingRight="10dp"
-                android:paddingBottom="20dp"/>
-
-            <TextView
-                android:layout_width="fill_parent"
-                android:layout_height="1dp"
-                android:background="@color/background_separator"
-                android:textAppearance="?android:attr/textAppearanceSmall"
-                android:layout_marginLeft="15dp"
-                android:layout_marginRight="15dp"
-                />
-
-        </LinearLayout>
-    </com.ivalentin.margolariak.CustomScrollView>
-</LinearLayout>

+ 8 - 9
app/src/main/res/layout/row_activity_future.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical" android:layout_width="match_parent"
+              xmlns:tools="http://schemas.android.com/tools"
+              android:orientation="vertical" android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:background="@drawable/entry"
     android:padding="7dp">
@@ -46,8 +47,7 @@
                 android:textAppearance="?android:attr/textAppearanceMedium"
                 android:textStyle="italic"
                 android:layout_marginTop="4dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginLeft="8dp" />
+                android:layout_marginStart="8dp"/>
 
             <TextView
                 android:id="@+id/tv_row_activity_future_city"
@@ -56,8 +56,7 @@
                 android:textAppearance="?android:attr/textAppearanceMedium"
                 android:textStyle="italic"
                 android:layout_marginTop="4dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginLeft="8dp" />
+                android:layout_marginStart="8dp"/>
 
             <TextView
                 android:id="@+id/tv_row_activity_future_price"
@@ -66,8 +65,7 @@
                 android:textAppearance="?android:attr/textAppearanceMedium"
                 android:textStyle="italic"
                 android:layout_marginTop="4dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginLeft="8dp" />
+                android:layout_marginStart="8dp"/>
         </LinearLayout>
 
     </LinearLayout>
@@ -86,12 +84,13 @@
         android:layout_weight="1"
         android:layout_height="40dp"
         android:layout_marginTop="-40dp"
-        android:background="@drawable/gradient_v_white"/>
+        android:importantForAccessibility="no"
+        android:background="@drawable/gradient_v_white"
+        tools:ignore="InefficientWeight"/>
 
     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:text="New Text"
         android:id="@+id/tv_row_activity_future_hidden"
         android:visibility="gone" />
 </LinearLayout>

+ 6 - 4
app/src/main/res/layout/row_activity_past.xml

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              xmlns:tools="http://schemas.android.com/tools"
               android:orientation="vertical" android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:background="@drawable/entry"
@@ -53,14 +54,13 @@
                 android:id="@+id/tv_row_activity_past_date"
                 android:layout_marginStart="10dp"
                 android:textStyle="italic"
-                android:layout_marginLeft="10dp"
                 android:layout_marginTop="10dp"/>
 
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:id="@+id/tv_row_activity_past_text"
-                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:textAppearance="@android:style/TextAppearance.Medium"
                 android:layout_margin="5dp"
                 android:maxLines="4"
                 android:minHeight="30dp"/>
@@ -70,10 +70,12 @@
                 android:layout_weight="1"
                 android:layout_height="40dp"
                 android:layout_marginTop="-40dp"
-                android:background="@drawable/gradient_v_white"/>
+                android:background="@drawable/gradient_v_white"
+                android:importantForAccessibility="no"
+                tools:ignore="InefficientWeight"/>
 
         </LinearLayout>
 
     </LinearLayout>
 
-</LinearLayout>
+</LinearLayout>

+ 5 - 5
app/src/main/res/layout/row_activity_schedule.xml

@@ -52,7 +52,7 @@
         android:orientation="vertical"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_weight=".4">
+        android:layout_weight=".2">
 
         <TextView
             android:layout_width="wrap_content"
@@ -79,11 +79,11 @@
             android:layout_marginBottom="10dp">
 
             <ImageView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
                 android:id="@+id/iv_row_activity_itinerary_pinpoint"
+                android:layout_width="45dp"
+                android:layout_height="45dp"
                 android:contentDescription="@string/app_cdesc"
-                android:src="@drawable/pinpoint_map"
+                android:src="@drawable/pinpoint"
                 android:layout_gravity="center_vertical" />
 
             <LinearLayout
@@ -110,4 +110,4 @@
         </LinearLayout>
 
     </LinearLayout>
-</LinearLayout>
+</LinearLayout>

+ 0 - 4
app/src/main/res/layout/row_album.xml

@@ -17,8 +17,6 @@
         android:id="@+id/ll_row_album_left"
         android:layout_marginBottom="8dp"
         android:layout_marginEnd="8dp"
-        android:layout_marginLeft="0dp"
-        android:layout_marginRight="8dp"
         android:layout_marginStart="0dp"
         android:layout_marginTop="8dp">
 
@@ -85,8 +83,6 @@
         android:id="@+id/ll_row_album_right"
         android:layout_marginBottom="8dp"
         android:layout_marginEnd="8dp"
-        android:layout_marginLeft="0dp"
-        android:layout_marginRight="8dp"
         android:layout_marginStart="0dp"
         android:layout_marginTop="8dp"
         android:visibility="invisible">

+ 0 - 1
app/src/main/res/layout/row_comment.xml

@@ -28,7 +28,6 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:id="@+id/tv_row_comment_date"
-            android:layout_marginLeft="15dp"
             android:layout_marginStart="15dp"
             android:layout_gravity="bottom"
             android:textAppearance="@android:style/TextAppearance.Small" />

+ 0 - 1
app/src/main/res/layout/row_festival_price_day.xml

@@ -28,7 +28,6 @@
                 android:id="@+id/tv_row_festival_price_day_name"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginLeft="5dp"
                 android:layout_marginStart="5dp"
                 android:textAppearance="@android:style/TextAppearance.Medium"
                 android:textStyle="italic"/>

+ 0 - 1
app/src/main/res/layout/row_festival_price_pack.xml

@@ -29,7 +29,6 @@
                 android:id="@+id/tv_row_festival_price_pack_text"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginLeft="5dp"
                 android:layout_marginStart="5dp"
                 android:textAppearance="@android:style/TextAppearance.Medium"
                 android:textStyle="italic"/>

+ 0 - 5
app/src/main/res/layout/row_gallery.xml

@@ -28,8 +28,6 @@
             android:id="@+id/iv_row_gallery_0"
             android:background="@color/album_border"
             android:layout_alignParentTop="false"
-            android:layout_alignParentLeft="false"
-            android:layout_alignParentRight="false"
             android:layout_alignParentBottom="false"
             android:layout_marginEnd="110dp"
             android:layout_marginBottom="110dp"
@@ -51,7 +49,6 @@
             android:id="@+id/iv_row_gallery_1"
             android:background="@color/album_border"
             android:layout_alignParentTop="false"
-            android:layout_alignParentLeft="false"
             android:layout_alignParentEnd="false"
             android:layout_alignParentBottom="false"
             android:layout_marginEnd="80dp"
@@ -73,7 +70,6 @@
             android:id="@+id/iv_row_gallery_2"
             android:background="@color/album_border"
             android:layout_alignParentTop="false"
-            android:layout_alignParentLeft="false"
             android:layout_alignParentEnd="false"
             android:layout_alignParentBottom="false"
             android:layout_marginStart="80dp"
@@ -95,7 +91,6 @@
             android:id="@+id/iv_row_gallery_3"
             android:background="@color/album_border"
             android:layout_alignParentTop="false"
-            android:layout_alignParentLeft="false"
             android:layout_alignParentEnd="false"
             android:layout_alignParentBottom="false"
             android:layout_marginStart="110dp"

+ 7 - 6
app/src/main/res/layout/row_home_activities.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
     android:orientation="vertical" android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:background="@drawable/entry"
@@ -54,8 +55,7 @@
                 android:textAppearance="?android:attr/textAppearanceSmall"
                 android:textStyle="italic"
                 android:layout_marginTop="4dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginLeft="8dp"/>
+                android:layout_marginStart="8dp"/>
 
             <TextView
                 android:id="@+id/tv_row_home_activity_city"
@@ -64,8 +64,7 @@
                 android:textAppearance="?android:attr/textAppearanceSmall"
                 android:textStyle="italic"
                 android:layout_marginTop="4dp"
-                android:layout_marginStart="8dp"
-                android:layout_marginLeft="8dp"/>
+                android:layout_marginStart="8dp"/>
 
             <TextView
                 android:layout_width="fill_parent"
@@ -77,19 +76,21 @@
                 android:minHeight="30dp"/>
 
             <ImageView
+                android:importantForAccessibility="no"
                 android:layout_width="match_parent"
                 android:layout_weight="1"
                 android:layout_height="40dp"
                 android:layout_marginTop="-40dp"
-                android:background="@drawable/gradient_v_white"/>
+                android:background="@drawable/gradient_v_white"
+                tools:ignore="NestedWeights"/>
 
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:textAppearance="?android:attr/textAppearanceSmall"
                 android:id="@+id/tv_row_home_activity_price"
+                android:importantForAccessibility="no"
                 android:layout_weight="1"
-                android:layout_marginLeft="35dp"
                 android:layout_marginStart="35dp"/>
         </LinearLayout>
 

+ 3 - 1
app/src/main/res/layout/row_home_blog.xml

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              xmlns:tools="http://schemas.android.com/tools"
               android:orientation="vertical" android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:background="@drawable/entry"
@@ -54,7 +55,7 @@
                 android:textStyle="italic"
                 android:layout_marginTop="4dp"
                 android:layout_marginStart="8dp"
-                android:layout_marginLeft="8dp"/>
+                tools:ignore="NestedWeights"/>
 
             <TextView
                 android:layout_width="match_parent"
@@ -70,6 +71,7 @@
                 android:layout_weight="1"
                 android:layout_height="40dp"
                 android:layout_marginTop="-40dp"
+                android:importantForAccessibility="no"
                 android:background="@drawable/gradient_v_white"/>
 
         </LinearLayout>

+ 1 - 6
app/src/main/res/layout/row_home_schedule.xml

@@ -1,6 +1,5 @@
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
@@ -9,8 +8,6 @@
     android:padding="7dp"
     android:paddingBottom="7dp"
     android:paddingEnd="7dp"
-    android:paddingLeft="25dp"
-    android:paddingRight="7dp"
     android:paddingStart="25dp"
     android:paddingTop="7dp">
 
@@ -30,15 +27,14 @@
             android:layout_width="75dp"
             android:layout_height="wrap_content"
             android:minWidth="75dp"
-            android:text="0000"
             android:textAlignment="textEnd"
             android:textAppearance="@android:style/TextAppearance.Medium"
             android:textStyle="bold"/>
 
         <ImageView
-            android:id="@+id/imageView5"
             android:layout_width="15dp"
             android:layout_height="match_parent"
+            android:importantForAccessibility="no"
             android:layout_marginEnd="8dp"
             android:layout_marginLeft="8dp"
             android:layout_marginRight="8dp"
@@ -59,7 +55,6 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginBottom="10dp"
-        android:layout_marginLeft="55dp"
         android:layout_marginStart="55dp"
         android:layout_marginTop="5dp"
         android:gravity="center_vertical"

+ 3 - 4
app/src/main/res/layout/row_schedule.xml

@@ -20,7 +20,6 @@
             android:layout_width="20dp"
             android:layout_height="fill_parent"
             android:layout_alignParentEnd="true"
-            android:layout_alignParentRight="true"
             android:orientation="vertical" >
 
             <ImageView
@@ -47,7 +46,6 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_alignParentTop="true"
-            android:layout_toLeftOf="@id/schedule_timeline"
             android:layout_toStartOf="@id/schedule_timeline"
             android:textAppearance="?android:attr/textAppearanceMedium"
             android:textColor="@color/entry_title"
@@ -109,7 +107,7 @@
                     android:layout_height="wrap_content"
                     android:gravity="center_vertical"
                     android:textAppearance="@android:style/TextAppearance.Small"
-                    android:textColor="#000000"/>
+                    android:textColor="@color/schedule_place"/>
 
                 <TextView
                     android:id="@+id/tv_row_schedule_address"
@@ -117,6 +115,7 @@
                     android:layout_height="wrap_content"
                     android:gravity="center_vertical"
                     android:textStyle="italic"
+                    android:textColor="@color/schedule_address"
                     android:textAppearance="@android:style/TextAppearance.Small"/>
             </LinearLayout>
         </LinearLayout>
@@ -129,4 +128,4 @@
 
     </LinearLayout>
     
-</LinearLayout>
+</LinearLayout>

+ 12 - 43
app/src/main/res/values-en/strings.xml

@@ -19,16 +19,11 @@
 	<string name="menu_blog">Blog</string>
 	<string name="menu_gallery">Gallery</string>
 	<string name="menu_settings">Settings</string>
-
-	<string name="tutorial_menu">Touch the Margolariak icon or slide the screen to the right to toggle the menu.</string>
-	<string name="tutorial_content">Toca the content to navigate between sections.</string>
-	<string name="tutorial_button">Understood</string>
-
 	<!-- Schedule strings -->
 	<string name="schedule_filter">Search&#8230;</string>
 	<string name="schedule_close">Close</string>
 	<string name="schedule_host">Host: %1$s</string>
-
+	<string name="schedule_osm">® OpenStreetMap contributors</string>
 
 
 	<!-- Day strings -->
@@ -39,7 +34,6 @@
 	<!-- Home section strings -->
 
 	<string name="home_section_location">Find us</string>
-	<string name="home_section_lablanca">La Blanca</string>
 	<string name="home_section_gmschedule">Margolari Schedule</string>
 	<string name="home_section_cityschedule">City Schedule</string>
 	<string name="home_section_around">Around me</string>
@@ -53,26 +47,7 @@
 	<string name="home_section_location_text_short" tools:ignore="PluralsCandidate">They are just %1$d meters away from you!\n(About %2$d minutes walking)</string>
 	<string name="home_section_location_text_long">They are just %1$s kilometers away from you!</string>
 
-
-
-	<!-- Settings section strings -->
-
-	<string name="settings_notification">Receive notifications</string>
-	<string name="settings_notification_on">You will receive notifications</string>
-	<string name="settings_notification_off">You won\'t receive notifications</string>
-	<string name="settings_license">License</string>
-	<string name="settings_privacy">Privacy</string>
-	<string name="settings_about">About us</string>
-	<string name="settings_transparency">Transparency</string>
-	<string name="settings_license_content">Copyright 2016 Iñigo Valentin&lt;br/>&lt;br/>This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.&lt;br/>&lt;br/>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/.&lt;br/>&lt;br/>The name "Gasteizko Margolariak" and its logotype are property of Gasteizko Margolariak.&lt;br/>&lt;br/>&lt;br/>&lt;div style="background-color:#bbbbbb;padding:6px;border-radius:5px;border-style:solid;border-width:2px;border-color:#333333;text-align:center;">You can get the source code for this project at &lt;a href="https://github.com/Seavenois/GM">Github&lt;/a>&lt;/div></string>
-	<string name="settings_privacy_content"><![CDATA[In Gasteizko Margolariak we respect your privacy. We don\'t collect ANY data from our users, including personal information, location, shopping habits, sexual preferences, favourite colour, first love\'s name… ANY.<br/><br/>In order of making you believe us, we\'ll explain what we DO store:<br/><br/><ul><li>A randomly generated user code, unique to your device. This is necessary to sync content with aur database, so you can get info about our post, activities… But it\'s done in a way that won\'t allow un to identify you as a person with that number.</li><li>When commenting on a photo ar an entry, we store your current IP address. This is incredibly useful for us to know how many actual people are posting comments, and it also makes imposible for us to identify you as a person.</li></ul>]]></string>
-	<string name="settings_about_content">La Asociación Cultural Gasteizko Margolariak nace en el año 2013 con la idea de estimular la participación ciudadana y fortalecer la cultura y las tradiciones de Vitoria-Gasteiz.&lt;br/>&lt;br/>En nuestro nombre se refleja un barrio en el que las calles nos recuerdan a grandes pintores: el barrio de San Martín. Estamos representados en los barrios, y creemos que son la esencia de esta ciudad.&lt;br/>&lt;br/>Nos convertimos en Cuadrilla de Blusas y Neskas en 2013, y en ese mismo año, miembros de la Comisión de Blusas y Neskas.&lt;br/>&lt;br/>Desde entonces no hemos hecho más que crecer junto con todos los que han decidido, año tras año, apostar por nosotros.</string>
-	<string name="settings_transparency_content">¿Te preocupa saber dónde va tu dinero? En Gasteizko Margolariak queremos que estés tranquilo.&lt;br/>&lt;br/>Muchas de nuestras actividades son gratuitas. Otras, como las fiestas de La Blanca, tienen una cuota de inscripción. Gasteizko Margolariak no es una empresa, es una Asociación Cultural, y como tal, no tenemos beneficios.&lt;br/>&lt;br/>Queremos ser transparentes, y por eso, empezando en 2016, pondremos a tu disposición nuestras cuentas de manera online, para que sepas que cada euro se reinvierte en tí.</string>
-
-	
-
 	<!-- Activity section strings -->
-	<string name="activity_city">City:</string>
 	<string name="activity_price">Price:</string>
 	<string name="activity_no_future">There are no upcaming activities for now. We\'ll tell you when there is something planned!</string>
 	<string name="activity_schedule">Schedule</string>
@@ -98,8 +73,6 @@
 	<string name="lablanca_schedule">Schedule</string>
 	<string name="lablanca_schedule_city">City schedule</string>
 	<string name="lablanca_schedule_gm">Margolariak schedule</string>
-	<string name="lablanca_date_july">July %1$s</string>
-	<string name="lablanca_date_august">August %1$s</string>
 
 	<!--Schedule section strings-->
 	<string name="schedule_month_july">July</string>
@@ -138,7 +111,6 @@
 	<string name="notification_action_lablanca"> Open La Blanca </string>
 	<string name="notification_action_gmschedule"> Open Margolari schedule </string>
 	<string name="notification_action_cityschedule"> Open city schedule </string>
-	<string name="notification_action_location"> Show location </string>
 	<string name="notification_action_blog"> Open blog </string>
 	<string name="notification_action_activities"> Open activities </string>
 	<string name="notification_action_gallery"> Open gallery </string>
@@ -153,14 +125,14 @@
 	<string name="dialog_sync_text_3">Tú eres el piloto</string>
 	<string name="dialog_sync_text_4">Afinando la tuba&#8230;</string>
 	<string name="dialog_sync_text_5">Margolari camina pa\'lante, margolari camina pa\'trás.</string>
-	<string name="dialog_sync_text_6">Ari ari ari!</string>
+	<string name="dialog_sync_text_6" tools:ignore="Typos">Ari ari ari!</string>
 	<string name="dialog_sync_text_7">Llegando tarde…</string>
 	<string name="dialog_sync_text_8">¿Cabe más gente en el Foro Margolari?</string>
-	<string name="dialog_sync_text_9">Arreglando el tirador de cerveza...</string>
-	<string name="dialog_sync_text_10">Descorchando botellas...</string>
-	<string name="dialog_sync_text_11">Repartiendo pulseras...</string>
-	<string name="dialog_sync_text_12">Pintando las fiestas...</string>
-	<string name="dialog_sync_text_13">Desplegando pancarta...</string>
+	<string name="dialog_sync_text_9">Arreglando el tirador de cerveza</string>
+	<string name="dialog_sync_text_10">Descorchando botellas</string>
+	<string name="dialog_sync_text_11">Repartiendo pulseras</string>
+	<string name="dialog_sync_text_12">Pintando las fiestas</string>
+	<string name="dialog_sync_text_13">Desplegando pancarta</string>
 	<string name="dialog_sync_failed_title">Synchronization failed</string>
 	<string name="dialog_sync_failed_text">Couldn\'t download content.\n\nMake sure you have a network connection and try again.</string>
 	<string name="dialog_sync_failed_close">Close</string>
@@ -170,15 +142,15 @@
 	<string name="lablanca_nofestivals_2_title">Dormir es de cobardes:</string>
 	<string name="lablanca_nofestivals_2"><![CDATA[Casi todos los días organizamos actividades desde la mañana, ya sean almuerzos, actividades para el público general o competiciones en los Herri Kirolak. Después solemos ir a comer juntos, antes de los paseillos, y después, siempre cenamos juntos. Y por la noche, hasta que el cuerpo aguante!]]></string>
 	<string name="lablanca_nofestivals_3_title">Especialistas en paseillos:</string>
-	<string name="lablanca_nofestivals_3"><![CDATA[A la hora de hacer paseillos, no hay quien nos gane. Con nuestra furgoneta siempre abierta a la cabeza, y la txaranga El Postín animando desde atrás, es imposible aburrirse. Y entre paseillos tampoco descansamos, siempre estamos organizando cosas: juegos, carreras, bingos, música, ida a las barracas...]]></string>
+	<string name="lablanca_nofestivals_3"><![CDATA[A la hora de hacer paseillos, no hay quien nos gane. Con nuestra furgoneta siempre abierta a la cabeza, y la txaranga El Postín animando desde atrás, es imposible aburrirse. Y entre paseillos tampoco descansamos, siempre estamos organizando cosas: juegos, carreras, bingos, música, ida a las barracas]]></string>
 	<string name="lablanca_nofestivals_4_title">Nos gusta comer:</string>
 	<string name="lablanca_nofestivals_4"><![CDATA[No queremos que un Margolari pase hambre. Las comidas en Gasteizko Margolariak son en restaurante, con un buen men&ú, que nos den fuerzas para aguantar el resto del día. Las cenas las hacemos bien en la calle o bien en restaurante, pero siempre con comida buena y caliente. Los mismo que los almuerzos.]]></string>
 	<string name="lablanca_nofestivals_5_title">Y beber:</string>
 	<string name="lablanca_nofestivals_5"><![CDATA[Sea cual sea tu veneno, lo tenemos: Ron, vodka, kalimotxo, cerveza, whiskey, agua, refrescos Durante los paseillos (y varias veces m&aacute;s a lo largo del d&iacute;a) en la furgoneta tendr&aacute;s barra libre de todo lo que quieras.]]></string>
 	<string name="lablanca_nofestivals_6_title">Nos apuntamos a un bombardeo:</string>
-	<string name="lablanca_nofestivals_6"><![CDATA[Carrera de Barricas, Herri Kirolak... Nunca hemos faltado a nada. Ganar, lo que es ganar, aún lo tenemos pendiente, pero lo pasamos bien. Así que ya sabes, si quieres representar a Gasteizko Margolariak, avísanos!]]></string>
+	<string name="lablanca_nofestivals_6"><![CDATA[Carrera de Barricas, Herri Kirolak Nunca hemos faltado a nada. Ganar, lo que es ganar, aún lo tenemos pendiente, pero lo pasamos bien. Así que ya sabes, si quieres representar a Gasteizko Margolariak, avísanos!]]></string>
 	<string name="lablanca_nofestivals_7_title">Por la ciudad, para la ciudad:</string>
-	<string name="lablanca_nofestivals_7"><![CDATA[No nos gusta mirarnos el ombligo. Aunque la mayor parte de actividades que organizamos son para los miembros de Gasteizko Margolariak, hay otras que son para todo el público. Hasta ahora hemos organizado talleres de Cesta Punta para txikis, Margotxef (un concurso de cocina infantil), visitas a residencias de ancianos...]]></string>
+	<string name="lablanca_nofestivals_7"><![CDATA[No nos gusta mirarnos el ombligo. Aunque la mayor parte de actividades que organizamos son para los miembros de Gasteizko Margolariak, hay otras que son para todo el público. Hasta ahora hemos organizado talleres de Cesta Punta para txikis, Margotxef (un concurso de cocina infantil), visitas a residencias de ancianos]]></string>
 	<string name="lablanca_nofestivals_8_title">Margolaris:</string>
 	<string name="lablanca_nofestivals_8"><![CDATA[Todo lo demás no sirve de nada si en una cuadrilla no hay buen ambiente. En Gasteizko Margolariak podemos presumir de gente cercana, participativa, capaz de hacer que desde el primer día ya te sientas como en casa. Además, los organizadores son gente cercana, que escucha y está siempre abierta a nuevas propuestas. Por esto, quien prueba, repite.]]></string>
 	<string name="home_section_location_text_calculating">Calculating distance…</string>
@@ -189,18 +161,16 @@
 	<string name="sponsors_url">Open web site</string>
 
 	<!-- Us -->
-	<string name="us_title">Nosotros</string>
 	<string name="us_association">La asociación</string>
 	<string name="us_association_content">La Asociación Cultural Gasteizko Margolariak nace en el año 2013 con la idea de estimular la participación ciudadana y fortalecer la cultura y las tradiciones de Vitoria-Gasteiz.\n\nEn nuestro nombre se refleja un barrio en el que las calles nos recuerdan a grandes pintores: el barrio de San Martín. Estamos representados en los barrios, y creemos que son la esencia de esta ciudad.</string>
 	<string name="us_cuadrilla">La cuadrilla</string>
 	<string name="us_cuadrilla_content">Nos convertimos en Cuadrilla de Blusas y Neskas en 2013, y en ese mismo año, miembros de la Comisión de Blusas y Neskas.\n\nDesde entonces no hemos hecho mas que crecer junto con todos los que han decidido, año tras año, apostar por nosotros.</string>
 	<string name="us_activities">Lo que hacemos</string>
-	<string name="us_activities_content">Excursiones, partidos, causas benéficas... No solo se nos ve en fiestas.\n\nCreemos que, como Cuadrilla de Blusas y Neskas, existimos por y para la ciudad, y por eso organizamos actividades durante todo el año, para todo aquel que quiera acompañarnos.</string>
+	<string name="us_activities_content">Excursiones, partidos, causas benéficas No solo se nos ve en fiestas.\n\nCreemos que, como Cuadrilla de Blusas y Neskas, existimos por y para la ciudad, y por eso organizamos actividades durante todo el año, para todo aquel que quiera acompañarnos.</string>
 	<string name="us_transparency">Transparencia</string>
 	<string name="us_transparency_content">¿Te preocupa saber dónde va tu dinero? En Gasteizko Margolariak queremos que estés tranquilo.\n\nMuchas de nuestras actividades son gratuitas. Otras, como las fiestas de La Blanca, tienen una cuota de inscripción. Gasteizko Margolariak no es una empresa, es una Asociación Cultural, y como tal, no tenemos beneficios.\n\nQueremos ser transparentes, y por eso, empezando en 2017, pondremos a tu disposición nuestras cuentas de manera online, para que sepas que cada euro se reinvierte en ti.</string>
 
 
-	<string name="preferences">Preferences</string>
 	<string name="preferences_info">Information</string>
 	<string name="preferences_info_feedback">Feedback</string>
 	<string name="preferences_info_feedback_summary">Send anonymous feedback to the developer</string>
@@ -209,7 +179,6 @@
 	<string name="preferences_info_version">App version</string>
 	<string name="preferences_sync">Sync</string>
 	<string name="preferences_sync_notifications">Notifications</string>
-	<string name="preferences_sync_usage">Background data usage</string>
 	<string name="preferences_sync_sync_on">Background sync is enabled</string>
 	<string name="preferences_sync_notifications_on">Notifications will be received</string>
 	<string name="preferences_sync_notifications_off">Notifications will not be received</string>
@@ -219,7 +188,6 @@
 	<string name="changelog">Changelog</string>
 
 	<!-- Share menu -->
-	<string name="share">Share</string>
 	<string name="share_with">Share using…</string>
 	<string name="share_home">Gasteizko Margolariak</string>
 	<string name="share_lablanca">La Blanca - Gasteizko Margolariak</string>
@@ -229,5 +197,6 @@
 	<string name="share_with_title">%s - Gasteizko Margolariak</string>
 
 	<string name="accept">Accept</string>
+	<string name="schedule_sponsor">Sponsor: %1$s</string>
 
 </resources>

+ 11 - 37
app/src/main/res/values-eu-rES/strings.xml

@@ -26,15 +26,12 @@
 	<string name="menu_gallery">Galeria</string>
 	<string name="menu_settings">Ezarpenak</string>
 
-	<string name="tutorial_menu">Toca el icono de Margolariak o desliza la pantalla hacia la derecha para ver el menú.</string>
-	<string name="tutorial_content">Toca cualquier entrada para ir a la sección correspondiente.</string>
-	<string name="tutorial_button">Entendido</string>
-
 	<!-- Schedule strings -->
 
 	<string name="schedule_filter">Bilatu…</string>
 	<string name="schedule_close">Itzali</string>
 	<string name="schedule_host">Antolatu: %1$s</string>
+        <string name="schedule_osm">® Colaboradores OpenStreetMap</string>
 
 
 	<!-- Day strings -->
@@ -46,7 +43,6 @@
 	<!-- Home section strings -->
 
 	<string name="home_section_location">Aurkitu Gasteizko Margolariak</string>
-	<string name="home_section_lablanca">Andre Zuria</string>
 	<string name="home_section_gmschedule">Margolari Programa</string>
 	<string name="home_section_cityschedule">Jaiako programa</string>
 	<string name="home_section_around">Nire ondoan</string>
@@ -61,13 +57,7 @@
 	<string name="home_section_location_text_long">Zure inguruan %1$s kilometrokoan daude!</string>
 
 
-	<!-- Settings section strings -->
-
-	<string name="settings_notification">Notifikazioiak</string>
-
-
 	<!-- Activity section strings -->
-	<string name="activity_city">Hiria:</string>
 	<string name="activity_price">Prezioa:</string>
 	<string name="activity_no_future">Oraindik ex dira datozen jarduerak. Bat prestatzen dugunean, hemen agertzeko da.</string>
 	<string name="activity_schedule">Ordutegia</string>
@@ -93,8 +83,6 @@
 	<string name="lablanca_schedule">Programa</string>
 	<string name="lablanca_schedule_city">Jaiako programa</string>
 	<string name="lablanca_schedule_gm">Margolari programa</string>
-	<string name="lablanca_date_july">Uztalaren %1$san</string>
-	<string name="lablanca_date_august">Abuztuaren %1$san</string>
 
 	<!--Schedule section strings-->
 	<string name="schedule_month_july">Uztaila</string>
@@ -132,7 +120,6 @@
 	<string name="notification_action_lablanca">Ireki Andre Zuria</string>
 	<string name="notification_action_gmschedule">Ikusi Margolari programa</string>
 	<string name="notification_action_cityschedule">Ireki jaiako programa</string>
-	<string name="notification_action_location">Ikus lokalizazioia</string>
 	<string name="notification_action_blog">Ireki blog</string>
 	<string name="notification_action_activities">Ireki ekitaldiak</string>
 	<string name="notification_action_gallery">Ireki galeria</string>
@@ -144,14 +131,6 @@
 	<string name="dialog_sync_failed_title">Sinkronizazioko errakuntza</string>
 	<string name="dialog_sync_failed_close">Itxali</string>
 	<string name="price">Prezioa: %1$d €</string>
-	<string name="settings_about">Gu</string>
-	<string name="settings_about_content"><![CDATA[La Asociación Cultural Gasteizko Margolariak nace en el año 2013 con la idea de estimular la participación ciudadana y fortalecer la cultura y las tradiciones de Vitoria-Gasteiz.<br/><br/>En nuestro nombre se refleja un barrio en el que las calles nos recuerdan a grandes pintores: el barrio de San Martín. Estamos representados en los barrios, y creemos que son la esencia de esta ciudad.<br/><br/>Nos convertimos en Cuadrilla de Blusas y Neskas en 2013, y en ese mismo año, miembros de la Comisión de Blusas y Neskas.<br/><br/>Desde entonces no hemos hecho más que crecer junto con todos los que han decidido, año tras año, apostar por nosotros.]]></string>
-	<string name="settings_license">Lizentzia</string>
-	<string name="settings_license_content"><![CDATA[Copyright 2016 Iñigo Valentin<br/><br/>This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.<br/><br/>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/.<br/><br/>The name "Gasteizko Margolariak" and its logotype are property of Gasteizko Margolariak.<br/><br/><br/><div style="background-color:#bbbbbb;padding:6px;border-radius:5px;border-style:solid;border-width:2px;border-color:#333333;text-align:center;">You can get the source code for this project at <a href="https://github.com/Seavenois/GM">Github</a></div>]]></string>
-	<string name="settings_privacy">Pribazitatea</string>
-	<string name="settings_transparency">Transparentzia</string>
-	<string name="settings_privacy_content"><![CDATA[En Gasteizko Margolariak respetamos tu privacidad. No guardamos NINGÚN dato de nuestros usuarios, incluyendo información personal, localización, hábitos de compra, preferencias sexuales, color favorito, nombre de su primer amor… NINGUNO.<br/><br/>Para que nos creas, te explicamos lo que sí almacenamos:<br/><br/><ul><li>Un código de usuario, generado aleatoriamente, único para tu dispositivo. Esto es necesario para sincronizar la aplicación con nuestra base de datos y poder descargar los últimos posts, actividades… Pero esta hecho de tal manera que no podamos identificarte como persona a través de ese código.</li><li>Al publicar un comentario en una entrada o una foto, guardaremos temporalmente (120 minutos, lo justo para procesar información) tu dirección IP. Esto nos es súper útil para saber cuántas personas diferentes publican comentarios, y tampoco nos permite identificarte como persona.</li></ul>]]></string>
-	<string name="settings_transparency_content"><![CDATA[¿Te preocupa saber dónde va tu dinero? En Gasteizko Margolariak queremos que estés tranquilo.<br/><br/>Muchas de nuestras actividades son gratuitas. Otras, como las fiestas de La Blanca, tienen una cuota de inscripción. Gasteizko Margolariak no es una empresa, es una Asociación Cultural, y como tal, no tenemos beneficios.<br/><br/>Queremos ser transparentes, y por eso, empezando en 2016, pondremos a tu disposición nuestras cuentas de manera online, para que sepas que cada euro se reinvierte en tí.]]></string>
 	<string name="dialog_sync_text_0">Locating Don Margolo&#8230;</string>
 	<string name="dialog_sync_text_1">Starting up the van&#8230;</string>
 	<string name="dialog_sync_text_2">Serving kalimotxos&#8230;</string>
@@ -161,11 +140,11 @@
 	<string name="dialog_sync_text_6">Ari ari ari!</string>
 	<string name="dialog_sync_text_7">Llegando tarde…</string>
 	<string name="dialog_sync_text_8">¿Cabe más gente en el Foro Margolari?</string>
-	<string name="dialog_sync_text_9">Arreglando el tirador de cerveza...</string>
-	<string name="dialog_sync_text_10">Descorchando botellas...</string>
-	<string name="dialog_sync_text_11">Repartiendo pulseras...</string>
-	<string name="dialog_sync_text_12">Pintando las fiestas...</string>
-	<string name="dialog_sync_text_13">Desplegando pancarta...</string>
+	<string name="dialog_sync_text_9">Arreglando el tirador de cerveza</string>
+	<string name="dialog_sync_text_10">Descorchando botellas</string>
+	<string name="dialog_sync_text_11">Repartiendo pulseras</string>
+	<string name="dialog_sync_text_12">Pintando las fiestas</string>
+	<string name="dialog_sync_text_13">Desplegando pancarta</string>
 	<string name="dialog_sync_failed_text">No se pudierdon descargar los contenidos\n\nAsegúrate de que dispones de conexión a internet e inténtalo de nuevo.</string>
 	<string name="lablanca_nofestivals"><![CDATA[Las Fiestas de La Blanca. Esos días, del 4 al 9 de agosto, en los que Vitoria-Gasteiz se transforma. Se llena de color y alegría, y en cada esquina puedes encontrar actividades y espectáculos. Todos las estamos esperando.\n\nPor desgracia, aún hay que esperar más.\n\nNosotros ya estamos trabajando en ello. Tan pronto como vayamos sabiendo más, aquí iremos publicando nuestro programa y otra información sobre las fiestas. Para ir abriendo boca, dejanos contarte algunas de las claves del plan Margolari de fiestas:]]></string>
 	<string name="lablanca_nofestivals_1_title">Planes que se adaptan a tí:</string>
@@ -173,19 +152,17 @@
 	<string name="lablanca_nofestivals_2_title">Dormir es de cobardes:</string>
 	<string name="lablanca_nofestivals_2"><![CDATA[Casi todos los días organizamos actividades desde la mañana, ya sean almuerzos, actividades para el público general o competiciones en los Herri Kirolak. Después solemos ir a comer juntos, antes de los paseillos, y después, siempre cenamos juntos. Y por la noche, hasta que el cuerpo aguante!]]></string>
 	<string name="lablanca_nofestivals_3_title">Especialistas en paseillos:</string>
-	<string name="lablanca_nofestivals_3"><![CDATA[A la hora de hacer paseillos, no hay quien nos gane. Con nuestra furgoneta siempre abierta a la cabeza, y la txaranga El Postín animando desde atrás, es imposible aburrirse. Y entre paseillos tampoco descansamos, siempre estamos organizando cosas: juegos, carreras, bingos, música, ida a las barracas...]]></string>
+	<string name="lablanca_nofestivals_3"><![CDATA[A la hora de hacer paseillos, no hay quien nos gane. Con nuestra furgoneta siempre abierta a la cabeza, y la txaranga El Postín animando desde atrás, es imposible aburrirse. Y entre paseillos tampoco descansamos, siempre estamos organizando cosas: juegos, carreras, bingos, música, ida a las barracas]]></string>
 	<string name="lablanca_nofestivals_4_title">Nos gusta comer:</string>
 	<string name="lablanca_nofestivals_4"><![CDATA[No queremos que un Margolari pase hambre. Las comidas en Gasteizko Margolariak son en restaurante, con un buen men&ú, que nos den fuerzas para aguantar el resto del día. Las cenas las hacemos bien en la calle o bien en restaurante, pero siempre con comida buena y caliente. Los mismo que los almuerzos.]]></string>
 	<string name="lablanca_nofestivals_5_title">Y beber:</string>
 	<string name="lablanca_nofestivals_5"><![CDATA[Sea cual sea tu veneno, lo tenemos: Ron, vodka, kalimotxo, cerveza, whiskey, agua, refrescos Durante los paseillos (y varias veces m&aacute;s a lo largo del d&iacute;a) en la furgoneta tendr&aacute;s barra libre de todo lo que quieras.]]></string>
 	<string name="lablanca_nofestivals_6_title">Nos apuntamos a un bombardeo:</string>
-	<string name="lablanca_nofestivals_6"><![CDATA[Carrera de Barricas, Herri Kirolak... Nunca hemos faltado a nada. Ganar, lo que es ganar, aún lo tenemos pendiente, pero lo pasamos bien. Así que ya sabes, si quieres representar a Gasteizko Margolariak, avísanos!]]></string>
+	<string name="lablanca_nofestivals_6"><![CDATA[Carrera de Barricas, Herri Kirolak Nunca hemos faltado a nada. Ganar, lo que es ganar, aún lo tenemos pendiente, pero lo pasamos bien. Así que ya sabes, si quieres representar a Gasteizko Margolariak, avísanos!]]></string>
 	<string name="lablanca_nofestivals_7_title">Por la ciudad, para la ciudad:</string>
-	<string name="lablanca_nofestivals_7"><![CDATA[No nos gusta mirarnos el ombligo. Aunque la mayor parte de actividades que organizamos son para los miembros de Gasteizko Margolariak, hay otras que son para todo el público. Hasta ahora hemos organizado talleres de Cesta Punta para txikis, Margotxef (un concurso de cocina infantil), visitas a residencias de ancianos...]]></string>
+	<string name="lablanca_nofestivals_7"><![CDATA[No nos gusta mirarnos el ombligo. Aunque la mayor parte de actividades que organizamos son para los miembros de Gasteizko Margolariak, hay otras que son para todo el público. Hasta ahora hemos organizado talleres de Cesta Punta para txikis, Margotxef (un concurso de cocina infantil), visitas a residencias de ancianos]]></string>
 	<string name="lablanca_nofestivals_8_title">Margolaris:</string>
 	<string name="lablanca_nofestivals_8"><![CDATA[Todo lo demás no sirve de nada si en una cuadrilla no hay buen ambiente. En Gasteizko Margolariak podemos presumir de gente cercana, participativa, capaz de hacer que desde el primer día ya te sientas como en casa. Además, los organizadores son gente cercana, que escucha y está siempre abierta a nuevas propuestas. Por esto, quien prueba, repite.]]></string>
-	<string name="settings_notification_off">No recibir notificaciones</string>
-	<string name="settings_notification_on">Recibir notificaciones</string>
 	<string name="home_section_location_text_calculating">Calculando distancia…</string>
 	<string name="pop_menu_share">Bitarte</string>
 	<string name="pop_menu_about">Gu</string>
@@ -194,13 +171,12 @@
 	<string name="sponsors_url">Web horria</string>
 
 	<!-- Us -->
-	<string name="us_title">Nosotros</string>
 	<string name="us_association">La asociación</string>
 	<string name="us_association_content">La Asociación Cultural Gasteizko Margolariak nace en el año 2013 con la idea de estimular la participación ciudadana y fortalecer la cultura y las tradiciones de Vitoria-Gasteiz.\n\nEn nuestro nombre se refleja un barrio en el que las calles nos recuerdan a grandes pintores: el barrio de San Martín. Estamos representados en los barrios, y creemos que son la esencia de esta ciudad.</string>
 	<string name="us_cuadrilla">La cuadrilla</string>
 	<string name="us_cuadrilla_content">Nos convertimos en Cuadrilla de Blusas y Neskas en 2013, y en ese mismo año, miembros de la Comisión de Blusas y Neskas.\n\nDesde entonces no hemos hecho mas que crecer junto con todos los que han decidido, año tras año, apostar por nosotros.</string>
 	<string name="us_activities">Lo que hacemos</string>
-	<string name="us_activities_content">Excursiones, partidos, causas benéficas... No solo se nos ve en fiestas.\n\nCreemos que, como Cuadrilla de Blusas y Neskas, existimos por y para la ciudad, y por eso organizamos actividades durante todo el año, para todo aquel que quiera acompañarnos.</string>
+	<string name="us_activities_content">Excursiones, partidos, causas benéficas No solo se nos ve en fiestas.\n\nCreemos que, como Cuadrilla de Blusas y Neskas, existimos por y para la ciudad, y por eso organizamos actividades durante todo el año, para todo aquel que quiera acompañarnos.</string>
 	<string name="us_transparency">Transparencia</string>
 	<string name="us_transparency_content">¿Te preocupa saber dónde va tu dinero? En Gasteizko Margolariak queremos que estés tranquilo.\n\nMuchas de nuestras actividades son gratuitas. Otras, como las fiestas de La Blanca, tienen una cuota de inscripción. Gasteizko Margolariak no es una empresa, es una Asociación Cultural, y como tal, no tenemos beneficios.\n\nQueremos ser transparentes, y por eso, empezando en 2017, pondremos a tu disposición nuestras cuentas de manera online, para que sepas que cada euro se reinvierte en ti.</string>
 
@@ -216,15 +192,12 @@
 	<string name="preferences_sync_notifications_off">No se recibirán notificaciones</string>
 	<string name="preferences_sync_notifications_on">Se recibirán notificaciones</string>
 	<string name="preferences_sync_sync_on">Sincronización activada</string>
-	<string name="preferences_sync_usage">Uso de datos</string>
-	<string name="preferences">Preferences</string>
 	<string name="preferences_info_feedback">Feedback</string>
 	<string name="preferences_sync_sync">Sincronización en segundo plano</string>
 	<string name="preferences_sync_sync_off">Sincronización desactivada</string>
 	<string name="changelog">Changelog</string>
 
 	<!-- Share menu -->
-	<string name="share">Compartir</string>
 	<string name="share_with">Enviar con…</string>
 	<string name="share_home">Gasteizko Margolariak</string>
 	<string name="share_lablanca">Andre Zuria - Gasteizko Margolariak</string>
@@ -234,5 +207,6 @@
 	<string name="share_with_title">%s - Gasteizko Margolariak</string>
 
 	<string name="accept">Aceptar</string>
+    <string name="schedule_sponsor">Patrocina %1$s</string>
 
 </resources>

+ 0 - 16
app/src/main/res/values-v11/styles.xml

@@ -1,16 +0,0 @@
-<resources>
-
-    <!--
-        Base application theme for API 11+. This theme completely replaces
-        AppBaseTheme from res/values/styles.xml on API 11+ devices.
-    -->
-    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
-        <!-- API 11 theme customizations can go here. -->
-    </style>
-    
-    <style name="Theme.Default" parent="Theme.AppCompat.Light"></style>
-    <style name="Theme.NoTitle" parent="Theme.AppCompat.Light.NoActionBar"></style>
-    <style name="Theme.FullScreen" parent="Theme.AppCompat.Light.NoActionBar"></style>
-    
-
-</resources>

+ 0 - 17
app/src/main/res/values-v14/styles.xml

@@ -1,17 +0,0 @@
-<resources>
-
-    <!--
-        Base application theme for API 14+. This theme completely replaces
-        AppBaseTheme from BOTH res/values/styles.xml and
-        res/values-v11/styles.xml on API 14+ devices.
-    -->
-    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
-        <!-- API 14 theme customizations can go here. -->
-    </style>
-    
-    <style name="Theme.Default" parent="Theme.AppCompat.Light"></style>
-    <style name="Theme.NoTitle" parent="Theme.AppCompat.Light.NoActionBar"></style>
-    <style name="Theme.FullScreen" parent="Theme.AppCompat.Light.NoActionBar"></style>
-    
-
-</resources>

+ 0 - 10
app/src/main/res/values-v21/styles.xml

@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
-    <style name="Theme.AppBaseTheme" parent="android:Theme.Material.Light">
-        <item name="android:colorPrimary">@color/background_menu</item>
-        <item name="android:colorPrimaryDark">@color/background_menu</item>
-        <item name="android:colorAccent">@color/background_menu</item>
-        <item name="android:colorBackground">@color/background_app</item>
-    </style>
-</resources>

+ 0 - 5
app/src/main/res/values-v24/styles.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources xmlns:tools="http://schemas.android.com/tools">
-    <style name="Base.TextAppearance.AppCompat.Widget.Button.Borderless.Colored" parent="android:TextAppearance.Material.Widget.Button" tools:override="true" />
-    <style name="Base.TextAppearance.AppCompat.Widget.Button.Colored" parent="android:TextAppearance.Material.Widget.Button" tools:override="true" />
-</resources>

+ 12 - 2
app/src/main/res/values/color.xml

@@ -20,7 +20,7 @@
     <!--Color for the border of the image-->
     <color name="image_border">#292690</color>
     
-    <!--Color for the menu entries-->
+    <!-- Color for the menu entries -->
     <color name="menu_entry">#ffffff</color>
 
     <!-- Colors for top bar -->
@@ -29,7 +29,7 @@
     <color name="background_bar_gradient">#bdf8fd</color>
     <color name="menu_selected">#ccccff</color>
 
-    <!--Color for input fields-->
+    <!-- Color for input fields -->
     <color name="input_background">#ccddff</color>
     <color name="input_border">#0078ff</color>
     <color name="input_text_color">#0078ff</color>
@@ -38,8 +38,18 @@
     <color name="input_button_color">#cccccc</color>
     <color name="input_button_background_pressed">#446688</color>
 
+    <!-- Color for maps -->
+    <color name="map_border">#0077ff</color>
+    <color name="map_background">#ffffff</color>
+    <color name="map_route">#0022aa</color>
 
+    <!--Colors for album covers -->
     <color name="album_border">#111111</color>
     <color name="album_background">#aaaaaa</color>
 
+    <!-- Color for schedule rows -->
+    <color name="schedule_place">#555577</color>
+    <color name="schedule_address">#8888aa</color>
+
 </resources>
+

+ 16 - 48
app/src/main/res/values/strings.xml

@@ -30,15 +30,13 @@
 	<string name="menu_gallery">Galería</string>
 	<string name="menu_settings">Preferencias</string>
 
-	<string name="tutorial_menu">Toca el icono de Margolariak o desliza la pantalla hacia la derecha para ver el menú.</string>
-	<string name="tutorial_content">Toca cualquier entrada para ir a la sección correspondiente.</string>
-	<string name="tutorial_button">Entendido</string>
-
 	<!-- Schedule strings -->
 
 	<string name="schedule_filter">Buscar&#8230;</string>
 	<string name="schedule_close">Cerrar</string>
 	<string name="schedule_host">Organiza %1$s</string>
+	<string name="schedule_sponsor">Patrocina %1$s</string>
+	<string name="schedule_osm">® Colaboradores OpenStreetMap</string>
 
 
 	<!-- Day strings -->
@@ -58,16 +56,6 @@
 	<string name="home_section_social">Síguenos</string>
 
 
-	<!-- Prices dialog strings -->
-
-
-	<!-- Settings section strings -->
-
-	<string name="settings_notification">Notificaciones</string>
-	<string name="settings_notification_on">Recibir notificaciones</string>
-	<string name="settings_notification_off">No recibir notificaciones</string>
-
-
 	<!-- Social networks strings -->
 
 	<string name="social_phone" translatable="false">Phone</string>
@@ -101,7 +89,6 @@
 	<string name="dialog_sync_failed_title">Error de sincronización</string>
 	<string name="dialog_sync_failed_text">No se pudierdon descargar los contenidos\n\nAsegúrate de que dispones de conexión a internet e inténtalo de nuevo.</string>
 	<string name="dialog_sync_failed_close">Cerrar</string>
-	<string name="activity_city">Cudad:</string>
 	<string name="activity_future">Próximas actividades</string>
 	<string name="activity_no_future">No hay actividades planeadas proximamanete. Cuando organicemos algo, aparecera aquí.</string>
 	<string name="activity_past">Actividades pasadas</string>
@@ -117,20 +104,20 @@
 		<item quantity="one">%1$d comentario</item>
 		<item quantity="other">%1$d comentarios</item>
 	</plurals>
-	<string name="dialog_sync_text_0">Contactando con Don Margolo&#8230;</string>
-	<string name="dialog_sync_text_1">Arrancando la furgo&#8230;</string>
-	<string name="dialog_sync_text_2">Preparando kalimotxos&#8230;</string>
+	<string name="dialog_sync_text_0">Contactando con Don Margolo</string>
+	<string name="dialog_sync_text_1">Arrancando la furgo</string>
+	<string name="dialog_sync_text_2">Preparando kalimotxos</string>
 	<string name="dialog_sync_text_3">Tú eres el piloto</string>
-	<string name="dialog_sync_text_4">Afinando la tuba&#8230;</string>
+	<string name="dialog_sync_text_4">Afinando la tuba</string>
 	<string name="dialog_sync_text_5">Margolari camina pa\'lante, margolari camina pa\'trás.</string>
-	<string name="dialog_sync_text_6">Ari ari ari!</string>
+	<string name="dialog_sync_text_6" tools:ignore="Typos">Ari ari ari!</string>
 	<string name="dialog_sync_text_7">Llegando tarde…</string>
 	<string name="dialog_sync_text_8">¿Cabe más gente en el Foro Margolari?</string>
-	<string name="dialog_sync_text_9">Arreglando el tirador de cerveza...</string>
-	<string name="dialog_sync_text_10">Descorchando botellas...</string>
-	<string name="dialog_sync_text_11">Repartiendo pulseras...</string>
-	<string name="dialog_sync_text_12">Pintando las fiestas...</string>
-	<string name="dialog_sync_text_13">Desplegando pancarta...</string>
+	<string name="dialog_sync_text_9">Arreglando el tirador de cerveza</string>
+	<string name="dialog_sync_text_10">Descorchando botellas</string>
+	<string name="dialog_sync_text_11">Repartiendo pulseras</string>
+	<string name="dialog_sync_text_12">Pintando las fiestas</string>
+	<string name="dialog_sync_text_13">Desplegando pancarta</string>
 	<string name="gallery_albums">Albums</string>
 	<string name="gallery_upload">Subir fotos</string>
 	<string name="gallery_upload_button">Subir</string>
@@ -144,8 +131,6 @@
 	<string name="home_section_location_text_short" tools:ignore="PluralsCandidate">¡Están a solo %1$d metros de ti! (Unos %2$d minutos andando)</string>
 	<string name="home_section_location_text_long">¡Están a solo %1$s kilometros de ti!</string>
 	<string name="home_section_location_text_calculating">Calculando distancia…</string>
-	<string name="lablanca_date_august">%1$s de agosto</string>
-	<string name="lablanca_date_july">%1$s de julio</string>
 	<string name="lablanca_prices">Precios</string>
 	<string name="lablanca_prices_days">Días sueltos</string>
 	<string name="lablanca_prices_pack">Packs</string>
@@ -163,40 +148,30 @@
 	<string name="home_section_blog">Últimos posts</string>
 	<string name="home_section_cityschedule">Programa de fiestas</string>
 	<string name="home_section_gallery">Últimas fotos</string>
-	<string name="home_section_lablanca">La Blanca</string>
 	<string name="home_section_activities_past">Últimas actividades</string>
 	<string name="notification_action_activities">Ver actividades</string>
 	<string name="notification_action_blog">Abrir blog</string>
 	<string name="notification_action_cityschedule">Programa de fiestas</string>
 	<string name="notification_action_gallery">Abrir galería</string>
 	<string name="notification_action_lablanca">Abrir La Blanca</string>
-	<string name="notification_action_location">Ver localización</string>
 	<string name="price">Precio: %1$d €</string>
-	<string name="settings_about">Sobre nosotros</string>
-	<string name="settings_license">Licencia</string>
-	<string name="settings_license_content"><![CDATA[Copyright 2016 Iñigo Valentin<br/><br/>This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.<br/><br/>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details at http://www.gnu.org/licenses/.<br/><br/>The name "Gasteizko Margolariak" and its logotype are property of Gasteizko Margolariak.<br/><br/><br/><div style="background-color:#bbbbbb;padding:6px;border-radius:5px;border-style:solid;border-width:2px;border-color:#333333;text-align:center;">You can get the source code for this project at <a href="https://github.com/Seavenois/GM">Github</a></div>]]></string>
-	<string name="settings_privacy">Privacidad</string>
-	<string name="settings_privacy_content"><![CDATA[En Gasteizko Margolariak respetamos tu privacidad. No guardamos NINGÚN dato de nuestros usuarios, incluyendo información personal, localización, hábitos de compra, preferencias sexuales, color favorito, nombre de su primer amor… NINGUNO.<br/><br/>Para que nos creas, te explicamos lo que sí almacenamos:<br/><br/><ul><li>Un código de usuario, generado aleatoriamente, único para tu dispositivo. Esto es necesario para sincronizar la aplicación con nuestra base de datos y poder descargar los últimos posts, actividades… Pero esta hecho de tal manera que no podamos identificarte como persona a través de ese código.</li><li>Al publicar un comentario en una entrada o una foto, guardaremos temporalmente (120 minutos, lo justo para procesar información) tu dirección IP. Esto nos es súper útil para saber cuántas personas diferentes publican comentarios, y tampoco nos permite identificarte como persona.</li></ul>]]></string>
-	<string name="settings_transparency">Transparencia</string>
-	<string name="settings_transparency_content"><![CDATA[¿Te preocupa saber dónde va tu dinero? En Gasteizko Margolariak queremos que estés tranquilo.<br/><br/>Muchas de nuestras actividades son gratuitas. Otras, como las fiestas de La Blanca, tienen una cuota de inscripción. Gasteizko Margolariak no es una empresa, es una Asociación Cultural, y como tal, no tenemos beneficios.<br/><br/>Queremos ser transparentes, y por eso, empezando en 2016, pondremos a tu disposición nuestras cuentas de manera online, para que sepas que cada euro se reinvierte en tí.]]></string>
 	<string name="lablanca_nofestivals"><![CDATA[Las Fiestas de La Blanca. Esos días, del 4 al 9 de agosto, en los que Vitoria-Gasteiz se transforma. Se llena de color y alegría, y en cada esquina puedes encontrar actividades y espectáculos. Todos las estamos esperando.\n\nPor desgracia, aún hay que esperar más.\n\nNosotros ya estamos trabajando en ello. Tan pronto como vayamos sabiendo más, aquí iremos publicando nuestro programa y otra información sobre las fiestas. Para ir abriendo boca, dejanos contarte algunas de las claves del plan Margolari de fiestas:]]></string>
 	<string name="lablanca_nofestivals_1_title">Planes que se adaptan a tí:</string>
 	<string name="lablanca_nofestivals_1"><![CDATA[Puedes apuntarte días sueltos, o elegir entre las varias ofertas por varios días para conseguir descuentos.]]></string>
 	<string name="lablanca_nofestivals_2_title">Dormir es de cobardes:</string>
 	<string name="lablanca_nofestivals_2"><![CDATA[Casi todos los días organizamos actividades desde la mañana, ya sean almuerzos, actividades para el público general o competiciones en los Herri Kirolak. Después solemos ir a comer juntos, antes de los paseillos, y después, siempre cenamos juntos. Y por la noche, hasta que el cuerpo aguante!]]></string>
 	<string name="lablanca_nofestivals_3_title">Especialistas en paseillos:</string>
-	<string name="lablanca_nofestivals_3"><![CDATA[A la hora de hacer paseillos, no hay quien nos gane. Con nuestra furgoneta siempre abierta a la cabeza, y la txaranga El Postín animando desde atrás, es imposible aburrirse. Y entre paseillos tampoco descansamos, siempre estamos organizando cosas: juegos, carreras, bingos, música, ida a las barracas...]]></string>
+	<string name="lablanca_nofestivals_3"><![CDATA[A la hora de hacer paseillos, no hay quien nos gane. Con nuestra furgoneta siempre abierta a la cabeza, y la txaranga El Postín animando desde atrás, es imposible aburrirse. Y entre paseillos tampoco descansamos, siempre estamos organizando cosas: juegos, carreras, bingos, música, ida a las barracas…]]></string>
 	<string name="lablanca_nofestivals_4_title">Nos gusta comer:</string>
 	<string name="lablanca_nofestivals_4"><![CDATA[No queremos que un Margolari pase hambre. Las comidas en Gasteizko Margolariak son en restaurante, con un buen men&ú, que nos den fuerzas para aguantar el resto del día. Las cenas las hacemos bien en la calle o bien en restaurante, pero siempre con comida buena y caliente. Los mismo que los almuerzos.]]></string>
 	<string name="lablanca_nofestivals_5_title">Y beber:</string>
 	<string name="lablanca_nofestivals_5"><![CDATA[Sea cual sea tu veneno, lo tenemos: Ron, vodka, kalimotxo, cerveza, whiskey, agua, refrescos Durante los paseillos (y varias veces m&aacute;s a lo largo del d&iacute;a) en la furgoneta tendr&aacute;s barra libre de todo lo que quieras.]]></string>
 	<string name="lablanca_nofestivals_6_title">Nos apuntamos a un bombardeo:</string>
-	<string name="lablanca_nofestivals_6"><![CDATA[Carrera de Barricas, Herri Kirolak... Nunca hemos faltado a nada. Ganar, lo que es ganar, aún lo tenemos pendiente, pero lo pasamos bien. Así que ya sabes, si quieres representar a Gasteizko Margolariak, avísanos!]]></string>
+	<string name="lablanca_nofestivals_6"><![CDATA[Carrera de Barricas, Herri Kirolak Nunca hemos faltado a nada. Ganar, lo que es ganar, aún lo tenemos pendiente, pero lo pasamos bien. Así que ya sabes, si quieres representar a Gasteizko Margolariak, avísanos!]]></string>
 	<string name="lablanca_nofestivals_7_title">Por la ciudad, para la ciudad:</string>
-	<string name="lablanca_nofestivals_7"><![CDATA[No nos gusta mirarnos el ombligo. Aunque la mayor parte de actividades que organizamos son para los miembros de Gasteizko Margolariak, hay otras que son para todo el público. Hasta ahora hemos organizado talleres de Cesta Punta para txikis, Margotxef (un concurso de cocina infantil), visitas a residencias de ancianos...]]></string>
+	<string name="lablanca_nofestivals_7"><![CDATA[No nos gusta mirarnos el ombligo. Aunque la mayor parte de actividades que organizamos son para los miembros de Gasteizko Margolariak, hay otras que son para todo el público. Hasta ahora hemos organizado talleres de Cesta Punta para txikis, Margotxef (un concurso de cocina infantil), visitas a residencias de ancianos]]></string>
 	<string name="lablanca_nofestivals_8_title">Margolaris:</string>
 	<string name="lablanca_nofestivals_8"><![CDATA[Todo lo demás no sirve de nada si en una cuadrilla no hay buen ambiente. En Gasteizko Margolariak podemos presumir de gente cercana, participativa, capaz de hacer que desde el primer día ya te sientas como en casa. Además, los organizadores son gente cercana, que escucha y está siempre abierta a nuevas propuestas. Por esto, quien prueba, repite.]]></string>
-	<string name="settings_about_content"><![CDATA[La Asociación Cultural Gasteizko Margolariak nace en el año 2013 con la idea de estimular la participación ciudadana y fortalecer la cultura y las tradiciones de Vitoria-Gasteiz.<br/><br/>En nuestro nombre se refleja un barrio en el que las calles nos recuerdan a grandes pintores: el barrio de San Martín. Estamos representados en los barrios, y creemos que son la esencia de esta ciudad.<br/><br/>Nos convertimos en Cuadrilla de Blusas y Neskas en 2013, y en ese mismo año, miembros de la Comisión de Blusas y Neskas.<br/><br/>Desde entonces no hemos hecho más que crecer junto con todos los que han decidido, año tras año, apostar por nosotros.]]></string>
 
 	<!-- Misc strings -->
 
@@ -211,19 +186,16 @@
 	<string name="sponsors_url">Sitio web</string>
 
 	<!-- Us -->
-	<string name="us_title">Nosotros</string>
 	<string name="us_association">La asociación</string>
 	<string name="us_association_content">La Asociación Cultural Gasteizko Margolariak nace en el año 2013 con la idea de estimular la participación ciudadana y fortalecer la cultura y las tradiciones de Vitoria-Gasteiz.\n\nEn nuestro nombre se refleja un barrio en el que las calles nos recuerdan a grandes pintores: el barrio de San Martín. Estamos representados en los barrios, y creemos que son la esencia de esta ciudad.</string>
 	<string name="us_cuadrilla">La cuadrilla</string>
 	<string name="us_cuadrilla_content">Nos convertimos en Cuadrilla de Blusas y Neskas en 2013, y en ese mismo año, miembros de la Comisión de Blusas y Neskas.\n\nDesde entonces no hemos hecho mas que crecer junto con todos los que han decidido, año tras año, apostar por nosotros.</string>
 	<string name="us_activities">Lo que hacemos</string>
-	<string name="us_activities_content">Excursiones, partidos, causas benéficas... No solo se nos ve en fiestas.\n\nCreemos que, como Cuadrilla de Blusas y Neskas, existimos por y para la ciudad, y por eso organizamos actividades durante todo el año, para todo aquel que quiera acompañarnos.</string>
+	<string name="us_activities_content">Excursiones, partidos, causas benéficas No solo se nos ve en fiestas.\n\nCreemos que, como Cuadrilla de Blusas y Neskas, existimos por y para la ciudad, y por eso organizamos actividades durante todo el año, para todo aquel que quiera acompañarnos.</string>
 	<string name="us_transparency">Transparencia</string>
 	<string name="us_transparency_content">¿Te preocupa saber dónde va tu dinero? En Gasteizko Margolariak queremos que estés tranquilo.\n\nMuchas de nuestras actividades son gratuitas. Otras, como las fiestas de La Blanca, tienen una cuota de inscripción. Gasteizko Margolariak no es una empresa, es una Asociación Cultural, y como tal, no tenemos beneficios.\n\nQueremos ser transparentes, y por eso, empezando en 2017, pondremos a tu disposición nuestras cuentas de manera online, para que sepas que cada euro se reinvierte en ti.</string>
 
 	<!--Preferences screen-->
-	<string name="preferences">Preferencias</string>
-	<string name="preferences_sync">Sincronización</string>
 	<string name="preferences_sync_sync">Sincronización en segundo plano</string>
 	<string name="preferences_sync_sync_on">Sincronización activada</string>
 	<string name="preferences_sync_sync_off">Sincronización desactivada</string>
@@ -231,7 +203,6 @@
 	<string name="preferences_sync_notifications_on">Se recibirán notificaciones</string>
 	<string name="preferences_sync_notifications_off">No se recibirán notificaciones</string>
 	<string name="preferences_sync_notifications_disabled">Activa la sincronización en segundo plano para recibir notificaciones</string>
-	<string name="preferences_sync_usage">Uso de datos</string>
 	<string name="preferences_info">Informacion</string>
 	<string name="preferences_info_version">Versión de la aplicación</string>
 	<string name="preferences_info_source_summary">Ojear el código fuente en Github</string>
@@ -239,7 +210,6 @@
 	<string name="preferences_info_feedback_summary">Enviar información anónima al desarrollador</string>
 
 	<!-- Share menu -->
-	<string name="share">Comartir</string>
 	<string name="share_with">Enviar con…</string>
 	<string name="share_home">Gasteizko Margolariak</string>
 	<string name="share_lablanca">La Blanca - Gasteizko Margolariak</string>
@@ -249,8 +219,6 @@
 	<string name="share_with_title">%s - Gasteizko Margolariak</string>
 
 	<string name="eur" translatable="false">€</string>
-	<string name="Kb" translatable="false"> Kb</string>
-	<string name="Mb" translatable="false"> Mb</string>
 	<string name="preferences_info_source">Código fuente</string>
 	<string name="changelog">Changelog</string>
 	<string name="empty" translatable="false"> </string>

+ 4 - 20
app/src/main/res/values/styles.xml

@@ -1,32 +1,16 @@
 <resources>
 
-    <!--
-        Base application theme, dependent on API level. This theme is replaced
-        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-    -->
-    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
-        <!--
-            Theme customizations available in newer API levels can go in
-            res/values-vXX/styles.xml, while customizations related to
-            backward-compatibility can go here.
-        -->
-    </style>
-
     <!-- Application theme. -->
-    <style name="AppTheme" parent="AppBaseTheme">
+    <style name="AppTheme" parent="android:Theme.Material">
         <!-- All customizations that are NOT specific to a particular API-level can go here. -->
         <item name="android:textColorPrimary">#333333</item>
         <item name="android:windowBackground">@color/background_menu</item>
         <item name="android:colorBackground">@color/background_app</item>
 
-        <item name="colorPrimary">@color/background_menu</item>
-        <item name="colorPrimaryDark">@color/background_menu</item>
-        <item name="colorAccent">@color/background_menu</item>
+        <item name="android:colorPrimary">@color/background_menu</item>
+        <item name="android:colorPrimaryDark">@color/background_menu</item>
+        <item name="android:colorAccent">@color/background_menu</item>
 
     </style>
-    
-    <style name="Theme.Default" parent="Theme.AppCompat.Light"></style>
-    <style name="Theme.NoTitle" parent="Theme.AppCompat.Light.NoActionBar"></style>
-    <style name="Theme.FullScreen" parent="Theme.AppCompat.Light.NoActionBar"></style>
 
 </resources>

+ 0 - 38
app/src/main/res/xml/preferences.xml

@@ -1,38 +0,0 @@
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
-    <PreferenceCategory
-        android:title="@string/preferences_sync">
-
-        <CheckBoxPreference
-            android:key="preference_key_sync"
-            android:title="@string/preferences_sync_sync"
-            android:summary="@string/preferences_sync_sync_on"
-            android:defaultValue="true" />
-        <CheckBoxPreference
-            android:key="preference_key_notification"
-            android:title="@string/preferences_sync_notifications"
-            android:summary="@string/preferences_sync_notifications_on"
-            android:defaultValue="true" />
-
-    </PreferenceCategory>
-
-    <PreferenceCategory
-        android:title="@string/preferences_info">
-
-        <Preference
-            android:key="preference_key_version"
-            android:title="@string/preferences_info_version"
-            android:summary="_" />
-
-        <Preference
-            android:key="preference_key_source"
-            android:title="@string/preferences_info_source"
-            android:summary="@string/preferences_info_source_summary" />
-
-        <Preference
-            android:key="preference_key_feedback"
-            android:title="@string/preferences_info_feedback"
-            android:summary="@string/preferences_info_feedback_summary" />
-
-    </PreferenceCategory>
-
-</PreferenceScreen>

部分文件因为文件数量过多而无法显示