Panagiotis Triantafyllou

version 4.5.2

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.1' 5 + PUBLISH_VERSION = '4.5.2'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
1 /* 1 /*
2 * Copyright 2010-2013 Warply Ltd. All rights reserved. 2 * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 - * 3 + *
4 * Redistribution and use in source and binary forms, without modification, are 4 * Redistribution and use in source and binary forms, without modification, are
5 * permitted provided that the following conditions are met: 5 * permitted provided that the following conditions are met:
6 - * 6 + *
7 * 1. Redistributions of source code must retain the above copyright notice, 7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer. 8 * this list of conditions and the following disclaimer.
9 - * 9 + *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 - * 13 + *
14 * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR 14 * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
...@@ -121,11 +121,11 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -121,11 +121,11 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
121 } 121 }
122 } 122 }
123 123
124 - @Override 124 +// @Override
125 - public IBinder onBind(Intent arg0) { 125 +// public IBinder onBind(Intent arg0) {
126 - // We don't provide binding, so return null 126 +// // We don't provide binding, so return null
127 - return null; 127 +// return null;
128 - } 128 +// }
129 129
130 // tells handler to send a message 130 // tells handler to send a message
131 class firstTask extends TimerTask { 131 class firstTask extends TimerTask {
...@@ -140,14 +140,14 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -140,14 +140,14 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
140 140
141 @Override 141 @Override
142 public boolean handleMessage(Message msg) { 142 public boolean handleMessage(Message msg) {
143 - 143 + if (Warply.getWarplyContext() != null) {
144 - if ((new WarplyPreferences(Warply.getWarplyContext()).getUpdateLocationServiceStatus()).equals("off")) { 144 + if ((new WarplyPreferences(Warply.getWarplyContext()).getUpdateLocationServiceStatus()).equals("off")) {
145 - timer.cancel(); 145 + timer.cancel();
146 - stopSelf(); 146 + stopSelf();
147 - } 147 + } else {
148 - else { 148 + if (isGeofencingEnabled() && (getGeofences() == null || getGeofences().isEmpty()))
149 - if (isGeofencingEnabled() && (getGeofences() == null || getGeofences().isEmpty())) 149 + retrieveGeofences();
150 - retrieveGeofences(); 150 + }
151 } 151 }
152 Log.i("regulation", "regulation started"); 152 Log.i("regulation", "regulation started");
153 regulateLocationReporting(); 153 regulateLocationReporting();
...@@ -174,6 +174,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -174,6 +174,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
174 @Override 174 @Override
175 public void onSuccess(JSONObject result) { 175 public void onSuccess(JSONObject result) {
176 } 176 }
177 +
177 @Override 178 @Override
178 public void onFailure(int errorCode) { 179 public void onFailure(int errorCode) {
179 WarpUtils.log("failed during sending location data with error " + errorCode); 180 WarpUtils.log("failed during sending location data with error " + errorCode);
...@@ -191,7 +192,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -191,7 +192,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
191 // ------------------- Geofencing ------------------- 192 // ------------------- Geofencing -------------------
192 193
193 private void retrieveGeofences() { 194 private void retrieveGeofences() {
194 - if(!isGeofencingEnabled()) 195 + if (!isGeofencingEnabled())
195 return; 196 return;
196 JSONObject jObj = new JSONObject(); 197 JSONObject jObj = new JSONObject();
197 try { 198 try {
...@@ -205,38 +206,38 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -205,38 +206,38 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
205 @Override 206 @Override
206 public void onSuccess(JSONObject result) { 207 public void onSuccess(JSONObject result) {
207 JSONObject json = result.optJSONObject("context"); 208 JSONObject json = result.optJSONObject("context");
208 - if(json != null){ 209 + if (json != null) {
209 try { 210 try {
210 JSONArray geoArray = json.getJSONArray("MAPP_GEOFENCING"); 211 JSONArray geoArray = json.getJSONArray("MAPP_GEOFENCING");
211 geofences = new ArrayList<>(); 212 geofences = new ArrayList<>();
212 - for(int i=0;i<geoArray.length();i++){ 213 + for (int i = 0; i < geoArray.length(); i++) {
213 getGeofences().add(new WarpGeoFence(geoArray.getJSONObject(i))); 214 getGeofences().add(new WarpGeoFence(geoArray.getJSONObject(i)));
214 } 215 }
215 } catch (JSONException e) { 216 } catch (JSONException e) {
216 - if(BuildConfig.DEBUG) 217 + if (BuildConfig.DEBUG)
217 e.printStackTrace(); 218 e.printStackTrace();
218 geofences = null; 219 geofences = null;
219 WarpUtils.log("failed during parsing geofencing data."); 220 WarpUtils.log("failed during parsing geofencing data.");
220 } 221 }
221 } 222 }
222 } 223 }
224 +
223 @Override 225 @Override
224 public void onFailure(int errorCode) { 226 public void onFailure(int errorCode) {
225 geofences = null; 227 geofences = null;
226 WarpUtils.log("failed during getting geofencing data with error " + errorCode); 228 WarpUtils.log("failed during getting geofencing data with error " + errorCode);
227 } 229 }
228 }); 230 });
229 - } 231 + } else {
230 - else {
231 WarpUtils.log("Could not get geofencing data. You must registrer to warply first"); 232 WarpUtils.log("Could not get geofencing data. You must registrer to warply first");
232 } 233 }
233 } 234 }
234 235
235 - public boolean isInsideFence(double lat, double lon){ 236 + public boolean isInsideFence(double lat, double lon) {
236 - if(getGeofences() == null) 237 + if (getGeofences() == null)
237 return false; 238 return false;
238 - for(WarpGeoFence fence : getGeofences()){ 239 + for (WarpGeoFence fence : getGeofences()) {
239 - if(fence.isInsideFence(lat, lon)) 240 + if (fence.isInsideFence(lat, lon))
240 return true; 241 return true;
241 } 242 }
242 return false; 243 return false;
...@@ -299,21 +300,21 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -299,21 +300,21 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
299 300
300 } else if (foregroundProvider == WarpConstants.LocationModes.OFF.ordinal()) { 301 } else if (foregroundProvider == WarpConstants.LocationModes.OFF.ordinal()) {
301 302
302 - /* 303 + /*
303 - * in case foreground provider is off and app is in 304 + * in case foreground provider is off and app is in
304 - * foreground mode then app should stop reporting the 305 + * foreground mode then app should stop reporting the
305 - * location 306 + * location
306 - */ 307 + */
307 if (!LocationChangedReceiver.isAppShutDown && appStatus.equals("foreground")) { 308 if (!LocationChangedReceiver.isAppShutDown && appStatus.equals("foreground")) {
308 WarplyLocationManager.stopReportingLocation(context); 309 WarplyLocationManager.stopReportingLocation(context);
309 310
310 - /* 311 + /*
311 - * in case background provider is on and app is in 312 + * in case background provider is on and app is in
312 - * background mode or shut down then app should check for 313 + * background mode or shut down then app should check for
313 - * settings changes in every fixed time(a day). If none of 314 + * settings changes in every fixed time(a day). If none of
314 - * the settings is changed then continue with the previous 315 + * the settings is changed then continue with the previous
315 - * settings. 316 + * settings.
316 - */ 317 + */
317 } else if (!((lastBacProvider == backgroundProvider) 318 } else if (!((lastBacProvider == backgroundProvider)
318 && (lastBacTime == backgroundMinTime) 319 && (lastBacTime == backgroundMinTime)
319 && (lastBacDistance == backgroundMinDistance))) { 320 && (lastBacDistance == backgroundMinDistance))) {
...@@ -333,21 +334,21 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService { ...@@ -333,21 +334,21 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
333 334
334 } else if (backgroundProvider == WarpConstants.LocationModes.OFF.ordinal()) { 335 } else if (backgroundProvider == WarpConstants.LocationModes.OFF.ordinal()) {
335 336
336 - /* 337 + /*
337 * in case background provider is off and app is in 338 * in case background provider is off and app is in
338 - * background mode then app should stop reporting the 339 + * background mode then app should stop reporting the
339 - * location 340 + * location
340 - */ 341 + */
341 if (LocationChangedReceiver.isAppShutDown || appStatus.equals("background")) { 342 if (LocationChangedReceiver.isAppShutDown || appStatus.equals("background")) {
342 WarplyLocationManager.stopReportingLocation(context); 343 WarplyLocationManager.stopReportingLocation(context);
343 344
344 - /* 345 + /*
345 - * in case foreground provider is on and app is in 346 + * in case foreground provider is on and app is in
346 - * foreground mode then app should check for settings 347 + * foreground mode then app should check for settings
347 - * changes in every fixed time(a day). If none of the 348 + * changes in every fixed time(a day). If none of the
348 - * settings is changed then continue with the previous 349 + * settings is changed then continue with the previous
349 - * settings. 350 + * settings.
350 - */ 351 + */
351 } else if (!((lastForProvider == foregroundProvider) 352 } else if (!((lastForProvider == foregroundProvider)
352 && (lastForTime == foregroundMinTime) 353 && (lastForTime == foregroundMinTime)
353 && (lastForDistance == foregroundMinDistance))) { 354 && (lastForDistance == foregroundMinDistance))) {
......
...@@ -38,9 +38,9 @@ public class PermissionsUtil{ ...@@ -38,9 +38,9 @@ public class PermissionsUtil{
38 // PERMISSION_WRITE_EXTERNAL = Manifest.permission.WRITE_EXTERNAL_STORAGE; 38 // PERMISSION_WRITE_EXTERNAL = Manifest.permission.WRITE_EXTERNAL_STORAGE;
39 39
40 private static final String[] DANGEROUS_PERMISSIONS = { 40 private static final String[] DANGEROUS_PERMISSIONS = {
41 - PERMISSION_LOCATION_FINE, 41 +// PERMISSION_LOCATION_FINE,
42 - PERMISSION_LOCATION_COARSE, 42 +// PERMISSION_LOCATION_COARSE,
43 - PERMISSION_PHONE_STATE, 43 +// PERMISSION_PHONE_STATE,
44 // PERMISSION_WRITE_EXTERNAL 44 // PERMISSION_WRITE_EXTERNAL
45 }; 45 };
46 46
......
...@@ -390,7 +390,7 @@ public class WarplyDeviceInfoCollector { ...@@ -390,7 +390,7 @@ public class WarplyDeviceInfoCollector {
390 return json; 390 return json;
391 } 391 }
392 392
393 - private boolean isPackageInstalled(String packageName, PackageManager packageManager) { 393 + public boolean isPackageInstalled(String packageName, PackageManager packageManager) {
394 try { 394 try {
395 return packageManager.getApplicationInfo(packageName, 0).enabled; 395 return packageManager.getApplicationInfo(packageName, 0).enabled;
396 } catch (PackageManager.NameNotFoundException e) { 396 } catch (PackageManager.NameNotFoundException e) {
......
...@@ -30,7 +30,7 @@ public class WarpConstants { ...@@ -30,7 +30,7 @@ public class WarpConstants {
30 /** 30 /**
31 * The version of the SDK installed in the device 31 * The version of the SDK installed in the device
32 */ 32 */
33 - public static final String SDK_VERSION = "4.5.1"; 33 + public static final String SDK_VERSION = "4.5.2";
34 34
35 /** 35 /**
36 * The URL of the server where it should ping 36 * The URL of the server where it should ping
......