Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[android] Update Android SDK, gradle plugin and mapzen lib #6548

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions platform/android/MapboxGLAndroidSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ repositories {
}

ext {
supportLibVersion = '23.4.0'
supportLibVersion = '24.2.1'
}

dependencies {
compile "com.android.support:support-annotations:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile 'com.squareup.okhttp3:okhttp:3.3.0'
compile 'com.mapzen.android:lost:1.1.1'
compile 'com.mapzen.android:lost:2.0.0'

// Mapbox Android Services
compile('com.mapbox.mapboxsdk:mapbox-java-services:1.3.1@jar') {
Expand Down
6 changes: 3 additions & 3 deletions platform/android/MapboxGLAndroidSDK/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ POM_DEVELOPER_ID=mapbox
POM_DEVELOPER_NAME=Mapbox

ANDROID_MIN_SDK=15
ANDROID_BUILD_TARGET_SDK_VERSION=23
ANDROID_BUILD_TOOLS_VERSION=23.0.3
ANDROID_BUILD_SDK_VERSION=23
ANDROID_BUILD_TARGET_SDK_VERSION=24
ANDROID_BUILD_TOOLS_VERSION=24.0.2
ANDROID_BUILD_SDK_VERSION=24

POM_NAME=Mapbox Android SDK
POM_ARTIFACT_ID=mapbox-android-sdk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* Do not unregister in Activity.onSaveInstanceState(), because this won't be called if the user moves back in the history stack.
* </p>
*/
public class LocationServices implements com.mapzen.android.lost.api.LocationListener {
public class LocationServices implements com.mapzen.android.lost.api.LocationListener, LostApiClient.ConnectionCallbacks {

private static final String TAG = "LocationServices";

Expand Down Expand Up @@ -76,42 +76,17 @@ public void toggleGPS(boolean enableGPS) {
Log.w(TAG, "Location Permissions Not Granted Yet. Try again after requesting.");
return;
}
isGPSEnabled = enableGPS;

// Disconnect
if (locationClient.isConnected()) {
// Disconnect first to ensure that the new requests are GPS
com.mapzen.android.lost.api.LocationServices.FusedLocationApi.removeLocationUpdates(this);
com.mapzen.android.lost.api.LocationServices.FusedLocationApi.removeLocationUpdates(locationClient, this);
locationClient.disconnect();
}

// Setup Fresh
locationClient.connect();
Location lastLocation = com.mapzen.android.lost.api.LocationServices.FusedLocationApi.getLastLocation();
if (lastLocation != null) {
this.lastLocation = lastLocation;
}

LocationRequest locationRequest;

if (enableGPS) {
// 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);
} 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);
}

isGPSEnabled = enableGPS;
}

/**
Expand Down Expand Up @@ -144,6 +119,16 @@ public void onLocationChanged(Location location) {
context.sendBroadcast(locIntent);
}

@Override
public void onProviderDisabled(String provider) {

}

@Override
public void onProviderEnabled(String provider) {

}

/**
* Last known location
*
Expand Down Expand Up @@ -176,6 +161,7 @@ public boolean removeLocationListener(@NonNull LocationListener locationListener

/**
* Check status of Location Permissions
*
* @return True if granted to the app, False if not
*/
public boolean areLocationPermissionsGranted() {
Expand All @@ -186,4 +172,31 @@ public boolean areLocationPermissionsGranted() {
}
return true;
}

/**
* Called when the LocationService is connected. Get the last location and start regular location updates.
*/
@Override
public void onConnected() {
lastLocation = com.mapzen.android.lost.api.LocationServices.FusedLocationApi.getLastLocation(locationClient);
LocationRequest locationRequest;
if (isGPSEnabled) {
// LocationRequest Tuned for GPS
locationRequest = LocationRequest.create()
.setFastestInterval(1000)
.setSmallestDisplacement(3.0f)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
} 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(locationClient, locationRequest, this);
}

@Override
public void onConnectionSuspended() {
}
}
8 changes: 4 additions & 4 deletions platform/android/MapboxGLAndroidSDKTestApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ gradle.projectsEvaluated {
}

ext {
supportLibVersion = '23.4.0'
supportLibVersion = '24.2.1'
}

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 24
buildToolsVersion "24.0.2"

defaultConfig {
applicationId "com.mapbox.mapboxsdk.testapp"
minSdkVersion 15
targetSdkVersion 23
targetSdkVersion 24
versionCode 9
versionName "4.1.0"

Expand Down
2 changes: 1 addition & 1 deletion platform/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.github.JakeWharton:sdk-manager-plugin:220bf7a88a7072df3ed16dc8466fb144f2817070'
classpath 'com.amazonaws:aws-devicefarm-gradle-plugin:1.2'
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.2.1'
Expand Down