From a30a81b53e3a985ca87eda6495b38957e7568795 Mon Sep 17 00:00:00 2001 From: Guardiola31337 Date: Tue, 23 Jan 2018 20:39:01 +0100 Subject: [PATCH 1/2] [android] integration of the new events library --- .../android/MapboxGLAndroidSDK/build.gradle | 1 - .../lint-baseline-local.xml | 37 ---- .../lint/lint-baseline-ci.xml | 44 ---- .../mapbox/mapboxsdk/EmptyLocationSource.java | 107 ---------- .../java/com/mapbox/mapboxsdk/Mapbox.java | 31 ++- .../mapboxsdk/camera/CameraPosition.java | 2 +- .../mapboxsdk/location/LocationSource.java | 199 ------------------ .../mapboxsdk/location/package-info.java | 4 - .../maps/AttributionDialogManager.java | 6 +- .../mapboxsdk/maps/MapGestureDetector.java | 101 +++++---- .../com/mapbox/mapboxsdk/maps/MapView.java | 8 +- .../mapboxsdk/maps/MapboxEventWrapper.java | 57 ----- .../com/mapbox/mapboxsdk/maps/MapboxMap.java | 2 +- .../mapboxsdk/maps/TrackingSettings.java | 6 +- .../mapboxsdk/maps/widgets/CompassView.java | 4 +- .../maps/widgets/MyLocationView.java | 6 +- .../com/mapbox/mapboxsdk/utils/MathUtils.java | 79 +++++++ .../res/{values-he => values-iw}/strings.xml | 0 .../java/com/mapbox/mapboxsdk/MapboxTest.java | 2 +- .../MapboxGLAndroidSDKTestApp/build.gradle | 3 +- .../src/main/AndroidManifest.xml | 2 +- .../activity/FeatureOverviewActivity.java | 4 +- .../userlocation/BaseLocationActivity.java | 4 +- .../userlocation/MockLocationEngine.java | 4 +- .../MyLocationDrawableActivity.java | 2 +- .../userlocation/MyLocationTintActivity.java | 2 +- .../MyLocationTrackingModeActivity.java | 2 +- platform/android/gradle/dependencies.gradle | 4 +- 28 files changed, 186 insertions(+), 537 deletions(-) delete mode 100644 platform/android/MapboxGLAndroidSDK/lint-baseline-local.xml delete mode 100644 platform/android/MapboxGLAndroidSDK/lint/lint-baseline-ci.xml delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/EmptyLocationSource.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/package-info.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxEventWrapper.java create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MathUtils.java rename platform/android/MapboxGLAndroidSDK/src/main/res/{values-he => values-iw}/strings.xml (100%) diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index 0900f700c8f..a1028aa1d03 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -114,7 +114,6 @@ android { lintOptions { disable 'MissingTranslation', 'TypographyQuotes', 'ObsoleteLintCustomCheck', 'MissingPermission' - baseline file("lint-baseline-local.xml") checkAllWarnings true warningsAsErrors false } diff --git a/platform/android/MapboxGLAndroidSDK/lint-baseline-local.xml b/platform/android/MapboxGLAndroidSDK/lint-baseline-local.xml deleted file mode 100644 index 0a76f535056..00000000000 --- a/platform/android/MapboxGLAndroidSDK/lint-baseline-local.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/platform/android/MapboxGLAndroidSDK/lint/lint-baseline-ci.xml b/platform/android/MapboxGLAndroidSDK/lint/lint-baseline-ci.xml deleted file mode 100644 index fd65c9f6277..00000000000 --- a/platform/android/MapboxGLAndroidSDK/lint/lint-baseline-ci.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/EmptyLocationSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/EmptyLocationSource.java deleted file mode 100644 index 8ea7e61eee0..00000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/EmptyLocationSource.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.mapbox.mapboxsdk; - - -import android.location.Location; -import android.support.annotation.Nullable; - -import com.mapbox.mapboxsdk.location.LocationSource; -import com.mapbox.services.android.telemetry.location.LocationEngine; -import com.mapbox.services.android.telemetry.location.LocationEngineListener; - -class EmptyLocationSource extends LocationSource { - - /** - * Activate the location engine which will connect whichever location provider you are using. You'll need to call - * this before requesting user location updates using {@link LocationEngine#requestLocationUpdates()}. - */ - @Override - public void activate() { - // Intentionally left empty - } - - /** - * Disconnect the location engine which is useful when you no longer need location updates or requesting the users - * {@link LocationEngine#getLastLocation()}. Before deactivating, you'll need to stop request user location updates - * using {@link LocationEngine#removeLocationUpdates()}. - */ - @Override - public void deactivate() { - // Intentionally left empty - } - - /** - * Check if your location provider has been activated/connected. This is mainly used internally but is also useful in - * the rare case when you'd like to know if your location engine is connected or not. - * - * @return boolean true if the location engine has been activated/connected, else false. - */ - @Override - public boolean isConnected() { - return false; - } - - /** - * Returns the Last known location is the location provider is connected and location permissions are granted. - * - * @return the last known location - */ - @Override - @Nullable - public Location getLastLocation() { - return null; - } - - /** - * Request location updates to the location provider. - */ - @Override - public void requestLocationUpdates() { - // Intentionally left empty - } - - /** - * Dismiss ongoing location update to the location provider. - */ - @Override - public void removeLocationUpdates() { - // Intentionally left empty - } - - /** - * Invoked when the Location has changed. - * - * @param location the new location - */ - @Override - public void onLocationChanged(Location location) { - // Intentionally left empty - } - - /** - * Useful when you'd like to add a location listener to handle location connections and update events. It is important - * to note, that the callback will continue getting called even when your application isn't in the foreground. - * Therefore, it is a good idea to use {@link LocationEngine#removeLocationEngineListener(LocationEngineListener)} - * inside your activities {@code onStop()} method. - * - * @param listener A {@link LocationEngineListener} which you'd like to add to your location engine. - * @since 2.0.0 - */ - @Override - public void addLocationEngineListener(LocationEngineListener listener) { - // Intentionally left empty - } - - /** - * If you no longer need your {@link LocationEngineListener} to be invoked with every location update, use this - * method to remove it. It's also important to remove your listeners before the activity is destroyed to prevent any - * potential memory leaks. - * - * @param listener the {@link LocationEngineListener} you'd like to remove from this {@link LocationEngine}. - * @return true. - * @since 2.0.0 - */ - @Override - public boolean removeLocationEngineListener(LocationEngineListener listener) { - return true; - } -} 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 b67b6e96f2b..245424d769c 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 @@ -8,14 +8,13 @@ import android.support.annotation.UiThread; import android.text.TextUtils; +import com.mapbox.android.core.location.LocationEngine; +import com.mapbox.android.core.location.LocationEnginePriority; +import com.mapbox.android.core.location.LocationEngineProvider; +import com.mapbox.android.telemetry.MapboxTelemetry; 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.MapboxTelemetry; -import com.mapbox.services.android.telemetry.location.LocationEngine; -import com.mapbox.services.android.telemetry.location.LocationEnginePriority; -import com.mapbox.services.android.telemetry.location.LocationEngineProvider; import timber.log.Timber; @@ -36,6 +35,8 @@ public final class Mapbox { private String accessToken; private Boolean connected; private LocationEngine locationEngine; + @SuppressLint("StaticFieldLeak") + private static MapboxTelemetry telemetry; /** * Get an instance of Mapbox. @@ -57,8 +58,8 @@ public static synchronized Mapbox getInstance(@NonNull Context context, @NonNull locationEngine.setPriority(LocationEnginePriority.NO_POWER); try { - MapboxTelemetry.getInstance().initialize( - appContext, accessToken, BuildConfig.MAPBOX_EVENTS_USER_AGENT, locationEngine); + telemetry = new MapboxTelemetry(appContext, accessToken, BuildConfig.MAPBOX_EVENTS_USER_AGENT); + telemetry.enable(); } catch (Exception exception) { Timber.e(exception, "Unable to instantiate Mapbox telemetry"); } @@ -145,18 +146,6 @@ public static synchronized Boolean isConnected() { return (activeNetwork != null && activeNetwork.isConnected()); } - /** - * Returns a location source instance with empty methods. - * - * @return an empty location source implementation - * @deprecated Replaced by {@link Mapbox#getLocationEngine()} - */ - @Deprecated - public static LocationSource getLocationSource() { - return new EmptyLocationSource(); - } - - /** * Returns the location engine used by the SDK. * @@ -165,4 +154,8 @@ public static LocationSource getLocationSource() { public static LocationEngine getLocationEngine() { return INSTANCE.locationEngine; } + + public static MapboxTelemetry obtainTelemetry() { + return INSTANCE.telemetry; + } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java index c2f19072dbd..e732b2525fd 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java @@ -8,7 +8,7 @@ import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.services.android.telemetry.utils.MathUtils; +import com.mapbox.mapboxsdk.utils.MathUtils; /** * Resembles the position, angle, zoom and tilt of the user's viewpoint. diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java deleted file mode 100644 index 13135871581..00000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java +++ /dev/null @@ -1,199 +0,0 @@ -package com.mapbox.mapboxsdk.location; - -import android.content.Context; -import android.location.Location; -import android.support.annotation.Nullable; - -import com.mapbox.mapboxsdk.Mapbox; -import com.mapbox.services.android.telemetry.location.LocationEngine; -import com.mapbox.services.android.telemetry.location.LocationEngineListener; -import com.mapbox.services.android.telemetry.location.LocationEnginePriority; -import com.mapzen.android.lost.api.LocationListener; -import com.mapzen.android.lost.api.LocationRequest; -import com.mapzen.android.lost.api.LocationServices; -import com.mapzen.android.lost.api.LostApiClient; - -/** - * LocationEngine using the Open Source Lost library - * Manages locational updates. Contains methods to register and unregister location listeners. - * - *

- * Note: If registering a listener in your Activity.onStart() implementation, you should unregister it in - * Activity.onStop(). (You won't receive location updates when paused, and this will cut down on unnecessary system - * overhead). Do not unregister in Activity.onSaveInstanceState(), because this won't be called if the user moves back - * in the history stack. - *

- * - * @deprecated Use a {@link Mapbox#getLocationEngine()} instead. - */ -@Deprecated -public class LocationSource extends LocationEngine implements LostApiClient.ConnectionCallbacks, LocationListener { - - private Context context; - private LostApiClient lostApiClient; - - /** - * Constructs a location source instance. - * - * @param context the context from which the Application context will be derived. - */ - public LocationSource(Context context) { - super(); - this.context = context.getApplicationContext(); - lostApiClient = new LostApiClient.Builder(this.context) - .addConnectionCallbacks(this) - .build(); - } - - /** - * Constructs a location source instance. - * Needed to create empty location source implementations. - */ - public LocationSource() { - } - - /** - * Activate the location engine which will connect whichever location provider you are using. You'll need to call - * this before requesting user location updates using {@link LocationEngine#requestLocationUpdates()}. - */ - @Override - public void activate() { - connect(); - } - - /** - * Disconnect the location engine which is useful when you no longer need location updates or requesting the users - * {@link LocationEngine#getLastLocation()}. Before deactivating, you'll need to stop request user location updates - * using {@link LocationEngine#removeLocationUpdates()}. - */ - @Override - public void deactivate() { - if (lostApiClient != null && lostApiClient.isConnected()) { - lostApiClient.disconnect(); - } - } - - /** - * Check if your location provider has been activated/connected. This is mainly used internally but is also useful in - * the rare case when you'd like to know if your location engine is connected or not. - * - * @return boolean true if the location engine has been activated/connected, else false. - */ - @Override - 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. - * - * @return the last known location - */ - @Override - @Nullable - public Location getLastLocation() { - if (lostApiClient.isConnected()) { - //noinspection MissingPermission - return LocationServices.FusedLocationApi.getLastLocation(lostApiClient); - } - return null; - } - - /** - * Request location updates to the location provider. - */ - @Override - public void requestLocationUpdates() { - LocationRequest request = LocationRequest.create(); - - if (interval != null) { - request.setInterval(interval); - } - if (fastestInterval != null) { - request.setFastestInterval(fastestInterval); - } - if (smallestDisplacement != null) { - request.setSmallestDisplacement(smallestDisplacement); - } - - if (priority == LocationEnginePriority.NO_POWER) { - request.setPriority(LocationRequest.PRIORITY_NO_POWER); - } else if (priority == LocationEnginePriority.LOW_POWER) { - request.setPriority(LocationRequest.PRIORITY_LOW_POWER); - } else if (priority == LocationEnginePriority.BALANCED_POWER_ACCURACY) { - request.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); - } else if (priority == LocationEnginePriority.HIGH_ACCURACY) { - request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); - } - - if (lostApiClient.isConnected()) { - //noinspection MissingPermission - LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this); - } - } - - /** - * Dismiss ongoing location update to the location provider. - */ - @Override - public void removeLocationUpdates() { - if (lostApiClient.isConnected()) { - LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this); - } - } - - /** - * Returns the location engine type. - * - * @return Lost type - */ - @Override - public Type obtainType() { - return Type.LOST; - } - - /** - * Invoked when the Location has changed. - * - * @param location the new location - */ - @Override - public void onLocationChanged(Location location) { - for (LocationEngineListener listener : locationListeners) { - listener.onLocationChanged(location); - } - } - - private void connect() { - if (lostApiClient != null) { - if (lostApiClient.isConnected()) { - onConnected(); - } else { - lostApiClient.connect(); - } - } - } -} \ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/package-info.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/package-info.java deleted file mode 100644 index b27559e95e0..00000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Contains the Mapbox Maps Android Location API classes. - */ -package com.mapbox.mapboxsdk.location; \ No newline at end of file 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 b12757c81ec..53472eb8706 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 @@ -11,12 +11,12 @@ import android.widget.ArrayAdapter; import android.widget.Toast; +import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.attribution.Attribution; import com.mapbox.mapboxsdk.attribution.AttributionParser; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.style.sources.Source; -import com.mapbox.services.android.telemetry.MapboxTelemetry; import java.util.ArrayList; import java.util.List; @@ -88,7 +88,7 @@ private void showTelemetryDialog() { builder.setPositiveButton(R.string.mapbox_attributionTelemetryPositive, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - MapboxTelemetry.getInstance().setTelemetryEnabled(true); + Mapbox.obtainTelemetry().enable(); dialog.cancel(); } }); @@ -102,7 +102,7 @@ public void onClick(DialogInterface dialog, int which) { builder.setNegativeButton(R.string.mapbox_attributionTelemetryNegative, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - MapboxTelemetry.getInstance().setTelemetryEnabled(false); + Mapbox.obtainTelemetry().disable(); dialog.cancel(); } }); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index 1788cb4428c..788ae48e8eb 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -5,7 +5,6 @@ import android.animation.ValueAnimator; import android.content.Context; import android.graphics.PointF; -import android.location.Location; import android.support.annotation.Nullable; import android.support.v4.view.GestureDetectorCompat; import android.support.v4.view.ScaleGestureDetectorCompat; @@ -19,12 +18,13 @@ import com.almeros.android.multitouch.gesturedetectors.RotateGestureDetector; import com.almeros.android.multitouch.gesturedetectors.ShoveGestureDetector; import com.almeros.android.multitouch.gesturedetectors.TwoFingerGestureDetector; +import com.mapbox.android.telemetry.Event; +import com.mapbox.android.telemetry.MapEventFactory; +import com.mapbox.android.telemetry.MapState; +import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.services.android.telemetry.MapboxEvent; -import com.mapbox.services.android.telemetry.MapboxTelemetry; -import com.mapbox.services.android.telemetry.utils.MathUtils; -import com.mapbox.services.android.telemetry.utils.TelemetryUtils; +import com.mapbox.mapboxsdk.utils.MathUtils; import java.util.concurrent.CopyOnWriteArrayList; @@ -144,19 +144,6 @@ PointF getFocalPoint() { return focalPoint; } - /** - * Given coordinates from a gesture, use the current projection to translate it into - * a Location object. - * - * @param x coordinate - * @param y coordinate - * @return location - */ - private Location getLocationFromGesture(float x, float y) { - LatLng latLng = projection.fromScreenLocation(new PointF(x, y)); - return TelemetryUtils.buildLocation(latLng.getLongitude(), latLng.getLatitude()); - } - /** * Called when user touches the screen, all positions are absolute. *

@@ -202,9 +189,13 @@ boolean onTouchEvent(MotionEvent event) { && uiSettings.isZoomGesturesEnabled(); if (twoTap) { // Confirmed 2nd Finger Down - MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( - getLocationFromGesture(event.getX(), event.getY()), - MapboxEvent.GESTURE_TWO_FINGER_SINGLETAP, transform)); + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(event.getX(), event.getY())); + // TODO transform.getZoom() may cause a NullPointerException + MapState twoFingerTap = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) + transform.getZoom()); + twoFingerTap.setGesture("TwoFingerTap"); + Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, twoFingerTap)); } break; @@ -233,8 +224,12 @@ boolean onTouchEvent(MotionEvent event) { // Scroll / Pan Has Stopped if (scrollGestureOccurred) { - MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapDragEndEvent( - getLocationFromGesture(event.getX(), event.getY()), transform)); + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(event.getX(), event.getY())); + // TODO transform.getZoom() may cause a NullPointerException + MapState dragend = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) + transform.getZoom()); + Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_DRAGEND, dragend)); scrollGestureOccurred = false; if (!scaleAnimating && !rotateAnimating) { @@ -350,9 +345,13 @@ public boolean onDoubleTapEvent(MotionEvent e) { // Zoom in on gesture transform.zoom(true, new PointF(e.getX(), e.getY())); } - MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( - getLocationFromGesture(e.getX(), e.getY()), - MapboxEvent.GESTURE_DOUBLETAP, transform)); + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(e.getX(), e.getY())); + // TODO transform.getZoom() may cause a NullPointerException + MapState doubleTap = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) + transform.getZoom()); + doubleTap.setGesture("DoubleTap"); + Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, doubleTap)); break; } @@ -380,9 +379,13 @@ public boolean onSingleTapConfirmed(MotionEvent motionEvent) { notifyOnMapClickListeners(tapPoint); } - MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( - getLocationFromGesture(motionEvent.getX(), motionEvent.getY()), - MapboxEvent.GESTURE_SINGLETAP, transform)); + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(motionEvent.getX(), motionEvent.getY())); + // TODO transform.getZoom() may cause a NullPointerException + MapState singleTap = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) + transform.getZoom()); + singleTap.setGesture("SingleTap"); + Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, singleTap)); return true; } @@ -456,9 +459,13 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float d cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); } - MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( - getLocationFromGesture(e1.getX(), e1.getY()), - MapboxEvent.GESTURE_PAN_START, transform)); + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(e1.getX(), e1.getY())); + // TODO transform.getZoom() may cause a NullPointerException + MapState pan = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) transform + .getZoom()); + pan.setGesture("Pan"); + Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, pan)); } // reset tracking if needed @@ -541,9 +548,13 @@ public boolean onScaleBegin(ScaleGestureDetector detector) { recentScaleGestureOccurred = true; scalePointBegin = new PointF(detector.getFocusX(), detector.getFocusY()); scaleBeginTime = detector.getEventTime(); - MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( - getLocationFromGesture(detector.getFocusX(), detector.getFocusY()), - MapboxEvent.GESTURE_PINCH_START, transform)); + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(detector.getFocusX(), detector.getFocusY())); + // TODO transform.getZoom() may cause a NullPointerException + MapState pinch = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) transform + .getZoom()); + pinch.setGesture("Pinch"); + Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, pinch)); return true; } @@ -724,9 +735,13 @@ public boolean onRotate(RotateGestureDetector detector) { // Also is zoom already started, don't rotate float angle = detector.getRotationDegreesDelta(); if (Math.abs(angle) >= ROTATE_INVOKE_ANGLE) { - MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( - getLocationFromGesture(detector.getFocusX(), detector.getFocusY()), - MapboxEvent.GESTURE_ROTATION_START, transform)); + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(detector.getFocusX(), detector.getFocusY())); + // TODO transform.getZoom() may cause a NullPointerException + MapState rotation = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) + transform.getZoom()); + rotation.setGesture("Rotation"); + Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, rotation)); started = true; } @@ -895,9 +910,13 @@ public boolean onShove(ShoveGestureDetector detector) { if (!tiltGestureOccurred && ((totalDelta > 10.0f) || (totalDelta < -10.0f))) { tiltGestureOccurred = true; beginTime = detector.getEventTime(); - MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( - getLocationFromGesture(detector.getFocusX(), detector.getFocusY()), - MapboxEvent.GESTURE_PITCH_START, transform)); + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(detector.getFocusX(), detector.getFocusY())); + // TODO transform.getZoom() may cause a NullPointerException + MapState pitch = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) transform + .getZoom()); + pitch.setGesture("Pitch"); + Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, pitch)); } if (!tiltGestureOccurred) { 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 7aa5d268d2d..9bd28a2baa4 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 @@ -23,6 +23,9 @@ import android.widget.ImageView; import android.widget.ZoomButtonsController; +import com.mapbox.android.telemetry.Event; +import com.mapbox.android.telemetry.MapEventFactory; +import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.annotations.Annotation; import com.mapbox.mapboxsdk.annotations.MarkerViewManager; @@ -36,7 +39,6 @@ import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings; import com.mapbox.mapboxsdk.net.ConnectivityReceiver; import com.mapbox.mapboxsdk.storage.FileSource; -import com.mapbox.services.android.telemetry.MapboxTelemetry; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -285,7 +287,9 @@ public void onClick(View v) { @UiThread public void onCreate(@Nullable Bundle savedInstanceState) { if (savedInstanceState == null) { - MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapLoadEvent()); + // TODO Push AppUserTurnstile event + MapEventFactory mapEventFactory = new MapEventFactory(); + Mapbox.obtainTelemetry().push(mapEventFactory.createMapLoadEvent(Event.Type.MAP_LOAD)); } else if (savedInstanceState.getBoolean(MapboxConstants.STATE_HAS_SAVED_STATE)) { this.savedInstanceState = savedInstanceState; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxEventWrapper.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxEventWrapper.java deleted file mode 100644 index 6730278d793..00000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxEventWrapper.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.mapbox.mapboxsdk.maps; - -import android.location.Location; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; - -import com.mapbox.mapboxsdk.constants.MapboxConstants; -import com.mapbox.services.android.telemetry.MapboxEvent; - -import java.util.Hashtable; - -/** - * Wrapper class for MapboxEvent - *

- * Provides facility methods to use Transform and handle the case that the zoom, required for a telemetry event, - * isn't available yet. - *

- */ -class MapboxEventWrapper { - - @Nullable - static Hashtable buildMapClickEvent( - @NonNull Location location, @NonNull String gestureId, Transform transform) { - try { - double mapZoom = transform.getZoom(); - if (mapZoom >= MapboxConstants.MINIMUM_ZOOM && mapZoom <= MapboxConstants.MAXIMUM_ZOOM) { - // validate zoom #8057 - return MapboxEvent.buildMapClickEvent(location, gestureId, transform.getZoom()); - } - } catch (NullPointerException exception) { - // Map/Transform is not ready yet #8650 - // returning null is valid, event is ignored. - } - return null; - } - - @Nullable - static Hashtable buildMapDragEndEvent( - @NonNull Location location, Transform transform) { - try { - double mapZoom = transform.getZoom(); - if (mapZoom >= MapboxConstants.MINIMUM_ZOOM && mapZoom <= MapboxConstants.MAXIMUM_ZOOM) { - // validate zoom #8057 - return MapboxEvent.buildMapDragEndEvent(location, transform.getZoom()); - } - } catch (NullPointerException exception) { - // Map/Transform is not ready yet #8650 - // returning null is valid, event is ignored. - } - return null; - } - - @Nullable - static Hashtable buildMapLoadEvent() { - return MapboxEvent.buildMapLoadEvent(); - } -} 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 509e784e587..46daab7d6ce 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 @@ -41,7 +41,7 @@ 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.telemetry.location.LocationEngine; +import com.mapbox.android.core.location.LocationEngine; import com.mapbox.services.commons.geojson.Feature; import com.mapbox.services.commons.geojson.Geometry; 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 6eacbbaeafb..adf67970c53 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 @@ -12,9 +12,9 @@ import com.mapbox.mapboxsdk.constants.MyBearingTracking; import com.mapbox.mapboxsdk.constants.MyLocationTracking; import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; -import com.mapbox.services.android.telemetry.location.LocationEngine; -import com.mapbox.services.android.telemetry.location.LocationEngineListener; -import com.mapbox.services.android.telemetry.permissions.PermissionsManager; +import com.mapbox.android.core.location.LocationEngine; +import com.mapbox.android.core.location.LocationEngineListener; +import com.mapbox.android.core.permissions.PermissionsManager; import timber.log.Timber; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java index 1e604c9befe..45f72af1c59 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java @@ -6,10 +6,10 @@ import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewPropertyAnimatorCompat; import android.support.v4.view.ViewPropertyAnimatorListenerAdapter; +import android.support.v7.widget.AppCompatImageView; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -22,7 +22,7 @@ * use {@link com.mapbox.mapboxsdk.maps.UiSettings}. *

*/ -public final class CompassView extends ImageView implements Runnable { +public final class CompassView extends AppCompatImageView implements Runnable { public static final long TIME_WAIT_IDLE = 500; public static final long TIME_MAP_NORTH_ANIMATION = 150; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index 4f27e0ada84..2cb31b9acc9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -35,9 +35,9 @@ import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.Projection; -import com.mapbox.services.android.telemetry.location.LocationEngine; -import com.mapbox.services.android.telemetry.location.LocationEngineListener; -import com.mapbox.services.android.telemetry.location.LocationEnginePriority; +import com.mapbox.android.core.location.LocationEngine; +import com.mapbox.android.core.location.LocationEngineListener; +import com.mapbox.android.core.location.LocationEnginePriority; import java.lang.ref.WeakReference; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MathUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MathUtils.java new file mode 100644 index 00000000000..c0c1971ccab --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MathUtils.java @@ -0,0 +1,79 @@ +package com.mapbox.mapboxsdk.utils; + +// TODO Remove this class if we finally include it within MAS 3.x (GeoJSON) +public class MathUtils { + + /** + * Test a value in specified range, returning minimum if it's below, and maximum if it's above + * + * @param value Value to test + * @param min Minimum value of range + * @param max Maximum value of range + * @return value if it's between min and max, min if it's below, max if it's above + */ + public static double clamp(double value, double min, double max) { + return Math.max(min, Math.min(max, value)); + } + + /** + * Test a value in specified range, returning minimum if it's below, and maximum if it's above + * + * @param value Value to test + * @param min Minimum value of range + * @param max Maximum value of range + * @return value if it's between min and max, min if it's below, max if it's above + */ + public static float clamp(float value, float min, float max) { + return Math.max(min, Math.min(max, value)); + } + + /** + * Constrains value to the given range (including min, excluding max) via modular arithmetic. + *

+ * Same formula as used in Core GL (wrap.hpp) + * std::fmod((std::fmod((value - min), d) + d), d) + min; + * + * @param value Value to wrap + * @param min Minimum value + * @param max Maximum value + * @return Wrapped value + */ + public static double wrap(double value, double min, double max) { + double delta = max - min; + + double firstMod = (value - min) % delta; + double secondMod = (firstMod + delta) % delta; + + return secondMod + min; + } + + /** + * Convert bearing from core to match Android SDK value. + * + * @param nativeBearing bearing value coming from core + * @return bearing in degrees starting from 0 rotating clockwise + */ + public static double convertNativeBearing(double nativeBearing) { + double direction = -nativeBearing; + + while (direction > 360) { + direction -= 360; + } + while (direction < 0) { + direction += 360; + } + return direction; + } + + /** + * Returns the smallest angle between two angles. + * + * @param alpha First angle in degrees + * @param beta Second angle in degrees + * @return Smallest angle between two angles. + */ + public static double differenceBetweenAngles(double alpha, double beta) { + double phi = Math.abs(beta - alpha) % 360; + return phi > 180 ? 360 - phi : phi; + } +} diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values-he/strings.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values-iw/strings.xml similarity index 100% rename from platform/android/MapboxGLAndroidSDK/src/main/res/values-he/strings.xml rename to platform/android/MapboxGLAndroidSDK/src/main/res/values-iw/strings.xml diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java index 7a28d846ea9..d9e3ae427dc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java @@ -5,7 +5,7 @@ import android.net.NetworkInfo; import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException; -import com.mapbox.services.android.telemetry.location.LocationEngine; +import com.mapbox.android.core.location.LocationEngine; import org.junit.Before; import org.junit.Test; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle index 3723ae2acf0..3cdd4ae9ef5 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle +++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle @@ -61,7 +61,8 @@ dependencies { implementation dependenciesList.supportRecyclerView implementation dependenciesList.supportDesign - implementation dependenciesList.lost + // implementation dependenciesList.lost + implementation dependenciesList.gmsLocation implementation dependenciesList.timber debugImplementation dependenciesList.leakCanaryDebug releaseImplementation dependenciesList.leakCanaryRelease diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 003fc1df6c6..7af739a8b0a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -795,7 +795,7 @@ + android:value="api-events-staging.tilestream.net"/> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java index 95cc9687f23..0ee1f78e0ec 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java @@ -22,8 +22,8 @@ import com.mapbox.mapboxsdk.testapp.adapter.FeatureSectionAdapter; import com.mapbox.mapboxsdk.testapp.model.activity.Feature; import com.mapbox.mapboxsdk.testapp.utils.ItemClickSupport; -import com.mapbox.services.android.telemetry.permissions.PermissionsListener; -import com.mapbox.services.android.telemetry.permissions.PermissionsManager; +import com.mapbox.android.core.permissions.PermissionsListener; +import com.mapbox.android.core.permissions.PermissionsManager; import java.util.ArrayList; import java.util.Collections; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java index 71b8115d2e8..eec26cc9a74 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java @@ -9,8 +9,8 @@ import android.support.v7.app.AppCompatActivity; import android.text.TextUtils; -import com.mapbox.services.android.telemetry.permissions.PermissionsListener; -import com.mapbox.services.android.telemetry.permissions.PermissionsManager; +import com.mapbox.android.core.permissions.PermissionsListener; +import com.mapbox.android.core.permissions.PermissionsManager; import java.util.List; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java index f4b54551bf1..f4fe710de14 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java @@ -5,8 +5,8 @@ import android.animation.ValueAnimator; import android.location.Location; -import com.mapbox.services.android.telemetry.location.LocationEngine; -import com.mapbox.services.android.telemetry.location.LocationEngineListener; +import com.mapbox.android.core.location.LocationEngine; +import com.mapbox.android.core.location.LocationEngineListener; import timber.log.Timber; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java index 000042306f0..f603050030e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java @@ -15,7 +15,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.services.android.telemetry.location.LocationEngineListener; +import com.mapbox.android.core.location.LocationEngineListener; /** * Test activity showcasing how to change the MyLocationView drawable. diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java index 89774dc507e..ff3c4dfbc0d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java @@ -18,7 +18,7 @@ import com.mapbox.mapboxsdk.maps.TrackingSettings; import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.services.android.telemetry.location.LocationEngineListener; +import com.mapbox.android.core.location.LocationEngineListener; /** * Test activity showcasing how to tint the MyLocationView. diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java index 5ebe43e68c3..ffbb2c1a905 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java @@ -25,7 +25,7 @@ import com.mapbox.mapboxsdk.maps.TrackingSettings; import com.mapbox.mapboxsdk.maps.UiSettings; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.services.android.telemetry.location.LocationEngineListener; +import com.mapbox.android.core.location.LocationEngineListener; import timber.log.Timber; diff --git a/platform/android/gradle/dependencies.gradle b/platform/android/gradle/dependencies.gradle index 0c72368d3d1..4186c7a26b9 100644 --- a/platform/android/gradle/dependencies.gradle +++ b/platform/android/gradle/dependencies.gradle @@ -9,6 +9,7 @@ ext { versions = [ mapboxServices: '2.2.9', + mapboxTelemetryVersion: '3.0.0-SNAPSHOT', supportLib : '25.4.0', espresso : '3.0.1', testRunner : '1.0.1', @@ -24,7 +25,7 @@ ext { dependenciesList = [ mapboxJavaServices : "com.mapbox.mapboxsdk:mapbox-java-services:${versions.mapboxServices}@jar", mapboxJavaGeoJSON : "com.mapbox.mapboxsdk:mapbox-java-geojson:${versions.mapboxServices}@jar", - mapboxAndroidTelemetry: "com.mapbox.mapboxsdk:mapbox-android-telemetry:${versions.mapboxServices}@aar", + mapboxAndroidTelemetry: "com.mapbox.mapboxsdk:mapbox-android-telemetry:${versions.mapboxTelemetryVersion}", junit : "junit:junit:${versions.junit}", mockito : "org.mockito:mockito-core:${versions.mockito}", @@ -42,6 +43,7 @@ ext { supportRecyclerView : "com.android.support:recyclerview-v7:${versions.supportLib}", lost : "com.mapzen.android:lost:${versions.lost}", + gmsLocation : 'com.google.android.gms:play-services-location:11.0.4', timber : "com.jakewharton.timber:timber:${versions.timber}", okhttp3 : "com.squareup.okhttp3:okhttp:${versions.okhttp}", leakCanaryDebug : "com.squareup.leakcanary:leakcanary-android:${versions.leakCanary}", From 0dd19374e53fc64fad841770337566f164d8447b Mon Sep 17 00:00:00 2001 From: Guardiola31337 Date: Mon, 29 Jan 2018 18:30:29 +0100 Subject: [PATCH 2/2] fix #10999 comments --- .../android/MapboxGLAndroidSDK/build.gradle | 2 + .../java/com/mapbox/mapboxsdk/Mapbox.java | 17 +-- .../maps/AttributionDialogManager.java | 5 +- .../com/mapbox/mapboxsdk/maps/Events.java | 36 ++++++ .../mapboxsdk/maps/MapGestureDetector.java | 122 ++++++++++-------- .../com/mapbox/mapboxsdk/maps/MapView.java | 11 +- 6 files changed, 115 insertions(+), 78 deletions(-) create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Events.java diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index a1028aa1d03..8305a0cf874 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -25,6 +25,8 @@ android { minSdkVersion androidVersions.minSdkVersion targetSdkVersion androidVersions.targetSdkVersion buildConfigField "String", "GIT_REVISION_SHORT", String.format("\"%s\"", getGitRevision()) + // TODO Review sdkIdentifier and sdkVersion values (used in AppUserTurnstile) + buildConfigField "String", "MAPBOX_SDK_IDENTIFIER", String.format("\"%s\"", "MapboxMapsAndroid") buildConfigField "String", "MAPBOX_VERSION_STRING", String.format("\"Mapbox/%s\"", project.VERSION_NAME) buildConfigField "String", "MAPBOX_EVENTS_USER_AGENT", String.format("\"MapboxEventsAndroid/%s\"", project.VERSION_NAME) } 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 245424d769c..5356242622b 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 @@ -11,13 +11,10 @@ import com.mapbox.android.core.location.LocationEngine; import com.mapbox.android.core.location.LocationEnginePriority; import com.mapbox.android.core.location.LocationEngineProvider; -import com.mapbox.android.telemetry.MapboxTelemetry; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException; import com.mapbox.mapboxsdk.net.ConnectivityReceiver; -import timber.log.Timber; - /** * The entry point to initialize the Mapbox Android SDK. *

@@ -35,8 +32,6 @@ public final class Mapbox { private String accessToken; private Boolean connected; private LocationEngine locationEngine; - @SuppressLint("StaticFieldLeak") - private static MapboxTelemetry telemetry; /** * Get an instance of Mapbox. @@ -57,13 +52,6 @@ public static synchronized Mapbox getInstance(@NonNull Context context, @NonNull INSTANCE = new Mapbox(appContext, accessToken, locationEngine); locationEngine.setPriority(LocationEnginePriority.NO_POWER); - try { - telemetry = new MapboxTelemetry(appContext, accessToken, BuildConfig.MAPBOX_EVENTS_USER_AGENT); - telemetry.enable(); - } catch (Exception exception) { - Timber.e(exception, "Unable to instantiate Mapbox telemetry"); - } - ConnectivityReceiver.instance(appContext); } return INSTANCE; @@ -151,11 +139,8 @@ public static synchronized Boolean isConnected() { * * @return the location engine configured */ + // TODO Do we need to expose this? public static LocationEngine getLocationEngine() { return INSTANCE.locationEngine; } - - public static MapboxTelemetry obtainTelemetry() { - return INSTANCE.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 53472eb8706..2bcbd5ce400 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 @@ -11,7 +11,6 @@ import android.widget.ArrayAdapter; import android.widget.Toast; -import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.attribution.Attribution; import com.mapbox.mapboxsdk.attribution.AttributionParser; @@ -88,7 +87,7 @@ private void showTelemetryDialog() { builder.setPositiveButton(R.string.mapbox_attributionTelemetryPositive, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - Mapbox.obtainTelemetry().enable(); + Events.obtainTelemetry().enable(); dialog.cancel(); } }); @@ -102,7 +101,7 @@ public void onClick(DialogInterface dialog, int which) { builder.setNegativeButton(R.string.mapbox_attributionTelemetryNegative, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - Mapbox.obtainTelemetry().disable(); + Events.obtainTelemetry().disable(); dialog.cancel(); } }); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Events.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Events.java new file mode 100644 index 00000000000..a68d4763acd --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Events.java @@ -0,0 +1,36 @@ +package com.mapbox.mapboxsdk.maps; + + +import com.mapbox.android.telemetry.MapboxTelemetry; +import com.mapbox.android.telemetry.TelemetryEnabler; +import com.mapbox.mapboxsdk.BuildConfig; +import com.mapbox.mapboxsdk.Mapbox; + +class Events { + static final String TWO_FINGER_TAP = "TwoFingerTap"; + static final String DOUBLE_TAP = "DoubleTap"; + static final String SINGLE_TAP = "SingleTap"; + static final String PAN = "Pan"; + static final String PINCH = "Pinch"; + static final String ROTATION = "Rotation"; + static final String PITCH = "Pitch"; + private MapboxTelemetry telemetry; + + private Events() { + telemetry = new MapboxTelemetry(Mapbox.getApplicationContext(), Mapbox.getAccessToken(), + BuildConfig.MAPBOX_EVENTS_USER_AGENT); + TelemetryEnabler.State telemetryState = TelemetryEnabler.retrieveTelemetryStateFromPreferences(); + if (TelemetryEnabler.State.NOT_INITIALIZED.equals(telemetryState) + || TelemetryEnabler.State.ENABLED.equals(telemetryState)) { + telemetry.enable(); + } + } + + private static class EventsHolder { + private static final Events INSTANCE = new Events(); + } + + static MapboxTelemetry obtainTelemetry() { + return EventsHolder.INSTANCE.telemetry; + } +} diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index 788ae48e8eb..8047e198093 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -21,7 +21,6 @@ import com.mapbox.android.telemetry.Event; import com.mapbox.android.telemetry.MapEventFactory; import com.mapbox.android.telemetry.MapState; -import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.utils.MathUtils; @@ -189,13 +188,13 @@ boolean onTouchEvent(MotionEvent event) { && uiSettings.isZoomGesturesEnabled(); if (twoTap) { // Confirmed 2nd Finger Down - MapEventFactory mapEventFactory = new MapEventFactory(); - LatLng latLng = projection.fromScreenLocation(new PointF(event.getX(), event.getY())); - // TODO transform.getZoom() may cause a NullPointerException - MapState twoFingerTap = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) - transform.getZoom()); - twoFingerTap.setGesture("TwoFingerTap"); - Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, twoFingerTap)); + if (isZoomValid(transform)) { + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(event.getX(), event.getY())); + MapState twoFingerTap = new MapState(latLng.getLatitude(), latLng.getLongitude(), transform.getZoom()); + twoFingerTap.setGesture(Events.TWO_FINGER_TAP); + Events.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, twoFingerTap)); + } } break; @@ -224,12 +223,12 @@ boolean onTouchEvent(MotionEvent event) { // Scroll / Pan Has Stopped if (scrollGestureOccurred) { - MapEventFactory mapEventFactory = new MapEventFactory(); - LatLng latLng = projection.fromScreenLocation(new PointF(event.getX(), event.getY())); - // TODO transform.getZoom() may cause a NullPointerException - MapState dragend = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) - transform.getZoom()); - Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_DRAGEND, dragend)); + if (isZoomValid(transform)) { + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(event.getX(), event.getY())); + MapState dragend = new MapState(latLng.getLatitude(), latLng.getLongitude(), transform.getZoom()); + Events.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_DRAGEND, dragend)); + } scrollGestureOccurred = false; if (!scaleAnimating && !rotateAnimating) { @@ -345,13 +344,13 @@ public boolean onDoubleTapEvent(MotionEvent e) { // Zoom in on gesture transform.zoom(true, new PointF(e.getX(), e.getY())); } - MapEventFactory mapEventFactory = new MapEventFactory(); - LatLng latLng = projection.fromScreenLocation(new PointF(e.getX(), e.getY())); - // TODO transform.getZoom() may cause a NullPointerException - MapState doubleTap = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) - transform.getZoom()); - doubleTap.setGesture("DoubleTap"); - Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, doubleTap)); + if (isZoomValid(transform)) { + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(e.getX(), e.getY())); + MapState doubleTap = new MapState(latLng.getLatitude(), latLng.getLongitude(), transform.getZoom()); + doubleTap.setGesture(Events.DOUBLE_TAP); + Events.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, doubleTap)); + } break; } @@ -379,13 +378,13 @@ public boolean onSingleTapConfirmed(MotionEvent motionEvent) { notifyOnMapClickListeners(tapPoint); } - MapEventFactory mapEventFactory = new MapEventFactory(); - LatLng latLng = projection.fromScreenLocation(new PointF(motionEvent.getX(), motionEvent.getY())); - // TODO transform.getZoom() may cause a NullPointerException - MapState singleTap = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) - transform.getZoom()); - singleTap.setGesture("SingleTap"); - Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, singleTap)); + if (isZoomValid(transform)) { + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(motionEvent.getX(), motionEvent.getY())); + MapState singleTap = new MapState(latLng.getLatitude(), latLng.getLongitude(), transform.getZoom()); + singleTap.setGesture(Events.SINGLE_TAP); + Events.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, singleTap)); + } return true; } @@ -459,13 +458,13 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float d cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); } - MapEventFactory mapEventFactory = new MapEventFactory(); - LatLng latLng = projection.fromScreenLocation(new PointF(e1.getX(), e1.getY())); - // TODO transform.getZoom() may cause a NullPointerException - MapState pan = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) transform - .getZoom()); - pan.setGesture("Pan"); - Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, pan)); + if (isZoomValid(transform)) { + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(e1.getX(), e1.getY())); + MapState pan = new MapState(latLng.getLatitude(), latLng.getLongitude(), transform.getZoom()); + pan.setGesture(Events.PAN); + Events.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, pan)); + } } // reset tracking if needed @@ -548,13 +547,13 @@ public boolean onScaleBegin(ScaleGestureDetector detector) { recentScaleGestureOccurred = true; scalePointBegin = new PointF(detector.getFocusX(), detector.getFocusY()); scaleBeginTime = detector.getEventTime(); - MapEventFactory mapEventFactory = new MapEventFactory(); - LatLng latLng = projection.fromScreenLocation(new PointF(detector.getFocusX(), detector.getFocusY())); - // TODO transform.getZoom() may cause a NullPointerException - MapState pinch = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) transform - .getZoom()); - pinch.setGesture("Pinch"); - Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, pinch)); + if (isZoomValid(transform)) { + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(detector.getFocusX(), detector.getFocusY())); + MapState pinch = new MapState(latLng.getLatitude(), latLng.getLongitude(), transform.getZoom()); + pinch.setGesture(Events.PINCH); + Events.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, pinch)); + } return true; } @@ -735,13 +734,13 @@ public boolean onRotate(RotateGestureDetector detector) { // Also is zoom already started, don't rotate float angle = detector.getRotationDegreesDelta(); if (Math.abs(angle) >= ROTATE_INVOKE_ANGLE) { - MapEventFactory mapEventFactory = new MapEventFactory(); - LatLng latLng = projection.fromScreenLocation(new PointF(detector.getFocusX(), detector.getFocusY())); - // TODO transform.getZoom() may cause a NullPointerException - MapState rotation = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) - transform.getZoom()); - rotation.setGesture("Rotation"); - Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, rotation)); + if (isZoomValid(transform)) { + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(detector.getFocusX(), detector.getFocusY())); + MapState rotation = new MapState(latLng.getLatitude(), latLng.getLongitude(), transform.getZoom()); + rotation.setGesture(Events.ROTATION); + Events.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, rotation)); + } started = true; } @@ -910,13 +909,13 @@ public boolean onShove(ShoveGestureDetector detector) { if (!tiltGestureOccurred && ((totalDelta > 10.0f) || (totalDelta < -10.0f))) { tiltGestureOccurred = true; beginTime = detector.getEventTime(); - MapEventFactory mapEventFactory = new MapEventFactory(); - LatLng latLng = projection.fromScreenLocation(new PointF(detector.getFocusX(), detector.getFocusY())); - // TODO transform.getZoom() may cause a NullPointerException - MapState pitch = new MapState((float) latLng.getLatitude(), (float) latLng.getLongitude(), (float) transform - .getZoom()); - pitch.setGesture("Pitch"); - Mapbox.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, pitch)); + if (isZoomValid(transform)) { + MapEventFactory mapEventFactory = new MapEventFactory(); + LatLng latLng = projection.fromScreenLocation(new PointF(detector.getFocusX(), detector.getFocusY())); + MapState pitch = new MapState(latLng.getLatitude(), latLng.getLongitude(), transform.getZoom()); + pitch.setGesture(Events.PITCH); + Events.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, pitch)); + } } if (!tiltGestureOccurred) { @@ -981,4 +980,15 @@ void addOnScrollListener(MapboxMap.OnScrollListener onScrollListener) { void removeOnScrollListener(MapboxMap.OnScrollListener onScrollListener) { onScrollListenerList.remove(onScrollListener); } + + private boolean isZoomValid(Transform transform) { + if (transform == null) { + return false; + } + double mapZoom = transform.getZoom(); + if (mapZoom < MapboxConstants.MINIMUM_ZOOM || mapZoom > MapboxConstants.MAXIMUM_ZOOM) { + return false; + } + return true; + } } 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 9bd28a2baa4..cc25497f37e 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 @@ -23,9 +23,11 @@ import android.widget.ImageView; import android.widget.ZoomButtonsController; +import com.mapbox.android.telemetry.AppUserTurnstile; import com.mapbox.android.telemetry.Event; import com.mapbox.android.telemetry.MapEventFactory; -import com.mapbox.mapboxsdk.Mapbox; +import com.mapbox.android.telemetry.MapboxTelemetry; +import com.mapbox.mapboxsdk.BuildConfig; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.annotations.Annotation; import com.mapbox.mapboxsdk.annotations.MarkerViewManager; @@ -287,9 +289,12 @@ public void onClick(View v) { @UiThread public void onCreate(@Nullable Bundle savedInstanceState) { if (savedInstanceState == null) { - // TODO Push AppUserTurnstile event + MapboxTelemetry telemetry = Events.obtainTelemetry(); + AppUserTurnstile turnstileEvent = new AppUserTurnstile(BuildConfig.MAPBOX_SDK_IDENTIFIER, + BuildConfig.MAPBOX_VERSION_STRING); + telemetry.push(turnstileEvent); MapEventFactory mapEventFactory = new MapEventFactory(); - Mapbox.obtainTelemetry().push(mapEventFactory.createMapLoadEvent(Event.Type.MAP_LOAD)); + telemetry.push(mapEventFactory.createMapLoadEvent(Event.Type.MAP_LOAD)); } else if (savedInstanceState.getBoolean(MapboxConstants.STATE_HAS_SAVED_STATE)) { this.savedInstanceState = savedInstanceState; }