summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java239
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentConstants.java6
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java126
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationClickListener.java14
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationComponentClickListener.java11
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationComponentLongClickListener.java11
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationLongClickListener.java14
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationStaleListener.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/StaleStateManager.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java16
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/ZoomAnimator.java1
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/modes/RenderMode.java2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java7
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java14
14 files changed, 224 insertions, 245 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java
index c6b868f3da..0503c5e9dc 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java
@@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.hardware.SensorManager;
import android.location.Location;
-import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresPermission;
@@ -34,15 +33,10 @@ import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_TRACKING_TILT_ANIM_DURATION;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_TRACKING_ZOOM_ANIM_DURATION;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.STATE_LOCATION_CAMERA_MODE;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.STATE_LOCATION_ENABLED;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.STATE_LOCATION_LAST_LOCATION;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.STATE_LOCATION_OPTIONS;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.STATE_LOCATION_RENDER_MODE;
/**
- * The Location layer plugin provides location awareness to your mobile application. Enabling this
- * plugin provides a contextual experience to your users by showing an icon representing the users
+ * The Location Component provides location awareness to your mobile application. Enabling this
+ * component provides a contextual experience to your users by showing an icon representing the users
* current location. A few different modes are offered to provide the right context to your users at
* the correct time. {@link RenderMode#NORMAL} simply shows the users location on the map
* represented as a dot. {@link RenderMode#COMPASS} mode allows you to display an arrow icon
@@ -50,32 +44,33 @@ import static com.mapbox.mapboxsdk.location.LocationComponentConstants.STATE_LOC
* {@link RenderMode#GPS} can be used in conjunction with our Navigation SDK to
* display a larger icon (customized with {@link LocationComponentOptions#gpsDrawable()}) we call the user puck.
* <p>
- * This plugin also offers the ability to set a map camera behavior for tracking the user
+ * This component also offers the ability to set a map camera behavior for tracking the user
* location. These different {@link CameraMode}s will track, stop tracking the location based on the
* mode set with {@link LocationComponent#setCameraMode(int)}.
* <p>
- * Lastly, {@link LocationComponent#setLocationComponentEnabled(boolean)} can be used
- * to disable the Location Layer but keep the instance around till the activity is destroyed.
+ * <strong>
+ * To get the component object use {@link MapboxMap#getLocationComponent()} and activate it with
+ * {@link #activateLocationComponent(Context)} or one of the overloads.
+ * Then, manage its visibility with {@link #setLocationComponentEnabled(boolean)}.
+ * </strong>
* <p>
- * Using this plugin requires you to request permission beforehand manually or using
+ * Using this component requires you to request permission beforehand manually or using
* {@link com.mapbox.android.core.permissions.PermissionsManager}. Either
* {@code ACCESS_COARSE_LOCATION} or {@code ACCESS_FINE_LOCATION} permissions can be requested and
* this plugin work as expected.
* <p>
- * When instantiating the plugin for the first time, the map's max/min zoom levels will be set to
+ * This component offers a default, built-in {@link LocationEngine} with some of the activation methods.
+ * This engine will be obtained by {@link LocationEngineProvider#obtainBestLocationEngineAvailable} which defaults
+ * to the {@link com.mapbox.android.core.location.AndroidLocationEngine}. If you'd like to utilize Google Play Services
+ * for more precise location updates, simply add the Google Play Location Services dependency in your build script.
+ * This will make the default engine the {@link com.mapbox.android.core.location.GoogleLocationEngine} instead.
+ * <p>
+ * When activating the component for the first time, the map's max/min zoom levels will be set to
* {@link LocationComponentOptions#MAX_ZOOM_DEFAULT} and {@link LocationComponentOptions#MIN_ZOOM_DEFAULT} respectively.
* You can adjust the zoom range with {@link LocationComponentOptions#maxZoom()} and
* {@link LocationComponentOptions#minZoom()}.
* <p>
- * When an activity, or a fragment, that contains the plugin is destroyed and recreated,
- * the plugin will restore its state, which is:
- * <br/>
- * - If the plugin was enabled, last location will be displayed.
- * You still need to activate the plugin, or just provide the {@link LocationEngine}.
- * <br/>
- * - {@link CameraMode} and {@link RenderMode} will be restored.
- * <br/>
- * - {@link LocationComponentOptions} will be restored.
+ * Location Component doesn't support state saving out-of-the-box.
*/
public final class LocationComponent {
private static final String TAG = "Mbgl-LocationComponent";
@@ -99,18 +94,20 @@ public final class LocationComponent {
private CameraPosition lastCameraPosition;
/**
- * Indicates that the plugin is enabled and should be displaying location if Mapbox components are available and
- * the lifecycle is in a resumed state.
+ * Indicates whether the component has been initialized.
+ */
+ private boolean isInitialized;
+
+ /**
+ * Indicates that the component is enabled and should be displaying location if Mapbox components are available and
+ * the lifecycle is in a started state.
*/
private boolean isEnabled;
/**
- * Indicated that plugin's lifecycle {@link #onStart()} method has been called or the plugin is initialized..
+ * Indicated that component's lifecycle {@link #onStart()} method has been called.
* This allows Mapbox components enter started state and display data, and adds state safety for methods like
* {@link #setLocationComponentEnabled(boolean)}
- * <p>
- * Initialized in a started state because the plugin can be instantiated after lifecycle's onStart() and
- * the developer might not register the lifecycle observer but call lifecycle methods manually instead.
*/
private boolean isComponentStarted;
@@ -123,44 +120,27 @@ public final class LocationComponent {
private StaleStateManager staleStateManager;
private final CopyOnWriteArrayList<OnLocationStaleListener> onLocationStaleListeners
= new CopyOnWriteArrayList<>();
- private final CopyOnWriteArrayList<OnLocationComponentClickListener> onLocationComponentClickListeners
+ private final CopyOnWriteArrayList<OnLocationClickListener> onLocationClickListeners
= new CopyOnWriteArrayList<>();
- private final CopyOnWriteArrayList<OnLocationComponentLongClickListener> onLocationComponentLongClickListeners
+ private final CopyOnWriteArrayList<OnLocationLongClickListener> onLocationLongClickListeners
= new CopyOnWriteArrayList<>();
private final CopyOnWriteArrayList<OnCameraTrackingChangedListener> onCameraTrackingChangedListeners
= new CopyOnWriteArrayList<>();
/**
- * Construct a LocationComponent. In order to display location,
- * the location layer has to be activated with {@link LocationComponent#activateLocationComponent(Context)},
- * or one of the overloads.
- *
- * @param mapboxMap the MapboxMap to apply the LocationComponent with
+ * Internal use.
+ * <p>
+ * To get the component object use {@link MapboxMap#getLocationComponent()}.
*/
- public LocationComponent(@NonNull Context context, @NonNull MapboxMap mapboxMap) {
+ public LocationComponent(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
- options = LocationComponentOptions.createFromAttributes(context, R.style.mapbox_LocationComponent);
- initialize(context);
}
/**
- * This method will show or hide the location icon and enable or disable the camera
- * tracking the location.
- *
- * @param isEnabled true to show layers and enable camera, false otherwise
- */
- private void setLocationComponentEnabled(boolean isEnabled) {
- if (isEnabled) {
- enableLocationComponent();
- } else {
- disableLocationComponent();
- }
- }
-
- /**
- * This method will show the location icon and enable the camera tracking the location.
+ * This method initializes the component and needs to be called before any other operations are performed.
+ * Afterwards, you can manage component's visibility by {@link #setLocationComponentEnabled(boolean)}.
* <p>
- * <strong>Note</strong>: This method will initialize and use an internal {@link LocationEngine}.
+ * <strong>Note</strong>: This method will initialize and use an internal {@link LocationEngine} when enabled.
*
* @param context the context
*/
@@ -171,7 +151,8 @@ public final class LocationComponent {
}
/**
- * This method will show the location icon and enable the camera tracking the location.
+ * This method initializes the component and needs to be called before any other operations are performed.
+ * Afterwards, you can manage component's visibility by {@link #setLocationComponentEnabled(boolean)}.
*
* @param context the context
* @param useDefaultLocationEngine true if you want to initialize and use the built-in location engine or false if
@@ -187,9 +168,10 @@ public final class LocationComponent {
}
/**
- * This method will show the location icon and enable the camera tracking the location.
+ * This method initializes the component and needs to be called before any other operations are performed.
+ * Afterwards, you can manage component's visibility by {@link #setLocationComponentEnabled(boolean)}.
* <p>
- * <strong>Note</strong>: This method will initialize and use an internal {@link LocationEngine}.
+ * <strong>Note</strong>: This method will initialize and use an internal {@link LocationEngine} when enabled.
*
* @param context the context
* @param styleRes the LocationComponent style res
@@ -200,9 +182,10 @@ public final class LocationComponent {
}
/**
- * This method will show the location icon and enable the camera tracking the location.
+ * This method initializes the component and needs to be called before any other operations are performed.
+ * Afterwards, you can manage component's visibility by {@link #setLocationComponentEnabled(boolean)}.
* <p>
- * <strong>Note</strong>: This method will initialize and use an internal {@link LocationEngine}.
+ * <strong>Note</strong>: This method will initialize and use an internal {@link LocationEngine} when enabled.
* </p>
*
* @param context the context
@@ -210,13 +193,14 @@ public final class LocationComponent {
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
public void activateLocationComponent(@NonNull Context context, @NonNull LocationComponentOptions options) {
- applyStyle(options);
+ initialize(context, options);
initializeLocationEngine(context);
- setLocationComponentEnabled(true);
+ applyStyle(options);
}
/**
- * This method will show the location icon and enable the camera tracking the location.
+ * This method initializes the component and needs to be called before any other operations are performed.
+ * Afterwards, you can manage component's visibility by {@link #setLocationComponentEnabled(boolean)}.
*
* @param context the context
* @param locationEngine the engine, or null if you'd like to only force location updates
@@ -224,7 +208,8 @@ public final class LocationComponent {
*/
public void activateLocationComponent(@NonNull Context context, @Nullable LocationEngine locationEngine,
@StyleRes int styleRes) {
- activateLocationComponent(locationEngine, LocationComponentOptions.createFromAttributes(context, styleRes));
+ activateLocationComponent(context, locationEngine,
+ LocationComponentOptions.createFromAttributes(context, styleRes));
}
/**
@@ -238,23 +223,30 @@ public final class LocationComponent {
}
/**
- * This method will show the location icon and enable the camera tracking the location.
+ * This method initializes the component and needs to be called before any other operations are performed.
+ * Afterwards, you can manage component's visibility by {@link #setLocationComponentEnabled(boolean)}.
*
* @param locationEngine the engine, or null if you'd like to only force location updates
* @param options the options
*/
- public void activateLocationComponent(@Nullable LocationEngine locationEngine,
+ public void activateLocationComponent(@NonNull Context context, @Nullable LocationEngine locationEngine,
@NonNull LocationComponentOptions options) {
+ initialize(context, options);
setLocationEngine(locationEngine);
applyStyle(options);
- setLocationComponentEnabled(true);
}
/**
- * This method will hide the location icon and disable the camera tracking the location.
+ * Manage component's visibility after activation.
+ *
+ * @param isEnabled true if the plugin should be visible and listen for location updates, false otherwise.
*/
- public void deactivateLocationComponent() {
- setLocationComponentEnabled(false);
+ public void setLocationComponentEnabled(boolean isEnabled) {
+ if (isEnabled) {
+ enableLocationComponent();
+ } else {
+ disableLocationComponent();
+ }
}
/**
@@ -288,8 +280,7 @@ public final class LocationComponent {
}
/**
- * Provides the current camera mode being used to track
- * the location or compass updates.
+ * Provides the current camera mode being used to track the location or compass updates.
*
* @return the current camera mode
*/
@@ -335,7 +326,7 @@ public final class LocationComponent {
}
/**
- * Apply a new LocationLayerController style with a style resource.
+ * Apply a new component style with a style resource.
*
* @param styleRes a XML style overriding some or all the options
*/
@@ -344,7 +335,7 @@ public final class LocationComponent {
}
/**
- * Apply a new LocationLayerController style with location layer options.
+ * Apply a new component style with location component options.
*
* @param options to update the current style
*/
@@ -486,10 +477,10 @@ public final class LocationComponent {
/**
* Set the location engine to update the current user location.
* <p>
- * If {@code null} is passed in, all updates will occur through the
+ * If {@code null} is passed in, all updates will have to occur through the
* {@link LocationComponent#forceLocationUpdate(Location)} method.
*
- * @param locationEngine a {@link LocationEngine} this plugin should use to handle updates
+ * @param locationEngine a {@link LocationEngine} this component should use to handle updates
*/
public void setLocationEngine(@Nullable LocationEngine locationEngine) {
if (this.locationEngine != null) {
@@ -513,9 +504,9 @@ public final class LocationComponent {
}
/**
- * Returns the current {@link LocationEngine} being used for updating the user location layer.
+ * Returns the current {@link LocationEngine} being used for updating the user location.
*
- * @return the {@link LocationEngine} being used to update the user location layer
+ * @return the {@link LocationEngine} being used to update the user location
*/
@Nullable
public LocationEngine getLocationEngine() {
@@ -544,7 +535,7 @@ public final class LocationComponent {
}
/**
- * Get the last know location of the location layer plugin.
+ * Get the last know location of the location component.
*
* @return the last known location
*/
@@ -559,7 +550,7 @@ public final class LocationComponent {
}
/**
- * Return the last known {@link CompassEngine} accuracy status of the location layer plugin.
+ * Return the last known {@link CompassEngine} accuracy status of the location component.
* <p>
* The last known accuracy of the compass sensor, one of SensorManager.SENSOR_STATUS_*
*
@@ -591,13 +582,13 @@ public final class LocationComponent {
}
/**
- * Adds a listener that gets invoked when the user clicks the location layer.
+ * Adds a listener that gets invoked when the user clicks the displayed location.
*
- * @param listener The location layer click listener that is invoked when the
- * location layer is clicked
+ * @param listener The location click listener that is invoked when the
+ * location is clicked
*/
- public void addOnLocationClickListener(@NonNull OnLocationComponentClickListener listener) {
- onLocationComponentClickListeners.add(listener);
+ public void addOnLocationClickListener(@NonNull OnLocationClickListener listener) {
+ onLocationClickListeners.add(listener);
}
/**
@@ -605,18 +596,18 @@ public final class LocationComponent {
*
* @param listener to be removed
*/
- public void removeOnLocationClickListener(@NonNull OnLocationComponentClickListener listener) {
- onLocationComponentClickListeners.remove(listener);
+ public void removeOnLocationClickListener(@NonNull OnLocationClickListener listener) {
+ onLocationClickListeners.remove(listener);
}
/**
- * Adds a listener that gets invoked when the user long clicks the location layer.
+ * Adds a listener that gets invoked when the user long clicks the displayed location.
*
- * @param listener The location layer click listener that is invoked when the
- * location layer is clicked
+ * @param listener The location click listener that is invoked when the
+ * location is clicked
*/
- public void addOnLocationLongClickListener(@NonNull OnLocationComponentLongClickListener listener) {
- onLocationComponentLongClickListeners.add(listener);
+ public void addOnLocationLongClickListener(@NonNull OnLocationLongClickListener listener) {
+ onLocationLongClickListeners.add(listener);
}
/**
@@ -624,8 +615,8 @@ public final class LocationComponent {
*
* @param listener to be removed
*/
- public void removeOnLocationLongClickListener(@NonNull OnLocationComponentLongClickListener listener) {
- onLocationComponentLongClickListeners.remove(listener);
+ public void removeOnLocationLongClickListener(@NonNull OnLocationLongClickListener listener) {
+ onLocationLongClickListeners.remove(listener);
}
/**
@@ -686,28 +677,6 @@ public final class LocationComponent {
/**
* Internal use.
*/
- public void onSaveInstanceState(@NonNull Bundle outState) {
- outState.putBoolean(STATE_LOCATION_ENABLED, isEnabled);
- outState.putParcelable(STATE_LOCATION_OPTIONS, options);
- outState.putInt(STATE_LOCATION_RENDER_MODE, locationLayerController.getRenderMode());
- outState.putInt(STATE_LOCATION_CAMERA_MODE, locationCameraController.getCameraMode());
- outState.putParcelable(STATE_LOCATION_LAST_LOCATION, lastLocation);
- }
-
- /**
- * Internal use.
- */
- public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
- updateLocation(savedInstanceState.getParcelable(STATE_LOCATION_LAST_LOCATION), true);
- setCameraMode(savedInstanceState.getInt(STATE_LOCATION_CAMERA_MODE));
- setRenderMode(savedInstanceState.getInt(STATE_LOCATION_RENDER_MODE));
- applyStyle(savedInstanceState.getParcelable(STATE_LOCATION_OPTIONS));
- setLocationComponentEnabled(savedInstanceState.getBoolean(STATE_LOCATION_ENABLED));
- }
-
- /**
- * Internal use.
- */
public void onDestroy() {
if (locationEngine != null && usingInternalLocationEngine) {
locationEngine.deactivate();
@@ -725,23 +694,23 @@ public final class LocationComponent {
* Internal use.
*/
public void onFinishLoadingStyle() {
- locationLayerController.initializeComponents(options);
- locationCameraController.initializeOptions(options);
+ if (isInitialized) {
+ locationLayerController.initializeComponents(options);
+ locationCameraController.initializeOptions(options);
+ }
onLocationLayerStart();
}
@SuppressLint("MissingPermission")
private void onLocationLayerStart() {
- if (!isComponentStarted) {
+ if (!isInitialized || !isComponentStarted) {
return;
}
if (!isLayerReady) {
isLayerReady = true;
- if (mapboxMap != null) {
- mapboxMap.addOnCameraMoveListener(onCameraMoveListener);
- mapboxMap.addOnCameraIdleListener(onCameraIdleListener);
- }
+ mapboxMap.addOnCameraMoveListener(onCameraMoveListener);
+ mapboxMap.addOnCameraIdleListener(onCameraIdleListener);
if (options.enableStaleState()) {
staleStateManager.onStart();
}
@@ -762,7 +731,7 @@ public final class LocationComponent {
}
private void onLocationLayerStop() {
- if (!isLayerReady || !isComponentStarted) {
+ if (!isInitialized || !isLayerReady || !isComponentStarted) {
return;
}
@@ -777,13 +746,17 @@ public final class LocationComponent {
}
locationEngine.removeLocationEngineListener(locationEngineListener);
}
- if (mapboxMap != null) {
- mapboxMap.removeOnCameraMoveListener(onCameraMoveListener);
- mapboxMap.removeOnCameraIdleListener(onCameraIdleListener);
- }
+ mapboxMap.removeOnCameraMoveListener(onCameraMoveListener);
+ mapboxMap.removeOnCameraIdleListener(onCameraIdleListener);
}
- private void initialize(@NonNull Context context) {
+ private void initialize(@NonNull Context context, @NonNull LocationComponentOptions options) {
+ if (isInitialized) {
+ return;
+ }
+ isInitialized = true;
+ this.options = options;
+
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
mapboxMap.addOnMapClickListener(onMapClickListener);
@@ -810,6 +783,8 @@ public final class LocationComponent {
setRenderMode(RenderMode.NORMAL);
setCameraMode(CameraMode.NONE);
+
+ onLocationLayerStart();
}
private void initializeLocationEngine(@NonNull Context context) {
@@ -936,8 +911,8 @@ public final class LocationComponent {
private OnMapClickListener onMapClickListener = new OnMapClickListener() {
@Override
public void onMapClick(@NonNull LatLng point) {
- if (!onLocationComponentClickListeners.isEmpty() && locationLayerController.onMapClick(point)) {
- for (OnLocationComponentClickListener listener : onLocationComponentClickListeners) {
+ if (!onLocationClickListeners.isEmpty() && locationLayerController.onMapClick(point)) {
+ for (OnLocationClickListener listener : onLocationClickListeners) {
listener.onLocationComponentClick();
}
}
@@ -947,8 +922,8 @@ public final class LocationComponent {
private MapboxMap.OnMapLongClickListener onMapLongClickListener = new MapboxMap.OnMapLongClickListener() {
@Override
public void onMapLongClick(@NonNull LatLng point) {
- if (!onLocationComponentLongClickListeners.isEmpty() && locationLayerController.onMapClick(point)) {
- for (OnLocationComponentLongClickListener listener : onLocationComponentLongClickListeners) {
+ if (!onLocationLongClickListeners.isEmpty() && locationLayerController.onMapClick(point)) {
+ for (OnLocationLongClickListener listener : onLocationLongClickListeners) {
listener.onLocationComponentLongClick();
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentConstants.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentConstants.java
index 854170d617..40aae5bb6f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentConstants.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentConstants.java
@@ -5,12 +5,6 @@ package com.mapbox.mapboxsdk.location;
*/
final class LocationComponentConstants {
- static final String STATE_LOCATION_ENABLED = "mapbox_location_locationEnabled";
- static final String STATE_LOCATION_OPTIONS = "mapbox_location_options";
- static final String STATE_LOCATION_LAST_LOCATION = "mapbox_location_lastLocation";
- static final String STATE_LOCATION_RENDER_MODE = "mapbox_location_renderMode";
- static final String STATE_LOCATION_CAMERA_MODE = "mapbox_location_cameraMode";
-
// Controls the compass update rate in milliseconds
static final int COMPASS_UPDATE_RATE_MS = 500;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java
index fcca4764d4..584d214f6e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentOptions.java
@@ -19,11 +19,11 @@ import com.mapbox.mapboxsdk.constants.MapboxConstants;
import java.util.Arrays;
/**
- * This class exposes options for the Location Layer Plugin. The options can be set by defining a
+ * This class exposes options for the Location Component. The options can be set by defining a
* style in your apps style.xml file and passing in directly into the {@link LocationComponent}
* class. Alternatively, if properties need to be changed at runtime depending on a specific state,
* you can build an instance of this class, setting the values you desire, and then passing it into
- * either the {@link LocationComponent} constructor (if it isn't initialized yet) or
+ * either the {@link LocationComponent} activation method (if it isn't initialized yet) or
* {@link LocationComponent#applyStyle(LocationComponentOptions)}.
* <p>
* When the {@link #createFromAttributes(Context, int)} methods called, any attributes not found
@@ -35,7 +35,7 @@ import java.util.Arrays;
* get the currently used options object using {@link LocationComponent#getLocationComponentOptions()}
* and it's {@code toBuilder} method to modify a single entry while also maintaining the other
* settings. Once your modifications have been made, you'll need to pass it back into the location
- * layer plugin using {@link LocationComponent#applyStyle(LocationComponentOptions)}.
+ * component using {@link LocationComponent#applyStyle(LocationComponentOptions)}.
*/
public class LocationComponentOptions implements Parcelable {
@@ -72,7 +72,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* The default value which is used when the stale state is enabled
*/
- private static final long STALE_STATE_DELAY_MS = 30000;
+ private static final long STALE_STATE_DELAY_MS = 30_000L;
private float accuracyAlpha;
private int accuracyColor;
@@ -175,7 +175,7 @@ public class LocationComponentOptions implements Parcelable {
}
/**
- * Construct a new Location Layer Options class using the attributes found within a style
+ * Construct a new Location Component Options class using the attributes found within a style
* resource. It's important to note that you only need to define the attributes you plan to
* change and can safely ignore the other attributes which will be set to their default value.
*
@@ -300,8 +300,7 @@ public class LocationComponentOptions implements Parcelable {
* with all the values set matching the values in this instance. This allows you to modify a
* single attribute and then rebuild the object.
*
- * @return the Location Layer builder which contains the values defined in this current instance
- * as defaults.
+ * @return the builder which contains the values defined in this current instance as defaults.
*/
public Builder toBuilder() {
return new Builder(this);
@@ -313,8 +312,7 @@ public class LocationComponentOptions implements Parcelable {
* attributes while leaving the rest alone and maintaining their default behavior.
*
* @param context your activities context used to acquire the style resource
- * @return the Location Layer builder which contains the default values defined by the style
- * resource
+ * @return the builder which contains the default values defined by the style resource
*/
public static Builder builder(Context context) {
return LocationComponentOptions.createFromAttributes(context,
@@ -326,7 +324,7 @@ public class LocationComponentOptions implements Parcelable {
* completely transparent and 1 means the view is completely opaque.
*
* @return the opacity of the accuracy view
- * @attr ref R.styleable#LocationLayer_accuracyAlpha
+ * @attr ref R.styleable#LocationComponent_accuracyAlpha
*/
public float accuracyAlpha() {
return accuracyAlpha;
@@ -336,7 +334,7 @@ public class LocationComponentOptions implements Parcelable {
* Solid color to use as the accuracy view color property.
*
* @return the color of the accuracy view
- * @attr ref R.styleable#LocationLayer_accuracyColor
+ * @attr ref R.styleable#LocationComponent_accuracyColor
*/
@ColorInt
public int accuracyColor() {
@@ -347,7 +345,7 @@ public class LocationComponentOptions implements Parcelable {
* Defines the drawable used for the stale background icon.
*
* @return the drawable resource ID
- * @attr ref R.styleable#LocationLayer_backgroundDrawableStale
+ * @attr ref R.styleable#LocationComponent_backgroundDrawableStale
*/
@DrawableRes
public int backgroundDrawableStale() {
@@ -357,7 +355,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_foregroundDrawableStale.
+ * component, will use this image in place of the provided or default mapbox_foregroundDrawableStale.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -374,7 +372,7 @@ public class LocationComponentOptions implements Parcelable {
* Defines the drawable used for the stale foreground icon.
*
* @return the drawable resource ID
- * @attr ref R.styleable#LocationLayer_foregroundDrawableStale
+ * @attr ref R.styleable#LocationComponent_foregroundDrawableStale
*/
@DrawableRes
public int foregroundDrawableStale() {
@@ -384,7 +382,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_foregroundDrawableStale.
+ * component, will used this image in place of the provided or default mapbox_foregroundDrawableStale.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -401,7 +399,7 @@ public class LocationComponentOptions implements Parcelable {
* Defines the drawable used for the navigation state icon.
*
* @return the drawable resource ID
- * @attr ref R.styleable#LocationLayer_gpsDrawable
+ * @attr ref R.styleable#LocationComponent_gpsDrawable
*/
@DrawableRes
public int gpsDrawable() {
@@ -411,7 +409,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_gpsDrawable.
+ * component, will used this image in place of the provided or default mapbox_gpsDrawable.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -425,11 +423,10 @@ public class LocationComponentOptions implements Parcelable {
}
/**
- * Supply a Drawable that is to be rendered on top of all of the content in the Location Layer
- * Plugin layer stack.
+ * Supply a Drawable that is to be rendered on top of all of the content in the Location LayerComponent layer stack.
*
* @return the drawable resource used for the foreground layer
- * @attr ref R.styleable#LocationLayer_foregroundDrawable
+ * @attr ref R.styleable#LocationComponent_foregroundDrawable
*/
@DrawableRes
public int foregroundDrawable() {
@@ -439,7 +436,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_foregroundDrawable.
+ * component, will used this image in place of the provided or default mapbox_foregroundDrawable.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -456,7 +453,7 @@ public class LocationComponentOptions implements Parcelable {
* Defines the drawable used for the background state icon.
*
* @return the drawable resource ID
- * @attr ref R.styleable#LocationLayer_backgroundDrawable
+ * @attr ref R.styleable#LocationComponent_backgroundDrawable
*/
@DrawableRes
public int backgroundDrawable() {
@@ -466,7 +463,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_backgroundDrawable.
+ * component, will used this image in place of the provided or default mapbox_backgroundDrawable.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -483,7 +480,7 @@ public class LocationComponentOptions implements Parcelable {
* Defines the drawable used for the bearing icon.
*
* @return the drawable resource ID
- * @attr ref R.styleable#LocationLayer_bearingDrawable
+ * @attr ref R.styleable#LocationComponent_bearingDrawable
*/
@DrawableRes
public int bearingDrawable() {
@@ -493,7 +490,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_bearingDrawable.
+ * component, will used this image in place of the provided or default mapbox_bearingDrawable.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -510,7 +507,7 @@ public class LocationComponentOptions implements Parcelable {
* Defines the bearing icon color as an integer.
*
* @return the color integer resource
- * @attr ref R.styleable#LocationLayer_bearingTintColor
+ * @attr ref R.styleable#LocationComponent_bearingTintColor
*/
@ColorInt
@Nullable
@@ -522,7 +519,7 @@ public class LocationComponentOptions implements Parcelable {
* Defines the foreground color as an integer.
*
* @return the color integer resource
- * @attr ref R.styleable#LocationLayer_foregroundTintColor
+ * @attr ref R.styleable#LocationComponent_foregroundTintColor
*/
@ColorInt
@Nullable
@@ -534,7 +531,7 @@ public class LocationComponentOptions implements Parcelable {
* Defines the background color as an integer.
*
* @return the color integer resource
- * @attr ref R.styleable#LocationLayer_backgroundTintColor
+ * @attr ref R.styleable#LocationComponent_backgroundTintColor
*/
@ColorInt
@Nullable
@@ -546,7 +543,7 @@ public class LocationComponentOptions implements Parcelable {
* Defines the foreground stale color as an integer.
*
* @return the color integer resource
- * @attr ref R.styleable#LocationLayer_foregroundStaleTintColor
+ * @attr ref R.styleable#LocationComponent_foregroundStaleTintColor
*/
@ColorInt
@Nullable
@@ -558,7 +555,7 @@ public class LocationComponentOptions implements Parcelable {
* Defines the background stale color as an integer.
*
* @return the color integer resource
- * @attr ref R.styleable#LocationLayer_backgroundStaleTintColor
+ * @attr ref R.styleable#LocationComponent_backgroundStaleTintColor
*/
@ColorInt
@Nullable
@@ -569,8 +566,8 @@ public class LocationComponentOptions implements Parcelable {
/**
* Sets the base elevation of this view, in pixels.
*
- * @return the elevation currently set for the location layer icon
- * @attr ref R.styleable#LocationLayer_elevation
+ * @return the elevation currently set for the location component icon
+ * @attr ref R.styleable#LocationComponent_elevation
*/
@Dimension
public float elevation() {
@@ -582,7 +579,7 @@ public class LocationComponentOptions implements Parcelable {
* displayed on the map hasn't been updated in a specific amount of time.
*
* @return whether the stale state mode is enabled or not
- * @attr ref R.styleable#LocationLayer_enableStaleState
+ * @attr ref R.styleable#LocationComponent_enableStaleState
*/
public boolean enableStaleState() {
return enableStaleState;
@@ -593,9 +590,9 @@ public class LocationComponentOptions implements Parcelable {
* location update comes in and using this defined time, if an update hasn't occured by the end,
* the location is considered stale.
*
- * @return the duration in milliseconds which it should take before the location layer is
+ * @return the duration in milliseconds which it should take before the location is
* considered stale
- * @attr ref R.styleable#LocationLayer_staleStateDelay
+ * @attr ref R.styleable#LocationComponent_staleStateDelay
*/
public long staleStateTimeout() {
return staleStateTimeout;
@@ -694,9 +691,9 @@ public class LocationComponentOptions implements Parcelable {
}
/**
- * Gets the id of the layer to add the location layer above to.
+ * Gets the id of the layer to add the location component above to.
*
- * @return layerBelow the id of the layer to add the location layer above to
+ * @return layerBelow the id of the layer to add the location component above to
*/
public String layerBelow() {
return layerBelow;
@@ -1099,7 +1096,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param accuracyAlpha the opacity of the accuracy view
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_accuracyAlpha
+ * @attr ref R.styleable#LocationComponent_accuracyAlpha
*/
public LocationComponentOptions.Builder accuracyAlpha(float accuracyAlpha) {
this.accuracyAlpha = accuracyAlpha;
@@ -1111,7 +1108,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param accuracyColor the color of the accuracy view
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_accuracyColor
+ * @attr ref R.styleable#LocationComponent_accuracyColor
*/
public LocationComponentOptions.Builder accuracyColor(int accuracyColor) {
this.accuracyColor = accuracyColor;
@@ -1123,7 +1120,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param backgroundDrawableStale the drawable resource ID
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_backgroundDrawableStale
+ * @attr ref R.styleable#LocationComponent_backgroundDrawableStale
*/
public LocationComponentOptions.Builder backgroundDrawableStale(int backgroundDrawableStale) {
this.backgroundDrawableStale = backgroundDrawableStale;
@@ -1133,7 +1130,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* Given a String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_backgroundDrawableStale.
+ * component, will used this image in place of the provided or default mapbox_backgroundDrawableStale.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -1152,7 +1149,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param foregroundDrawableStale the drawable resource ID
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_foregroundDrawableStale
+ * @attr ref R.styleable#LocationComponent_foregroundDrawableStale
*/
public LocationComponentOptions.Builder foregroundDrawableStale(int foregroundDrawableStale) {
this.foregroundDrawableStale = foregroundDrawableStale;
@@ -1162,7 +1159,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* Given a String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_foregroundDrawableStale.
+ * component, will used this image in place of the provided or default mapbox_foregroundDrawableStale.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -1181,7 +1178,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param gpsDrawable the drawable resource ID
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_gpsDrawable
+ * @attr ref R.styleable#LocationComponent_gpsDrawable
*/
public LocationComponentOptions.Builder gpsDrawable(int gpsDrawable) {
this.gpsDrawable = gpsDrawable;
@@ -1191,7 +1188,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* Given a String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_gpsDrawable.
+ * component, will used this image in place of the provided or default mapbox_gpsDrawable.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -1206,12 +1203,11 @@ public class LocationComponentOptions implements Parcelable {
}
/**
- * Supply a Drawable that is to be rendered on top of all of the content in the Location Layer
- * Plugin layer stack.
+ * Supply a Drawable that is to be rendered on top of all of the content in the Location Component layer stack.
*
* @param foregroundDrawable the drawable resource used for the foreground layer
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_foregroundDrawable
+ * @attr ref R.styleable#LocationComponent_foregroundDrawable
*/
public LocationComponentOptions.Builder foregroundDrawable(int foregroundDrawable) {
this.foregroundDrawable = foregroundDrawable;
@@ -1221,7 +1217,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* Given a String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_foregroundDrawable.
+ * component, will used this image in place of the provided or default mapbox_foregroundDrawable.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -1240,7 +1236,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param backgroundDrawable the drawable resource ID
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_backgroundDrawable
+ * @attr ref R.styleable#LocationComponent_backgroundDrawable
*/
public LocationComponentOptions.Builder backgroundDrawable(int backgroundDrawable) {
this.backgroundDrawable = backgroundDrawable;
@@ -1250,7 +1246,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* Given a String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_backgroundDrawable.
+ * component, will used this image in place of the provided or default mapbox_backgroundDrawable.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -1269,7 +1265,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param bearingDrawable the drawable resource ID
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_bearingDrawable
+ * @attr ref R.styleable#LocationComponent_bearingDrawable
*/
public LocationComponentOptions.Builder bearingDrawable(int bearingDrawable) {
this.bearingDrawable = bearingDrawable;
@@ -1279,7 +1275,7 @@ public class LocationComponentOptions implements Parcelable {
/**
* Given a String image name, identical to one used in
* the first parameter of {@link com.mapbox.mapboxsdk.maps.MapboxMap#addImage(String, Bitmap)}, the
- * plugin, will used this image in place of the provided or default mapbox_bearingDrawable.
+ * component, will used this image in place of the provided or default mapbox_bearingDrawable.
* <p>
* A maki-icon name (example: "circle-15") may also be provided. These are images that can be loaded
* with certain styles. Note, this will fail if the provided icon name is not provided by the loaded map style.
@@ -1298,7 +1294,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param bearingTintColor the color integer resource
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_bearingTintColor
+ * @attr ref R.styleable#LocationComponent_bearingTintColor
*/
public LocationComponentOptions.Builder bearingTintColor(@Nullable Integer bearingTintColor) {
this.bearingTintColor = bearingTintColor;
@@ -1310,7 +1306,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param foregroundTintColor the color integer resource
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_foregroundTintColor
+ * @attr ref R.styleable#LocationComponent_foregroundTintColor
*/
public LocationComponentOptions.Builder foregroundTintColor(@Nullable Integer foregroundTintColor) {
this.foregroundTintColor = foregroundTintColor;
@@ -1322,7 +1318,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param backgroundTintColor the color integer resource
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_backgroundTintColor
+ * @attr ref R.styleable#LocationComponent_backgroundTintColor
*/
public LocationComponentOptions.Builder backgroundTintColor(@Nullable Integer backgroundTintColor) {
this.backgroundTintColor = backgroundTintColor;
@@ -1334,7 +1330,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param foregroundStaleTintColor the color integer resource
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_foregroundStaleTintColor
+ * @attr ref R.styleable#LocationComponent_foregroundStaleTintColor
*/
public LocationComponentOptions.Builder foregroundStaleTintColor(@Nullable Integer foregroundStaleTintColor) {
this.foregroundStaleTintColor = foregroundStaleTintColor;
@@ -1346,7 +1342,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param backgroundStaleTintColor the color integer resource
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_backgroundStaleTintColor
+ * @attr ref R.styleable#LocationComponent_backgroundStaleTintColor
*/
public LocationComponentOptions.Builder backgroundStaleTintColor(@Nullable Integer backgroundStaleTintColor) {
this.backgroundStaleTintColor = backgroundStaleTintColor;
@@ -1356,9 +1352,9 @@ public class LocationComponentOptions implements Parcelable {
/**
* Sets the base elevation of this view, in pixels.
*
- * @param elevation the elevation currently set for the location layer icon
+ * @param elevation the elevation currently set for the location icon
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_elevation
+ * @attr ref R.styleable#LocationComponent_elevation
*/
public LocationComponentOptions.Builder elevation(float elevation) {
this.elevation = elevation;
@@ -1371,7 +1367,7 @@ public class LocationComponentOptions implements Parcelable {
*
* @param enabled whether the stale state mode is enabled or not
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_enableStaleState
+ * @attr ref R.styleable#LocationComponent_enableStaleState
*/
public LocationComponentOptions.Builder enableStaleState(boolean enabled) {
this.enableStaleState = enabled;
@@ -1383,10 +1379,10 @@ public class LocationComponentOptions implements Parcelable {
* new location update comes in and using this defined time, if an update hasn't occurred by the
* end, the location is considered stale.
*
- * @param timeout the duration in milliseconds which it should take before the location layer is
+ * @param timeout the duration in milliseconds which it should take before the location is
* considered stale
* @return this builder for chaining options together
- * @attr ref R.styleable#LocationLayer_staleStateTimeout
+ * @attr ref R.styleable#LocationComponent_staleStateTimeout
*/
public LocationComponentOptions.Builder staleStateTimeout(long timeout) {
this.staleStateTimeout = timeout;
@@ -1506,9 +1502,9 @@ public class LocationComponentOptions implements Parcelable {
}
/**
- * Sets the layer id to set the location layer plugin below to.
+ * Sets the layer id to set the location component below to.
*
- * @param layerBelow the id to set the location layer plugin below to.
+ * @param layerBelow the id to set the location component below to.
*/
public LocationComponentOptions.Builder layerBelow(String layerBelow) {
this.layerBelow = layerBelow;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationClickListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationClickListener.java
new file mode 100644
index 0000000000..fdd2aeb811
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationClickListener.java
@@ -0,0 +1,14 @@
+package com.mapbox.mapboxsdk.location;
+
+/**
+ * The Location Component exposes an API for listening to when the user clicks on the location
+ * layer icon visible on the map. When this event occurs, the {@link #onLocationComponentClick()} method
+ * gets invoked.
+ */
+public interface OnLocationClickListener {
+
+ /**
+ * Called whenever user clicks on the location layer drawn on the map.
+ */
+ void onLocationComponentClick();
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationComponentClickListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationComponentClickListener.java
deleted file mode 100644
index c592ae3a25..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationComponentClickListener.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.mapbox.mapboxsdk.location;
-
-/**
- * The Location Layer Plugin exposes an API for listening to when the user clicks on the location
- * layer icon visible on the map. when this event occurs, the {@link #onLocationComponentClick()} method
- * gets invoked.
- */
-public interface OnLocationComponentClickListener {
-
- void onLocationComponentClick();
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationComponentLongClickListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationComponentLongClickListener.java
deleted file mode 100644
index dc63e48a58..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationComponentLongClickListener.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.mapbox.mapboxsdk.location;
-
-/**
- * The Location Layer Plugin exposes an API for listening to when the user long clicks on the location
- * layer icon visible on the map. when this event occurs, the {@link #onLocationComponentLongClick()} method
- * gets invoked.
- */
-public interface OnLocationComponentLongClickListener {
-
- void onLocationComponentLongClick();
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationLongClickListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationLongClickListener.java
new file mode 100644
index 0000000000..0c34614f3e
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationLongClickListener.java
@@ -0,0 +1,14 @@
+package com.mapbox.mapboxsdk.location;
+
+/**
+ * The Location Component exposes an API for listening to when the user long clicks on the location
+ * layer icon visible on the map. when this event occurs, the {@link #onLocationComponentLongClick()} method
+ * gets invoked.
+ */
+public interface OnLocationLongClickListener {
+
+ /**
+ * Called whenever user long clicks on the location layer drawn on the map.
+ */
+ void onLocationComponentLongClick();
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationStaleListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationStaleListener.java
index d42eddf277..6bbe7f34b3 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationStaleListener.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/OnLocationStaleListener.java
@@ -9,5 +9,9 @@ package com.mapbox.mapboxsdk.location;
*/
public interface OnLocationStaleListener {
+ /**
+ * Called when the stale state changes.
+ * @param isStale true if location is stale, false otherwise
+ */
void onStaleStateChange(boolean isStale);
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/StaleStateManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/StaleStateManager.java
index c2d50610fa..c8f6ed58b9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/StaleStateManager.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/StaleStateManager.java
@@ -3,9 +3,9 @@ package com.mapbox.mapboxsdk.location;
import android.os.Handler;
/**
- * Class controls the location layer stale state when the {@link android.location.Location} hasn't
+ * Class controls the location stale state when the {@link android.location.Location} hasn't
* been updated in 'x' amount of time. {@link LocationComponentOptions#staleStateTimeout()} can be used to
- * control the amount of time before the locations considered stale.
+ * control the amount of time before the location's considered stale.
* {@link LocationComponentOptions#enableStaleState()} is available for disabling this behaviour.
*/
class StaleStateManager {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java
index aa01c914dd..ff0a9ce193 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java
@@ -23,20 +23,20 @@ public final class Utils {
}
/**
- * Util for finding the shortest path from the current icon rotated degree to the new degree.
+ * Util for finding the shortest path from the current rotated degree to the new degree.
*
- * @param magneticHeading the new position of the rotation
- * @param previousMagneticHeading the current position of the rotation
+ * @param heading the new position of the rotation
+ * @param previousHeading the current position of the rotation
* @return the shortest degree of rotation possible
*/
- public static float shortestRotation(float magneticHeading, float previousMagneticHeading) {
- double diff = previousMagneticHeading - magneticHeading;
+ public static float shortestRotation(float heading, float previousHeading) {
+ double diff = previousHeading - heading;
if (diff > 180.0f) {
- magneticHeading += 360.0f;
+ heading += 360.0f;
} else if (diff < -180.0f) {
- magneticHeading -= 360.f;
+ heading -= 360.f;
}
- return magneticHeading;
+ return heading;
}
static Bitmap getBitmapFromDrawable(Drawable drawable) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/ZoomAnimator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/ZoomAnimator.java
index 204a1457dc..323b51fa88 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/ZoomAnimator.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/ZoomAnimator.java
@@ -25,5 +25,4 @@ class ZoomAnimator extends MapboxCameraAnimatorAdapter {
listener.onNewZoomValue((Float) animation.getAnimatedValue());
}
}
-
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/modes/RenderMode.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/modes/RenderMode.java
index 0f7fa24008..3d20313dfe 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/modes/RenderMode.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/modes/RenderMode.java
@@ -19,7 +19,7 @@ public final class RenderMode {
/**
* One of these constants should be used with {@link LocationComponent#setRenderMode(int)}.
- * mode can be switched at anytime by calling the {@code setLocationLayerMode} method passing
+ * Mode can be switched at anytime by calling the {@code setLocationLayerMode} method passing
* in the new mode you'd like the location layer to be in.
*/
@IntDef( {COMPASS, GPS, NORMAL})
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 60cf9bb31d..73495f78e7 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
@@ -200,7 +200,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
compassView.setOnClickListener(createCompassClickListener(cameraChangeDispatcher));
// LocationComponent
- mapboxMap.injectLocationComponent(new LocationComponent(context, mapboxMap));
+ mapboxMap.injectLocationComponent(new LocationComponent(mapboxMap));
// inject widgets with MapboxMap
attrView.setOnClickListener(new AttributionClickListener(context, mapboxMap));
@@ -1224,7 +1224,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
@Override
public void onMapChanged(@MapChange int change) {
- if (change == WILL_START_LOADING_MAP) {
+ if (change == WILL_START_LOADING_MAP && !initialLoad) {
mapboxMap.onStartLoadingMap();
} else if (change == DID_FINISH_LOADING_STYLE) {
if (initialLoad) {
@@ -1232,8 +1232,9 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
mapboxMap.onPreMapReady();
onMapReady();
mapboxMap.onPostMapReady();
+ } else {
+ mapboxMap.onFinishLoadingStyle();
}
- mapboxMap.onFinishLoadingStyle();
} else if (change == DID_FINISH_RENDERING_FRAME || change == DID_FINISH_RENDERING_FRAME_FULLY_RENDERED) {
mapboxMap.onUpdateFullyRendered();
} else if (change == REGION_IS_CHANGING || change == REGION_DID_CHANGE || change == DID_FINISH_LOADING_MAP) {
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 688b90eb8e..c1392be731 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
@@ -42,8 +42,8 @@ import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
-import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.location.LocationComponent;
+import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.light.Light;
@@ -132,7 +132,6 @@ public final class MapboxMap {
outState.putBoolean(MapboxConstants.STATE_DEBUG_ACTIVE, nativeMapView.getDebug());
outState.putString(MapboxConstants.STATE_STYLE_URL, nativeMapView.getStyleUrl());
uiSettings.onSaveInstanceState(outState);
- locationComponent.onSaveInstanceState(outState);
}
/**
@@ -157,7 +156,6 @@ public final class MapboxMap {
if (!TextUtils.isEmpty(styleUrl)) {
nativeMapView.setStyleUrl(savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL));
}
- locationComponent.onRestoreInstanceState(savedInstanceState);
}
/**
@@ -2319,8 +2317,14 @@ public final class MapboxMap {
}
/**
- * Returns an object that can be used to display user's location on the Map.
- * @return the location layer
+ * Returns the {@link LocationComponent} that can be used to display user's location on the map.
+ * <p>
+ * Use {@link LocationComponent#activateLocationComponent(Context)} or any overload to activate the component,
+ * then, enable it with {@link LocationComponent#setLocationComponentEnabled(boolean)}.
+ * <p>
+ * You can customize the location icon and more with {@link com.mapbox.mapboxsdk.location.LocationComponentOptions}.
+ *
+ * @return the Location Component
*/
@NonNull
public LocationComponent getLocationComponent() {