summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Paczos <lukasz.paczos@mapbox.com>2018-03-02 11:01:10 +0100
committerGitHub <noreply@github.com>2018-03-02 11:01:10 +0100
commit899211d816ccbb89d6fb4f7b5f9d9dc1708287cb (patch)
tree4dd604ec94654f4977eb4c600aafa453f2e7bcb2
parent87f88f37c4d111cc0f329f0e5f9c3fb10aae69bb (diff)
downloadqtlocation-mapboxgl-899211d816ccbb89d6fb4f7b5f9d9dc1708287cb.tar.gz
Remove deprecated location APIs (#11351)
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java24
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java50
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java42
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java16
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java42
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java228
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java360
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java16
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java419
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java25
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java1104
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java389
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java22
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml6
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java5
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java19
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java3
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java99
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java106
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java34
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java229
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml57
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java77
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java12
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java19
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java27
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java66
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java117
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java130
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java114
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java181
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java91
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java296
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java10
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled.xml9
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_location_engine.xml27
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml11
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml62
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml23
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_tracking.xml50
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_engine.xml20
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_padding.xml4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_tracking.xml32
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml12
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/arrays.xml12
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/dimens.xml1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml5
49 files changed, 30 insertions, 4679 deletions
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 db89f5efbb..b3dcf87c7e 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,9 +8,6 @@ import android.support.annotation.NonNull;
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.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException;
import com.mapbox.mapboxsdk.maps.Events;
@@ -32,7 +29,6 @@ public final class Mapbox {
private Context context;
private String accessToken;
private Boolean connected;
- private LocationEngine locationEngine;
/**
* Get an instance of Mapbox.
@@ -48,10 +44,7 @@ public final class Mapbox {
public static synchronized Mapbox getInstance(@NonNull Context context, @NonNull String accessToken) {
if (INSTANCE == null) {
Context appContext = context.getApplicationContext();
- LocationEngineProvider locationEngineProvider = new LocationEngineProvider(context);
- LocationEngine locationEngine = locationEngineProvider.obtainBestLocationEngineAvailable();
- INSTANCE = new Mapbox(appContext, accessToken, locationEngine);
- locationEngine.setPriority(LocationEnginePriority.NO_POWER);
+ INSTANCE = new Mapbox(appContext, accessToken);
Events.initialize();
ConnectivityReceiver.instance(appContext);
@@ -60,10 +53,9 @@ public final class Mapbox {
return INSTANCE;
}
- Mapbox(@NonNull Context context, @NonNull String accessToken, LocationEngine locationEngine) {
+ Mapbox(@NonNull Context context, @NonNull String accessToken) {
this.context = context;
this.accessToken = accessToken;
- this.locationEngine = locationEngine;
}
/**
@@ -136,16 +128,4 @@ public final class Mapbox {
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
return (activeNetwork != null && activeNetwork.isConnected());
}
-
- /**
- * Returns the location engine used by the SDK.
- *
- * @return the location engine configured
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead.
- */
- @Deprecated
- public static LocationEngine getLocationEngine() {
- return INSTANCE.locationEngine;
- }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java
deleted file mode 100644
index c042b00577..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.mapbox.mapboxsdk.constants;
-
-import android.support.annotation.IntDef;
-
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * MyBearingTracking exposes different types of bearing tracking modes.
- * <p>
- * These modes visualise the user direction by extracting the direction from either sensor or location data.
- * </p>
- * <p>
- * Required to enable showing the user location first through {@link MapboxMap#setMyLocationEnabled(boolean)}.
- * </p>
- *
- * @see com.mapbox.mapboxsdk.maps.TrackingSettings#setMyBearingTrackingMode(int)
- * @see MyLocationView#setMyBearingTrackingMode(int)
- */
-public class MyBearingTracking {
-
- @IntDef( {NONE, COMPASS, GPS, GPS_NORTH_FACING})
- @Retention(RetentionPolicy.SOURCE)
- public @interface Mode {
- }
-
- /**
- * Bearing tracking is disabled
- */
- public static final int NONE = 0x00000000;
-
- /**
- * Tracking the bearing of the user based on sensor data
- */
- public static final int COMPASS = 0x00000004;
-
- /**
- * Tracking the bearing of the user based on GPS data
- */
- public static final int GPS = 0x00000008;
-
- /**
- * Tracking the bearing of the user based on GPS data, but camera always faces north direction
- */
- public static final int GPS_NORTH_FACING = 0x0000000B;
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java
deleted file mode 100644
index 1283283fa5..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.mapbox.mapboxsdk.constants;
-
-import android.support.annotation.IntDef;
-
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.TrackingSettings;
-import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * MyLocationTracking exposes types of location tracking modes.
- * * <p>
- * This allows tracking the user location on screen by updating the camera position when a location update occurs.
- * </p>
- * <p>
- * Required to enable showing the user location first through {@link MapboxMap#setMyLocationEnabled(boolean)}.
- * </p>
- *
- * @see MapboxMap#setMyLocationEnabled(boolean)
- * @see TrackingSettings#setMyLocationTrackingMode(int)
- */
-public class MyLocationTracking {
-
- @IntDef( {TRACKING_NONE, TRACKING_FOLLOW})
- @Retention(RetentionPolicy.SOURCE)
- public @interface Mode {
- }
-
- /**
- * Tracking the location of the user is disabled.
- */
- public static final int TRACKING_NONE = 0x00000000;
-
- /**
- * Tracking the location of the user. {@link MapView} will reposition to center of {@link MyLocationView}
- */
- public static final int TRACKING_FOLLOW = 0x00000004;
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java
index 9bd9499fff..7bd74d56a0 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java
@@ -13,23 +13,19 @@ import android.view.ViewConfiguration;
* <p>
* <ul>
* <li> Uses {@link Transform} to change the map state</li>
- * <li> Uses {@link TrackingSettings} to verify validity of the current tracking mode.</li>
* <li> Uses {@link UiSettings} to verify validity of user restricted movement.</li>
* </ul>
* <p>
*/
final class MapKeyListener {
- private final TrackingSettings trackingSettings;
private final Transform transform;
private final UiSettings uiSettings;
private TrackballLongPressTimeOut currentTrackballLongPressTimeOut;
- MapKeyListener(@NonNull Transform transform, @NonNull TrackingSettings trackingSettings,
- @NonNull UiSettings uiSettings) {
+ MapKeyListener(@NonNull Transform transform, @NonNull UiSettings uiSettings) {
this.transform = transform;
- this.trackingSettings = trackingSettings;
this.uiSettings = uiSettings;
}
@@ -55,7 +51,7 @@ final class MapKeyListener {
return true;
case KeyEvent.KEYCODE_DPAD_LEFT:
- if (!trackingSettings.isScrollGestureCurrentlyEnabled()) {
+ if (!uiSettings.isScrollGesturesEnabled()) {
return false;
}
@@ -67,7 +63,7 @@ final class MapKeyListener {
return true;
case KeyEvent.KEYCODE_DPAD_RIGHT:
- if (!trackingSettings.isScrollGestureCurrentlyEnabled()) {
+ if (!uiSettings.isScrollGesturesEnabled()) {
return false;
}
@@ -79,7 +75,7 @@ final class MapKeyListener {
return true;
case KeyEvent.KEYCODE_DPAD_UP:
- if (!trackingSettings.isScrollGestureCurrentlyEnabled()) {
+ if (!uiSettings.isScrollGesturesEnabled()) {
return false;
}
@@ -91,7 +87,7 @@ final class MapKeyListener {
return true;
case KeyEvent.KEYCODE_DPAD_DOWN:
- if (!trackingSettings.isScrollGestureCurrentlyEnabled()) {
+ if (!uiSettings.isScrollGesturesEnabled()) {
return false;
}
@@ -183,7 +179,7 @@ final class MapKeyListener {
switch (event.getActionMasked()) {
// The trackball was rotated
case MotionEvent.ACTION_MOVE:
- if (!trackingSettings.isScrollGestureCurrentlyEnabled()) {
+ if (!uiSettings.isScrollGesturesEnabled()) {
return false;
}
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 eabec0b3ac..e86829c3e4 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
@@ -39,8 +39,6 @@ import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer;
import com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewMapRenderer;
import com.mapbox.mapboxsdk.maps.widgets.CompassView;
-import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
-import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
import com.mapbox.mapboxsdk.net.ConnectivityReceiver;
import com.mapbox.mapboxsdk.storage.FileSource;
@@ -84,7 +82,6 @@ public class MapView extends FrameLayout {
private boolean destroyed;
private boolean hasSurface;
- private MyLocationView myLocationView;
private CompassView compassView;
private PointF focalPoint;
private ImageView attrView;
@@ -132,7 +129,6 @@ public class MapView extends FrameLayout {
// inflate view
View view = LayoutInflater.from(context).inflate(R.layout.mapbox_mapview_internal, this);
compassView = (CompassView) view.findViewById(R.id.compassView);
- myLocationView = (MyLocationView) view.findViewById(R.id.userLocationView);
attrView = (ImageView) view.findViewById(R.id.attributionView);
logoView = (ImageView) view.findViewById(R.id.logoView);
@@ -154,19 +150,12 @@ public class MapView extends FrameLayout {
// callback for registering touch listeners
GesturesManagerInteractionListener registerTouchListener = new GesturesManagerInteractionListener();
- // callback for zooming in the camera
- CameraZoomInvalidator zoomInvalidator = new CameraZoomInvalidator();
-
// callback for camera change events
final CameraChangeDispatcher cameraChangeDispatcher = new CameraChangeDispatcher();
// setup components for MapboxMap creation
Projection proj = new Projection(nativeMapView);
UiSettings uiSettings = new UiSettings(proj, focalPointInvalidator, compassView, attrView, logoView);
- TrackingSettings trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointInvalidator,
- zoomInvalidator);
- MyLocationViewSettings myLocationViewSettings = new MyLocationViewSettings(myLocationView, proj,
- focalPointInvalidator);
LongSparseArray<Annotation> annotationsArray = new LongSparseArray<>();
MarkerViewManager markerViewManager = new MarkerViewManager((ViewGroup) findViewById(R.id.markerViewContainer));
IconManager iconManager = new IconManager(nativeMapView);
@@ -177,19 +166,18 @@ public class MapView extends FrameLayout {
ShapeAnnotations shapeAnnotations = new ShapeAnnotationContainer(nativeMapView, annotationsArray);
AnnotationManager annotationManager = new AnnotationManager(nativeMapView, this, annotationsArray,
markerViewManager, iconManager, annotations, markers, polygons, polylines, shapeAnnotations);
- Transform transform = new Transform(nativeMapView, annotationManager.getMarkerViewManager(), trackingSettings,
+ Transform transform = new Transform(nativeMapView, annotationManager.getMarkerViewManager(),
cameraChangeDispatcher);
- mapboxMap = new MapboxMap(nativeMapView, transform, uiSettings, trackingSettings, myLocationViewSettings, proj,
- registerTouchListener, annotationManager, cameraChangeDispatcher);
- focalPointInvalidator.addListener(mapboxMap.createFocalPointChangeListener());
+ mapboxMap = new MapboxMap(nativeMapView, transform, uiSettings, proj, registerTouchListener,
+ annotationManager, cameraChangeDispatcher);
mapCallback.attachMapboxMap(mapboxMap);
// user input
mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings,
annotationManager, cameraChangeDispatcher);
- mapKeyListener = new MapKeyListener(transform, trackingSettings, uiSettings);
+ mapKeyListener = new MapKeyListener(transform, uiSettings);
// overlain zoom buttons
mapZoomButtonController = new MapZoomButtonController(new ZoomButtonsController(this));
@@ -200,7 +188,6 @@ public class MapView extends FrameLayout {
compassView.injectCompassAnimationListener(createCompassAnimationListener(cameraChangeDispatcher));
compassView.setOnClickListener(createCompassClickListener(cameraChangeDispatcher));
// inject widgets with MapboxMap
- myLocationView.setMapboxMap(mapboxMap);
attrView.setOnClickListener(new AttributionClickListener(context, mapboxMap));
// Ensure this view is interactable
@@ -1084,27 +1071,6 @@ public class MapView extends FrameLayout {
}
}
- private class CameraZoomInvalidator implements TrackingSettings.CameraZoomInvalidator {
-
- @Override
- public void zoomTo(double zoomLevel) {
- Transform transform = mapboxMap.getTransform();
- double currentZoomLevel = transform.getCameraPosition().zoom;
- if (currentZoomLevel < zoomLevel) {
- setZoom(zoomLevel, mapGestureDetector.getFocalPoint(), transform);
- }
- }
-
- private void setZoom(double zoomLevel, @Nullable PointF focalPoint, @NonNull Transform transform) {
- if (focalPoint != null) {
- transform.setZoom(zoomLevel, focalPoint);
- } else {
- PointF centerPoint = new PointF(getMeasuredWidth() / 2, getMeasuredHeight() / 2);
- transform.setZoom(zoomLevel, centerPoint);
- }
- }
- }
-
private static class MapCallback implements OnMapChangedListener {
private MapboxMap mapboxMap;
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 69fc4d2f2d..a245c283bd 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
@@ -4,7 +4,6 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PointF;
import android.graphics.RectF;
-import android.location.Location;
import android.os.Bundle;
import android.support.annotation.FloatRange;
import android.support.annotation.IntRange;
@@ -16,7 +15,6 @@ import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
-import com.mapbox.android.core.location.LocationEngine;
import com.mapbox.android.gestures.AndroidGesturesManager;
import com.mapbox.android.gestures.MoveGestureDetector;
import com.mapbox.android.gestures.RotateGestureDetector;
@@ -39,12 +37,9 @@ import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.constants.MyBearingTracking;
-import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
-import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
import com.mapbox.mapboxsdk.style.layers.Filter;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.light.Light;
@@ -71,26 +66,21 @@ public final class MapboxMap {
private final NativeMapView nativeMapView;
private final UiSettings uiSettings;
- private final TrackingSettings trackingSettings;
private final Projection projection;
private final Transform transform;
private final AnnotationManager annotationManager;
- private final MyLocationViewSettings myLocationViewSettings;
private final CameraChangeDispatcher cameraChangeDispatcher;
private final OnGesturesManagerInteractionListener onGesturesManagerInteractionListener;
private MapboxMap.OnFpsChangedListener onFpsChangedListener;
- private PointF focalPoint;
- MapboxMap(NativeMapView map, Transform transform, UiSettings ui, TrackingSettings tracking,
- MyLocationViewSettings myLocationView, Projection projection, OnGesturesManagerInteractionListener listener,
- AnnotationManager annotations, CameraChangeDispatcher cameraChangeDispatcher) {
+ MapboxMap(NativeMapView map, Transform transform, UiSettings ui, Projection projection,
+ OnGesturesManagerInteractionListener listener, AnnotationManager annotations,
+ CameraChangeDispatcher cameraChangeDispatcher) {
this.nativeMapView = map;
this.uiSettings = ui;
- this.trackingSettings = tracking;
this.projection = projection;
- this.myLocationViewSettings = myLocationView;
this.annotationManager = annotations.bind(this);
this.transform = transform;
this.onGesturesManagerInteractionListener = listener;
@@ -100,8 +90,6 @@ public final class MapboxMap {
void initialise(@NonNull Context context, @NonNull MapboxMapOptions options) {
transform.initialise(this, options);
uiSettings.initialise(context, options);
- myLocationViewSettings.initialise(options);
- trackingSettings.initialise(options);
// Map configuration
setDebugActive(options.getDebugActive());
@@ -115,7 +103,6 @@ public final class MapboxMap {
*/
void onStart() {
nativeMapView.update();
- trackingSettings.onStart();
if (TextUtils.isEmpty(nativeMapView.getStyleUrl())) {
// if user hasn't loaded a Style yet
nativeMapView.setStyleUrl(Style.MAPBOX_STREETS);
@@ -126,7 +113,6 @@ public final class MapboxMap {
* Called when the hosting Activity/Fragment onStop() method is called.
*/
void onStop() {
- trackingSettings.onStop();
}
/**
@@ -138,9 +124,7 @@ public final class MapboxMap {
outState.putParcelable(MapboxConstants.STATE_CAMERA_POSITION, transform.getCameraPosition());
outState.putBoolean(MapboxConstants.STATE_DEBUG_ACTIVE, nativeMapView.getDebug());
outState.putString(MapboxConstants.STATE_STYLE_URL, nativeMapView.getStyleUrl());
- trackingSettings.onSaveInstanceState(outState);
uiSettings.onSaveInstanceState(outState);
- myLocationViewSettings.onSaveInstanceState(outState);
}
/**
@@ -151,9 +135,7 @@ public final class MapboxMap {
void onRestoreInstanceState(Bundle savedInstanceState) {
final CameraPosition cameraPosition = savedInstanceState.getParcelable(MapboxConstants.STATE_CAMERA_POSITION);
- myLocationViewSettings.onRestoreInstanceState(savedInstanceState);
uiSettings.onRestoreInstanceState(savedInstanceState);
- trackingSettings.onRestoreInstanceState(savedInstanceState);
if (cameraPosition != null) {
moveCamera(CameraUpdateFactory.newCameraPosition(
@@ -192,7 +174,6 @@ public final class MapboxMap {
* Called when the region is changing or has changed.
*/
void onUpdateRegionChange() {
- trackingSettings.update();
annotationManager.update();
}
@@ -560,38 +541,6 @@ public final class MapboxMap {
}
//
- // TrackingSettings
- //
-
- /**
- * Gets the tracking interface settings for the map.
- *
- * @return the TrackingSettings asssociated with this map
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-locationlayer instead.
- */
- @Deprecated
- public TrackingSettings getTrackingSettings() {
- return trackingSettings;
- }
-
- //
- // MyLocationViewSettings
- //
-
- /**
- * Gets the settings of the user location for the map.
- *
- * @return the MyLocationViewSettings associated with this map
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-locationlayer instead.
- */
- @Deprecated
- public MyLocationViewSettings getMyLocationViewSettings() {
- return myLocationViewSettings;
- }
-
- //
// Projection
//
@@ -750,11 +699,6 @@ public final class MapboxMap {
* unless specified within {@link CameraUpdate}. A callback can be used to be notified when
* easing the camera stops. If {@link #getCameraPosition()} is called during the animation, it
* will return the current location of the camera in flight.
- * <p>
- * Note that this will cancel location tracking mode if enabled. You can change this behaviour by calling
- * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setDismissLocationTrackingOnGesture(boolean)} with false before
- * invoking this method and calling it with true in the {@link CancelableCallback#onFinish()}.
- * </p>
*
* @param update The change that should be applied to the camera.
* @param durationMs The duration of the animation in milliseconds. This must be strictly
@@ -776,11 +720,6 @@ public final class MapboxMap {
* unless specified within {@link CameraUpdate}. A callback can be used to be notified when
* easing the camera stops. If {@link #getCameraPosition()} is called during the animation, it
* will return the current location of the camera in flight.
- * <p>
- * Note that this will cancel location tracking mode if enabled. You can change this behaviour by calling
- * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setDismissLocationTrackingOnGesture(boolean)} with false before
- * invoking this method and calling it with true in the {@link CancelableCallback#onFinish()}.
- * </p>
*
* @param update The change that should be applied to the camera.
* @param durationMs The duration of the animation in milliseconds. This must be strictly
@@ -1616,7 +1555,7 @@ public final class MapboxMap {
for (int i = 0; i < padding.length; i++) {
padding[i] = mapPadding[i] + padding[i];
}
- projection.setContentPadding(padding, myLocationViewSettings.getPadding());
+ projection.setContentPadding(padding);
// get padded camera position from LatLngBounds
CameraPosition cameraPosition = nativeMapView.getCameraForLatLngBounds(latLngBounds);
@@ -1640,7 +1579,7 @@ public final class MapboxMap {
for (int i = 0; i < padding.length; i++) {
padding[i] = mapPadding[i] + padding[i];
}
- projection.setContentPadding(padding, myLocationViewSettings.getPadding());
+ projection.setContentPadding(padding);
// get padded camera position from LatLngBounds
CameraPosition cameraPosition = nativeMapView.getCameraForGeometry(geometry, bearing);
@@ -1677,7 +1616,7 @@ public final class MapboxMap {
}
private void setPadding(int[] padding) {
- projection.setContentPadding(padding, myLocationViewSettings.getPadding());
+ projection.setContentPadding(padding);
uiSettings.invalidate();
}
@@ -2118,107 +2057,6 @@ public final class MapboxMap {
}
//
- // User location
- //
-
- /**
- * Returns the status of the my-location layer.
- *
- * @return True if the my-location layer is enabled, false otherwise.
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-locationlayer instead.
- */
- @Deprecated
- public boolean isMyLocationEnabled() {
- return trackingSettings.isMyLocationEnabled();
- }
-
- /**
- * <p>
- * Enables or disables the my-location layer.
- * While enabled, the my-location layer continuously draws an indication of a user's current
- * location and bearing.
- * </p>
- * In order to use the my-location layer feature you need to request permission for either
- * android.Manifest.permission#ACCESS_COARSE_LOCATION or android.Manifest.permission#ACCESS_FINE_LOCATION.
- *
- * @param enabled True to enable; false to disable.
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-locationlayer instead.
- */
- @Deprecated
- public void setMyLocationEnabled(boolean enabled) {
- trackingSettings.setMyLocationEnabled(enabled);
- }
-
- /**
- * Returns the currently displayed user location, or null if there is no location data available.
- *
- * @return The currently displayed user location.
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-locationlayer instead.
- */
- @Nullable
- @Deprecated
- public Location getMyLocation() {
- return trackingSettings.getMyLocation();
- }
-
- /**
- * Sets a callback that's invoked when the the My Location view
- * (which signifies the user's location) changes location.
- *
- * @param listener The callback that's invoked when the user clicks on a marker.
- * To unset the callback, use null.
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-locationlayer instead.
- */
- @Deprecated
- public void setOnMyLocationChangeListener(@Nullable MapboxMap.OnMyLocationChangeListener
- listener) {
- 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/plugin-locationlayer instead.
- */
- @Deprecated
- public void setLocationSource(@Nullable LocationEngine locationSource) {
- trackingSettings.setLocationSource(locationSource);
- }
-
- /**
- * Sets a callback that's invoked when the location tracking mode changes.
- *
- * @param listener The callback that's invoked when the location tracking mode changes.
- * To unset the callback, use null.
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-locationlayer instead.
- */
- @Deprecated
- public void setOnMyLocationTrackingModeChangeListener(
- @Nullable MapboxMap.OnMyLocationTrackingModeChangeListener listener) {
- trackingSettings.setOnMyLocationTrackingModeChangeListener(listener);
- }
-
- /**
- * Sets a callback that's invoked when the bearing tracking mode changes.
- *
- * @param listener The callback that's invoked when the bearing tracking mode changes.
- * To unset the callback, use null.
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-locationlayer instead.
- */
- @Deprecated
- public void setOnMyBearingTrackingModeChangeListener(@Nullable OnMyBearingTrackingModeChangeListener listener) {
- trackingSettings.setOnMyBearingTrackingModeChangeListener(listener);
- }
-
- //
// Invalidate
//
@@ -2287,15 +2125,6 @@ public final class MapboxMap {
return nativeMapView.queryRenderedFeatures(coordinates, layerIds, filter);
}
- FocalPointChangeListener createFocalPointChangeListener() {
- return new FocalPointChangeListener() {
- @Override
- public void onFocalPointChanged(PointF pointF) {
- focalPoint = pointF;
- }
- };
- }
-
//
// Interfaces
//
@@ -2796,51 +2625,6 @@ public final class MapboxMap {
}
/**
- * Interface definition for a callback to be invoked when the the My Location view changes location.
- *
- * @see MapboxMap#setOnMyLocationChangeListener(OnMyLocationChangeListener)
- */
- public interface OnMyLocationChangeListener {
- /**
- * Called when the location of the My Location view has changed
- * (be it latitude/longitude, bearing or accuracy).
- *
- * @param location The current location of the My Location view The type of map change event.
- */
- void onMyLocationChange(@Nullable Location location);
- }
-
- /**
- * Interface definition for a callback to be invoked when the the My Location tracking mode changes.
- *
- * @see TrackingSettings#setMyLocationTrackingMode(int)
- */
- public interface OnMyLocationTrackingModeChangeListener {
-
- /**
- * Called when the tracking mode of My Location tracking has changed
- *
- * @param myLocationTrackingMode the current active location tracking mode
- */
- void onMyLocationTrackingModeChange(@MyLocationTracking.Mode int myLocationTrackingMode);
- }
-
- /**
- * Interface definition for a callback to be invoked when the the My Location tracking mode changes.
- *
- * @see TrackingSettings#setMyLocationTrackingMode(int)
- */
- public interface OnMyBearingTrackingModeChangeListener {
-
- /**
- * Called when the tracking mode of My Bearing tracking has changed
- *
- * @param myBearingTrackingMode the current active bearing tracking mode
- */
- void onMyBearingTrackingModeChange(@MyBearingTracking.Mode int myBearingTrackingMode);
- }
-
- /**
* Interface definition for a callback to be invoked when a task is complete or cancelled.
*/
public interface CancelableCallback {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
index 759a0a0f2d..bb4e2f9212 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
@@ -8,10 +8,8 @@ import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.ColorInt;
-import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
import android.util.AttributeSet;
import android.view.Gravity;
@@ -20,7 +18,6 @@ import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.utils.BitmapUtils;
-import com.mapbox.mapboxsdk.utils.ColorUtils;
import java.util.Arrays;
@@ -68,18 +65,6 @@ public class MapboxMapOptions implements Parcelable {
private boolean zoomControlsEnabled = false;
private boolean doubleTapGesturesEnabled = true;
- private boolean myLocationEnabled;
- private Drawable myLocationForegroundDrawable;
- private Drawable myLocationForegroundBearingDrawable;
- private Drawable myLocationBackgroundDrawable;
- @ColorInt
- private int myLocationForegroundTintColor = UNDEFINED_COLOR;
- @ColorInt
- private int myLocationBackgroundTintColor = UNDEFINED_COLOR;
- private int[] myLocationBackgroundPadding;
- private int myLocationAccuracyTintColor;
- private int myLocationAccuracyAlpha;
- private float myLocationAccuracyThreshold;
private boolean prefetchesTiles = true;
private boolean zMediaOverlay = false;
private String localIdeographFontFamily;
@@ -130,30 +115,6 @@ public class MapboxMapOptions implements Parcelable {
zoomGesturesEnabled = in.readByte() != 0;
doubleTapGesturesEnabled = in.readByte() != 0;
- myLocationEnabled = in.readByte() != 0;
-
- Bitmap foregroundBitmap = in.readParcelable(getClass().getClassLoader());
- if (foregroundBitmap != null) {
- myLocationForegroundDrawable = new BitmapDrawable(foregroundBitmap);
- }
-
- Bitmap foregroundBearingBitmap = in.readParcelable(getClass().getClassLoader());
- if (foregroundBearingBitmap != null) {
- myLocationForegroundBearingDrawable = new BitmapDrawable(foregroundBearingBitmap);
- }
-
- Bitmap backgroundBitmap = in.readParcelable(getClass().getClassLoader());
- if (backgroundBitmap != null) {
- myLocationBackgroundDrawable = new BitmapDrawable(backgroundBitmap);
- }
-
- myLocationForegroundTintColor = in.readInt();
- myLocationBackgroundTintColor = in.readInt();
- myLocationBackgroundPadding = in.createIntArray();
- myLocationAccuracyAlpha = in.readInt();
- myLocationAccuracyTintColor = in.readInt();
- myLocationAccuracyThreshold = in.readFloat();
-
style = in.readString();
apiBaseUrl = in.readString();
textureMode = in.readByte() != 0;
@@ -247,48 +208,6 @@ public class MapboxMapOptions implements Parcelable {
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginBottom,
FOUR_DP * pxlRatio))});
- mapboxMapOptions.locationEnabled(typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_myLocation, false));
- mapboxMapOptions.myLocationForegroundTintColor(
- typedArray.getColor(R.styleable.mapbox_MapView_mapbox_myLocationTintColor, UNDEFINED_COLOR));
- mapboxMapOptions.myLocationBackgroundTintColor(
- typedArray.getColor(R.styleable.mapbox_MapView_mapbox_myLocationBackgroundTintColor, UNDEFINED_COLOR));
-
- Drawable foregroundDrawable = typedArray.getDrawable(R.styleable.mapbox_MapView_mapbox_myLocationDrawable);
- if (foregroundDrawable == null) {
- foregroundDrawable = ContextCompat.getDrawable(context, R.drawable.mapbox_mylocation_icon_default);
- }
-
- Drawable foregroundBearingDrawable = typedArray.getDrawable(
- R.styleable.mapbox_MapView_mapbox_myLocationBearingDrawable);
- if (foregroundBearingDrawable == null) {
- foregroundBearingDrawable = ContextCompat.getDrawable(context, R.drawable.mapbox_mylocation_icon_bearing);
- }
-
- Drawable backgroundDrawable = typedArray.getDrawable(
- R.styleable.mapbox_MapView_mapbox_myLocationBackgroundDrawable);
- if (backgroundDrawable == null) {
- backgroundDrawable = ContextCompat.getDrawable(context, R.drawable.mapbox_mylocation_bg_shape);
- }
-
- mapboxMapOptions.myLocationForegroundDrawables(foregroundDrawable, foregroundBearingDrawable);
- mapboxMapOptions.myLocationBackgroundDrawable(backgroundDrawable);
- mapboxMapOptions.myLocationBackgroundPadding(new int[] {
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_myLocationBackgroundMarginLeft,
- 0) * pxlRatio),
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_myLocationBackgroundMarginTop,
- 0) * pxlRatio),
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_myLocationBackgroundMarginRight,
- 0) * pxlRatio),
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_myLocationBackgroundMarginBottom,
- 0) * pxlRatio)
- });
- mapboxMapOptions.myLocationAccuracyAlpha(
- typedArray.getInt(R.styleable.mapbox_MapView_mapbox_myLocationAccuracyAlpha, 100));
- mapboxMapOptions.myLocationAccuracyTint(
- typedArray.getColor(R.styleable.mapbox_MapView_mapbox_myLocationAccuracyTintColor,
- ColorUtils.getPrimaryColor(context)));
- mapboxMapOptions.myLocationAccuracyThreshold(
- typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_myLocationAccuracyThreshold, 0));
mapboxMapOptions.textureMode(
typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_renderTextureMode, false));
mapboxMapOptions.translucentTextureSurface(
@@ -576,128 +495,6 @@ public class MapboxMapOptions implements Parcelable {
}
/**
- * Specifies if the user location view is enabled for a map view.
- *
- * @param locationEnabled True and gesture will be enabled
- * @return This
- */
- public MapboxMapOptions locationEnabled(boolean locationEnabled) {
- this.myLocationEnabled = locationEnabled;
- return this;
- }
-
- /**
- * Set the foreground drawables of the MyLocationView.
- *
- * @param myLocationForegroundDrawable the drawable to show as foreground without bearing
- * @param myLocationBearingDrawable the drawable to show as foreground when bearing is disabled
- * @return This
- */
- public MapboxMapOptions myLocationForegroundDrawables(Drawable myLocationForegroundDrawable,
- Drawable myLocationBearingDrawable) {
- this.myLocationForegroundDrawable = myLocationForegroundDrawable;
- this.myLocationForegroundBearingDrawable = myLocationBearingDrawable;
- return this;
- }
-
- /**
- * Set the foreground drawable of the MyLocationView.
- * <p>
- * The same drawable will be used for both bearing as non bearing modes.
- * </p>
- *
- * @param myLocationForegroundDrawable the drawable to show as foreground
- * @return This
- */
- public MapboxMapOptions myLocationForegroundDrawable(Drawable myLocationForegroundDrawable) {
- this.myLocationForegroundDrawable = myLocationForegroundDrawable;
- return this;
- }
-
- /**
- * Set the background drawable of MyLocationView.
- * <p>
- * Padding can be added to provide an offset to the background.
- * </p>
- *
- * @param myLocationBackgroundDrawable the drawable to show as background
- * @return This
- */
- public MapboxMapOptions myLocationBackgroundDrawable(Drawable myLocationBackgroundDrawable) {
- this.myLocationBackgroundDrawable = myLocationBackgroundDrawable;
- return this;
- }
-
- /**
- * Set the foreground tint color of MyLocationView.
- * <p>
- * The color will tint both the foreground and the bearing foreground drawable.
- * </p>
- *
- * @param myLocationForegroundTintColor the color to tint the foreground drawable
- * @return This
- */
- public MapboxMapOptions myLocationForegroundTintColor(@ColorInt int myLocationForegroundTintColor) {
- this.myLocationForegroundTintColor = myLocationForegroundTintColor;
- return this;
- }
-
- /**
- * Set the background tint color of MyLocationView.
- *
- * @param myLocationBackgroundTintColor the color to tint the background drawable
- * @return This
- */
- public MapboxMapOptions myLocationBackgroundTintColor(@ColorInt int myLocationBackgroundTintColor) {
- this.myLocationBackgroundTintColor = myLocationBackgroundTintColor;
- return this;
- }
-
- /**
- * Set the MyLocationView padding.
- *
- * @param myLocationBackgroundPadding the color to tint the background
- * @return This
- */
- public MapboxMapOptions myLocationBackgroundPadding(int[] myLocationBackgroundPadding) {
- this.myLocationBackgroundPadding = myLocationBackgroundPadding;
- return this;
- }
-
- /**
- * Set the MyLocationView accuracy circle tint color.
- *
- * @param myLocationAccuracyTintColor the color to tint the accuracy circle
- * @return This
- */
- public MapboxMapOptions myLocationAccuracyTint(@ColorInt int myLocationAccuracyTintColor) {
- this.myLocationAccuracyTintColor = myLocationAccuracyTintColor;
- return this;
- }
-
- /**
- * Set the MyLocationView accuracy alpha value.
- *
- * @param alpha the alpha value
- * @return This
- */
- public MapboxMapOptions myLocationAccuracyAlpha(@IntRange(from = 0, to = 255) int alpha) {
- this.myLocationAccuracyAlpha = alpha;
- return this;
- }
-
- /**
- * Set accuracy circle threshold. Circle won't be displayed if accuracy is below set value.
- *
- * @param myLocationAccuracyThreshold Value of accuracy (in meters), below which circle won't be displayed
- * @return This
- */
- public MapboxMapOptions myLocationAccuracyThreshold(float myLocationAccuracyThreshold) {
- this.myLocationAccuracyThreshold = myLocationAccuracyThreshold;
- return this;
- }
-
- /**
* Enable {@link android.view.TextureView} as rendered surface.
* <p>
* Since the 5.2.0 release we replaced our TextureView with an {@link android.opengl.GLSurfaceView}
@@ -736,7 +533,7 @@ public class MapboxMapOptions implements Parcelable {
/**
* Set the font family for generating glyphs locally for ideographs in the &#x27;CJK Unified Ideographs&#x27;
* and &#x27;Hangul Syllables&#x27; ranges.
- *
+ * <p>
* The font family argument is passed to {@link android.graphics.Typeface#create(String, int)}.
* Default system fonts are defined in &#x27;/system/etc/fonts.xml&#x27;
*
@@ -985,98 +782,6 @@ public class MapboxMapOptions implements Parcelable {
}
/**
- * Get the current configured user location view state for a map view.
- *
- * @return True and user location will be shown
- */
- public boolean getLocationEnabled() {
- return myLocationEnabled;
- }
-
- /**
- * Get the current configured MyLocationView foreground drawable.
- *
- * @return the drawable used as foreground
- */
- public Drawable getMyLocationForegroundDrawable() {
- return myLocationForegroundDrawable;
- }
-
- /**
- * Get the current configured MyLocationView foreground bearing drawable.
- *
- * @return the drawable used as foreground when bearing is enabled
- */
- public Drawable getMyLocationForegroundBearingDrawable() {
- return myLocationForegroundBearingDrawable;
- }
-
- /**
- * Get the current configured MyLocationView background drawable.
- *
- * @return the drawable used as background
- */
- public Drawable getMyLocationBackgroundDrawable() {
- return myLocationBackgroundDrawable;
- }
-
- /**
- * Get the current configured MyLocationView foreground tint color.
- *
- * @return the tint color
- */
- @ColorInt
- public int getMyLocationForegroundTintColor() {
- return myLocationForegroundTintColor;
- }
-
- /**
- * Get the current configured MyLocationView background tint color.
- *
- * @return the tint color
- */
- @ColorInt
- public int getMyLocationBackgroundTintColor() {
- return myLocationBackgroundTintColor;
- }
-
- /**
- * Get the current configured MyLocationView background padding.
- *
- * @return an array describing the padding in a LTRB manner
- */
- public int[] getMyLocationBackgroundPadding() {
- return myLocationBackgroundPadding;
- }
-
- /**
- * Get the current configured MyLocationView accuracy circle color tint value.
- *
- * @return the tint color
- */
- public int getMyLocationAccuracyTintColor() {
- return myLocationAccuracyTintColor;
- }
-
- /**
- * Get the current configured MyLocationView accuracy circle alpha value.
- *
- * @return the alpha value
- */
- public int getMyLocationAccuracyAlpha() {
- return myLocationAccuracyAlpha;
- }
-
- /**
- * Returns current accuracy threshold value (in meters).
- *
- * @return Value of accuracy threshold (in meters), below which circle won't be displayed
- */
- public float getMyLocationAccuracyThreshold() {
- return myLocationAccuracyThreshold;
- }
-
- /**
* Get the current configured debug state for a map view.
*
* @return True indicates debug is enabled.
@@ -1154,21 +859,6 @@ public class MapboxMapOptions implements Parcelable {
dest.writeByte((byte) (zoomGesturesEnabled ? 1 : 0));
dest.writeByte((byte) (doubleTapGesturesEnabled ? 1 : 0));
- dest.writeByte((byte) (myLocationEnabled ? 1 : 0));
-
- dest.writeParcelable(myLocationForegroundDrawable != null
- ? BitmapUtils.getBitmapFromDrawable(myLocationForegroundDrawable) : null, flags);
- dest.writeParcelable(myLocationForegroundBearingDrawable != null
- ? BitmapUtils.getBitmapFromDrawable(myLocationForegroundBearingDrawable) : null, flags);
- dest.writeParcelable(myLocationBackgroundDrawable != null
- ? BitmapUtils.getBitmapFromDrawable(myLocationBackgroundDrawable) : null, flags);
- dest.writeInt(myLocationForegroundTintColor);
- dest.writeInt(myLocationBackgroundTintColor);
- dest.writeIntArray(myLocationBackgroundPadding);
- dest.writeInt(myLocationAccuracyAlpha);
- dest.writeInt(myLocationAccuracyTintColor);
- dest.writeFloat(myLocationAccuracyThreshold);
-
dest.writeString(style);
dest.writeString(apiBaseUrl);
dest.writeByte((byte) (textureMode ? 1 : 0));
@@ -1245,24 +935,6 @@ public class MapboxMapOptions implements Parcelable {
if (doubleTapGesturesEnabled != options.doubleTapGesturesEnabled) {
return false;
}
- if (myLocationEnabled != options.myLocationEnabled) {
- return false;
- }
- if (myLocationForegroundTintColor != options.myLocationForegroundTintColor) {
- return false;
- }
- if (myLocationBackgroundTintColor != options.myLocationBackgroundTintColor) {
- return false;
- }
- if (myLocationAccuracyTintColor != options.myLocationAccuracyTintColor) {
- return false;
- }
- if (myLocationAccuracyAlpha != options.myLocationAccuracyAlpha) {
- return false;
- }
- if (myLocationAccuracyThreshold != options.myLocationAccuracyThreshold) {
- return false;
- }
if (cameraPosition != null ? !cameraPosition.equals(options.cameraPosition) : options.cameraPosition != null) {
return false;
}
@@ -1275,24 +947,6 @@ public class MapboxMapOptions implements Parcelable {
if (!Arrays.equals(attributionMargins, options.attributionMargins)) {
return false;
}
- if (myLocationForegroundDrawable != null
- ? !myLocationForegroundDrawable.equals(options.myLocationForegroundDrawable)
- : options.myLocationForegroundDrawable != null) {
- return false;
- }
- if (myLocationForegroundBearingDrawable != null
- ? !myLocationForegroundBearingDrawable.equals(options.myLocationForegroundBearingDrawable)
- : options.myLocationForegroundBearingDrawable != null) {
- return false;
- }
- if (myLocationBackgroundDrawable != null
- ? !myLocationBackgroundDrawable.equals(options.myLocationBackgroundDrawable)
- : options.myLocationBackgroundDrawable != null) {
- return false;
- }
- if (!Arrays.equals(myLocationBackgroundPadding, options.myLocationBackgroundPadding)) {
- return false;
- }
if (style != null ? !style.equals(options.style) : options.style != null) {
return false;
}
@@ -1340,18 +994,6 @@ public class MapboxMapOptions implements Parcelable {
result = 31 * result + (zoomGesturesEnabled ? 1 : 0);
result = 31 * result + (zoomControlsEnabled ? 1 : 0);
result = 31 * result + (doubleTapGesturesEnabled ? 1 : 0);
- result = 31 * result + (myLocationEnabled ? 1 : 0);
- result = 31 * result + (myLocationForegroundDrawable != null ? myLocationForegroundDrawable.hashCode() : 0);
- result = 31 * result + (myLocationForegroundBearingDrawable != null
- ? myLocationForegroundBearingDrawable.hashCode() : 0);
- result = 31 * result + (myLocationBackgroundDrawable != null ? myLocationBackgroundDrawable.hashCode() : 0);
- result = 31 * result + myLocationForegroundTintColor;
- result = 31 * result + myLocationBackgroundTintColor;
- result = 31 * result + Arrays.hashCode(myLocationBackgroundPadding);
- result = 31 * result + myLocationAccuracyTintColor;
- result = 31 * result + myLocationAccuracyAlpha;
- result = 31 * result + (myLocationAccuracyThreshold != +0.0f
- ? Float.floatToIntBits(myLocationAccuracyThreshold) : 0);
result = 31 * result + (apiBaseUrl != null ? apiBaseUrl.hashCode() : 0);
result = 31 * result + (textureMode ? 1 : 0);
result = 31 * result + (translucentTextureSurface ? 1 : 0);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java
index 4709ebd060..f35355533d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java
@@ -27,25 +27,17 @@ public class Projection {
this.contentPadding = new int[] {0, 0, 0, 0};
}
- void setContentPadding(int[] contentPadding, int[] userLocationViewPadding) {
+ void setContentPadding(int[] contentPadding) {
this.contentPadding = contentPadding;
-
- int[] padding = new int[] {
- contentPadding[0] + userLocationViewPadding[0],
- contentPadding[1] + userLocationViewPadding[1],
- contentPadding[2] + userLocationViewPadding[2],
- contentPadding[3] + userLocationViewPadding[3]
- };
-
- nativeMapView.setContentPadding(padding);
+ nativeMapView.setContentPadding(contentPadding);
}
int[] getContentPadding() {
return contentPadding;
}
- public void invalidateContentPadding(int[] userLocationViewPadding) {
- setContentPadding(contentPadding, userLocationViewPadding);
+ public void invalidateContentPadding() {
+ setContentPadding(contentPadding);
}
/**
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
deleted file mode 100644
index 3743096824..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java
+++ /dev/null
@@ -1,419 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.location.Location;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.UiThread;
-
-import com.mapbox.mapboxsdk.Mapbox;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.constants.MyBearingTracking;
-import com.mapbox.mapboxsdk.constants.MyLocationTracking;
-import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
-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;
-
-/**
- * Settings for the user location and bearing tracking of a MapboxMap.
- *
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead.
- */
-@Deprecated
-public final class TrackingSettings {
-
- private final MyLocationView myLocationView;
- private final UiSettings uiSettings;
- private final FocalPointChangeListener focalPointChangedListener;
- private final CameraZoomInvalidator zoomInvalidator;
- private LocationEngine locationSource;
- private LocationEngineListener myLocationListener;
- private boolean locationChangeAnimationEnabled = true;
- private boolean isCustomLocationSource;
-
- private boolean myLocationEnabled;
- private boolean dismissLocationTrackingOnGesture = true;
- private boolean dismissBearingTrackingOnGesture = true;
-
- private MapboxMap.OnMyLocationTrackingModeChangeListener onMyLocationTrackingModeChangeListener;
- private MapboxMap.OnMyBearingTrackingModeChangeListener onMyBearingTrackingModeChangeListener;
-
- TrackingSettings(@NonNull MyLocationView myLocationView, UiSettings uiSettings,
- FocalPointChangeListener focalPointChangedListener, CameraZoomInvalidator zoomInvalidator) {
- this.myLocationView = myLocationView;
- this.focalPointChangedListener = focalPointChangedListener;
- this.uiSettings = uiSettings;
- this.zoomInvalidator = zoomInvalidator;
- }
-
- void initialise(MapboxMapOptions options) {
- locationSource = Mapbox.getLocationEngine();
- setMyLocationEnabled(options.getLocationEnabled());
- }
-
- void onSaveInstanceState(Bundle outState) {
- outState.putInt(MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, getMyLocationTrackingMode());
- outState.putInt(MapboxConstants.STATE_MY_BEARING_TRACKING_MODE, getMyBearingTrackingMode());
- outState.putBoolean(MapboxConstants.STATE_MY_LOCATION_TRACKING_DISMISS, isDismissLocationTrackingOnGesture());
- outState.putBoolean(MapboxConstants.STATE_MY_BEARING_TRACKING_DISMISS, isDismissBearingTrackingOnGesture());
- outState.putBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED, isMyLocationEnabled());
- outState.putBoolean(MapboxConstants.STATE_LOCATION_CHANGE_ANIMATION_ENABLED, isLocationChangeAnimationEnabled());
- outState.putBoolean(MapboxConstants.STATE_USING_CUSTOM_LOCATION_SOURCE, isCustomLocationSource());
- }
-
- void onRestoreInstanceState(Bundle savedInstanceState) {
- try {
- setMyLocationEnabled(
- savedInstanceState.getBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED),
- savedInstanceState.getBoolean(MapboxConstants.STATE_USING_CUSTOM_LOCATION_SOURCE)
- );
- } catch (SecurityException ignore) {
- // User did not accept location permissions
- }
- // noinspection ResourceType
- setMyLocationTrackingMode(savedInstanceState.getInt(
- MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, MyLocationTracking.TRACKING_NONE));
- // noinspection ResourceType
- setMyBearingTrackingMode(savedInstanceState.getInt(
- MapboxConstants.STATE_MY_BEARING_TRACKING_MODE, MyBearingTracking.NONE));
- setDismissLocationTrackingOnGesture(savedInstanceState.getBoolean(
- MapboxConstants.STATE_MY_LOCATION_TRACKING_DISMISS, true));
- setDismissBearingTrackingOnGesture(savedInstanceState.getBoolean(
- MapboxConstants.STATE_MY_BEARING_TRACKING_DISMISS, true));
- setLocationChangeAnimationEnabled(savedInstanceState.getBoolean(
- MapboxConstants.STATE_LOCATION_CHANGE_ANIMATION_ENABLED, true));
- }
-
- /**
- * <p>
- * Set the current my location tracking mode.
- * </p>
- * <p>
- * Will enable my location if not active.
- * </p>
- * See {@link MyLocationTracking} for different values.
- *
- * @param myLocationTrackingMode The location tracking mode to be used.
- * @throws SecurityException if no suitable permission is present
- * @see MyLocationTracking
- */
- @UiThread
- public void setMyLocationTrackingMode(@MyLocationTracking.Mode int myLocationTrackingMode) {
- myLocationView.setLocationChangeAnimationEnabled(isLocationChangeAnimationEnabled());
- myLocationView.setMyLocationTrackingMode(myLocationTrackingMode);
-
- if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
- zoomInvalidator.zoomTo(2.0);
- focalPointChangedListener.onFocalPointChanged(myLocationView.getCenter());
- } else {
- focalPointChangedListener.onFocalPointChanged(null);
- }
-
- if (onMyLocationTrackingModeChangeListener != null) {
- onMyLocationTrackingModeChangeListener.onMyLocationTrackingModeChange(myLocationTrackingMode);
- }
- }
-
- /**
- * Returns the current user location tracking mode.
- *
- * @return The current user location tracking mode.
- * One of the values from {@link MyLocationTracking.Mode}.
- * @see MyLocationTracking.Mode
- */
- @UiThread
- @MyLocationTracking.Mode
- public int getMyLocationTrackingMode() {
- return myLocationView.getMyLocationTrackingMode();
- }
-
- /**
- * <p>
- * Set the current my bearing tracking mode.
- * </p>
- * Shows the direction the user is heading.
- * <p>
- * When location tracking is disabled the direction of {@link MyLocationView} is rotated. When
- * location tracking is enabled the {@link MapView} is rotated based on the bearing value.
- * </p>
- * See {@link MyBearingTracking} for different values.
- *
- * @param myBearingTrackingMode The bearing tracking mode to be used.
- * @throws SecurityException if no suitable permission is present
- * @see MyBearingTracking
- */
- @UiThread
- public void setMyBearingTrackingMode(@MyBearingTracking.Mode int myBearingTrackingMode) {
- myLocationView.setMyBearingTrackingMode(myBearingTrackingMode);
- if (onMyBearingTrackingModeChangeListener != null) {
- onMyBearingTrackingModeChangeListener.onMyBearingTrackingModeChange(myBearingTrackingMode);
- }
- }
-
- /**
- * Returns the current user bearing tracking mode.
- * See {@link MyBearingTracking} for possible return values.
- *
- * @return the current user bearing tracking mode.
- * @see MyBearingTracking
- */
- @UiThread
- @MyBearingTracking.Mode
- public int getMyBearingTrackingMode() {
- return myLocationView.getMyBearingTrackingMode();
- }
-
- /**
- * Returns if all tracking modes will be dismissed when a gesture occurs.
- *
- * @return True to indicate that location and bearing tracking will be dismissed.
- */
- public boolean isAllDismissTrackingOnGesture() {
- return dismissLocationTrackingOnGesture && dismissBearingTrackingOnGesture;
- }
-
- /**
- * Set the dismissal of the tracking modes if a gesture occurs.
- *
- * @param dismissTrackingOnGesture True to dismiss all the tracking modes.
- */
- public void setDismissAllTrackingOnGesture(boolean dismissTrackingOnGesture) {
- dismissLocationTrackingOnGesture = dismissTrackingOnGesture;
- dismissBearingTrackingOnGesture = dismissTrackingOnGesture;
- }
-
- /**
- * Set the dismissal of the tracking modes if a gesture occurs.
- *
- * @param dismissLocationTrackingOnGesture True to dismiss the location tracking mode.
- */
- public void setDismissLocationTrackingOnGesture(boolean dismissLocationTrackingOnGesture) {
- this.dismissLocationTrackingOnGesture = dismissLocationTrackingOnGesture;
- }
-
- /**
- * Returns if the location tracking will be disabled when a gesture occurs
- *
- * @return True if location tracking will be disabled.
- */
- public boolean isDismissLocationTrackingOnGesture() {
- return dismissLocationTrackingOnGesture;
- }
-
- /**
- * Set the dismissal of the bearing tracking modes if a gesture occurs.
- *
- * @param dismissBearingTrackingOnGesture True to dimsiss the bearinf tracking mode
- */
- public void setDismissBearingTrackingOnGesture(boolean dismissBearingTrackingOnGesture) {
- this.dismissBearingTrackingOnGesture = dismissBearingTrackingOnGesture;
- }
-
- /**
- * Returns if bearing will disabled when a gesture occurs
- *
- * @return True if bearing tracking will be disabled
- */
- public boolean isDismissBearingTrackingOnGesture() {
- return dismissBearingTrackingOnGesture;
- }
-
- /**
- * Returns if location tracking is disabled
- *
- * @return True if location tracking is disabled.
- */
- public boolean isLocationTrackingDisabled() {
- return myLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE;
- }
-
- /**
- * Returns if bearing tracking disabled
- *
- * @return True if bearing tracking is disabled.
- */
- public boolean isBearingTrackingDisabled() {
- return myLocationView.getMyBearingTrackingMode() == MyBearingTracking.NONE;
- }
-
- /**
- * Returns if rotate gesture are currently enabled.
- *
- * @return True if rotate gestures are currently enabled.
- */
- public boolean isRotateGestureCurrentlyEnabled() {
- // rotate gestures are recognised if:
- // The user settings are enabled AND;
- // EITHER bearing tracking is dismissed on gesture OR there is no bearing tracking
- return uiSettings.isRotateGesturesEnabled()
- && (dismissBearingTrackingOnGesture
- || myLocationView.getMyBearingTrackingMode() == MyBearingTracking.NONE
- || myLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE);
- }
-
- /**
- * Returns if scroll gesture are currently enabled.
- *
- * @return True if scroll gestures are currently enabled.
- */
- public boolean isScrollGestureCurrentlyEnabled() {
- return uiSettings.isScrollGesturesEnabled()
- && (dismissLocationTrackingOnGesture
- || myLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE);
- }
-
- /**
- * Returns whether location change animation is applied for {@link MyLocationTracking#TRACKING_FOLLOW}.
- *
- * @return True if animation is applied, false otherwise.
- */
- public boolean isLocationChangeAnimationEnabled() {
- return locationChangeAnimationEnabled;
- }
-
- /**
- * Set whether location change animation should be applied for {@link MyLocationTracking#TRACKING_FOLLOW}.
- *
- * @param locationChangeAnimationEnabled True if animation should be applied, false otherwise.
- */
- public void setLocationChangeAnimationEnabled(boolean locationChangeAnimationEnabled) {
- this.locationChangeAnimationEnabled = locationChangeAnimationEnabled;
-
- myLocationView.setLocationChangeAnimationEnabled(locationChangeAnimationEnabled);
- }
-
- /**
- * Reset the tracking modes as necessary. Location tracking is reset if the map center is changed and not from
- * location, bearing tracking if there is a rotation.
- *
- * @param translate true if translation
- * @param rotate true if rotation
- * @param isFromLocation true if from location
- */
- void resetTrackingModesIfRequired(boolean translate, boolean rotate, boolean isFromLocation) {
- // if tracking is on, and we should dismiss tracking with gestures, and this is a scroll action, turn tracking off
- if (translate && !isLocationTrackingDisabled() && isDismissLocationTrackingOnGesture() && !isFromLocation) {
- setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
- }
-
- // reset bearing tracking only on rotate
- if (rotate && !isBearingTrackingDisabled() && isDismissBearingTrackingOnGesture()) {
- setMyBearingTrackingMode(MyBearingTracking.NONE);
- }
- }
-
- /**
- * Reset the tracking modes as necessary. Animated camera position changes can reset the underlying tracking modes.
- *
- * @param currentCameraPosition the current camera position
- * @param targetCameraPosition the changed camera position
- * @param isFromLocation true if from location
- */
- void resetTrackingModesIfRequired(CameraPosition currentCameraPosition, CameraPosition targetCameraPosition,
- boolean isFromLocation) {
- if (currentCameraPosition.target != null) {
- resetTrackingModesIfRequired(!currentCameraPosition.target.equals(targetCameraPosition.target), false,
- isFromLocation);
- }
- }
-
- Location getMyLocation() {
- return myLocationView.getLocation();
- }
-
- void setOnMyLocationChangeListener(@Nullable final MapboxMap.OnMyLocationChangeListener listener) {
- if (listener != null) {
- myLocationListener = new LocationEngineListener() {
- @Override
- public void onConnected() {
- // Nothing
- }
-
- @Override
- public void onLocationChanged(Location location) {
- if (listener != null) {
- listener.onMyLocationChange(location);
- }
- }
- };
- locationSource.addLocationEngineListener(myLocationListener);
- } else {
- locationSource.removeLocationEngineListener(myLocationListener);
- myLocationListener = null;
- }
- }
-
- public boolean isCustomLocationSource() {
- return isCustomLocationSource;
- }
-
- void setOnMyLocationTrackingModeChangeListener(MapboxMap.OnMyLocationTrackingModeChangeListener listener) {
- this.onMyLocationTrackingModeChangeListener = listener;
- }
-
- void setOnMyBearingTrackingModeChangeListener(MapboxMap.OnMyBearingTrackingModeChangeListener listener) {
- this.onMyBearingTrackingModeChangeListener = listener;
- }
-
- MyLocationView getMyLocationView() {
- return myLocationView;
- }
-
-
- boolean isMyLocationEnabled() {
- return myLocationEnabled;
- }
-
- void setMyLocationEnabled(boolean locationEnabled) {
- setMyLocationEnabled(locationEnabled, isCustomLocationSource());
- }
-
- private void setMyLocationEnabled(boolean locationEnabled, boolean isCustomLocationSource) {
- if (locationEnabled && !PermissionsManager.areLocationPermissionsGranted(myLocationView.getContext())) {
- Timber.e("Could not activate user location tracking: "
- + "user did not accept the permission or permissions were not requested.");
- return;
- }
- myLocationEnabled = locationEnabled;
- this.isCustomLocationSource = isCustomLocationSource;
- myLocationView.setEnabled(locationEnabled, isCustomLocationSource);
- }
-
- void setLocationSource(LocationEngine locationSource) {
- if (this.locationSource != null && this.locationSource.equals(locationSource)) {
- // this source is already active
- return;
- }
-
- this.isCustomLocationSource = locationSource != null;
- if (locationSource == null) {
- locationSource = Mapbox.getLocationEngine();
- }
- this.locationSource = locationSource;
- myLocationView.setLocationSource(locationSource);
- }
-
- void update() {
- if (!myLocationView.isEnabled()) {
- return;
- }
- myLocationView.update();
- }
-
- void onStart() {
- myLocationView.onStart();
- }
-
- void onStop() {
- myLocationView.onStop();
- }
-
- interface CameraZoomInvalidator {
- void zoomTo(double zoomLevel);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
index 43c943a16f..c226833f3e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
@@ -12,7 +12,6 @@ import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
import timber.log.Timber;
@@ -30,8 +29,6 @@ final class Transform implements MapView.OnMapChangedListener {
private final NativeMapView mapView;
private final MarkerViewManager markerViewManager;
- private final TrackingSettings trackingSettings;
- private final MyLocationView myLocationView;
private final Handler handler = new Handler();
private CameraPosition cameraPosition;
@@ -41,12 +38,10 @@ final class Transform implements MapView.OnMapChangedListener {
private CameraChangeDispatcher cameraChangeDispatcher;
- Transform(NativeMapView mapView, MarkerViewManager markerViewManager, TrackingSettings trackingSettings,
+ Transform(NativeMapView mapView, MarkerViewManager markerViewManager,
CameraChangeDispatcher cameraChangeDispatcher) {
this.mapView = mapView;
this.markerViewManager = markerViewManager;
- this.trackingSettings = trackingSettings;
- this.myLocationView = trackingSettings.getMyLocationView();
this.cameraChangeDispatcher = cameraChangeDispatcher;
}
@@ -73,9 +68,6 @@ final class Transform implements MapView.OnMapChangedListener {
@UiThread
void updateCameraPosition(@NonNull CameraPosition position) {
- if (myLocationView != null) {
- myLocationView.setCameraPosition(position);
- }
markerViewManager.setTilt((float) position.tilt);
}
@@ -103,7 +95,6 @@ final class Transform implements MapView.OnMapChangedListener {
final void moveCamera(MapboxMap mapboxMap, CameraUpdate update, final MapboxMap.CancelableCallback callback) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (isValidCameraPosition(cameraPosition)) {
- trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false);
cancelTransitions();
cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
mapView.jumpTo(cameraPosition.bearing, cameraPosition.target, cameraPosition.tilt, cameraPosition.zoom);
@@ -125,7 +116,6 @@ final class Transform implements MapView.OnMapChangedListener {
final MapboxMap.CancelableCallback callback, boolean isDismissable) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (isValidCameraPosition(cameraPosition)) {
- trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, isDismissable);
cancelTransitions();
cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
@@ -143,7 +133,6 @@ final class Transform implements MapView.OnMapChangedListener {
final MapboxMap.CancelableCallback callback) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (isValidCameraPosition(cameraPosition)) {
- trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false);
cancelTransitions();
cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
@@ -297,23 +286,14 @@ final class Transform implements MapView.OnMapChangedListener {
}
void setBearing(double bearing) {
- if (myLocationView != null) {
- myLocationView.setBearing(bearing);
- }
mapView.setBearing(bearing);
}
void setBearing(double bearing, float focalX, float focalY) {
- if (myLocationView != null) {
- myLocationView.setBearing(bearing);
- }
mapView.setBearing(bearing, focalX, focalY);
}
void setBearing(double bearing, float focalX, float focalY, long duration) {
- if (myLocationView != null) {
- myLocationView.setBearing(bearing);
- }
mapView.setBearing(bearing, focalX, focalY, duration);
}
@@ -335,9 +315,6 @@ final class Transform implements MapView.OnMapChangedListener {
}
void setTilt(Double pitch) {
- if (myLocationView != null) {
- myLocationView.setTilt(pitch);
- }
markerViewManager.setTilt(pitch.floatValue());
mapView.setPitch(pitch, 0);
}
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
deleted file mode 100644
index 3f37da99d5..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ /dev/null
@@ -1,1104 +0,0 @@
-package com.mapbox.mapboxsdk.maps.widgets;
-
-import android.animation.ValueAnimator;
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.graphics.Camera;
-import android.graphics.Canvas;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.PointF;
-import android.graphics.PorterDuff;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-import android.location.Location;
-import android.os.Bundle;
-import android.os.Parcelable;
-import android.os.SystemClock;
-import android.support.annotation.ColorInt;
-import android.support.annotation.FloatRange;
-import android.support.annotation.IntRange;
-import android.support.annotation.NonNull;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.mapbox.mapboxsdk.Mapbox;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.constants.MyBearingTracking;
-import com.mapbox.mapboxsdk.constants.MyLocationTracking;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.Projection;
-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;
-
-import timber.log.Timber;
-
-/**
- * UI element overlaid on a map to show the user's location.
- * <p>
- * Use {@link MyLocationViewSettings} to manipulate the state of this view.
- * </p>
- *
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead.
- */
-@Deprecated
-public class MyLocationView extends View {
-
- private static final int UNDEFINED_TINT_COLOR = -1;
- private MyLocationBehavior myLocationBehavior;
- private MapboxMap mapboxMap;
-
- private Projection projection;
- private float[] projectedCoordinate = new float[2];
- private float projectedX;
- private float projectedY;
-
- private float contentPaddingX;
- private float contentPaddingY;
-
- private LatLng latLng;
- private Location location;
- private LocationEngine locationEngine;
- private long locationUpdateTimestamp;
- private float previousDirection;
-
- private float accuracy;
- private Paint accuracyPaint;
- private float accuracyThreshold;
-
- private ValueAnimator locationChangeAnimator;
- private ValueAnimator accuracyAnimator;
- private ValueAnimator directionAnimator;
- private boolean locationChangeAnimationEnabled = true;
-
- private ValueAnimator.AnimatorUpdateListener invalidateSelfOnUpdateListener =
- new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- invalidate();
- }
- };
-
- private Drawable foregroundDrawable;
- private Drawable foregroundBearingDrawable;
- private Drawable backgroundDrawable;
-
- private Rect foregroundBounds;
- private Rect backgroundBounds;
-
- private int backgroundOffsetLeft;
- private int backgroundOffsetTop;
- private int backgroundOffsetRight;
- private int backgroundOffsetBottom;
-
- private Matrix matrix;
- private Camera camera;
- private PointF screenLocation;
-
- // camera vars
- private double tilt;
- private double bearing;
- private float magneticHeading;
-
- // Controls the compass update rate in milliseconds
- private static final int COMPASS_UPDATE_RATE_MS = 500;
-
- @MyLocationTracking.Mode
- private int myLocationTrackingMode;
-
- @MyBearingTracking.Mode
- private int myBearingTrackingMode;
-
- private GpsLocationListener userLocationListener;
- private CompassListener compassListener;
-
- public MyLocationView(Context context) {
- super(context);
- init(context);
- }
-
- public MyLocationView(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context);
- }
-
- public MyLocationView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- init(context);
- }
-
- private void init(Context context) {
- if (isInEditMode()) {
- return;
- }
-
- setEnabled(false);
-
- // setup LayoutParams
- ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT);
- setLayoutParams(lp);
-
- matrix = new Matrix();
- camera = new Camera();
- camera.setLocation(0, 0, -1000);
- accuracyPaint = new Paint();
-
- myLocationBehavior = new MyLocationBehaviorFactory().getBehavioralModel(MyLocationTracking.TRACKING_NONE);
- compassListener = new CompassListener(context);
- }
-
- @Deprecated
- public void init(LocationEngine locationSource) {
- this.locationEngine = locationSource;
- }
-
- /**
- * Set the foreground drawable, for internal use only.
- *
- * @param defaultDrawable The drawable shown when showing this view
- * @param bearingDrawable The drawable shown when tracking of bearing is enabled
- */
- public final void setForegroundDrawables(Drawable defaultDrawable, Drawable bearingDrawable) {
- if (defaultDrawable == null) {
- return;
- }
-
- if (bearingDrawable == null) {
- // if user only provided one resource
- // use same for bearing mode
- bearingDrawable = defaultDrawable.getConstantState().newDrawable();
- }
-
- if (backgroundDrawable == null) {
- // if the user didn't provide a background resource we will use the foreground resource instead,
- // we need to create a new drawable to handle tinting correctly
- backgroundDrawable = defaultDrawable.getConstantState().newDrawable();
- }
-
- if (defaultDrawable.getIntrinsicWidth() != bearingDrawable.getIntrinsicWidth()
- || defaultDrawable.getIntrinsicHeight() != bearingDrawable.getIntrinsicHeight()) {
- throw new RuntimeException("The dimensions from location and bearing drawables should be match");
- }
-
- foregroundDrawable = defaultDrawable;
- foregroundBearingDrawable = bearingDrawable;
-
- invalidateBounds();
- }
-
- /**
- * Set the foreground drawable tint, for internal use only.
- *
- * @param color The color to tint the drawable with
- */
- public final void setForegroundDrawableTint(@ColorInt int color) {
- applyDrawableTint(foregroundDrawable, color);
- applyDrawableTint(foregroundBearingDrawable, color);
- invalidate();
- }
-
- /**
- * Set the shadow drawable, for internal use only.
- *
- * @param drawable The drawable shown as shadow
- */
- public final void setShadowDrawable(Drawable drawable) {
- setShadowDrawable(drawable, 0, 0, 0, 0);
- }
-
- /**
- * Set the shadow drawable with some additional offset.
- *
- * @param drawable The drawable shown as shadow
- * @param left The left offset margin
- * @param top The top offset margin
- * @param right The right offset margin
- * @param bottom The bottom offset margin
- */
- public final void setShadowDrawable(Drawable drawable, int left, int top, int right, int bottom) {
- if (drawable != null) {
- backgroundDrawable = drawable;
- }
-
- backgroundOffsetLeft = left;
- backgroundOffsetTop = top;
- backgroundOffsetRight = right;
- backgroundOffsetBottom = bottom;
-
- invalidateBounds();
- }
-
- /**
- * Set the shadow drawable tint color, for internal use only.
- *
- * @param color The tint color to apply
- */
- public final void setShadowDrawableTint(@ColorInt int color) {
- if (backgroundDrawable == null) {
- return;
- }
- applyDrawableTint(backgroundDrawable, color);
- invalidate();
- }
-
- /**
- * Set the accuracy tint color, for internal use only.
- *
- * @param color The tint color to apply
- */
- public final void setAccuracyTint(@ColorInt int color) {
- int alpha = accuracyPaint.getAlpha();
- accuracyPaint.setColor(color);
- accuracyPaint.setAlpha(alpha);
- invalidate();
- }
-
- /**
- * Set the accuracy alpha value, for internal use only.
- *
- * @param alpha The alpha accuracy value to apply
- */
- public final void setAccuracyAlpha(@IntRange(from = 0, to = 255) int alpha) {
- accuracyPaint.setAlpha(alpha);
- invalidate();
- }
-
- private void invalidateBounds() {
- if (backgroundDrawable == null || foregroundDrawable == null || foregroundBearingDrawable == null) {
- return;
- }
-
- int backgroundWidth = backgroundDrawable.getIntrinsicWidth();
- int backgroundHeight = backgroundDrawable.getIntrinsicHeight();
- int horizontalOffset = backgroundOffsetLeft - backgroundOffsetRight;
- int verticalOffset = backgroundOffsetTop - backgroundOffsetBottom;
- backgroundBounds = new Rect(-backgroundWidth / 2 + horizontalOffset,
- -backgroundHeight / 2 + verticalOffset, backgroundWidth / 2 + horizontalOffset, backgroundHeight / 2
- + verticalOffset);
- backgroundDrawable.setBounds(backgroundBounds);
-
- int foregroundWidth = foregroundDrawable.getIntrinsicWidth();
- int foregroundHeight = foregroundDrawable.getIntrinsicHeight();
- foregroundBounds = new Rect(-foregroundWidth / 2, -foregroundHeight / 2, foregroundWidth / 2, foregroundHeight / 2);
- foregroundDrawable.setBounds(foregroundBounds);
- foregroundBearingDrawable.setBounds(foregroundBounds);
-
- // invoke a new draw
- invalidate();
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- if (location == null || foregroundBounds == null || backgroundBounds == null || accuracyAnimator == null
- || screenLocation == null) {
- // Not ready yet
- return;
- }
-
- final PointF pointF = screenLocation;
- float metersPerPixel = (float) projection.getMetersPerPixelAtLatitude(location.getLatitude());
- float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel;
-
- // reset
- matrix.reset();
- projectedCoordinate[0] = 0;
- projectedCoordinate[1] = 0;
-
- // put camera in position
- camera.save();
- camera.rotate((float) tilt, 0, 0);
- camera.getMatrix(matrix);
-
- if (myBearingTrackingMode != MyBearingTracking.NONE && directionAnimator != null) {
- matrix.preRotate((Float) directionAnimator.getAnimatedValue());
- }
-
- matrix.preTranslate(0, contentPaddingY);
- matrix.postTranslate(pointF.x, pointF.y - contentPaddingY);
-
- // concat our matrix on canvas
- canvas.concat(matrix);
-
- // calculate focal point
- matrix.mapPoints(projectedCoordinate);
- projectedX = pointF.x - projectedCoordinate[0];
- projectedY = pointF.y - projectedCoordinate[1];
-
- // restore orientation from camera
- camera.restore();
-
- // draw circle
- canvas.drawCircle(0, 0, accuracyPixels, accuracyPaint);
-
- // draw shadow
- if (backgroundDrawable != null) {
- backgroundDrawable.draw(canvas);
- }
-
- // draw foreground
- if (myBearingTrackingMode == MyBearingTracking.NONE) {
- if (foregroundDrawable != null) {
- foregroundDrawable.draw(canvas);
- }
- } else if (foregroundBearingDrawable != null && foregroundBounds != null) {
- if (myBearingTrackingMode == MyBearingTracking.GPS
- || myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING
- || compassListener.isSensorAvailable()) {
- foregroundBearingDrawable.draw(canvas);
- } else {
- // We are tracking MyBearingTracking.COMPASS, but sensor is not available.
- foregroundDrawable.draw(canvas);
- }
- }
- }
-
- /**
- * Set the tilt value, for internal use only.
- *
- * @param tilt The tilt to apply
- */
- public void setTilt(@FloatRange(from = 0, to = 60.0f) double tilt) {
- this.tilt = tilt;
- invalidate();
- }
-
- /**
- * Set the bearing value, for internal use only.
- *
- * @param bearing The bearing to apply
- */
- public void setBearing(double bearing) {
- this.bearing = bearing;
- if (myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) {
- if (myBearingTrackingMode == MyBearingTracking.GPS
- || myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING) {
- if (location != null) {
- setCompass(location.getBearing() - bearing);
- }
- } else if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) {
- setCompass(magneticHeading - bearing);
- }
- }
- }
-
- /**
- * Set the bearing and tilt from a camera position, for internal use only.
- *
- * @param position The camera position to extract bearing and tilt from
- */
- public void setCameraPosition(CameraPosition position) {
- if (position != null) {
- setBearing(position.bearing);
- setTilt(position.tilt);
- }
- }
-
- /**
- * Called when the hosting activity is starting, for internal use only.
- */
- public void onStart() {
- if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) {
- compassListener.onResume();
- }
- if (isEnabled()) {
- toggleGps(true);
- }
- }
-
- /**
- * Called when the hosting activity is stopping, for internal use only.
- */
- public void onStop() {
- compassListener.onPause();
- toggleGps(false);
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- // cleanup to prevent memory leaks
- if (locationChangeAnimator != null) {
- locationChangeAnimator.cancel();
- locationChangeAnimator = null;
- }
-
- if (accuracyAnimator != null) {
- accuracyAnimator.cancel();
- accuracyAnimator = null;
- }
-
- if (directionAnimator != null) {
- directionAnimator.cancel();
- directionAnimator = null;
- }
-
- if (userLocationListener != null) {
- locationEngine.removeLocationEngineListener(userLocationListener);
- locationEngine = null;
- userLocationListener = null;
- }
- }
-
- /**
- * Update current locationstate.
- */
- public void update() {
- if (isEnabled()) {
- myLocationBehavior.invalidate();
- } else {
- setVisibility(View.INVISIBLE);
- }
- }
-
- // TODO refactor MapboxMap out
- public void setMapboxMap(MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- this.projection = mapboxMap.getProjection();
- }
-
- /**
- * Set the enabled state, for internal use only.
- *
- * @param enabled The value to set the state to
- */
- @Override
- public void setEnabled(boolean enabled) {
- setEnabled(enabled, false);
- }
-
- /**
- * Set the enabled state, for internal use only.
- *
- * @param enabled The value to set the state to
- * @param isCustomLocationEngine Flag handling for handling user provided custom location engine
- */
- public void setEnabled(boolean enabled, boolean isCustomLocationEngine) {
- super.setEnabled(enabled);
- setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
- toggleGps(enabled, isCustomLocationEngine);
- }
-
- /**
- * Save the view instance state, for internal use only.
- *
- * @return the marshaled representation of the view state
- */
- @Override
- protected Parcelable onSaveInstanceState() {
- Bundle bundle = new Bundle();
- bundle.putParcelable("superState", super.onSaveInstanceState());
- bundle.putDouble("tilt", tilt);
- return bundle;
- }
-
- /**
- * Restore the view instance state, for internal use only.
- *
- * @param state the marshalled representation of the state to restore
- */
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- if (state instanceof Bundle) {
- Bundle bundle = (Bundle) state;
- tilt = bundle.getDouble("tilt");
- state = bundle.getParcelable("superState");
- }
- super.onRestoreInstanceState(state);
- }
-
- private void toggleGps(boolean enableGps) {
- toggleGps(enableGps, mapboxMap != null
- && mapboxMap.getTrackingSettings().isCustomLocationSource());
- }
-
- /**
- * Enabled / Disable GPS location updates along with updating the UI, for internal use only.
- *
- * @param enableGps true if GPS is to be enabled, false if GPS is to be disabled
- */
- private void toggleGps(boolean enableGps, boolean isCustomLocationEngine) {
- if (enableGps) {
- if (locationEngine == null) {
- if (!isCustomLocationEngine) {
- locationEngine = Mapbox.getLocationEngine();
- } else {
- return;
- }
- }
-
- if (userLocationListener == null) {
- userLocationListener = new GpsLocationListener(this, locationEngine);
- }
-
- locationEngine.addLocationEngineListener(userLocationListener);
- locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
- locationEngine.activate();
- } else {
- if (locationEngine == null) {
- return;
- }
- // Disable location and user dot
- location = null;
- locationEngine.removeLocationEngineListener(userLocationListener);
- locationEngine.removeLocationUpdates();
- locationEngine.deactivate();
- restoreLocationEngine();
- }
- }
-
- /**
- * Get the current location.
- *
- * @return the current location
- */
- public Location getLocation() {
- return location;
- }
-
- /**
- * Set the current location, for internal use only.
- *
- * @param location The current location
- */
- public void setLocation(Location location) {
- if (location == null) {
- this.location = null;
- return;
- }
-
- this.location = location;
- myLocationBehavior.updateLatLng(location);
-
- if (mapboxMap != null && (myBearingTrackingMode == MyBearingTracking.GPS
- || myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING)
- && myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) {
- setBearing(mapboxMap.getCameraPosition().bearing);
- }
- }
-
- /**
- * Set location change animation enabled, for internal use only.
- *
- * @param locationChangeAnimationEnabled True if location changes are animated
- */
- public void setLocationChangeAnimationEnabled(boolean locationChangeAnimationEnabled) {
- this.locationChangeAnimationEnabled = locationChangeAnimationEnabled;
- }
-
- /**
- * Set accuracy circle threshold. Circle won't be displayed if accuracy is below set value.
- * For internal use only.
- *
- * @param accuracyThreshold Value below which circle won't be displayed
- */
- public void setAccuracyThreshold(float accuracyThreshold) {
- this.accuracyThreshold = accuracyThreshold;
- }
-
- /**
- * Set the bearing tracking mode, for internal use only.
- *
- * @param myBearingTrackingMode The bearing tracking mode
- */
- public void setMyBearingTrackingMode(@MyBearingTracking.Mode int myBearingTrackingMode) {
- this.myBearingTrackingMode = myBearingTrackingMode;
- if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) {
- compassListener.onResume();
- } else {
- compassListener.onPause();
- if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW
- && myBearingTrackingMode == MyBearingTracking.GPS) {
- // always face north
- setCompass(0);
- } else {
- myLocationBehavior.invalidate();
- }
- }
- invalidate();
- }
-
- /**
- * Set the location tracking mode, for internla use only.
- *
- * @param myLocationTrackingMode The location tracking mode
- */
- public void setMyLocationTrackingMode(@MyLocationTracking.Mode int myLocationTrackingMode) {
- MyLocationBehaviorFactory factory = new MyLocationBehaviorFactory();
- myLocationBehavior = factory.getBehavioralModel(myLocationTrackingMode);
-
- if (location != null) {
- if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
- // center map directly
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(location)));
- } else {
- // do not use interpolated location from tracking mode
- latLng = null;
- }
- myLocationBehavior.updateLatLng(location);
- }
-
- this.myLocationTrackingMode = myLocationTrackingMode;
- invalidate();
- }
-
- /**
- * Get the location tracking mode, for internal use only.
- *
- * @return The location tracking mode
- */
- @MyLocationTracking.Mode
- public int getMyLocationTrackingMode() {
- return myLocationTrackingMode;
- }
-
-
- /**
- * Get the bearing tracking mode, for internal use only.
- *
- * @return the bearing tracking mode
- */
- @MyBearingTracking.Mode
- public int getMyBearingTrackingMode() {
- return myBearingTrackingMode;
- }
-
- /**
- * Set the compass bearing value, for internal use only.
- *
- * @param bearing The compas bearing value
- */
- private void setCompass(double bearing) {
- setCompass(bearing, 0 /* no animation */);
- }
-
- private void setCompass(double bearing, long duration) {
- float oldDir = previousDirection;
- if (directionAnimator != null) {
- oldDir = (Float) directionAnimator.getAnimatedValue();
- directionAnimator.end();
- directionAnimator = null;
- }
-
- float newDir = (float) bearing;
- float diff = oldDir - newDir;
- if (diff > 180.0f) {
- newDir += 360.0f;
- } else if (diff < -180.0f) {
- newDir -= 360.f;
- }
- previousDirection = newDir;
-
- directionAnimator = ValueAnimator.ofFloat(oldDir, newDir);
- directionAnimator.setDuration(duration);
- directionAnimator.addUpdateListener(invalidateSelfOnUpdateListener);
- directionAnimator.start();
- }
-
- /**
- * Get the center of this view in screen coordinates.
- *
- * @return the center of the view
- */
- public PointF getCenter() {
- return new PointF(getCenterX(), getCenterY());
- }
-
- /**
- * Get the x value of the center of this view.
- *
- * @return the x value of the center of the view
- */
- private float getCenterX() {
- return (getX() + getMeasuredWidth()) / 2 + contentPaddingX - projectedX;
- }
-
- /**
- * Get the y value of the center of this view.
- *
- * @return the y value of the center of the view
- */
- private float getCenterY() {
- return (getY() + getMeasuredHeight()) / 2 + contentPaddingY - projectedY;
- }
-
- public void setContentPadding(int[] padding) {
- contentPaddingX = (padding[0] - padding[2]) / 2;
- contentPaddingY = (padding[1] - padding[3]) / 2;
- }
-
- /**
- * Set the location source from which location updates are received, for internal use only.
- *
- * @param locationEngine The location engine to receive updates from
- */
- public void setLocationSource(LocationEngine locationEngine) {
- toggleGps(false);
- this.locationEngine = locationEngine;
- this.userLocationListener = null;
- setEnabled(isEnabled(), locationEngine != null);
- }
-
- private void applyDrawableTint(Drawable drawable, @ColorInt int color) {
- if (color == UNDEFINED_TINT_COLOR) {
- removeTintColorFilter(drawable);
- } else {
- applyTintColorFilter(drawable, color);
- }
- }
-
- private void removeTintColorFilter(Drawable drawable) {
- if (drawable != null) {
- drawable.mutate().setColorFilter(null);
- }
- }
-
- private void applyTintColorFilter(Drawable drawable, @ColorInt int color) {
- if (drawable != null) {
- drawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
- }
- }
-
- private void restoreLocationEngine() {
- locationEngine.setPriority(LocationEnginePriority.LOW_POWER);
- locationEngine.activate();
- }
-
- private static class GpsLocationListener implements LocationEngineListener {
-
- private WeakReference<MyLocationView> userLocationView;
- private WeakReference<LocationEngine> locationSource;
-
- GpsLocationListener(MyLocationView myLocationView, LocationEngine locationEngine) {
- userLocationView = new WeakReference<>(myLocationView);
- locationSource = new WeakReference<>(locationEngine);
- }
-
- @SuppressLint("MissingPermission")
- @Override
- public void onConnected() {
- MyLocationView locationView = userLocationView.get();
- LocationEngine locationEngine = locationSource.get();
- if (locationView != null && locationEngine != null) {
- Location lastKnownLocation = locationEngine.getLastLocation();
- if (lastKnownLocation != null) {
- locationView.setLocation(lastKnownLocation);
- }
- locationEngine.requestLocationUpdates();
- }
- }
-
- /**
- * Callback method for receiving location updates from LocationServices.
- *
- * @param location The new Location data
- */
- @Override
- public void onLocationChanged(Location location) {
- MyLocationView locationView = userLocationView.get();
- if (locationView != null) {
- locationView.setLocation(location);
- }
- }
- }
-
- private class CompassListener implements SensorEventListener {
-
- private final SensorManager sensorManager;
-
- private Sensor rotationVectorSensor;
- private float[] matrix = new float[9];
- private float[] rotationVectorValue;
- private float[] truncatedRotationVectorValue = new float[4];
-
- private float[] orientation = new float[3];
- private boolean reportMissingSensor = true;
- // Compass data
- private long compassUpdateNextTimestamp = 0;
-
- CompassListener(Context context) {
- sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
- rotationVectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
- }
-
- public void onResume() {
- sensorManager.registerListener(this, rotationVectorSensor, SensorManager.SENSOR_DELAY_GAME);
- }
-
- public void onPause() {
- sensorManager.unregisterListener(this, rotationVectorSensor);
- }
-
- public boolean isSensorAvailable() {
- if (rotationVectorSensor == null && reportMissingSensor) {
- reportMissingSensor = false;
- Timber.e("Sensor.TYPE_ROTATION_VECTOR is missing from this device. Unable to use MyBearingTracking.COMPASS.");
- }
- return rotationVectorSensor != null;
- }
-
- @Override
- public void onSensorChanged(SensorEvent event) {
-
- // check when the last time the compass was updated, return if too soon.
- long currentTime = SystemClock.elapsedRealtime();
- if (currentTime < compassUpdateNextTimestamp) {
- return;
- }
-
- if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
- rotationVectorValue = getRotationVectorFromSensorEvent(event);
- SensorManager.getRotationMatrixFromVector(matrix, rotationVectorValue);
- SensorManager.getOrientation(matrix, orientation);
-
- magneticHeading = (float) Math.toDegrees(SensorManager.getOrientation(matrix, orientation)[0]);
- if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
- // Change the user location view orientation to reflect the device orientation
- rotateCamera(magneticHeading);
- setCompass(0, COMPASS_UPDATE_RATE_MS);
- } else {
- // Change compass direction
- setCompass(magneticHeading - bearing, COMPASS_UPDATE_RATE_MS);
- }
-
- compassUpdateNextTimestamp = currentTime + COMPASS_UPDATE_RATE_MS;
- }
- }
-
- /**
- * Pulls out the rotation vector from a SensorEvent, with a maximum length
- * vector of four elements to avoid potential compatibility issues.
- *
- * @param event the sensor event
- * @return the events rotation vector, potentially truncated
- */
- @NonNull
- float[] getRotationVectorFromSensorEvent(@NonNull SensorEvent event) {
- if (event.values.length > 4) {
- // On some Samsung devices SensorManager.getRotationMatrixFromVector
- // appears to throw an exception if rotation vector has length > 4.
- // For the purposes of this class the first 4 values of the
- // rotation vector are sufficient (see crbug.com/335298 for details).
- // Only affects Android 4.3
- System.arraycopy(event.values, 0, truncatedRotationVectorValue, 0, 4);
- return truncatedRotationVectorValue;
- } else {
- return event.values;
- }
- }
-
- private void rotateCamera(float rotation) {
- CameraPosition.Builder builder = new CameraPosition.Builder();
- builder.bearing(rotation);
- mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), COMPASS_UPDATE_RATE_MS,
- false /*linear interpolator*/, null);
- }
-
- @Override
- public void onAccuracyChanged(Sensor sensor, int accuracy) {
- }
-
- }
-
- private class MarkerCoordinateAnimatorListener implements ValueAnimator.AnimatorUpdateListener {
-
- private MyLocationBehavior behavior;
- private double fromLat;
- private double fromLng;
- private double toLat;
- private double toLng;
-
- private MarkerCoordinateAnimatorListener(MyLocationBehavior myLocationBehavior, LatLng from, LatLng to) {
- behavior = myLocationBehavior;
- fromLat = from.getLatitude();
- fromLng = from.getLongitude();
- toLat = to.getLatitude();
- toLng = to.getLongitude();
- }
-
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- float frac = animation.getAnimatedFraction();
- double latitude = fromLat + (toLat - fromLat) * frac;
- double longitude = fromLng + (toLng - fromLng) * frac;
- behavior.updateLatLng(latitude, longitude);
- update();
- }
- }
-
- private class MyLocationBehaviorFactory {
-
- MyLocationBehavior getBehavioralModel(@MyLocationTracking.Mode int mode) {
- if (mode == MyLocationTracking.TRACKING_NONE) {
- return new MyLocationShowBehavior();
- } else {
- return new MyLocationTrackingBehavior();
- }
- }
- }
-
- private abstract class MyLocationBehavior {
-
- MyLocationBehavior() {
- if (latLng != null) {
- locationUpdateTimestamp = SystemClock.elapsedRealtime();
- }
- }
-
- void updateLatLng(@NonNull Location newLocation) {
- location = newLocation;
- }
-
- void updateLatLng(double lat, double lon) {
- if (latLng != null) {
- latLng.setLatitude(lat);
- latLng.setLongitude(lon);
- }
- }
-
- void updateAccuracy(@NonNull Location location) {
- if (accuracyAnimator != null && accuracyAnimator.isRunning()) {
- // use current accuracy as a starting point
- accuracy = (Float) accuracyAnimator.getAnimatedValue();
- accuracyAnimator.end();
- }
-
- float newAccuracy = location.getAccuracy() >= accuracyThreshold ? location.getAccuracy() : 0f;
- accuracyAnimator = ValueAnimator.ofFloat(accuracy, newAccuracy);
- accuracyAnimator.setDuration(750);
- accuracyAnimator.start();
- accuracy = newAccuracy;
- }
-
- abstract void invalidate();
- }
-
- private class MyLocationTrackingBehavior extends MyLocationBehavior {
-
- @Override
- void updateLatLng(@NonNull Location location) {
- super.updateLatLng(location);
- if (latLng == null) {
- // first location fix
- latLng = new LatLng(location);
- locationUpdateTimestamp = SystemClock.elapsedRealtime();
- }
-
- // updateLatLng timestamp
- float previousUpdateTimeStamp = locationUpdateTimestamp;
- locationUpdateTimestamp = SystemClock.elapsedRealtime();
-
- // calculate animation duration
- int animationDuration;
- if (previousUpdateTimeStamp == 0) {
- animationDuration = 0;
- } else {
- animationDuration = (int) ((locationUpdateTimestamp - previousUpdateTimeStamp) * 1.1f)
- /*make animation slightly longer*/;
- }
-
- // calculate interpolated location
- latLng = new LatLng(location);
- CameraPosition.Builder builder = new CameraPosition.Builder().target(latLng);
-
- // add direction
- if (myBearingTrackingMode == MyBearingTracking.GPS) {
- if (location.hasBearing()) {
- builder.bearing(location.getBearing());
- }
- setCompass(0, COMPASS_UPDATE_RATE_MS);
- }
-
- if (myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING) {
- builder.bearing(0);
- if (location.hasBearing()) {
- setCompass(location.getBearing(), COMPASS_UPDATE_RATE_MS);
- }
- }
-
- // accuracy
- updateAccuracy(location);
-
- if (locationChangeAnimationEnabled && animationDuration > 0) {
- // ease to new camera position with a linear interpolator
- mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), animationDuration, false, null,
- true);
- } else {
- mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(builder.build()));
- }
- }
-
- @Override
- void invalidate() {
- int[] mapPadding = mapboxMap.getPadding();
- float x = (getWidth() + mapPadding[0] - mapPadding[2]) / 2 + contentPaddingX;
- float y = (getHeight() - mapPadding[3] + mapPadding[1]) / 2 + contentPaddingY;
- screenLocation = new PointF(x, y);
- MyLocationView.this.invalidate();
- }
- }
-
- private class MyLocationShowBehavior extends MyLocationBehavior {
-
- @Override
- void updateLatLng(@NonNull final Location location) {
- super.updateLatLng(location);
- if (latLng == null) {
- // first location update
- latLng = new LatLng(location);
- locationUpdateTimestamp = SystemClock.elapsedRealtime();
- }
-
- // update LatLng location
- LatLng newLocation = new LatLng(location);
-
- // update LatLng accuracy
- updateAccuracy(location);
-
- // calculate updateLatLng time + add some extra offset to improve animation
- long previousUpdateTimeStamp = locationUpdateTimestamp;
- locationUpdateTimestamp = SystemClock.elapsedRealtime();
- long locationUpdateDuration = (long) ((locationUpdateTimestamp - previousUpdateTimeStamp) * 1.2f);
-
- // animate changes
- if (locationChangeAnimator != null) {
- locationChangeAnimator.end();
- locationChangeAnimator = null;
- }
-
- locationChangeAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
- if (locationChangeAnimationEnabled) {
- locationChangeAnimator.setDuration(locationUpdateDuration);
- } else {
- locationChangeAnimator.setDuration(0);
- }
- locationChangeAnimator.addUpdateListener(new MarkerCoordinateAnimatorListener(this,
- latLng, newLocation
- ));
- locationChangeAnimator.start();
- latLng = newLocation;
- }
-
- @Override
- void invalidate() {
- if (latLng != null) {
- screenLocation = projection.toScreenLocation(latLng);
- }
- MyLocationView.this.invalidate();
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java
deleted file mode 100644
index ec7c53e1d0..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java
+++ /dev/null
@@ -1,389 +0,0 @@
-package com.mapbox.mapboxsdk.maps.widgets;
-
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.support.annotation.ColorInt;
-import android.support.annotation.IntRange;
-import android.support.annotation.NonNull;
-
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.constants.MyLocationTracking;
-import com.mapbox.mapboxsdk.maps.FocalPointChangeListener;
-import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
-import com.mapbox.mapboxsdk.maps.Projection;
-import com.mapbox.mapboxsdk.utils.BitmapUtils;
-
-/**
- * Settings to configure the visual appearance of the MyLocationView.
- *
- * @deprecated use location layer plugin from
- * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead.
- */
-@Deprecated
-public class MyLocationViewSettings {
-
- private Projection projection;
- private MyLocationView myLocationView;
- private FocalPointChangeListener focalPointChangeListener;
-
- //
- // State
- //
-
- private boolean enabled;
-
- //
- // Foreground
- //
-
- private Drawable foregroundDrawable;
- private Drawable foregroundBearingDrawable;
-
- @ColorInt
- private int foregroundTintColor;
-
- //
- // Background
- //
-
- private Drawable backgroundDrawable;
- private int[] backgroundOffset = new int[4];
-
- @ColorInt
- private int backgroundTintColor;
-
- //
- // Accuracy
- //
-
- private int accuracyAlpha;
- private float accuracyThreshold = 0f;
-
- @ColorInt
- private int accuracyTintColor;
-
- //
- // Padding
- //
-
- private int[] padding = new int[4];
-
- /**
- * Creates an instance of MyLocationViewSettings
- * <p>
- *
- * @param myLocationView the MyLocationView to apply the settings to
- * @param projection the MapView projection
- * @param focalPointChangedListener the interface to be invoked when focal points changes
- * @see MyLocationView
- */
- public MyLocationViewSettings(MyLocationView myLocationView, Projection projection, FocalPointChangeListener
- focalPointChangedListener) {
- this.myLocationView = myLocationView;
- this.projection = projection;
- this.focalPointChangeListener = focalPointChangedListener;
- }
-
- /**
- * Initialise this with MapboxMapOptions.
- *
- * @param options the options to initialise this class from
- */
- public void initialise(@NonNull MapboxMapOptions options) {
- CameraPosition position = options.getCamera();
- if (position != null && !position.equals(CameraPosition.DEFAULT)) {
- setTilt(position.tilt);
- }
- setForegroundDrawable(options.getMyLocationForegroundDrawable(), options.getMyLocationForegroundBearingDrawable());
- setForegroundTintColor(options.getMyLocationForegroundTintColor());
- setBackgroundDrawable(options.getMyLocationBackgroundDrawable(), options.getMyLocationBackgroundPadding());
- setBackgroundTintColor(options.getMyLocationBackgroundTintColor());
- setAccuracyAlpha(options.getMyLocationAccuracyAlpha());
- setAccuracyTintColor(options.getMyLocationAccuracyTintColor());
- setAccuracyThreshold(options.getMyLocationAccuracyThreshold());
- }
-
- public void onSaveInstanceState(Bundle outState) {
- outState.putBoolean(MapboxConstants.STATE_LOCATION_VIEW_ENABLED, isEnabled());
- outState.putByteArray(
- MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_DRAWABLE,
- BitmapUtils.getByteArrayFromDrawable(getForegroundDrawable())
- );
- outState.putByteArray(
- MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_BEARING_DRAWABLE,
- BitmapUtils.getByteArrayFromDrawable(getForegroundBearingDrawable())
- );
- outState.putInt(MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_TINT_COLOR, getForegroundTintColor());
- outState.putByteArray(
- MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_DRAWABLE,
- BitmapUtils.getByteArrayFromDrawable(getBackgroundDrawable())
- );
- outState.putIntArray(MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_OFFSET, getBackgroundOffset());
- outState.putInt(MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_TINT_COLOR, getBackgroundTintColor());
- outState.putInt(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_ALPHA, getAccuracyAlpha());
- outState.putInt(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_TINT_COLOR, getAccuracyTintColor());
- outState.putFloat(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_THRESHOLD, getAccuracyThreshold());
- outState.putIntArray(MapboxConstants.STATE_LOCATION_VIEW_PADDING, getPadding());
- }
-
- public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
- setEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_LOCATION_VIEW_ENABLED));
- setForegroundDrawable(
- BitmapUtils.getDrawableFromByteArray(
- myLocationView.getContext(),
- savedInstanceState.getByteArray(MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_DRAWABLE)
- ),
- BitmapUtils.getDrawableFromByteArray(
- myLocationView.getContext(),
- savedInstanceState.getByteArray(MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_BEARING_DRAWABLE)
- )
- );
- setForegroundTintColor(savedInstanceState.getInt(MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_TINT_COLOR));
- setBackgroundDrawable(
- BitmapUtils.getDrawableFromByteArray(
- myLocationView.getContext(),
- savedInstanceState.getByteArray(MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_DRAWABLE)
- ),
- savedInstanceState.getIntArray(MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_OFFSET)
- );
- setBackgroundTintColor(savedInstanceState.getInt(MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_TINT_COLOR));
- setAccuracyAlpha(savedInstanceState.getInt(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_ALPHA));
- setAccuracyTintColor(savedInstanceState.getInt(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_TINT_COLOR));
- setAccuracyThreshold(savedInstanceState.getFloat(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_THRESHOLD));
- setPadding(savedInstanceState.getIntArray(MapboxConstants.STATE_LOCATION_VIEW_PADDING));
- }
-
- /**
- * Returns if the MyLocationView is enabled
- *
- * @return true if MyLocationView is enabled,
- */
- public boolean isEnabled() {
- return enabled;
- }
-
- /**
- * Set the enabled state of MyLocationView
- *
- * @param enabled true shows the MyLocationView on the map
- */
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- myLocationView.setEnabled(enabled);
- }
-
- /**
- * Set the foreground drawable of the MyLocationView
- * <p>
- * The foreground drawable is the image visible on screen
- * </p>
- * It's linked with the foreground tint color
- *
- * @param foregroundDrawable the drawable to show as foreground without bearing
- * @param foregroundBearingDrawable the drawable to show as foreground when bearing is enabled
- */
- public void setForegroundDrawable(Drawable foregroundDrawable, Drawable foregroundBearingDrawable) {
- this.foregroundDrawable = foregroundDrawable;
- this.foregroundBearingDrawable = foregroundBearingDrawable;
- myLocationView.setForegroundDrawables(foregroundDrawable, foregroundBearingDrawable);
- myLocationView.setForegroundDrawableTint(foregroundTintColor);
- }
-
- /**
- * Get the foreground drawable when bearing is disabled.
- *
- * @return the drawable used as foreground
- */
- public Drawable getForegroundDrawable() {
- return foregroundDrawable;
- }
-
- /**
- * Get the foreground drawable when bearing is enabled.
- *
- * @return the bearing drawable used as foreground
- */
- public Drawable getForegroundBearingDrawable() {
- return foregroundBearingDrawable;
- }
-
- /**
- * Set the foreground tint color.
- * <p>
- * The color will tint both the foreground and the bearing foreground drawable.
- * </p>
- *
- * @param foregroundTintColor the color to tint the foreground drawable or -1 (undefined color) to remove the
- * existing foreground tint color
- */
- public void setForegroundTintColor(@ColorInt int foregroundTintColor) {
- this.foregroundTintColor = foregroundTintColor;
- myLocationView.setForegroundDrawableTint(foregroundTintColor);
- }
-
- /**
- * Get the foreground tint color.
- *
- * @return the foreground tint color
- */
- public int getForegroundTintColor() {
- return foregroundTintColor;
- }
-
- /**
- * Set the background drawable of MyLocationView
- * <p>
- * Padding can be added to provide an offset to the background
- * </p>
- * It's linked with the background tint color
- *
- * @param backgroundDrawable the drawable to show as background
- * @param padding the padding added to the background
- */
- public void setBackgroundDrawable(Drawable backgroundDrawable, int[] padding) {
- this.backgroundDrawable = backgroundDrawable;
- this.backgroundOffset = padding;
- if (padding != null && padding.length == 4) {
- myLocationView.setShadowDrawable(backgroundDrawable, padding[0], padding[1], padding[2], padding[3]);
- } else {
- myLocationView.setShadowDrawable(backgroundDrawable);
- }
- myLocationView.setShadowDrawableTint(backgroundTintColor);
- }
-
- /**
- * Get the background drawable of MyLocationView.
- *
- * @return the drawable used as background
- */
- public Drawable getBackgroundDrawable() {
- return backgroundDrawable;
- }
-
- /**
- * Set the background tint color.
- *
- * @param backgroundTintColor the color to tint the background drawable or -1 (undefined color) to remove the
- * existing background tint color
- */
- public void setBackgroundTintColor(@ColorInt int backgroundTintColor) {
- this.backgroundTintColor = backgroundTintColor;
- myLocationView.setShadowDrawableTint(backgroundTintColor);
- }
-
- /**
- * Get the background tint color.
- *
- * @return the background tint color
- */
- public int getBackgroundTintColor() {
- return backgroundTintColor;
- }
-
- /**
- * Get the background offset.
- *
- * @return the background offset
- */
- public int[] getBackgroundOffset() {
- return backgroundOffset;
- }
-
- /**
- * Set the MyLocationView padding.
- *
- * @param left the padding left of MyLocationView
- * @param top the padding top of MyLocationView
- * @param right the padding right of MyLocationView
- * @param bottom the padding bottom of MyLocaionView
- */
- public void setPadding(int left, int top, int right, int bottom) {
- padding = new int[] {left, top, right, bottom};
- setPadding(padding);
- }
-
- private void setPadding(int[] padding) {
- myLocationView.setContentPadding(padding);
- projection.invalidateContentPadding(padding);
- invalidateFocalPointForTracking(myLocationView);
- }
-
- /**
- * Get the MyLocationView padding.
- *
- * @return an array describing the padding in a LTRB manner
- */
- public int[] getPadding() {
- return padding;
- }
-
- /**
- * Get the alpha value of the accuracy circle of MyLocationView
- *
- * @return the alpha value
- */
- public int getAccuracyAlpha() {
- return accuracyAlpha;
- }
-
- /**
- * Set the alpha value of the accuracy circle of MyLocationView
- *
- * @param accuracyAlpha the alpha value to set
- */
- public void setAccuracyAlpha(@IntRange(from = 0, to = 255) int accuracyAlpha) {
- this.accuracyAlpha = accuracyAlpha;
- myLocationView.setAccuracyAlpha(accuracyAlpha);
- }
-
- /**
- * Get the accuracy tint color of MyLocationView.
- *
- * @return the tint color used for accuracy
- */
- public int getAccuracyTintColor() {
- return accuracyTintColor;
- }
-
- /**
- * Set the accuracy tint color of MyLocationView.
- *
- * @param accuracyTintColor the accuracy tint color
- */
- public void setAccuracyTintColor(@ColorInt int accuracyTintColor) {
- this.accuracyTintColor = accuracyTintColor;
- myLocationView.setAccuracyTint(accuracyTintColor);
- }
-
- /**
- * Returns current accuracy threshold value (in meters).
- *
- * @return Value of accuracy threshold (in meters), below which circle won't be displayed
- */
- public float getAccuracyThreshold() {
- return accuracyThreshold;
- }
-
- /**
- * Set accuracy circle threshold. Circle won't be displayed if accuracy is below set value.
- *
- * @param accuracyThreshold Value of accuracy (in meters), below which circle won't be displayed
- */
- public void setAccuracyThreshold(float accuracyThreshold) {
- this.accuracyThreshold = accuracyThreshold;
- myLocationView.setAccuracyThreshold(accuracyThreshold);
- }
-
- public void setTilt(double tilt) {
- myLocationView.setTilt(tilt);
- }
-
- private void invalidateFocalPointForTracking(MyLocationView myLocationView) {
- if (!(myLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE)) {
- focalPointChangeListener.onFocalPointChanged(myLocationView.getCenter());
- } else {
- focalPointChangeListener.onFocalPointChanged(null);
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java
index 007880acd1..08d39d6b3b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java
@@ -1,11 +1,8 @@
package com.mapbox.mapboxsdk.utils;
import android.content.Context;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.support.v4.content.ContextCompat;
-import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
@@ -45,25 +42,6 @@ public class MapFragmentUtils {
// load default options
options = MapboxMapOptions.createFromAttributes(context, null);
}
- options = loadDefaultMyLocationViewDrawables(context, options);
- return options;
- }
-
- private static MapboxMapOptions loadDefaultMyLocationViewDrawables(Context context, MapboxMapOptions options) {
- Drawable foregroundDrawable = options.getMyLocationForegroundDrawable();
- Drawable foregroundBearingDrawable = options.getMyLocationForegroundBearingDrawable();
- if (foregroundDrawable == null || foregroundBearingDrawable == null) {
- if (foregroundDrawable == null) {
- foregroundDrawable = ContextCompat.getDrawable(context, R.drawable.mapbox_mylocation_icon_default);
- }
- if (foregroundBearingDrawable == null) {
- foregroundBearingDrawable = ContextCompat.getDrawable(context, R.drawable.mapbox_mylocation_icon_bearing);
- }
- options.myLocationForegroundDrawables(foregroundDrawable, foregroundBearingDrawable);
- }
- if (options.getMyLocationBackgroundDrawable() == null) {
- options.myLocationBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.mapbox_mylocation_bg_shape));
- }
return options;
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml
index 29ff49f47e..8dd4a858df 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml
@@ -8,12 +8,6 @@
android:background="@android:color/transparent"
android:contentDescription="@null"/>
- <com.mapbox.mapboxsdk.maps.widgets.MyLocationView
- android:id="@+id/userLocationView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:contentDescription="@string/mapbox_myLocationViewContentDescription"/>
-
<com.mapbox.mapboxsdk.maps.widgets.CompassView
android:id="@+id/compassView"
android:layout_width="wrap_content"
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 d9e3ae427d..6ee5c157b9 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,6 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException;
-import com.mapbox.android.core.location.LocationEngine;
import org.junit.Before;
import org.junit.Test;
@@ -25,13 +24,11 @@ public class MapboxTest {
private Context context;
private Context appContext;
- private LocationEngine locationSource;
@Before
public void before() {
context = mock(Context.class);
appContext = mock(Context.class);
- locationSource = mock(LocationEngine.class);
when(context.getApplicationContext()).thenReturn(appContext);
}
@@ -83,7 +80,7 @@ public class MapboxTest {
}
private void injectMapboxSingleton(String accessToken) {
- Mapbox mapbox = new Mapbox(appContext, accessToken, locationSource);
+ Mapbox mapbox = new Mapbox(appContext, accessToken);
try {
Field field = Mapbox.class.getDeclaredField("INSTANCE");
field.setAccessible(true);
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java
index 65bdff41ab..9dd0ca9285 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java
@@ -119,13 +119,6 @@ public class MapboxMapOptionsTest {
}
@Test
- public void testLocationEnabled() {
- assertFalse(new MapboxMapOptions().getLocationEnabled());
- assertTrue(new MapboxMapOptions().locationEnabled(true).getLocationEnabled());
- assertFalse(new MapboxMapOptions().locationEnabled(false).getLocationEnabled());
- }
-
- @Test
public void testTiltGesturesEnabled() {
assertTrue(new MapboxMapOptions().getTiltGesturesEnabled());
assertTrue(new MapboxMapOptions().tiltGesturesEnabled(true).getTiltGesturesEnabled());
@@ -176,18 +169,6 @@ public class MapboxMapOptionsTest {
}
@Test
- public void testMyLocationForegroundTint() {
- assertEquals(Color.BLUE, new MapboxMapOptions()
- .myLocationForegroundTintColor(Color.BLUE).getMyLocationForegroundTintColor());
- }
-
- @Test
- public void testMyLocationBackgroundTint() {
- assertEquals(Color.BLUE, new MapboxMapOptions()
- .myLocationBackgroundTintColor(Color.BLUE).getMyLocationBackgroundTintColor());
- }
-
- @Test
public void testPrefetchesTiles() {
// Default value
assertTrue(new MapboxMapOptions().getPrefetchesTiles());
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
index d61947f00e..9a323a1d75 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.maps;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
import org.junit.After;
import org.junit.Before;
@@ -20,8 +19,6 @@ public class MapboxMapTest {
mapboxMap = new MapboxMap(mock(NativeMapView.class),
mock(Transform.class),
mock(UiSettings.class),
- mock(TrackingSettings.class),
- mock(MyLocationViewSettings.class),
mock(Projection.class),
mock(MapboxMap.OnGesturesManagerInteractionListener.class),
mock(AnnotationManager.class),
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java
deleted file mode 100644
index de5f364a5b..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.Manifest;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.graphics.PointF;
-
-import com.mapbox.mapboxsdk.constants.MyLocationTracking;
-import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.atLeast;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class TrackingSettingsTest {
-
- @InjectMocks
- MyLocationView myLocationView = mock(MyLocationView.class);
-
- @InjectMocks
- UiSettings uiSettings = mock(UiSettings.class);
-
- @InjectMocks
- FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class);
-
- @InjectMocks
- TrackingSettings.CameraZoomInvalidator zoomInvalidator = mock(TrackingSettings.CameraZoomInvalidator.class);
-
- private TrackingSettings trackingSettings;
-
- @Before
- public void beforeTest() {
- trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointChangeListener, zoomInvalidator);
- }
-
- @Test
- public void testSanity() {
- assertNotNull("trackingsettings should not be null", trackingSettings);
- }
-
- @Test
- public void testDismissTrackingModesOnGesture() {
- trackingSettings.setDismissAllTrackingOnGesture(false);
- assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isAllDismissTrackingOnGesture());
- }
-
- @Test
- public void testValidateGesturesForTrackingModes() {
- trackingSettings.setDismissAllTrackingOnGesture(false);
- trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isAllDismissTrackingOnGesture());
- }
-
- @Test
- public void testMyLocationEnabled() {
- // setup mock context to provide accepted location permission
- Context context = mock(Context.class);
- when(myLocationView.getContext()).thenReturn(context);
- when(context.checkPermission(eq(Manifest.permission.ACCESS_COARSE_LOCATION), anyInt(),
- anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED);
-
- assertFalse("Location should be disabled by default.", trackingSettings.isMyLocationEnabled());
- trackingSettings.setMyLocationEnabled(true);
- assertTrue("Location should be enabled", trackingSettings.isMyLocationEnabled());
- }
-
- @Test
- public void testCameraZoomTo2forTracking() {
- trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- verify(zoomInvalidator, atLeast(1)).zoomTo(2.0);
- }
-
- @Test
- public void testFocalPointChangeForTracking() {
- final float centerX = 32.3f;
- final float centerY = 46.3f;
- final PointF pointF = new PointF(centerX, centerY);
- when(myLocationView.getCenter()).thenReturn(pointF);
-
- trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- verify(focalPointChangeListener, atLeast(1)).onFocalPointChanged(pointF);
- }
-
- @Test
- public void testFocalPointChangeForNonTracking() {
- trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
- verify(focalPointChangeListener, atLeast(1)).onFocalPointChanged(null);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java
deleted file mode 100644
index c9ce19dc85..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package com.mapbox.mapboxsdk.maps.widgets;
-
-import android.graphics.Color;
-import android.graphics.drawable.Drawable;
-
-import com.mapbox.mapboxsdk.maps.FocalPointChangeListener;
-import com.mapbox.mapboxsdk.maps.Projection;
-import com.mapbox.mapboxsdk.maps.TrackingSettings;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-
-import java.util.Arrays;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class MyLocationViewSettingsTest {
-
- @InjectMocks
- Projection projection = mock(Projection.class);
-
- @InjectMocks
- MyLocationView myLocationView = mock(MyLocationView.class);
-
- @InjectMocks
- TrackingSettings trackingSettings = mock(TrackingSettings.class);
-
- @InjectMocks
- FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class);
-
- private MyLocationViewSettings locationViewSettings;
-
- @Before
- public void beforeTest() {
- locationViewSettings = new MyLocationViewSettings(myLocationView, projection, focalPointChangeListener);
- }
-
- @Test
- public void testSanity() {
- assertNotNull("should not be null", locationViewSettings);
- }
-
- @Test
- public void testForegroundDrawables() {
- Drawable foregroundDrawable = mock(Drawable.class);
- Drawable foregroundBearingDrawable = mock(Drawable.class);
- Drawable.ConstantState constantState = mock(Drawable.ConstantState.class);
- when(foregroundDrawable.getConstantState()).thenReturn(constantState);
- when(constantState.newDrawable()).thenReturn(foregroundDrawable);
- locationViewSettings.setForegroundDrawable(foregroundDrawable, foregroundBearingDrawable);
- assertEquals("foreground should match", foregroundDrawable, locationViewSettings.getForegroundDrawable());
- assertEquals("foreground bearing should match", foregroundBearingDrawable,
- locationViewSettings.getForegroundBearingDrawable());
- }
-
- @Test
- public void testBackgroundDrawable() {
- Drawable backgroundDrawable = mock(Drawable.class);
- int[] offset = new int[] {1, 2, 3, 4};
- locationViewSettings.setBackgroundDrawable(backgroundDrawable, offset);
- assertEquals("foreground should match", backgroundDrawable, locationViewSettings.getBackgroundDrawable());
- assertTrue("offsets should match", Arrays.equals(offset, locationViewSettings.getBackgroundOffset()));
- }
-
- @Test
- public void testForegroundTint() {
- int color = Color.RED;
- locationViewSettings.setForegroundTintColor(Color.RED);
- assertEquals("color should match", color, locationViewSettings.getForegroundTintColor());
- }
-
- @Test
- public void testForegroundTransparentTint() {
- int color = Color.TRANSPARENT;
- locationViewSettings.setForegroundTintColor(Color.TRANSPARENT);
- assertEquals("color should match", color, locationViewSettings.getForegroundTintColor());
- }
-
- @Test
- public void testBackgroundTint() {
- int color = Color.RED;
- locationViewSettings.setBackgroundTintColor(Color.RED);
- assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor());
- }
-
- @Test
- public void testBackgroundTransparentTint() {
- int color = Color.TRANSPARENT;
- locationViewSettings.setBackgroundTintColor(Color.TRANSPARENT);
- assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor());
- }
-
- @Test
- public void testEnabled() {
- assertFalse("initial state should be false", locationViewSettings.isEnabled());
- locationViewSettings.setEnabled(true);
- assertTrue("state should be true", locationViewSettings.isEnabled());
- }
-}
-
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
index b4bc118129..38fd8491a8 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
@@ -162,16 +162,6 @@ public class MapboxMapTest extends BaseActivityTest {
}
//
- // TrackingSettings
- //
-
- @Test
- public void testTrackingSettings() {
- validateTestSetup();
- assertNotNull("TrackingSettings should not be null", mapboxMap.getTrackingSettings());
- }
-
- //
// InfoWindow
//
@@ -204,30 +194,6 @@ public class MapboxMapTest extends BaseActivityTest {
}
//
- // Location
- //
-
- @Test
- @Ignore /* disabled due to enabling permissions during test #7177 */
- public void testMyLocationEnabled() {
- validateTestSetup();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
- mapboxMap.setMyLocationEnabled(true);
- assertTrue("MyLocationEnabled should be true", mapboxMap.isMyLocationEnabled());
- }));
- }
-
- @Test
- @Ignore /* can't create handler inside thread that not called Looper.prepare() */
- public void testMyLocationDisabled() {
- validateTestSetup();
- onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
- mapboxMap.setMyLocationEnabled(false);
- assertFalse("MyLocationEnabled should be false", mapboxMap.isMyLocationEnabled());
- }));
- }
-
- //
// setters/getters interfaces
//
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java
deleted file mode 100644
index cf58ba50a6..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.maps.widgets;
-
-import android.annotation.SuppressLint;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.support.test.espresso.UiController;
-import android.support.test.espresso.ViewAction;
-import android.view.View;
-
-import com.mapbox.mapboxsdk.Mapbox;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.constants.MyBearingTracking;
-import com.mapbox.mapboxsdk.constants.MyLocationTracking;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
-import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
-
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
-import org.hamcrest.TypeSafeMatcher;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import static android.support.test.espresso.Espresso.onView;
-import static android.support.test.espresso.assertion.ViewAssertions.matches;
-import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
-import static android.support.test.espresso.matcher.ViewMatchers.withId;
-import static org.hamcrest.Matchers.not;
-
-/**
- * Experimental MyLocationView tests,
- * requires application to be granted with runtime location permissions.
- * <p>
- * Tests for enabling and disabling the {@link MyLocationView}.
- * Tests for enabling tracking modes and if the correct default images are shown when toggling
- * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setMyLocationTrackingMode(int)} &
- * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setMyBearingTrackingMode(int)}.
- * </p>
- */
-public class MyLocationViewTest extends BaseActivityTest {
-
- @Override
- protected Class getActivityClass() {
- return EspressoTestActivity.class;
- }
-
- @Test
- @Ignore // requires runtime permissions, disabled for CI
- public void testEnabled() {
- validateTestSetup();
- onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
- onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true));
- onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
- onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, false));
- onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
- }
-
- @Test
- @Ignore
- // requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException:
- // Looped for 5049 iterations over 60 SECONDS.
- public void testTracking() {
- validateTestSetup();
- onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
- onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap));
- onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
- onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap,
- R.drawable.mapbox_mylocation_icon_default, false)));
- onView(withId(R.id.mapView)).perform(new EnableCompassBearingTrackingAction(mapboxMap));
- onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap,
- R.drawable.mapbox_mylocation_icon_bearing, true)));
- }
-
- private class ToggleLocationAction implements ViewAction {
-
- private MapboxMap mapboxMap;
- private boolean isEnabled;
-
- ToggleLocationAction(MapboxMap map, boolean enable) {
- mapboxMap = map;
- isEnabled = enable;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @SuppressLint("MissingPermission")
- @Override
- public void perform(UiController uiController, View view) {
- if (isEnabled) {
- // move camera above user location
- mapboxMap.moveCamera(
- CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder()
- .target(new LatLng(Mapbox.getLocationEngine().getLastLocation()))
- .build()
- )
- );
- }
-
- // show loction on screen
- mapboxMap.setMyLocationEnabled(isEnabled);
- }
- }
-
- private class EnableLocationTrackingAction implements ViewAction {
-
- private MapboxMap mapboxMap;
-
- EnableLocationTrackingAction(MapboxMap map) {
- mapboxMap = map;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- }
- }
-
- private class EnableCompassBearingTrackingAction implements ViewAction {
-
- private MapboxMap mapboxMap;
-
- EnableCompassBearingTrackingAction(MapboxMap map) {
- mapboxMap = map;
- }
-
- @Override
- public Matcher<View> getConstraints() {
- return isDisplayed();
- }
-
- @Override
- public String getDescription() {
- return getClass().getSimpleName();
- }
-
- @Override
- public void perform(UiController uiController, View view) {
- mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS);
- // wait for next compass update cycle
- uiController.loopMainThreadForAtLeast(500);
- }
- }
-
- private class DrawableMatcher extends TypeSafeMatcher<View> {
-
- private MapboxMap mapboxMap;
- private boolean isBearingDrawable;
- private final int expectedId;
-
- DrawableMatcher(MapboxMap mapboxMap, int expectedId, boolean isBearingDrawable) {
- super(MyLocationView.class);
- this.mapboxMap = mapboxMap;
- this.expectedId = expectedId;
- this.isBearingDrawable = isBearingDrawable;
- }
-
- @Override
- protected boolean matchesSafely(View target) {
- Drawable currentDrawable = isBearingDrawable
- ? mapboxMap.getMyLocationViewSettings().getForegroundBearingDrawable() :
- mapboxMap.getMyLocationViewSettings().getForegroundDrawable();
-
- Resources resources = target.getContext().getResources();
- Drawable expectedDrawable = resources.getDrawable(expectedId);
- return areDrawablesIdentical(currentDrawable, expectedDrawable);
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("trying to match MyLocationView drawable to " + expectedId);
- }
-
- boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) {
- Drawable.ConstantState stateA = drawableA.getConstantState();
- Drawable.ConstantState stateB = drawableB.getConstantState();
- return (stateA != null && stateB != null && stateA.equals(stateB))
- || getBitmap(drawableA).sameAs(getBitmap(drawableB));
- }
-
- Bitmap getBitmap(Drawable drawable) {
- Bitmap result;
- if (drawable instanceof BitmapDrawable) {
- result = ((BitmapDrawable) drawable).getBitmap();
- } else {
- int width = drawable.getIntrinsicWidth();
- int height = drawable.getIntrinsicHeight();
- // Some drawables have no intrinsic width - e.g. solid colours.
- if (width <= 0) {
- width = 1;
- }
- if (height <= 0) {
- height = 1;
- }
-
- result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(result);
- drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
- drawable.draw(canvas);
- }
- return result;
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
index 0b6d2a155d..65d7b34b21 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
@@ -2,7 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapbox.mapboxsdk.testapp">
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
@@ -213,62 +212,6 @@
android:value=".activity.FeatureOverviewActivity"/>
</activity>
<activity
- android:name=".activity.userlocation.MyLocationTrackingModeActivity"
- android:description="@string/description_user_location_tracking"
- android:label="@string/activity_user_tracking_mode"
- android:theme="@style/NoActionBar">
- <meta-data
- android:name="@string/category"
- android:value="@string/category_userlocation"/>
- <meta-data
- android:name="android.support.PARENT_ACTIVITY"
- android:value=".activity.FeatureOverviewActivity"/>
- </activity>
- <activity
- android:name=".activity.userlocation.MyLocationDrawableActivity"
- android:description="@string/description_user_location_customization"
- android:label="@string/activity_user_tracking_customization">
- <meta-data
- android:name="@string/category"
- android:value="@string/category_userlocation"/>
- <meta-data
- android:name="android.support.PARENT_ACTIVITY"
- android:value=".activity.FeatureOverviewActivity"/>
- </activity>
- <activity
- android:name=".activity.userlocation.MyLocationTintActivity"
- android:description="@string/description_user_location_dot_color"
- android:label="@string/activity_user_dot_color">
- <meta-data
- android:name="@string/category"
- android:value="@string/category_userlocation"/>
- <meta-data
- android:name="android.support.PARENT_ACTIVITY"
- android:value=".activity.FeatureOverviewActivity"/>
- </activity>
- <activity
- android:name=".activity.userlocation.MyLocationToggleActivity"
- android:description="@string/description_user_location_toggle"
- android:label="@string/activity_user_location_toggle">
- <meta-data
- android:name="@string/category"
- android:value="@string/category_userlocation"/>
- <meta-data
- android:name="android.support.PARENT_ACTIVITY"
- android:value=".activity.FeatureOverviewActivity"/>
- </activity>
- <activity
- android:name=".activity.userlocation.CustomLocationEngineActivity"
- android:description="@string/description_custom_location_engine"
- android:label="@string/activity_custom_location_engine">
- <meta-data
- android:name="@string/category"
- android:value="@string/category_userlocation"/>
- <meta-data
- android:name="android.support.PARENT_ACTIVITY"
- android:value=".activity.FeatureOverviewActivity"/>
- </activity>
- <activity
android:name=".activity.annotation.PolygonActivity"
android:description="@string/description_polygon"
android:label="@string/activity_polygon">
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 0ee1f78e0e..c8b15593ec 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
@@ -7,23 +7,17 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.AsyncTask;
-import android.os.Build;
import android.os.Bundle;
-import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
-import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.adapter.FeatureAdapter;
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.android.core.permissions.PermissionsListener;
-import com.mapbox.android.core.permissions.PermissionsManager;
import java.util.ArrayList;
import java.util.Collections;
@@ -39,23 +33,19 @@ import timber.log.Timber;
* It uses tags as category and description to order the different entries.
* </p>
*/
-public class FeatureOverviewActivity extends AppCompatActivity implements PermissionsListener {
+public class FeatureOverviewActivity extends AppCompatActivity {
private static final String KEY_STATE_FEATURES = "featureList";
- private PermissionsManager permissionsManager;
private RecyclerView recyclerView;
private FeatureSectionAdapter sectionAdapter;
private List<Feature> features;
- private int locationActivityInList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_feature_overview);
- permissionsManager = new PermissionsManager(this);
-
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener());
@@ -65,11 +55,6 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
if (!sectionAdapter.isSectionHeaderPosition(position)) {
int itemPosition = sectionAdapter.getConvertedPosition(position);
Feature feature = features.get(itemPosition);
- if (feature.isRequiresLocationPermission()) {
- if (requestLocationPermission(itemPosition)) {
- return;
- }
- }
startFeature(feature);
}
});
@@ -118,45 +103,6 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
startActivity(intent);
}
- private boolean requestLocationPermission(final int positionInList) {
- if (isRuntimePermissionsRequired()) {
- locationActivityInList = positionInList;
- permissionsManager.requestLocationPermissions(this);
- return true;
- }
- return false;
- }
-
- @Override
- public void onExplanationNeeded(List<String> list) {
- Snackbar.make(
- findViewById(android.R.id.content),
- TextUtils.join("", list.toArray()),
- Snackbar.LENGTH_SHORT).show();
- }
-
- @Override
- public void onPermissionResult(boolean isPermissionGranted) {
- if (isPermissionGranted) {
- startFeature(features.get(locationActivityInList));
- } else {
- Snackbar.make(
- findViewById(android.R.id.content),
- "Can't open without accepting the location permission.",
- Snackbar.LENGTH_SHORT).show();
- }
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults);
- }
-
- private boolean isRuntimePermissionsRequired() {
- return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
- }
-
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
@@ -178,8 +124,7 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
String label = getString(info.labelRes);
String description = resolveString(info.descriptionRes);
String category = resolveMetaData(info.metaData, metaDataKey);
- boolean requiresLocationPermission = requiresLocationPermission(label, category);
- features.add(new Feature(info.name, label, description, category, requiresLocationPermission));
+ features.add(new Feature(info.name, label, description, category));
}
}
@@ -213,24 +158,6 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
}
}
- private boolean requiresLocationPermission(String name, String category) {
- final Resources resources = getResources();
-
- List<String> requiresPermissionCategories = new ArrayList<String>() {
- {
- add(resources.getString(R.string.category_userlocation));
- }
- };
-
- List<String> requiresPermissionActivities = new ArrayList<String>() {
- {
- add(resources.getString(R.string.activity_double_map));
- }
- };
-
- return requiresPermissionCategories.contains(category) || requiresPermissionActivities.contains(name);
- }
-
@Override
protected void onPostExecute(List<Feature> features) {
super.onPostExecute(features);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java
index 3b58843e13..a165d9ab9d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java
@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.testapp.activity.maplayout;
import android.content.Context;
-import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -151,10 +150,7 @@ public class BottomSheetActivity extends AppCompatActivity {
@Override
public void onMapReady(MapboxMap mapboxMap) {
- Location location = mapboxMap.getMyLocation();
- if (location != null) {
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15));
- }
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.760545, -122.436055), 15));
}
@Override
@@ -207,7 +203,6 @@ public class BottomSheetActivity extends AppCompatActivity {
public static BottomSheetFragment newInstance() {
BottomSheetFragment mapFragment = new BottomSheetFragment();
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
- mapboxMapOptions.locationEnabled(true);
mapboxMapOptions.renderSurfaceOnTop(true);
mapboxMapOptions.styleUrl(Style.LIGHT);
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
@@ -230,10 +225,7 @@ public class BottomSheetActivity extends AppCompatActivity {
@Override
public void onMapReady(MapboxMap mapboxMap) {
- Location location = mapboxMap.getMyLocation();
- if (location != null) {
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15));
- }
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.760545, -122.436055), 15));
}
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java
index 75b2378ef7..b4dde8d2cd 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java
@@ -11,11 +11,9 @@ import android.view.View;
import android.view.ViewGroup;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.TrackingSettings;
import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.mapboxsdk.testapp.R;
@@ -50,14 +48,6 @@ public class DoubleMapActivity extends AppCompatActivity {
mapboxMap = map;
mapboxMap.setStyleUrl(Style.DARK);
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(18));
- try {
- mapboxMap.setMyLocationEnabled(true);
- TrackingSettings settings = mapboxMap.getTrackingSettings();
- settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- } catch (SecurityException securityException) {
- // permission is handled in MainActivity
- finish();
- }
}
/**
@@ -106,15 +96,6 @@ public class DoubleMapActivity extends AppCompatActivity {
uiSettings.setAttributionEnabled(false);
uiSettings.setLogoEnabled(false);
- try {
- mapboxMap.setMyLocationEnabled(true);
- TrackingSettings settings = mapboxMap.getTrackingSettings();
- settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- } catch (SecurityException securityException) {
- // permission is handled in MainActivity
- getActivity().finish();
- }
-
mapboxMap.setOnMapClickListener(point -> {
// test if we can open 2 activities after each other
startActivity(new Intent(mapViewMini.getContext(), DoubleMapActivity.class));
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java
index 9a6079b157..d547866239 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java
@@ -8,18 +8,13 @@ import android.view.MenuItem;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.TrackingSettings;
import com.mapbox.mapboxsdk.testapp.R;
/**
* Test activity showcasing using the map padding API.
- * <p>
- * This activity tests for correct padding around a marker (Bangalore) and correct padding around MyLocationView.
- * </p>
*/
public class MapPaddingActivity extends AppCompatActivity {
@@ -96,24 +91,7 @@ public class MapPaddingActivity extends AppCompatActivity {
return true;
}
- private void toggleGps(boolean enable) {
- try {
- // Enable user location
- mapboxMap.setMyLocationEnabled(enable);
-
- TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
- trackingSettings.setDismissLocationTrackingOnGesture(false);
- trackingSettings.setMyLocationTrackingMode(
- enable ? MyLocationTracking.TRACKING_FOLLOW : MyLocationTracking.TRACKING_NONE);
- } catch (SecurityException securityException) {
- // permission not granted is handled in FeatureOverviewActivity
- finish();
- }
- }
-
private void moveToBangalore() {
- toggleGps(false);
-
LatLng bangalore = new LatLng(12.9810816, 77.6368034);
CameraPosition cameraPosition = new CameraPosition.Builder()
.zoom(16)
@@ -129,11 +107,6 @@ public class MapPaddingActivity extends AppCompatActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.action_user_tracking:
- if (mapboxMap != null) {
- toggleGps(true);
- }
- return true;
case R.id.action_bangalore:
if (mapboxMap != null) {
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
deleted file mode 100644
index eec26cc9a7..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.activity.userlocation;
-
-import android.os.Build;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.UiThread;
-import android.support.design.widget.Snackbar;
-import android.support.v7.app.AppCompatActivity;
-import android.text.TextUtils;
-
-import com.mapbox.android.core.permissions.PermissionsListener;
-import com.mapbox.android.core.permissions.PermissionsManager;
-
-import java.util.List;
-
-/**
- * Base class for location aware activities.
- */
-public abstract class BaseLocationActivity extends AppCompatActivity implements PermissionsListener {
-
- private PermissionsManager permissionsManager;
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- permissionsManager = new PermissionsManager(this);
- }
-
- @UiThread
- protected final void toggleGps(boolean enableGps) {
- if (enableGps) {
- if (!isRuntimePermissionsRequired()) {
- permissionsManager.requestLocationPermissions(this);
- } else {
- enableLocation(true);
- }
- } else {
- enableLocation(false);
- }
- }
-
- @Override
- public void onExplanationNeeded(List<String> list) {
- Snackbar.make(
- findViewById(android.R.id.content),
- TextUtils.join("", list.toArray()),
- Snackbar.LENGTH_SHORT).show();
- }
-
- @Override
- public void onPermissionResult(boolean isPermissionAccepted) {
- enableLocation(isPermissionAccepted);
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults);
- }
-
- private boolean isRuntimePermissionsRequired() {
- return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
- }
-
- protected abstract void enableLocation(boolean enabled);
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java
deleted file mode 100644
index ff2559089c..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.activity.userlocation;
-
-import android.os.Bundle;
-import android.support.design.widget.FloatingActionButton;
-import android.view.Menu;
-import android.view.MenuItem;
-
-import com.mapbox.mapboxsdk.Mapbox;
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.testapp.R;
-
-/**
- * Test activity showcasing using a custom location engine.
- */
-public class CustomLocationEngineActivity extends BaseLocationActivity {
-
- private MapView mapView;
- private MapboxMap mapboxMap;
- private FloatingActionButton locationToggleFab;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_custom_location_engine);
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(map -> {
- mapboxMap = map;
- mapboxMap.setLocationSource(MockLocationEngine.getInstance());
- });
-
- locationToggleFab = (FloatingActionButton) findViewById(R.id.fabLocationToggle);
- locationToggleFab.setOnClickListener(view -> {
- if (mapboxMap != null) {
- enableLocation(!mapboxMap.isMyLocationEnabled());
- }
- });
- }
-
- @Override
- protected void enableLocation(boolean enabled) {
- mapboxMap.setMyLocationEnabled(enabled);
- if (enabled) {
- locationToggleFab.setImageResource(R.drawable.ic_location_disabled);
- } else {
- locationToggleFab.setImageResource(R.drawable.ic_my_location);
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_location_engine, menu);
- return super.onCreateOptionsMenu(menu);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (mapboxMap != null) {
- int itemId = item.getItemId();
- if (itemId == R.id.action_id_location_source_lost) {
- mapboxMap.setLocationSource(Mapbox.getLocationEngine());
- return true;
- } else if (itemId == R.id.action_id_location_source_mock) {
- mapboxMap.setLocationSource(MockLocationEngine.getInstance());
- return true;
- } else if (itemId == R.id.action_id_location_source_null) {
- mapboxMap.setLocationSource(null);
- return true;
- }
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-}
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
deleted file mode 100644
index f4fe710de1..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.activity.userlocation;
-
-import android.animation.AnimatorListenerAdapter;
-import android.animation.TypeEvaluator;
-import android.animation.ValueAnimator;
-import android.location.Location;
-
-import com.mapbox.android.core.location.LocationEngine;
-import com.mapbox.android.core.location.LocationEngineListener;
-
-import timber.log.Timber;
-
-/**
- * Sample LocationEngine that provides mocked LOCATIONS simulating GPS updates
- */
-public class MockLocationEngine extends LocationEngine {
- private static MockLocationEngine INSTANCE;
-
- private final LocationAnimator locationAnimator;
- private boolean running;
- private static int counter;
-
- MockLocationEngine(Location start, Location end) {
- locationAnimator = new LocationAnimator(start, end, animation -> {
- for (LocationEngineListener listener : locationListeners) {
- listener.onLocationChanged((Location) animation.getAnimatedValue());
- }
- });
- }
-
- public static synchronized MockLocationEngine getInstance() {
- if (INSTANCE == null) {
- INSTANCE = new MockLocationEngine(
- MockLocationEngine.createLocation(40.416913, -3.703861),
- MockLocationEngine.createLocation(39.461643, -0.368041)
- );
- }
- return INSTANCE;
- }
-
- public static Location createLocation(double latitude, double longitude) {
- Location location = new Location(MockLocationEngine.class.getSimpleName());
- location.setLatitude(latitude);
- location.setLongitude(longitude);
- return location;
- }
-
- @Override
- public void activate() {
- // "Connection" is immediate here
- for (LocationEngineListener listener : locationListeners) {
- listener.onConnected();
- }
- }
-
- @Override
- public void deactivate() {
- }
-
- @Override
- public boolean isConnected() {
- return true; // Always connected
- }
-
- @Override
- public Location getLastLocation() {
- return null;
- }
-
- @Override
- public void requestLocationUpdates() {
- if (!running) {
- locationAnimator.start();
- running = true;
- }
- }
-
- @Override
- public void removeLocationUpdates() {
- if (running) {
- locationAnimator.stop();
- running = false;
- Timber.e("LOC %s", counter);
- }
- }
-
- @Override
- public Type obtainType() {
- return Type.MOCK;
- }
-
- private static class LocationAnimator extends AnimatorListenerAdapter {
-
- private static final long DURATION_ANIMATION = 10000;
- private final ValueAnimator locationAnimator;
- private long animationTime;
-
- LocationAnimator(Location start, Location end, ValueAnimator.AnimatorUpdateListener listener) {
- locationAnimator = ValueAnimator.ofObject(new LocationEvaluator(), start, end);
- locationAnimator.setDuration(DURATION_ANIMATION);
- locationAnimator.addUpdateListener(listener);
- locationAnimator.addListener(this);
- }
-
- void start() {
- locationAnimator.start();
- locationAnimator.setCurrentPlayTime(animationTime);
- }
-
- void stop() {
- animationTime = locationAnimator.getCurrentPlayTime();
- locationAnimator.cancel();
- }
-
- private static class LocationEvaluator implements TypeEvaluator<Location> {
-
- private Location location = new Location(MockLocationEngine.class.getSimpleName());
-
- @Override
- public Location evaluate(float fraction, Location startValue, Location endValue) {
- counter++;
- location.setLatitude(startValue.getLatitude()
- + ((endValue.getLatitude() - startValue.getLatitude()) * fraction));
- location.setLongitude(startValue.getLongitude()
- + ((endValue.getLongitude() - startValue.getLongitude()) * fraction));
- return location;
- }
- }
- }
-}
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
deleted file mode 100644
index f603050030..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.activity.userlocation;
-
-import android.graphics.Color;
-import android.location.Location;
-import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v4.content.ContextCompat;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.constants.Style;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.android.core.location.LocationEngineListener;
-
-/**
- * Test activity showcasing how to change the MyLocationView drawable.
- */
-public class MyLocationDrawableActivity extends BaseLocationActivity implements LocationEngineListener {
-
- private MapView mapView;
- private MapboxMap mapboxMap;
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_my_location_customization);
- findViewById(R.id.progress).setVisibility(View.GONE);
-
- MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
- mapboxMapOptions.styleUrl(Style.MAPBOX_STREETS);
- mapboxMapOptions.myLocationForegroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_android));
- mapboxMapOptions.myLocationBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_android));
- mapboxMapOptions.myLocationForegroundTintColor(Color.GREEN);
- mapboxMapOptions.myLocationBackgroundTintColor(Color.YELLOW);
- mapboxMapOptions.myLocationBackgroundPadding(new int[] {0, 0,
- (int) getResources().getDimension(R.dimen.locationview_background_drawable_padding),
- (int) getResources().getDimension(R.dimen.locationview_background_drawable_padding)});
- mapboxMapOptions.myLocationAccuracyTint(Color.RED);
- mapboxMapOptions.myLocationAccuracyAlpha(155);
-
- mapView = new MapView(this, mapboxMapOptions);
- mapView.setId(R.id.mapView);
- ViewGroup parent = (ViewGroup) findViewById(android.R.id.content);
- parent.addView(mapView);
-
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(map -> {
- mapboxMap = map;
- toggleGps(true);
- });
- }
-
- @Override
- protected void enableLocation(boolean enabled) {
- mapboxMap.setMyLocationEnabled(enabled);
- }
-
- @Override
- public void onConnected() {
- // Nothing
- }
-
- @Override
- public void onLocationChanged(Location location) {
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 14));
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-}
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
deleted file mode 100644
index ff3c4dfbc0..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java
+++ /dev/null
@@ -1,181 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.activity.userlocation;
-
-import android.app.Activity;
-import android.graphics.Color;
-import android.location.Location;
-import android.os.Bundle;
-import android.support.annotation.IdRes;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.content.ContextCompat;
-import android.view.View;
-
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.constants.MyLocationTracking;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.TrackingSettings;
-import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.android.core.location.LocationEngineListener;
-
-/**
- * Test activity showcasing how to tint the MyLocationView.
- */
-public class MyLocationTintActivity extends BaseLocationActivity implements LocationEngineListener {
-
- private MapView mapView;
- private MapboxMap mapboxMap;
- private boolean firstRun;
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_my_location_dot_color);
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(map -> {
- mapboxMap = map;
-
- // enable location updates
- toggleGps(true);
-
- // add some padding
- final MyLocationViewSettings myLocationViewSettings = mapboxMap.getMyLocationViewSettings();
- myLocationViewSettings.setPadding(0, 500, 0, 0);
-
- // enable tracking
- TrackingSettings settings = mapboxMap.getTrackingSettings();
- settings.setDismissLocationTrackingOnGesture(false);
- settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
-
- // handle default button clicks
- ViewUtils.attachClickListener(
- MyLocationTintActivity.this,
- R.id.default_user_dot_coloring_button,
- view -> {
- myLocationViewSettings.setAccuracyTintColor(ContextCompat.getColor(
- MyLocationTintActivity.this, R.color.mapbox_blue));
- myLocationViewSettings.setForegroundTintColor(ContextCompat.getColor(
- MyLocationTintActivity.this, R.color.mapbox_blue));
- myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
- });
-
- // handle tint user dot button clicks
- ViewUtils.attachClickListener(
- MyLocationTintActivity.this,
- R.id.tint_user_dot_button,
- view -> {
- myLocationViewSettings.setAccuracyTintColor(
- ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen));
- myLocationViewSettings.setForegroundTintColor(
- ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen));
- myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
- });
-
- // handle tint accuracy ring button clicks
- ViewUtils.attachClickListener(
- MyLocationTintActivity.this,
- R.id.user_accuracy_ring_tint_button,
- view -> {
- myLocationViewSettings.setAccuracyTintColor(
- ContextCompat.getColor(MyLocationTintActivity.this, R.color.accent));
- myLocationViewSettings.setForegroundTintColor(
- ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_blue));
- myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
- });
-
- ViewUtils.attachClickListener(
- MyLocationTintActivity.this,
- R.id.user_dot_transparent_button,
- view -> {
- myLocationViewSettings.setForegroundTintColor(Color.TRANSPARENT);
- myLocationViewSettings.setBackgroundTintColor(Color.TRANSPARENT);
- }
- );
- });
-
- }
-
- @Override
- public void onConnected() {
- // Nothing
- }
-
- @Override
- public void onLocationChanged(Location location) {
- if (mapboxMap != null && firstRun) {
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15));
- firstRun = false;
- }
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- public void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mapView.onPause();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void enableLocation(boolean enabled) {
- if (enabled) {
- mapboxMap.setMyLocationEnabled(true);
- if (mapboxMap.getMyLocation() != null) {
- mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
- new LatLng(mapboxMap.getMyLocation().getLatitude(),
- mapboxMap.getMyLocation().getLongitude()), 15));
- }
- } else {
- mapboxMap.setMyLocationEnabled(false);
- }
- }
-
- private static class ViewUtils {
-
- public static void attachClickListener(
- @NonNull Activity activity, @IdRes int buttonId, @Nullable View.OnClickListener clickListener) {
- View view = activity.findViewById(buttonId);
- if (view != null) {
- view.setOnClickListener(clickListener);
- }
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java
deleted file mode 100644
index ea3a6f14bc..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.activity.userlocation;
-
-import android.os.Bundle;
-import android.support.design.widget.FloatingActionButton;
-
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.testapp.R;
-
-import timber.log.Timber;
-
-/**
- * Test activity showcasing toggling the user location on the map.
- */
-public class MyLocationToggleActivity extends BaseLocationActivity {
-
- private MapView mapView;
- private MapboxMap mapboxMap;
- private FloatingActionButton locationToggleFab;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_my_location_toggle);
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(map -> mapboxMap = map);
-
- locationToggleFab = (FloatingActionButton) findViewById(R.id.fabLocationToggle);
- locationToggleFab.setOnClickListener(view -> {
- if (mapboxMap != null) {
- toggleGps(!mapboxMap.isMyLocationEnabled());
- }
- });
- }
-
- @Override
- protected void enableLocation(boolean enabled) {
- Timber.e("Enabling location: %s", enabled);
- mapboxMap.setMyLocationEnabled(enabled);
- if (enabled) {
- locationToggleFab.setImageResource(R.drawable.ic_location_disabled);
- } else {
- locationToggleFab.setImageResource(R.drawable.ic_my_location);
- }
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- mapView.onStop();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
-}
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
deleted file mode 100644
index ffbb2c1a90..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java
+++ /dev/null
@@ -1,296 +0,0 @@
-package com.mapbox.mapboxsdk.testapp.activity.userlocation;
-
-import android.location.Location;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.Spinner;
-import android.widget.Toast;
-
-import com.mapbox.mapboxsdk.Mapbox;
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.constants.MyBearingTracking;
-import com.mapbox.mapboxsdk.constants.MyLocationTracking;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
-import com.mapbox.mapboxsdk.maps.TrackingSettings;
-import com.mapbox.mapboxsdk.maps.UiSettings;
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.android.core.location.LocationEngineListener;
-
-import timber.log.Timber;
-
-/**
- * Test activity showcasing the different tracking modes the SDK exposes.
- * <p>
- * This includes MyLocationTracking/MyLocationBearingTracking and how the components can be configured to be dismissed
- * using gesture configurations.
- * </p>
- */
-public class MyLocationTrackingModeActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener,
- OnMapReadyCallback, LocationEngineListener {
-
- public static final int TRACKING_NONE_INDEX = 0;
- public static final int TRACKING_FOLLOW_INDEX = 1;
- public static final int BEARING_NONE_INDEX = 0;
- public static final int BEARING_GPS_INDEX = 1;
- public static final int BEARING_COMPASS_INDEX = 2;
-
- private MapView mapView;
- private MapboxMap mapboxMap;
- private Spinner locationSpinner;
- private Spinner bearingSpinner;
- private boolean firstRun = true;
-
- private MenuItem dismissLocationTrackingOnGestureItem;
- private MenuItem dismissBearingTrackingOnGestureItem;
- private MenuItem enableRotateGesturesItem;
- private MenuItem enableScrollGesturesItem;
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_my_location_tracking);
- setupToolbar();
-
- mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(this);
- }
-
- @Override
- public void onMapReady(MapboxMap mapboxMap) {
- MyLocationTrackingModeActivity.this.mapboxMap = mapboxMap;
-
- mapboxMap.setMyLocationEnabled(true);
- Mapbox.getLocationEngine().addLocationEngineListener(this);
- Mapbox.getLocationEngine().requestLocationUpdates();
- }
-
- @Override
- public void onConnected() {
- // Nothing
- }
-
- @Override
- public void onLocationChanged(Location location) {
- Timber.e("Location changed %s", location);
- if (firstRun) {
- setInitialLocation(location, 16);
- }
- }
-
- private void setInitialLocation(Location location, double zoom) {
- mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), zoom));
- mapboxMap.setMyLocationEnabled(true);
- setupSpinners(mapboxMap);
- firstRun = false;
- }
-
- private void setupToolbar() {
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
-
- final ActionBar actionBar = getSupportActionBar();
- if (actionBar != null) {
- actionBar.setDisplayShowTitleEnabled(false);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowHomeEnabled(true);
-
- locationSpinner = (Spinner) findViewById(R.id.spinner_location);
- ArrayAdapter<CharSequence> locationTrackingAdapter = ArrayAdapter.createFromResource(
- actionBar.getThemedContext(), R.array.user_tracking_mode, android.R.layout.simple_spinner_item);
- locationTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- locationSpinner.setAdapter(locationTrackingAdapter);
-
- bearingSpinner = (Spinner) findViewById(R.id.spinner_bearing);
- ArrayAdapter<CharSequence> bearingTrackingAdapter = ArrayAdapter.createFromResource(
- actionBar.getThemedContext(), R.array.user_bearing_mode, android.R.layout.simple_spinner_item);
- bearingTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- bearingSpinner.setAdapter(bearingTrackingAdapter);
- }
- }
-
- private void setupSpinners(@NonNull MapboxMap mapboxMap) {
- locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
- bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
- setCheckBoxes();
-
- mapboxMap.setOnMyLocationTrackingModeChangeListener(myLocationTrackingMode -> {
- locationSpinner.setOnItemSelectedListener(null);
- switch (myLocationTrackingMode) {
- case MyLocationTracking.TRACKING_NONE:
- locationSpinner.setSelection(TRACKING_NONE_INDEX);
- break;
- case MyLocationTracking.TRACKING_FOLLOW:
- locationSpinner.setSelection(TRACKING_FOLLOW_INDEX);
- break;
- }
- locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
- });
-
- mapboxMap.setOnMyBearingTrackingModeChangeListener(myBearingTrackingMode -> {
- bearingSpinner.setOnItemSelectedListener(null);
- switch (myBearingTrackingMode) {
- case MyBearingTracking.NONE:
- bearingSpinner.setSelection(BEARING_NONE_INDEX);
- break;
-
- case MyBearingTracking.GPS:
- bearingSpinner.setSelection(BEARING_GPS_INDEX);
- break;
-
- case MyBearingTracking.COMPASS:
- bearingSpinner.setSelection(BEARING_COMPASS_INDEX);
- break;
- }
- bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
- });
- }
-
- @Override
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) throws SecurityException {
- TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
- if (parent.getId() == R.id.spinner_location) {
- switch (position) {
- case TRACKING_NONE_INDEX:
- trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
- break;
-
- case TRACKING_FOLLOW_INDEX:
- trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- break;
- }
- } else if (parent.getId() == R.id.spinner_bearing) {
- switch (position) {
- case BEARING_NONE_INDEX:
- trackingSettings.setMyBearingTrackingMode(MyBearingTracking.NONE);
- break;
-
- case BEARING_GPS_INDEX:
- trackingSettings.setMyBearingTrackingMode(MyBearingTracking.GPS);
- break;
-
- case BEARING_COMPASS_INDEX:
- trackingSettings.setMyBearingTrackingMode(MyBearingTracking.COMPASS);
- break;
- }
- }
- }
-
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
-
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mapView.onStart();
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mapView.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mapView.onPause();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- Mapbox.getLocationEngine().removeLocationEngineListener(this);
- Mapbox.getLocationEngine().removeLocationUpdates();
- mapView.onStop();
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- mapView.onSaveInstanceState(outState);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- mapView.onDestroy();
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- mapView.onLowMemory();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_tracking, menu);
- dismissLocationTrackingOnGestureItem = menu.findItem(R.id.action_toggle_dismissible_location);
- dismissBearingTrackingOnGestureItem = menu.findItem(R.id.action_toggle_dismissible_bearing);
- enableRotateGesturesItem = menu.findItem(R.id.action_toggle_rotate_gesture_enabled);
- enableScrollGesturesItem = menu.findItem(R.id.action_toggle_scroll_gesture_enabled);
- setCheckBoxes();
- return true;
- }
-
- private void setCheckBoxes() {
- if (mapboxMap != null && dismissBearingTrackingOnGestureItem != null) {
- TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
- UiSettings uiSettings = mapboxMap.getUiSettings();
- dismissBearingTrackingOnGestureItem.setChecked(trackingSettings.isDismissBearingTrackingOnGesture());
- dismissLocationTrackingOnGestureItem.setChecked(trackingSettings.isDismissLocationTrackingOnGesture());
- enableRotateGesturesItem.setChecked(uiSettings.isRotateGesturesEnabled());
- enableScrollGesturesItem.setChecked(uiSettings.isScrollGesturesEnabled());
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- boolean state;
- switch (item.getItemId()) {
- case android.R.id.home:
- onBackPressed();
- return true;
- case R.id.action_toggle_dismissible_location:
- state = !item.isChecked();
- mapboxMap.getTrackingSettings().setDismissLocationTrackingOnGesture(state);
- Toast.makeText(this, "Dismiss tracking mode on gesture = " + state, Toast.LENGTH_SHORT).show();
- item.setChecked(state);
- return true;
- case R.id.action_toggle_dismissible_bearing:
- state = !item.isChecked();
- mapboxMap.getTrackingSettings().setDismissBearingTrackingOnGesture(state);
- Toast.makeText(this, "Dismiss bearing mode on gesture = " + state, Toast.LENGTH_SHORT).show();
- item.setChecked(state);
- return true;
- case R.id.action_toggle_rotate_gesture_enabled:
- state = !item.isChecked();
- mapboxMap.getUiSettings().setRotateGesturesEnabled(state);
- Toast.makeText(this, "Rotate gesture enabled = " + state, Toast.LENGTH_SHORT).show();
- item.setChecked(state);
- return true;
- case R.id.action_toggle_scroll_gesture_enabled:
- state = !item.isChecked();
- mapboxMap.getUiSettings().setScrollGesturesEnabled(state);
- Toast.makeText(this, "Scroll gesture enabled = " + state, Toast.LENGTH_SHORT).show();
- item.setChecked(state);
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java
index d745982388..f3562b5b15 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/activity/Feature.java
@@ -9,14 +9,12 @@ public class Feature implements Parcelable {
private String label;
private String description;
private String category;
- private boolean requiresLocationPermission;
- public Feature(String name, String label, String description, String category, boolean requiresLocationPermission) {
+ public Feature(String name, String label, String description, String category) {
this.name = name;
this.label = label;
this.description = description;
this.category = category;
- this.requiresLocationPermission = requiresLocationPermission;
}
private Feature(Parcel in) {
@@ -24,7 +22,6 @@ public class Feature implements Parcelable {
label = in.readString();
description = in.readString();
category = in.readString();
- requiresLocationPermission = in.readByte() != 0;
}
public String getName() {
@@ -48,10 +45,6 @@ public class Feature implements Parcelable {
return category;
}
- public boolean isRequiresLocationPermission() {
- return requiresLocationPermission;
- }
-
public int describeContents() {
return 0;
}
@@ -61,7 +54,6 @@ public class Feature implements Parcelable {
out.writeString(label);
out.writeString(description);
out.writeString(category);
- out.writeByte((byte) (requiresLocationPermission ? 1 : 0));
}
public static final Parcelable.Creator<Feature> CREATOR
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled.xml
deleted file mode 100644
index 4fedff778b..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0">
- <path
- android:fillColor="#FFFFFF"
- android:pathData="M20.94,11c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94L13,1h-2v2.06c-1.13,0.12 -2.19,0.46 -3.16,0.97l1.5,1.5C10.16,5.19 11.06,5 12,5c3.87,0 7,3.13 7,7 0,0.94 -0.19,1.84 -0.52,2.65l1.5,1.5c0.5,-0.96 0.84,-2.02 0.97,-3.15L23,13v-2h-2.06zM3,4.27l2.04,2.04C3.97,7.62 3.25,9.23 3.06,11L1,11v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94L11,23h2v-2.06c1.77,-0.2 3.38,-0.91 4.69,-1.98L19.73,21 21,19.73 4.27,3 3,4.27zM16.27,17.54C15.09,18.45 13.61,19 12,19c-3.87,0 -7,-3.13 -7,-7 0,-1.61 0.55,-3.09 1.46,-4.27l9.81,9.81z"/>
-</vector>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_location_engine.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_location_engine.xml
deleted file mode 100644
index e9f461c7ee..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_location_engine.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<android.support.design.widget.CoordinatorLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@id/coordinator_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <com.mapbox.mapboxsdk.maps.MapView
- android:id="@id/mapView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:mapbox_cameraTargetLat="40.416872"
- app:mapbox_cameraTargetLng="-3.703807"
- app:mapbox_cameraZoom="4"/>
-
- <android.support.design.widget.FloatingActionButton
- android:id="@+id/fabLocationToggle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end|bottom"
- android:layout_margin="@dimen/fab_margin"
- android:src="@drawable/ic_my_location"
- tools:backgroundTint="@color/primary"/>
-
-</android.support.design.widget.CoordinatorLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml
deleted file mode 100644
index addfe8427b..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-
- <android.support.v4.widget.ContentLoadingProgressBar
- android:id="@id/progress"
- style="?android:attr/progressBarStyleLarge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"/>
-
-</merge>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml
deleted file mode 100644
index de18e265de..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:mapbox="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <com.mapbox.mapboxsdk.maps.MapView
- android:id="@id/mapView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- mapbox:mapbox_uiAttribution="false"
- mapbox:mapbox_uiLogo="false"/>
-
- <LinearLayout
- style="?android:attr/buttonBarStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:background="@color/accent"
- android:orientation="horizontal"
- android:weightSum="4">
-
- <Button
- android:id="@+id/default_user_dot_coloring_button"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/button_user_dot_default"
- android:textColor="@color/white"/>
-
- <Button
- android:id="@+id/tint_user_dot_button"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/button_user_dot_tint"
- android:textColor="@color/white"/>
-
- <Button
- android:id="@+id/user_accuracy_ring_tint_button"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/button_user_accuracy_ring_tint"
- android:textColor="@color/white"/>
-
- <Button
- android:id="@+id/user_dot_transparent_button"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/button_user_transparent_tint"
- android:textColor="@color/white"/>
-
- </LinearLayout>
-
-</RelativeLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml
deleted file mode 100644
index 2ec35faf04..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<android.support.design.widget.CoordinatorLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@id/coordinator_layout"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <com.mapbox.mapboxsdk.maps.MapView
- android:id="@id/mapView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
-
- <android.support.design.widget.FloatingActionButton
- android:id="@+id/fabLocationToggle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end|bottom"
- android:layout_margin="@dimen/fab_margin"
- android:src="@drawable/ic_my_location"
- tools:backgroundTint="@color/primary"/>
-
-</android.support.design.widget.CoordinatorLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_tracking.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_tracking.xml
deleted file mode 100644
index 7236a944e9..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_tracking.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <android.support.v7.widget.Toolbar
- android:id="@+id/toolbar"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:background="@color/primary"
- android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:weightSum="2">
-
- <Spinner
- android:id="@+id/spinner_location"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginEnd="8dp"
- android:layout_marginRight="8dp"
- android:layout_weight="1" />
-
- <Spinner
- android:id="@+id/spinner_bearing"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginLeft="8dp"
- android:layout_marginStart="8dp"
- android:layout_weight="1" />
-
- </LinearLayout>
-
-
- </android.support.v7.widget.Toolbar>
-
- <com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:mapbox_myLocationTintColor="@color/primary"
- app:mapbox_myLocationAccuracyTintColor="@color/primary"
- app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
- app:mapbox_cameraZoom="8" />
-
-</LinearLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_engine.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_engine.xml
deleted file mode 100644
index dd7408df09..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_engine.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:mapbox="http://schemas.android.com/apk/res-auto">
-
- <item
- android:id="@+id/action_id_location_source_lost"
- android:title="@string/menuitem_title_change_location_source_lost"
- mapbox:showAsAction="never"/>
-
- <item
- android:id="@+id/action_id_location_source_mock"
- android:title="@string/menuitem_title_change_location_source_mock"
- mapbox:showAsAction="never"/>
-
- <item
- android:id="@+id/action_id_location_source_null"
- android:title="@string/menuitem_title_change_location_source_null"
- mapbox:showAsAction="never"/>
-
-</menu> \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_padding.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_padding.xml
index 7132c0c2a9..f0197a9716 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_padding.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_padding.xml
@@ -2,10 +2,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto">
<item
- android:id="@+id/action_user_tracking"
- android:title="@string/my_location_tracking"
- mapbox:showAsAction="never" />
- <item
android:id="@+id/action_bangalore"
android:title="@string/bangalore"
mapbox:showAsAction="never" />
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_tracking.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_tracking.xml
deleted file mode 100644
index 940dd9c461..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_tracking.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
-
- <group android:checkableBehavior="all">
- <item
- android:id="@+id/action_toggle_dismissible_location"
- android:checkable="true"
- android:checked="false"
- android:title="@string/menuitem_title_tracking_mode_dismiss_on_gesture"
- app:showAsAction="never" />
- <item
- android:id="@+id/action_toggle_dismissible_bearing"
- android:checkable="true"
- android:checked="false"
- android:title="@string/menuitem_title_bearing_mode_dismiss_on_gesture"
- app:showAsAction="never" />
- <item
- android:id="@+id/action_toggle_rotate_gesture_enabled"
- android:checkable="true"
- android:checked="false"
- android:title="@string/menuitem_title_rotate_gesture_enabled"
- app:showAsAction="never" />
- <item
- android:id="@+id/action_toggle_scroll_gesture_enabled"
- android:checkable="true"
- android:checked="false"
- android:title="@string/menuitem_title_scroll_gesture_enabled"
- app:showAsAction="never" />
- </group>
-
-</menu>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml
index e7d140d7d4..04d2e8d56e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/actions.xml
@@ -2,14 +2,7 @@
<resources>
<string name="menuitem_title_concurrent_infowindow">Concurrent Open InfoWindows</string>
<string name="menuitem_title_deselect_markers_on_tap">Deselect Markers On Tap</string>
- <string name="menuitem_title_tracking_mode_dismiss_on_gesture">Dismiss location tracking on gesture</string>
- <string name="menuitem_title_bearing_mode_dismiss_on_gesture">Dismiss bearing tracking on gesture</string>
<string name="menuitem_title_reset">Reset</string>
- <string name="menuitem_title_rotate_gesture_enabled">Enable rotate gestures</string>
- <string name="menuitem_title_scroll_gesture_enabled">Enable scroll gestures</string>
- <string name="menuitem_title_change_location_source_lost">Change to LOST location source</string>
- <string name="menuitem_title_change_location_source_mock">Change to mock location source</string>
- <string name="menuitem_title_change_location_source_null">Reset location source to null</string>
<string name="menuitem_change_icon_overlap">Toggle icon overlap</string>
<string name="menuitem_filter">Filter layer</string>
<string name="menuitem_change_location">Change location</string>
@@ -21,10 +14,6 @@
<string name="button_camera_move">Move</string>
<string name="button_camera_ease">Ease</string>
<string name="button_camera_animate">Animate</string>
- <string name="button_user_dot_default">Default</string>
- <string name="button_user_dot_tint">Tint dot</string>
- <string name="button_user_accuracy_ring_tint">Tint ring</string>
- <string name="button_user_transparent_tint">tran</string>
<string name="button_open_dialog">Open dialog</string>
<string name="button_download_region">Download region</string>
<string name="button_list_regions">List regions</string>
@@ -73,7 +62,6 @@
<string name="add_a_composite_categorical_function">Add a composite, categorical function</string>
<string name="add_a_composite_exponential_function">Add a composite, exponential function</string>
<string name="add_a_composite_interval_function">Add a composite, interval function</string>
- <string name="my_location_tracking">My Location Tracking</string>
<string name="bangalore">Bangalore</string>
<string name="list_all_layers_in_the_style">List all layers in the style</string>
<string name="list_all_sources_in_the_style">List all sources in the style</string>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/arrays.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/arrays.xml
index 94763342d2..4b7ded8e3a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/arrays.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/arrays.xml
@@ -7,16 +7,4 @@
<item>1000</item>
<item>10000</item>
</string-array>
-
- <string-array name="user_tracking_mode">
- <item>Disabled</item>
- <item>Follow tracking</item>
- </string-array>
-
- <string-array name="user_bearing_mode">
- <item>Disabled</item>
- <item>GPS bearing</item>
- <item>Compass bearing</item>
- <!--<item>Combined mode</item>-->
- </string-array>
</resources> \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml
index dbc6b59db6..aafeb1cd9c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/categories.xml
@@ -10,7 +10,6 @@
<string name="category_infowindow">Info Window</string>
<string name="category_maplayout">Map Layout</string>
<string name="category_offline">Offline</string>
- <string name="category_userlocation">User Location</string>
<string name="category_style">Styling</string>
<string name="category_features">Features</string>
<string name="category_storage">Storage</string>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
index fc04851293..77ce50ecd0 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/descriptions.xml
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="description_user_location_tracking">Tracks the location of the user</string>
- <string name="description_user_location_customization">Customize the location of the user</string>
- <string name="description_user_location_dot_color">Customize the user location color</string>
- <string name="description_user_location_toggle">Toggle location of the user on and off</string>
- <string name="description_custom_location_engine">Customize location engine</string>
<string name="description_custom_layer">Overlay a custom native layer on the map</string>
<string name="description_info_window_adapter">Learn how to create a custom InfoWindow</string>
<string name="description_cameraposition">CameraPosition capabilities</string>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/dimens.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/dimens.xml
index 0a43af09de..9d34183435 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/dimens.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/dimens.xml
@@ -6,6 +6,5 @@
<dimen name="map_padding_bottom">256dp</dimen>
<dimen name="map_padding_right">32dp</dimen>
<dimen name="map_padding_top">0dp</dimen>
- <dimen name="locationview_background_drawable_padding">2dp</dimen>
<dimen name="navigation_drawer_width">240dp</dimen>
</resources>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
index e2bbf5af01..a3885dbf38 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/titles.xml
@@ -21,11 +21,6 @@
<string name="activity_scroll_by">Scroll By Method</string>
<string name="activity_double_map">Double Map Activity</string>
<string name="activity_snapshot">Snapshot Activity</string>
- <string name="activity_user_tracking_mode">User tracking mode</string>
- <string name="activity_user_tracking_customization">User location drawable</string>
- <string name="activity_user_dot_color">User location tint color</string>
- <string name="activity_user_location_toggle">User location toggle</string>
- <string name="activity_custom_location_engine">Custom location engine</string>
<string name="activity_custom_layer">Custom Layer</string>
<string name="activity_map_padding">Map Padding</string>
<string name="activity_debug_mode">Debug Mode</string>