summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2016-12-21 12:32:07 +0100
committerGitHub <noreply@github.com>2016-12-21 12:32:07 +0100
commit2b38af877871e234d9afb415dab68aa0543403da (patch)
tree50a064fcf8836ede081f65aaedb2e1e37514cbf9 /platform
parenta6b1773a44d4ef086eb30967cb041cb64312650a (diff)
downloadqtlocation-mapboxgl-2b38af877871e234d9afb415dab68aa0543403da.tar.gz
[android] - update lost to 2.0.0, gradle cleanup (#7494)
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/build.gradle4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java39
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/build.gradle27
3 files changed, 43 insertions, 27 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle
index b17fa91d04..b76889da5c 100644
--- a/platform/android/MapboxGLAndroidSDK/build.gradle
+++ b/platform/android/MapboxGLAndroidSDK/build.gradle
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
ext {
- supportLibVersion = '25.0.0'
+ supportLibVersion = '25.1.0'
}
dependencies {
@@ -9,7 +9,7 @@ dependencies {
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile 'com.squareup.okhttp3:okhttp:3.5.0'
- compile 'com.mapzen.android:lost:1.1.1'
+ compile 'com.mapzen.android:lost:2.0.0'
compile 'com.jakewharton.timber:timber:4.3.1'
// Mapbox Android Services
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java
index 666dcb565f..a1ed5d5b00 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java
@@ -17,6 +17,8 @@ import com.mapzen.android.lost.api.LostApiClient;
import java.util.concurrent.CopyOnWriteArrayList;
+import static com.mapzen.android.lost.api.LocationServices.FusedLocationApi;
+
/**
* Manages locational updates. Contains methods to register and unregister location listeners.
* <ul>
@@ -31,7 +33,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
* in the history stack.
* </p>
*/
-public class LocationServices implements com.mapzen.android.lost.api.LocationListener {
+public class LocationServices implements LostApiClient.ConnectionCallbacks,
+ com.mapzen.android.lost.api.LocationListener {
private static LocationServices instance;
@@ -50,7 +53,7 @@ public class LocationServices implements com.mapzen.android.lost.api.LocationLis
super();
this.context = context;
// Setup location services
- locationClient = new LostApiClient.Builder(context).build();
+ locationClient = new LostApiClient.Builder(context).addConnectionCallbacks(this).build();
locationListeners = new CopyOnWriteArrayList<>();
}
@@ -81,38 +84,46 @@ public class LocationServices implements com.mapzen.android.lost.api.LocationLis
// Disconnect
if (locationClient.isConnected()) {
// Disconnect first to ensure that the new requests are GPS
- com.mapzen.android.lost.api.LocationServices.FusedLocationApi.removeLocationUpdates(this);
+ FusedLocationApi.removeLocationUpdates(locationClient, this);
locationClient.disconnect();
}
+ isGpsEnabled = enableGPS;
// Setup Fresh
locationClient.connect();
- Location lastLocation = com.mapzen.android.lost.api.LocationServices.FusedLocationApi.getLastLocation();
+ }
+
+ @Override
+ public void onConnected() {
+ //noinspection MissingPermission
+ Location lastLocation = FusedLocationApi.getLastLocation(locationClient);
if (lastLocation != null) {
this.lastLocation = lastLocation;
}
LocationRequest locationRequest;
- if (enableGPS) {
+ if (isGpsEnabled) {
// LocationRequest Tuned for GPS
locationRequest = LocationRequest.create()
.setFastestInterval(1000)
.setSmallestDisplacement(3.0f)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
-
- com.mapzen.android.lost.api.LocationServices.FusedLocationApi.requestLocationUpdates(locationRequest, this);
+ //noinspection MissingPermission
+ FusedLocationApi.requestLocationUpdates(locationClient, locationRequest, this);
} else {
// LocationRequest Tuned for PASSIVE
locationRequest = LocationRequest.create()
.setFastestInterval(1000)
.setSmallestDisplacement(3.0f)
.setPriority(LocationRequest.PRIORITY_NO_POWER);
-
- com.mapzen.android.lost.api.LocationServices.FusedLocationApi.requestLocationUpdates(locationRequest, this);
+ //noinspection MissingPermission
+ FusedLocationApi.requestLocationUpdates(locationClient, locationRequest, this);
}
+ }
- isGpsEnabled = enableGPS;
+ @Override
+ public void onConnectionSuspended() {
}
/**
@@ -190,4 +201,12 @@ public class LocationServices implements com.mapzen.android.lost.api.LocationLis
}
return true;
}
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
index b4d5548ae5..9899942b5f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
+++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
@@ -1,7 +1,10 @@
apply plugin: 'com.android.application'
ext {
- supportLibVersion = '25.0.1'
+ supportLibVersion = '25.1.0'
+ espressoVersion = '2.2.2'
+ testRunnerVersion = '0.5'
+ leakCanaryVersion = '1.5'
}
android {
@@ -14,7 +17,6 @@ android {
targetSdkVersion 25
versionCode 11
versionName "5.0.0"
-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
@@ -66,24 +68,19 @@ dependencies {
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
// Leak Canary
- debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
- releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
- testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
-
- // Mapbox Android Services
- compile('com.mapbox.mapboxsdk:mapbox-android-services:1.3.0@aar') {
- transitive = true
- }
+ debugCompile "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}"
+ releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
+ testCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
// Testing dependencies
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.2.27'
- androidTestCompile "com.android.support:support-annotations:${supportLibVersion}"
- androidTestCompile 'com.android.support.test:runner:0.5'
- androidTestCompile 'com.android.support.test:rules:0.5'
- androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.squareup.spoon:spoon-client:1.6.2'
- androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
+ androidTestCompile "com.android.support:support-annotations:${supportLibVersion}"
+ androidTestCompile "com.android.support.test:runner:${testRunnerVersion}"
+ androidTestCompile "com.android.support.test:rules:${testRunnerVersion}"
+ androidTestCompile "com.android.support.test.espresso:espresso-core:${espressoVersion}"
+ androidTestCompile "com.android.support.test.espresso:espresso-intents:${espressoVersion}"
}
apply from: 'gradle-make.gradle'