Ver Fonte

Merge branch 'V4' of https://github.com/GasteizkoMargolariak/GasteizkoMargolariakApp into V4

Iñigo Valentin há 6 anos atrás
pai
commit
f0bf2f00db

+ 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>

+ 1 - 2
.idea/gradle.xml

@@ -3,9 +3,8 @@
   <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$" />

+ 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>

+ 14 - 1
app/build.gradle

@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
 
 android {
     compileSdkVersion 23
-    buildToolsVersion '25.0.0'
+    buildToolsVersion '27.0.3'
 
     defaultConfig {
         applicationId "com.ivalentin.margolariak"
@@ -23,6 +23,10 @@ android {
         preDexLibraries = false
         javaMaxHeapSize "2g"
     }
+
+    lintOptions {
+        checkReleaseBuilds false
+    }
 }
 
 dependencies {
@@ -30,3 +34,12 @@ dependencies {
     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()
+    }
+}

+ 2 - 2
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"/>

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

@@ -139,9 +139,8 @@ public class ActivityLayout extends Fragment{
 						//If not, create directories and download asynchronously
 						File fpath;
 						fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
-						if (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();
-						}
+						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();
@@ -237,9 +236,8 @@ public class ActivityLayout extends Fragment{
 					//If not, create directories and download asynchronously
 					File fpath;
 					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
-					if (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();
-					}
+					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();

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

@@ -94,9 +94,8 @@ public class ActivityPastLayout extends Fragment {
 				//If not, create directories and download asynchronously
 				File fpath;
 				fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/preview/");
-				if(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();
-				}
+				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 ++;
@@ -107,4 +106,4 @@ public class ActivityPastLayout extends Fragment {
 		db.close();
 		return view;
 	}
-}
+}

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

@@ -123,9 +123,8 @@ public class AlbumLayout extends Fragment {
 				//If not, create directories and download asynchronously
 				File fpath;
 				fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/");
-				if (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();
-				}
+				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
@@ -195,9 +194,8 @@ public class AlbumLayout extends Fragment {
 					//If not, create directories and download asynchronously
 					File fpath;
 					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/");
-					if (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();
-					}
+					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
@@ -235,4 +233,4 @@ public class AlbumLayout extends Fragment {
 		db.close();
 		return view;
 	}
-}
+}

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

@@ -194,9 +194,8 @@ public class BlogLayout extends Fragment{
 					//If not, create directories and download asynchronously
 					File fpath;
 					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/");
-					if (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();
-					}
+					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{

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

@@ -104,4 +104,4 @@ class DownloadImage extends AsyncTask<Void, Void, Void> {
 		}
 	}
 
-}
+}

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

@@ -1115,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;
 	}

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

