diff options
6 files changed, 72 insertions, 29 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index cdcf01b7b1..abcbd57964 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.library' +apply plugin: 'maven-publish' dependencies { compile rootProject.ext.dep.supportAnnotations diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java index a0d35c8727..5919d653e8 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java @@ -16,6 +16,7 @@ import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException; import com.mapbox.mapboxsdk.location.LocationSource; import com.mapbox.mapboxsdk.net.ConnectivityReceiver; +import com.mapbox.services.android.telemetry.TelemetryListener; import java.io.IOException; @@ -64,18 +65,21 @@ public final class Mapbox { locationEngine.setPriority(LocationEnginePriority.NO_POWER); try { - telemetry = new MapboxTelemetry(appContext, accessToken, BuildConfig.MAPBOX_EVENTS_USER_AGENT, - new Callback() { - @Override - public void onFailure(Call call, IOException exception) { - Timber.d(exception, "Mapbox telemetry request failed"); - } - - @Override - public void onResponse(Call call, Response response) throws IOException { - Timber.d("Mapbox telemetry response: %s", response.body().string()); - } - }); + telemetry = new MapboxTelemetry(appContext, accessToken, BuildConfig.MAPBOX_EVENTS_USER_AGENT); + + TelemetryListener telemetryListener = new TelemetryListener() { + @Override + public void onHttpResponse(boolean b, int i) { + + } + + @Override + public void onHttpFailure(String s) { + + } + }; + + telemetry.addTelemetryListener(telemetryListener); telemetry.enable(); } catch (Exception exception) { Timber.e(exception, "Unable to instantiate Mapbox telemetry"); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java index 4aab528181..95e37b7f92 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java @@ -90,7 +90,7 @@ class AttributionDialogManager implements View.OnClickListener, DialogInterface. builder.setPositiveButton(R.string.mapbox_attributionTelemetryPositive, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - Mapbox.obtainTelemetry().optIn(); + Mapbox.obtainTelemetry().enable(); dialog.cancel(); } }); @@ -104,7 +104,7 @@ class AttributionDialogManager implements View.OnClickListener, DialogInterface. builder.setNegativeButton(R.string.mapbox_attributionTelemetryNegative, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - Mapbox.obtainTelemetry().optOut(); + Mapbox.obtainTelemetry().disable(); dialog.cancel(); } }); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 921ecb31cf..44c2be6ae4 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -25,7 +25,6 @@ import android.widget.ZoomButtonsController; import com.mapbox.android.telemetry.Event; import com.mapbox.android.telemetry.MapEventFactory; -import com.mapbox.android.telemetry.MapboxTelemetry; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.annotations.Annotation; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 638e3f94eb..6b293f1efb 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -43,7 +43,6 @@ import com.mapbox.mapboxsdk.style.layers.Filter; import com.mapbox.mapboxsdk.style.layers.Layer; import com.mapbox.mapboxsdk.style.light.Light; import com.mapbox.mapboxsdk.style.sources.Source; -//import com.mapbox.services.android.core.location.LocationEngine; import com.mapbox.services.commons.geojson.Feature; import com.mapbox.services.commons.geojson.Geometry; @@ -2050,17 +2049,17 @@ public final class MapboxMap { trackingSettings.setOnMyLocationChangeListener(listener); } -// /** -// * Replaces the location source of the my-location layer. -// * -// * @param locationSource A {@link LocationEngine} location source to use in the my-location layer. -// * @deprecated use location layer plugin from -// * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. -// */ -// @Deprecated -// public void setLocationSource(@Nullable LocationEngine locationSource) { -// trackingSettings.setLocationSource(locationSource); -// } + /** + * Replaces the location source of the my-location layer. + * + * @param locationSource A {@link LocationEngine} location source to use in the my-location layer. + * @deprecated use location layer plugin from + * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. + */ + @Deprecated + public void setLocationSource(@Nullable LocationEngine locationSource) { + trackingSettings.setLocationSource(locationSource); + } /** * Sets a callback that's invoked when the location tracking mode changes. diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java index e61d49edb9..9482168e3e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java @@ -392,8 +392,7 @@ public final class TrackingSettings { this.isCustomLocationSource = locationSource != null; if (locationSource == null) { - locationSource = new LocationEngine() { - }; + locationSource = generateLocationEngine(); } this.locationSource = locationSource; myLocationView.setLocationSource(locationSource); @@ -417,4 +416,45 @@ public final class TrackingSettings { interface CameraZoomInvalidator { void zoomTo(double zoomLevel); } + + private LocationEngine generateLocationEngine() { + LocationEngine locationEngine = new LocationEngine() { + @Override + public void activate() { + + } + + @Override + public void deactivate() { + + } + + @Override + public boolean isConnected() { + return false; + } + + @Override + public Location getLastLocation() { + return null; + } + + @Override + public void requestLocationUpdates() { + + } + + @Override + public void removeLocationUpdates() { + + } + + @Override + public Type obtainType() { + return null; + } + }; + + return locationEngine; + } } |