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

Commit

Permalink
Downgrade min sdk to 14 (#10355)
Browse files Browse the repository at this point in the history
* [android] - downgrade minimum sdk version to 14

* [android] bump MAS version to the one which includes min sdk version 14

* bump lost version to 3.0.4
  • Loading branch information
tobrun authored Nov 13, 2017
1 parent a0cfac4 commit a9bd09c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 19 deletions.
1 change: 0 additions & 1 deletion platform/android/MapboxGLAndroidSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies {
compile rootProject.ext.dep.timber
compile rootProject.ext.dep.okhttp3
provided(rootProject.ext.dep.lost) {
exclude group: 'com.google.guava'
exclude group: 'com.android.support'
}
testCompile rootProject.ext.dep.junit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapbox.mapboxsdk">
xmlns:tools="http://schemas.android.com/tools"
package="com.mapbox.mapboxsdk">

<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-feature android:name="android.hardware.wifi" android:required="false" /> <!-- Implied by ACCESS_WIFI_STATE. -->
<uses-feature android:name="android.hardware.location.gps" android:required="false"/>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

<uses-sdk tools:overrideLibrary="com.mapzen.lost"/>

<application>
<!-- Include the telemetry service to simplify set up (https://www.mapbox.com/telemetry) -->
<service android:name="com.mapbox.services.android.telemetry.service.TelemetryService"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @deprecated Use a {@link Mapbox#getLocationEngine()} instead.
*/
@Deprecated
public class LocationSource extends LocationEngine implements LocationListener {
public class LocationSource extends LocationEngine implements LostApiClient.ConnectionCallbacks, LocationListener {

private Context context;
private LostApiClient lostApiClient;
Expand All @@ -45,7 +45,9 @@ public class LocationSource extends LocationEngine implements LocationListener {
public LocationSource(Context context) {
super();
this.context = context.getApplicationContext();
lostApiClient = new LostApiClient.Builder(this.context).build();
lostApiClient = new LostApiClient.Builder(this.context)
.addConnectionCallbacks(this)
.build();
}

/**
Expand All @@ -61,12 +63,7 @@ public LocationSource() {
*/
@Override
public void activate() {
if (!lostApiClient.isConnected()) {
lostApiClient.connect();
}
for (LocationEngineListener listener : locationListeners) {
listener.onConnected();
}
connect();
}

/**
Expand All @@ -76,7 +73,7 @@ public void activate() {
*/
@Override
public void deactivate() {
if (lostApiClient.isConnected()) {
if (lostApiClient != null && lostApiClient.isConnected()) {
lostApiClient.disconnect();
}
}
Expand All @@ -92,6 +89,24 @@ public boolean isConnected() {
return lostApiClient.isConnected();
}

/**
* Invoked when the location provider has connected.
*/
@Override
public void onConnected() {
for (LocationEngineListener listener : locationListeners) {
listener.onConnected();
}
}

/**
* Invoked when the location provider connection has been suspended.
*/
@Override
public void onConnectionSuspended() {
// Empty
}

/**
* Returns the Last known location is the location provider is connected and location permissions are granted.
*
Expand All @@ -102,7 +117,7 @@ public boolean isConnected() {
public Location getLastLocation() {
if (lostApiClient.isConnected()) {
//noinspection MissingPermission
return LocationServices.FusedLocationApi.getLastLocation();
return LocationServices.FusedLocationApi.getLastLocation(lostApiClient);
}
return null;
}
Expand Down Expand Up @@ -136,7 +151,7 @@ public void requestLocationUpdates() {

if (lostApiClient.isConnected()) {
//noinspection MissingPermission
LocationServices.FusedLocationApi.requestLocationUpdates(request, this);
LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
}
}

Expand All @@ -146,7 +161,7 @@ public void requestLocationUpdates() {
@Override
public void removeLocationUpdates() {
if (lostApiClient.isConnected()) {
LocationServices.FusedLocationApi.removeLocationUpdates(this);
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
}
}

Expand All @@ -171,4 +186,14 @@ public void onLocationChanged(Location location) {
listener.onLocationChanged(location);
}
}

private void connect() {
if (lostApiClient != null) {
if (lostApiClient.isConnected()) {
onConnected();
} else {
lostApiClient.connect();
}
}
}
}
6 changes: 3 additions & 3 deletions platform/android/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ext {
minSdkVersion = 15
minSdkVersion = 14
targetSdkVersion = 25
compileSdkVersion = 25
buildToolsVersion = "25.0.2"

versionCode = 11
versionName = "5.0.0"

mapboxServicesVersion = "2.2.8"
mapboxServicesVersion = "2.2.9"
supportLibVersion = "25.4.0"
espressoVersion = '3.0.1'
testRunnerVersion = '1.0.1'
Expand All @@ -20,7 +20,7 @@ ext {
mapboxAndroidTelemetry : "com.mapbox.mapboxsdk:mapbox-android-telemetry:${mapboxServicesVersion}@aar",

// mapzen lost
lost : 'com.mapzen.android:lost:1.1.1',
lost : 'com.mapzen.android:lost:3.0.4',

// unit test
junit : 'junit:junit:4.12',
Expand Down

0 comments on commit a9bd09c

Please sign in to comment.