@@ -123,9 +123,8 @@ public class GalleryLayout extends Fragment{
 					//If not, create directories and download asynchronously
 					File fpath;
 					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/miniature/");
-					if (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();
-					}
+					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

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

@@ -59,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}.
@@ -77,6 +78,11 @@ public class HomeLayout extends Fragment implements LocationListener {
 		//Load the layout.
 		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 (!checkLocationPermission()) {
 			requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, GM.PERMISSION.LOCATION);
@@ -448,9 +454,8 @@ public class HomeLayout extends Fragment implements LocationListener {
 						//If not, create directories and download asynchronously
 						File fpath;
 						fpath = new File(this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/");
-						if (fpath.mkdirs()) {
-							new DownloadImage(GM.API.SERVER + "/img/fiestas/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image, ivImage, GM.IMG.SIZE.PREVIEW).execute();
-						}
+						fpath.mkdirs();
+						new DownloadImage(GM.API.SERVER + "/img/fiestas/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/" + image, ivImage, GM.IMG.SIZE.PREVIEW).execute();
 					}
 				}
 				else {
@@ -559,9 +564,8 @@ public class HomeLayout extends Fragment implements LocationListener {
 				//If not, create directories and download asynchronously
 				File fpath;
 				fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/preview/");
-				if (fpath.mkdirs()){
-					new DownloadImage(GM.API.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivPhoto[counter], GM.IMG.SIZE.PREVIEW).execute();
-				}
+				fpath.mkdirs();
+				new DownloadImage(GM.API.SERVER + "/img/galeria/preview/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/preview/" + image, ivPhoto[counter], GM.IMG.SIZE.PREVIEW).execute();
 			}
 
 			//Set listeners for images
@@ -691,9 +695,8 @@ public class HomeLayout extends Fragment implements LocationListener {
 					//If not, create directories and download asynchronously
 					File fpath;
 					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
-					if (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();
-					}
+					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();
@@ -820,9 +823,8 @@ public class HomeLayout extends Fragment implements LocationListener {
 						//If not, create directories and download asynchronously
 						File fpath;
 						fpath = new File(this.getActivity().getFilesDir().toString() + "/img/actividades/miniature/");
-						if (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();
-						}
+						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();
 					}
 				}
 
@@ -937,9 +939,8 @@ public class HomeLayout extends Fragment implements LocationListener {
 					//If not, create directories and download asynchronously
 					File fpath;
 					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/miniature/");
-					if (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();
-					}
+					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();
 				}
 			}
 
@@ -1046,6 +1047,7 @@ public class HomeLayout extends Fragment implements LocationListener {
 		super.onPause();
 	}
 
+
 	/**
 	 * Called when the fragment is destroyed.
 	 * Stops the location manager
@@ -1063,11 +1065,12 @@ public class HomeLayout extends Fragment implements LocationListener {
 		}
 		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
@@ -1078,6 +1081,15 @@ public class HomeLayout extends Fragment implements LocationListener {
 		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.

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

@@ -77,9 +77,8 @@ public class LablancaLayout extends Fragment {
 					//If not, create directories and download asynchronously
 					File fpath;
 					fpath = new File(this.getActivity().getFilesDir().toString() + "/img/fiestas/preview/");
-					if (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();
-					}
+					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 {
 				headerImage.setVisibility(View.GONE);
@@ -192,4 +191,4 @@ public class LablancaLayout extends Fragment {
 
 		return view;
 	}
-}
+}

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

@@ -220,9 +220,8 @@ public class PhotoLayout extends Fragment {
 			imageView.setImageResource(getResources().getIdentifier("com.ivalentin.margolariak:drawable/photo_placeholder", null, null));
 			File fpath;
 			fpath = new File(this.getActivity().getFilesDir().toString() + "/img/galeria/view/");
-			if (fpath.mkdirs()) {
-				new DownloadImage(GM.API.SERVER + "/img/galeria/view/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/view/" + image, imageView, GM.IMG.SIZE.VIEW).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
-			}
+			fpath.mkdirs();
+			new DownloadImage(GM.API.SERVER + "/img/galeria/view/" + image, this.getActivity().getFilesDir().toString() + "/img/galeria/view/" + image, imageView, GM.IMG.SIZE.VIEW).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
 		}
 
 		//Hide or show comments, as needed
@@ -297,4 +296,4 @@ public class PhotoLayout extends Fragment {
 		cursor.close();
 		db.close();
 	}
-}
+}

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

@@ -101,9 +101,8 @@ public class PostLayout extends Fragment {
 				//If not, create directories and download asynchronously
 				File fpath;
 				fpath = new File(this.getActivity().getFilesDir().toString() + "/img/blog/preview/");
-				if (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();
-				}
+				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 ++;
@@ -167,4 +166,4 @@ public class PostLayout extends Fragment {
 		db.close();
 		return view;
 	}
-}
+}

+ 7 - 0
app/src/main/java/com/ivalentin/margolariak/ReceiveLocation.java

@@ -70,6 +70,10 @@ class ReceiveLocation extends AsyncTask<Void, Void, Void> {
 
 					//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();
 
@@ -85,6 +89,9 @@ class ReceiveLocation extends AsyncTask<Void, Void, Void> {
 		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());
+		}
 
 
 		return null;

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

@@ -267,17 +267,10 @@ class Sync extends AsyncTask<Void, Void, Void> {
 		try {
 
 			// Common parameters
-			url = GM.API.SERVER;
-			if (pbSync != null) { // First sync
-				url = url + GM.API.SYNC.PATH.FAST;
-			}
-			else{ // Regular sync
-				url = url + GM.API.SYNC.PATH.COMPLETE;
-			}
-			url = url + "?" +
-					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 + "&";
+			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;

+ 1 - 1
app/src/main/res/layout/fragment_layout_location.xml

@@ -50,7 +50,7 @@
 				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"/>
 
 			<LinearLayout
 				android:layout_width="match_parent"

+ 2 - 1
build.gradle

@@ -2,9 +2,10 @@
 buildscript {
     repositories {
         jcenter()
+        google()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.3.3'
+        classpath 'com.android.tools.build:gradle:3.1.3'
     }
 }
 

+ 2 - 3
gradle/wrapper/gradle-wrapper.properties

@@ -1,7 +1,6 @@
-#Sat Apr 01 22:26:43 CEST 2017
+#Sat Jul 07 19:08:38 CEST 2018
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-#distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-rc-2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip