Skip to content

Commit

Permalink
Merge pull request #7 from quentin7b/deprecation
Browse files Browse the repository at this point in the history
[Deprecation] Add deprecation items
  • Loading branch information
quentin7b committed Dec 19, 2015
2 parents abc65c9 + ff35209 commit 2e9a2c1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ Add this to your `build.gradle` file
url "https://jitpack.io"
}
}

dependencies {
compile 'com.github.quentin7b:android-location-tracker:3.0'
compile 'com.github.quentin7b:android-location-tracker:3.1'
}

Dont forget to add the following permissions to your *AndroidManifest.xml*
Don't forget to add the following permissions to your *AndroidManifest.xml*

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

Be aware of `Android Marshmallow`'s new [permission system](https://developer.android.com/preview/features/runtime-permissions.html)

<permission-group
<permission-group
android:name="android.permission-group.LOCATION"
android:label="A label for your permission"
android:description="A description for the permission" />
Expand All @@ -39,7 +39,7 @@ To create a tracker you just need to add the below code in your Android Activity

// You can pass an ui Context but it is not mandatory getApplicationContext() would also works
LocationTracker tracker = new LocationTracker(context) {

@Override
public void onLocationFound(Location location) {
// Do some stuff
Expand All @@ -65,7 +65,7 @@ As an example:
.setUseNetwork(false)
.setUsePassive(false)
) {

@Override
public void onLocationFound(Location location) {
// Do some stuff when a new GPS Location has been found
Expand All @@ -86,17 +86,17 @@ This, will call a location tracker that is looking *ONLY* for *GPS* updates.

To specify those parameters, `LocationTracker` you can set more settings.
Here is an example of call:
TrackerSettings settings =

TrackerSettings settings =
new TrackerSettings()
.setUseGPS(true)
.setUseNetwork(true)
.setUsePassive(true)
.setTimeBetweenUpdates(30 * 60 * 1000)
.setMetersBetweenUpdates(100);

LocationTracker tracker = new LocationTracker(context, settings) {

@Override
public void onLocationFound(Location location) {
// Do some stuff when a new location has been found.
Expand All @@ -118,7 +118,7 @@ If you want to *stop* listening for updates, just call the `stopListening()` met
For example, if you need a *one shot* position, you can do that:

LocationTracker tracker = new LocationTracker(context) {

@Override
public void onLocationFound(Location location) {
// Stop listening for updates
Expand All @@ -127,7 +127,7 @@ For example, if you need a *one shot* position, you can do that:
}
};
tracker.startListening();


You can also do it in the `onPause()` Activity method if you want.

Expand Down Expand Up @@ -157,7 +157,7 @@ For example, in the `onResume()` Activity method:

`LocationTracker` implements Android's [LocationListener](http://developer.android.com/reference/android/location/LocationListener.html) interface.

By default, it does nothing but logging.
By default, it does nothing but logging.

Excepts the `onLocationChanged()` method, you can override all the [LocationListener](http://developer.android.com/reference/android/location/LocationListener.html)'s metods, so here is the list:
<ul>
Expand Down
12 changes: 6 additions & 6 deletions simple-location-tracker/slt/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 5
versionName "3.0"
targetSdkVersion 23
versionCode 6
versionName "3.1"
}

libraryVariants.all { variant ->
Expand All @@ -32,5 +32,5 @@ android {
}

dependencies {
compile 'com.android.support:support-annotations:22.2.0'
compile 'com.android.support:support-annotations:23.1.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public abstract class LocationTracker implements LocationListener {
*
* @param context Android context, uiContext is not mandatory.
*/
@RequiresPermission(anyOf = {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION})
public LocationTracker(@NonNull Context context) {
this(context, TrackerSettings.DEFAULT);
}
Expand All @@ -67,6 +68,7 @@ public LocationTracker(@NonNull Context context) {
* @param context Android context, uiContext is not mandatory.
* @param trackerSettings {@link TrackerSettings}, the tracker settings
*/
@RequiresPermission(anyOf = {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION})
public LocationTracker(@NonNull Context context, @NonNull TrackerSettings trackerSettings) {
this.mContext = context;
this.mTrackerSettings = trackerSettings;
Expand All @@ -85,6 +87,17 @@ public LocationTracker(@NonNull Context context, @NonNull TrackerSettings tracke
}
}

/**
* Deprecated since 3.1
* Used to make the tracker listening for location updates
*
* @see #startListening()
*/
@Deprecated
public final void startListen() {
startListening();
}

/**
* Make the tracker listening for location updates
*/
Expand Down Expand Up @@ -130,9 +143,21 @@ public void run() {
}
}

/**
* Deprecated since 3.1
* Used to make the tracker stops listening for location updates
*
* @see #stopListening()
*/
@Deprecated
public final void stopListen() {
stopListening();
}

/**
* Make the tracker stops listening for location updates
*/
@RequiresPermission(anyOf = {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION})
public final void stopListening() {
if (this.mIsListening) {
Log.i(TAG, "LocationTracked has stopped listening for location updates");
Expand Down

0 comments on commit 2e9a2c1

Please sign in to comment.