Panagiotis Triantafyllou

version 4.5.2

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.1'
PUBLISH_VERSION = '4.5.2'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
......@@ -121,11 +121,11 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
}
}
@Override
public IBinder onBind(Intent arg0) {
// We don't provide binding, so return null
return null;
}
// @Override
// public IBinder onBind(Intent arg0) {
// // We don't provide binding, so return null
// return null;
// }
// tells handler to send a message
class firstTask extends TimerTask {
......@@ -140,14 +140,14 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
@Override
public boolean handleMessage(Message msg) {
if ((new WarplyPreferences(Warply.getWarplyContext()).getUpdateLocationServiceStatus()).equals("off")) {
timer.cancel();
stopSelf();
}
else {
if (isGeofencingEnabled() && (getGeofences() == null || getGeofences().isEmpty()))
retrieveGeofences();
if (Warply.getWarplyContext() != null) {
if ((new WarplyPreferences(Warply.getWarplyContext()).getUpdateLocationServiceStatus()).equals("off")) {
timer.cancel();
stopSelf();
} else {
if (isGeofencingEnabled() && (getGeofences() == null || getGeofences().isEmpty()))
retrieveGeofences();
}
}
Log.i("regulation", "regulation started");
regulateLocationReporting();
......@@ -174,6 +174,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
@Override
public void onSuccess(JSONObject result) {
}
@Override
public void onFailure(int errorCode) {
WarpUtils.log("failed during sending location data with error " + errorCode);
......@@ -191,7 +192,7 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
// ------------------- Geofencing -------------------
private void retrieveGeofences() {
if(!isGeofencingEnabled())
if (!isGeofencingEnabled())
return;
JSONObject jObj = new JSONObject();
try {
......@@ -205,38 +206,38 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
@Override
public void onSuccess(JSONObject result) {
JSONObject json = result.optJSONObject("context");
if(json != null){
if (json != null) {
try {
JSONArray geoArray = json.getJSONArray("MAPP_GEOFENCING");
geofences = new ArrayList<>();
for(int i=0;i<geoArray.length();i++){
for (int i = 0; i < geoArray.length(); i++) {
getGeofences().add(new WarpGeoFence(geoArray.getJSONObject(i)));
}
} catch (JSONException e) {
if(BuildConfig.DEBUG)
if (BuildConfig.DEBUG)
e.printStackTrace();
geofences = null;
WarpUtils.log("failed during parsing geofencing data.");
}
}
}
@Override
public void onFailure(int errorCode) {
geofences = null;
WarpUtils.log("failed during getting geofencing data with error " + errorCode);
}
});
}
else {
} else {
WarpUtils.log("Could not get geofencing data. You must registrer to warply first");
}
}
public boolean isInsideFence(double lat, double lon){
if(getGeofences() == null)
public boolean isInsideFence(double lat, double lon) {
if (getGeofences() == null)
return false;
for(WarpGeoFence fence : getGeofences()){
if(fence.isInsideFence(lat, lon))
for (WarpGeoFence fence : getGeofences()) {
if (fence.isInsideFence(lat, lon))
return true;
}
return false;
......@@ -299,21 +300,21 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
} else if (foregroundProvider == WarpConstants.LocationModes.OFF.ordinal()) {
/*
* in case foreground provider is off and app is in
* foreground mode then app should stop reporting the
* location
*/
/*
* in case foreground provider is off and app is in
* foreground mode then app should stop reporting the
* location
*/
if (!LocationChangedReceiver.isAppShutDown && appStatus.equals("foreground")) {
WarplyLocationManager.stopReportingLocation(context);
/*
* in case background provider is on and app is in
* background mode or shut down then app should check for
* settings changes in every fixed time(a day). If none of
* the settings is changed then continue with the previous
* settings.
*/
/*
* in case background provider is on and app is in
* background mode or shut down then app should check for
* settings changes in every fixed time(a day). If none of
* the settings is changed then continue with the previous
* settings.
*/
} else if (!((lastBacProvider == backgroundProvider)
&& (lastBacTime == backgroundMinTime)
&& (lastBacDistance == backgroundMinDistance))) {
......@@ -333,21 +334,21 @@ public class UpdateUserLocationService extends /*Service*/ JobIntentService {
} else if (backgroundProvider == WarpConstants.LocationModes.OFF.ordinal()) {
/*
/*
* in case background provider is off and app is in
* background mode then app should stop reporting the
* location
*/
* background mode then app should stop reporting the
* location
*/
if (LocationChangedReceiver.isAppShutDown || appStatus.equals("background")) {
WarplyLocationManager.stopReportingLocation(context);
/*
* in case foreground provider is on and app is in
* foreground mode then app should check for settings
* changes in every fixed time(a day). If none of the
* settings is changed then continue with the previous
* settings.
*/
/*
* in case foreground provider is on and app is in
* foreground mode then app should check for settings
* changes in every fixed time(a day). If none of the
* settings is changed then continue with the previous
* settings.
*/
} else if (!((lastForProvider == foregroundProvider)
&& (lastForTime == foregroundMinTime)
&& (lastForDistance == foregroundMinDistance))) {
......
......@@ -38,9 +38,9 @@ public class PermissionsUtil{
// PERMISSION_WRITE_EXTERNAL = Manifest.permission.WRITE_EXTERNAL_STORAGE;
private static final String[] DANGEROUS_PERMISSIONS = {
PERMISSION_LOCATION_FINE,
PERMISSION_LOCATION_COARSE,
PERMISSION_PHONE_STATE,
// PERMISSION_LOCATION_FINE,
// PERMISSION_LOCATION_COARSE,
// PERMISSION_PHONE_STATE,
// PERMISSION_WRITE_EXTERNAL
};
......
......@@ -390,7 +390,7 @@ public class WarplyDeviceInfoCollector {
return json;
}
private boolean isPackageInstalled(String packageName, PackageManager packageManager) {
public boolean isPackageInstalled(String packageName, PackageManager packageManager) {
try {
return packageManager.getApplicationInfo(packageName, 0).enabled;
} catch (PackageManager.NameNotFoundException e) {
......
......@@ -30,7 +30,7 @@ public class WarpConstants {
/**
* The version of the SDK installed in the device
*/
public static final String SDK_VERSION = "4.5.1";
public static final String SDK_VERSION = "4.5.2";
/**
* The URL of the server where it should ping
......