Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/geofencing #120

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions adal-location/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
~ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<manifest package="com.massivedisaster.location"
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest package="com.massivedisaster.adal.location"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
/*
* ADAL - A set of Android libraries to help speed up Android development.
* Copyright (C) 2017 ADAL.
*
* ADAL is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or any later version.
* Copyright (c) 2017 ADAL
*
* ADAL 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 Lesser General Public License for more
* details.
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* You should have received a copy of the GNU Lesser General Public License along
* with ADAL. If not, see <http://www.gnu.org/licenses/>.
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.massivedisaster.location;
package com.massivedisaster.adal.location;

import android.Manifest;
import android.app.Activity;
Expand All @@ -35,12 +43,12 @@
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationServices;
import com.massivedisaster.adal.location.broadcast.LocationStatusBroadcastReceiver;
import com.massivedisaster.adal.location.listener.OnLocationManager;
import com.massivedisaster.adal.location.listener.OnLocationStatusProviderListener;
import com.massivedisaster.adal.location.utils.LocationError;
import com.massivedisaster.adal.location.utils.LocationUtils;
import com.massivedisaster.adal.permissions.PermissionsManager;
import com.massivedisaster.location.broadcast.LocationStatusBroadcastReceiver;
import com.massivedisaster.location.listener.OnLocationManager;
import com.massivedisaster.location.listener.OnLocationStatusProviderListener;
import com.massivedisaster.location.utils.LocationError;
import com.massivedisaster.location.utils.LocationUtils;

/**
* AbstractLocationManager contains the base methods to request device location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.massivedisaster.location;
package com.massivedisaster.adal.location;

import android.content.IntentSender;
import android.support.annotation.NonNull;
Expand All @@ -37,8 +37,8 @@
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStatusCodes;
import com.massivedisaster.location.listener.OnLocationManager;
import com.massivedisaster.location.utils.LocationError;
import com.massivedisaster.adal.location.listener.OnLocationManager;
import com.massivedisaster.adal.location.utils.LocationError;

/**
* LocationManager requests single or multiple device locations.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* ADAL - A set of Android libraries to help speed up Android development.
*
* Copyright (c) 2017 ADAL
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.massivedisaster.adal.location.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
* Abstract Broadcast Receiver to handle Geofence messages
*/
public abstract class AbstractGeofenceBroadcastReceiver extends BroadcastReceiver {

public static final String ACTION_RECEIVE_GEOFENCE = "com.massivedisaster.adal.location.ACTION_RECEIVE_GEOFENCE";

private static final String ILLEGAL_ACTION_EXCEPTION = "You must define an action on your pending intent";
private static final String BOOT_COMPLETE_MESSAGE = "::: ::: ::: BOOT - ON RECEIVE";
private static final String GEOFENCE_RECEIVED_MESSAGE = "::: ::: ::: GEOFENCE - ON RECEIVE";

/**
* Handles broadcast message when action
* equals to {@link android.content.Intent#ACTION_BOOT_COMPLETED ACTION_BOOT_COMPLETED}
*
* @param context used by the application
* @param intent declared as a Pending Intent by the system or a user's request
*/
protected abstract void onBootCompleted(Context context, Intent intent);

/**
* Handles broadcast message when action
* equals to {@link #ACTION_RECEIVE_GEOFENCE ACTION_RECEIVE_GEOFENCE}
*
* @param context used by the application
* @param intent declared as a Pending Intent by the system or a user's request
*/
protected abstract void onReceiveGeofence(Context context, Intent intent);

/**
* @inheritdoc
*/
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action == null) {
throw new IllegalArgumentException(ILLEGAL_ACTION_EXCEPTION);
}

if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
Log.d(AbstractGeofenceBroadcastReceiver.class.getSimpleName(), BOOT_COMPLETE_MESSAGE);
onBootCompleted(context, intent);
} else if (action.equals(ACTION_RECEIVE_GEOFENCE)) {
Log.d(AbstractGeofenceBroadcastReceiver.class.getSimpleName(), GEOFENCE_RECEIVED_MESSAGE);
onReceiveGeofence(context, intent);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* with ADAL. If not, see <http://www.gnu.org/licenses/>.
*/

package com.massivedisaster.location.broadcast;
package com.massivedisaster.adal.location.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.massivedisaster.location.LocationManager;
import com.massivedisaster.location.listener.OnLocationStatusProviderListener;
import com.massivedisaster.location.utils.LocationUtils;
import com.massivedisaster.adal.location.LocationManager;
import com.massivedisaster.adal.location.listener.OnLocationStatusProviderListener;
import com.massivedisaster.adal.location.utils.LocationUtils;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* with ADAL. If not, see <http://www.gnu.org/licenses/>.
*/

package com.massivedisaster.location.listener;
package com.massivedisaster.adal.location.listener;

import android.location.Location;

import com.massivedisaster.location.utils.LocationError;
import com.massivedisaster.adal.location.utils.LocationError;

/**
* Manages location.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* with ADAL. If not, see <http://www.gnu.org/licenses/>.
*/

package com.massivedisaster.location.listener;
package com.massivedisaster.adal.location.listener;

/**
* Listener to provider status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* with ADAL. If not, see <http://www.gnu.org/licenses/>.
*/

package com.massivedisaster.location.utils;
package com.massivedisaster.adal.location.utils;

public enum LocationError {
TIMEOUT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* with ADAL. If not, see <http://www.gnu.org/licenses/>.
*/

package com.massivedisaster.location.utils;
package com.massivedisaster.adal.location.utils;

import android.util.Log;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

import com.massivedisaster.adal.fragment.BaseFragment;
import com.massivedisaster.adal.sample.R;
import com.massivedisaster.location.LocationManager;
import com.massivedisaster.location.listener.OnLocationManager;
import com.massivedisaster.location.utils.LocationError;
import com.massivedisaster.adal.location.LocationManager;
import com.massivedisaster.adal.location.listener.OnLocationManager;
import com.massivedisaster.adal.location.utils.LocationError;

public class FragmentLocation extends BaseFragment {

Expand Down