[android] updated naming scheme and packages structure for LocationLayerPlugin, now called LocationComponent

This commit is contained in:
Łukasz Paczos
2018-09-05 14:30:36 +02:00
committed by Łukasz Paczos
parent cf7752c80c
commit 907612e93d
64 changed files with 1399 additions and 1399 deletions

View File

@@ -1,10 +1,10 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.ValueAnimator;
import java.util.List;
class CameraCompassBearingAnimator extends PluginFloatAnimator<PluginAnimator.OnCameraAnimationsValuesChangeListener> {
class CameraCompassBearingAnimator extends MapboxFloatAnimator<MapboxAnimator.OnCameraAnimationsValuesChangeListener> {
CameraCompassBearingAnimator(Float previous, Float target,
List<OnCameraAnimationsValuesChangeListener> updateListeners) {
super(previous, target, updateListeners);

View File

@@ -1,10 +1,10 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.ValueAnimator;
import java.util.List;
class CameraGpsBearingAnimator extends PluginFloatAnimator<PluginAnimator.OnCameraAnimationsValuesChangeListener> {
class CameraGpsBearingAnimator extends MapboxFloatAnimator<MapboxAnimator.OnCameraAnimationsValuesChangeListener> {
CameraGpsBearingAnimator(Float previous, Float target, List<OnCameraAnimationsValuesChangeListener> updateListeners) {
super(previous, target, updateListeners);
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.ValueAnimator;
@@ -6,7 +6,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import java.util.List;
class CameraLatLngAnimator extends PluginLatLngAnimator<PluginAnimator.OnCameraAnimationsValuesChangeListener> {
class CameraLatLngAnimator extends MapboxLatLngAnimator<MapboxAnimator.OnCameraAnimationsValuesChangeListener> {
CameraLatLngAnimator(LatLng previous, LatLng target, List<OnCameraAnimationsValuesChangeListener> updateListeners) {
super(previous, target, updateListeners);
}

View File

@@ -1,12 +1,15 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.support.annotation.NonNull;
import com.mapbox.mapboxsdk.location.modes.CameraMode;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
/**
* Interface defining the source of compass heading data that is
* consumed by the {@link LocationLayerPlugin} when in compass related
* {@link com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode} or
* {@link com.mapbox.mapboxsdk.plugins.locationlayer.modes.CameraMode}s.
* consumed by the {@link LocationComponent} when in compass related
* {@link RenderMode} or
* {@link CameraMode}s.
*/
public interface CompassEngine {

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
/**
* Callbacks related to the compass
@@ -7,7 +7,7 @@ public interface CompassListener {
/**
* Callback's invoked when a new compass update occurs. You can listen into the compass updates
* using {@link LocationLayerPlugin#addCompassListener(CompassListener)} and implementing these
* using {@link LocationComponent#addCompassListener(CompassListener)} and implementing these
* callbacks. Note that this interface is also used internally to to update the UI chevron/arrow.
*
* @param userHeading the new compass heading

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.TypeEvaluator;

View File

@@ -1,10 +1,10 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.ValueAnimator;
import java.util.List;
class LayerAccuracyAnimator extends PluginFloatAnimator<PluginAnimator.OnLayerAnimationsValuesChangeListener> {
class LayerAccuracyAnimator extends MapboxFloatAnimator<MapboxAnimator.OnLayerAnimationsValuesChangeListener> {
LayerAccuracyAnimator(Float previous, Float target, List<OnLayerAnimationsValuesChangeListener> updateListeners) {
super(previous, target, updateListeners);

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.content.Context;
import android.graphics.Bitmap;
@@ -9,9 +9,9 @@ import android.support.v4.content.ContextCompat;
import com.mapbox.mapboxsdk.R;
import static com.mapbox.mapboxsdk.plugins.locationlayer.Utils.generateShadow;
import static com.mapbox.mapboxsdk.plugins.locationlayer.Utils.getBitmapFromDrawable;
import static com.mapbox.mapboxsdk.plugins.locationlayer.Utils.getDrawable;
import static com.mapbox.mapboxsdk.location.Utils.generateShadow;
import static com.mapbox.mapboxsdk.location.Utils.getBitmapFromDrawable;
import static com.mapbox.mapboxsdk.location.Utils.getDrawable;
class LayerBitmapProvider {
@@ -26,7 +26,7 @@ class LayerBitmapProvider {
return getBitmapFromDrawable(drawable);
}
Bitmap generateShadowBitmap(LocationLayerOptions options) {
Bitmap generateShadowBitmap(LocationComponentOptions options) {
Drawable shadowDrawable = ContextCompat.getDrawable(context, R.drawable.mapbox_user_icon_shadow);
return generateShadow(shadowDrawable, options.elevation());
}

View File

@@ -1,10 +1,10 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.ValueAnimator;
import java.util.List;
class LayerCompassBearingAnimator extends PluginFloatAnimator<PluginAnimator.OnLayerAnimationsValuesChangeListener> {
class LayerCompassBearingAnimator extends MapboxFloatAnimator<MapboxAnimator.OnLayerAnimationsValuesChangeListener> {
LayerCompassBearingAnimator(Float previous,
Float target, List<OnLayerAnimationsValuesChangeListener> updateListeners) {
super(previous, target, updateListeners);

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -6,14 +6,14 @@ import android.support.annotation.Nullable;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.Point;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_GPS_BEARING;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_LOCATION_STALE;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_GPS_BEARING;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_LOCATION_STALE;
class LayerFeatureProvider {
@NonNull
Feature generateLocationFeature(@Nullable Feature locationFeature, LocationLayerOptions options) {
Feature generateLocationFeature(@Nullable Feature locationFeature, LocationComponentOptions options) {
if (locationFeature != null) {
return locationFeature;
}

View File

@@ -1,10 +1,10 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.ValueAnimator;
import java.util.List;
class LayerGpsBearingAnimator extends PluginFloatAnimator<PluginAnimator.OnLayerAnimationsValuesChangeListener> {
class LayerGpsBearingAnimator extends MapboxFloatAnimator<MapboxAnimator.OnLayerAnimationsValuesChangeListener> {
LayerGpsBearingAnimator(Float previous, Float target, List<OnLayerAnimationsValuesChangeListener> updateListeners) {
super(previous, target, updateListeners);
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.ValueAnimator;
@@ -6,7 +6,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import java.util.List;
class LayerLatLngAnimator extends PluginLatLngAnimator<PluginAnimator.OnLayerAnimationsValuesChangeListener> {
class LayerLatLngAnimator extends MapboxLatLngAnimator<MapboxAnimator.OnLayerAnimationsValuesChangeListener> {
LayerLatLngAnimator(LatLng previous, LatLng target, List<OnLayerAnimationsValuesChangeListener> updateListeners) {
super(previous, target, updateListeners);
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import com.mapbox.geojson.Feature;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
@@ -8,26 +8,26 @@ import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.ACCURACY_LAYER;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BACKGROUND_LAYER;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BEARING_LAYER;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.FOREGROUND_LAYER;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.LOCATION_SOURCE;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_ACCURACY_ALPHA;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_ACCURACY_COLOR;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_ACCURACY_RADIUS;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_BACKGROUND_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_BACKGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_BEARING_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_FOREGROUND_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_FOREGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_GPS_BEARING;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_LOCATION_STALE;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_SHADOW_ICON_OFFSET;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.SHADOW_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.SHADOW_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.ACCURACY_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.LOCATION_SOURCE;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_ALPHA;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_COLOR;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_RADIUS;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BACKGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BACKGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BEARING_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_GPS_BEARING;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_LOCATION_STALE;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_SHADOW_ICON_OFFSET;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_LAYER;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.match;

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -18,46 +18,46 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.ACCURACY_RADIUS_ANIMATION_DURATION;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.COMPASS_UPDATE_RATE_MS;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.MAX_ANIMATION_DURATION_MS;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.TRANSITION_ANIMATION_DURATION_MS;
import static com.mapbox.mapboxsdk.plugins.locationlayer.PluginAnimator.ANIMATOR_CAMERA_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.plugins.locationlayer.PluginAnimator.ANIMATOR_CAMERA_GPS_BEARING;
import static com.mapbox.mapboxsdk.plugins.locationlayer.PluginAnimator.ANIMATOR_CAMERA_LATLNG;
import static com.mapbox.mapboxsdk.plugins.locationlayer.PluginAnimator.ANIMATOR_LAYER_ACCURACY;
import static com.mapbox.mapboxsdk.plugins.locationlayer.PluginAnimator.ANIMATOR_LAYER_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.plugins.locationlayer.PluginAnimator.ANIMATOR_LAYER_GPS_BEARING;
import static com.mapbox.mapboxsdk.plugins.locationlayer.PluginAnimator.ANIMATOR_LAYER_LATLNG;
import static com.mapbox.mapboxsdk.plugins.locationlayer.PluginAnimator.ANIMATOR_TILT;
import static com.mapbox.mapboxsdk.plugins.locationlayer.PluginAnimator.ANIMATOR_ZOOM;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.ACCURACY_RADIUS_ANIMATION_DURATION;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.COMPASS_UPDATE_RATE_MS;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.MAX_ANIMATION_DURATION_MS;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.TRANSITION_ANIMATION_DURATION_MS;
import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_CAMERA_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_CAMERA_GPS_BEARING;
import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_CAMERA_LATLNG;
import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_LAYER_ACCURACY;
import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_LAYER_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_LAYER_GPS_BEARING;
import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_LAYER_LATLNG;
import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_TILT;
import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_ZOOM;
final class PluginAnimatorCoordinator {
final class LocationAnimatorCoordinator {
@SuppressLint("UseSparseArrays")
final Map<Integer, PluginAnimator> animatorMap = new HashMap<>();
final Map<Integer, MapboxAnimator> animatorMap = new HashMap<>();
final List<PluginAnimator.OnLayerAnimationsValuesChangeListener> layerListeners = new ArrayList<>();
final List<PluginAnimator.OnCameraAnimationsValuesChangeListener> cameraListeners = new ArrayList<>();
final List<MapboxAnimator.OnLayerAnimationsValuesChangeListener> layerListeners = new ArrayList<>();
final List<MapboxAnimator.OnCameraAnimationsValuesChangeListener> cameraListeners = new ArrayList<>();
private Location previousLocation;
private float previousAccuracyRadius = -1;
private float previousCompassBearing = -1;
private long locationUpdateTimestamp = -1;
void addLayerListener(PluginAnimator.OnLayerAnimationsValuesChangeListener listener) {
void addLayerListener(MapboxAnimator.OnLayerAnimationsValuesChangeListener listener) {
layerListeners.add(listener);
}
void removeLayerListener(PluginAnimator.OnLayerAnimationsValuesChangeListener listener) {
void removeLayerListener(MapboxAnimator.OnLayerAnimationsValuesChangeListener listener) {
layerListeners.remove(listener);
}
void addCameraListener(PluginAnimator.OnCameraAnimationsValuesChangeListener listener) {
void addCameraListener(MapboxAnimator.OnCameraAnimationsValuesChangeListener listener) {
cameraListeners.add(listener);
}
void removeCameraListener(PluginAnimator.OnCameraAnimationsValuesChangeListener listener) {
void removeCameraListener(MapboxAnimator.OnCameraAnimationsValuesChangeListener listener) {
cameraListeners.remove(listener);
}
@@ -126,7 +126,7 @@ final class PluginAnimatorCoordinator {
private LatLng getPreviousLayerLatLng() {
LatLng previousLatLng;
PluginAnimator latLngAnimator = animatorMap.get(ANIMATOR_LAYER_LATLNG);
MapboxAnimator latLngAnimator = animatorMap.get(ANIMATOR_LAYER_LATLNG);
if (latLngAnimator != null) {
previousLatLng = (LatLng) latLngAnimator.getAnimatedValue();
} else {
@@ -265,19 +265,19 @@ final class PluginAnimatorCoordinator {
}
private void playAccuracyAnimator(long duration) {
PluginAnimator animator = animatorMap.get(ANIMATOR_LAYER_ACCURACY);
MapboxAnimator animator = animatorMap.get(ANIMATOR_LAYER_ACCURACY);
animator.setDuration(duration);
animator.start();
}
private void playZoomAnimator(long duration) {
PluginAnimator animator = animatorMap.get(ANIMATOR_ZOOM);
MapboxAnimator animator = animatorMap.get(ANIMATOR_ZOOM);
animator.setDuration(duration);
animator.start();
}
private void playTiltAnimator(long duration) {
PluginAnimator animator = animatorMap.get(ANIMATOR_TILT);
MapboxAnimator animator = animatorMap.get(ANIMATOR_TILT);
animator.setDuration(duration);
animator.start();
}
@@ -344,7 +344,7 @@ final class PluginAnimatorCoordinator {
new CameraCompassBearingAnimator(previousCameraBearing, normalizedCameraBearing, cameraListeners));
}
private void createNewAnimator(@PluginAnimator.Type int animatorType, PluginAnimator animator) {
private void createNewAnimator(@MapboxAnimator.Type int animatorType, MapboxAnimator animator) {
cancelAnimator(animatorType);
animatorMap.put(animatorType, animator);
}
@@ -358,13 +358,13 @@ final class PluginAnimatorCoordinator {
}
void cancelAllAnimations() {
for (@PluginAnimator.Type int animatorType : animatorMap.keySet()) {
for (@MapboxAnimator.Type int animatorType : animatorMap.keySet()) {
cancelAnimator(animatorType);
}
}
private void cancelAnimator(@PluginAnimator.Type int animatorType) {
PluginAnimator animator = animatorMap.get(animatorType);
private void cancelAnimator(@MapboxAnimator.Type int animatorType) {
MapboxAnimator animator = animatorMap.get(animatorType);
if (animator != null) {
animator.cancel();
animator.removeAllUpdateListeners();

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.content.Context;
import android.graphics.PointF;
@@ -10,33 +10,33 @@ import com.mapbox.android.gestures.RotateGestureDetector;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.CameraMode;
import com.mapbox.mapboxsdk.location.modes.CameraMode;
import java.util.List;
import java.util.Set;
final class LocationLayerCamera implements PluginAnimator.OnCameraAnimationsValuesChangeListener {
final class LocationCameraController implements MapboxAnimator.OnCameraAnimationsValuesChangeListener {
@CameraMode.Mode
private int cameraMode;
private final MapboxMap mapboxMap;
private final OnCameraTrackingChangedListener internalCameraTrackingChangedListener;
private LocationLayerOptions options;
private LocationComponentOptions options;
private boolean adjustFocalPoint;
private final MoveGestureDetector moveGestureDetector;
private final OnCameraMoveInvalidateListener onCameraMoveInvalidateListener;
LocationLayerCamera(
LocationCameraController(
Context context,
MapboxMap mapboxMap,
OnCameraTrackingChangedListener internalCameraTrackingChangedListener,
LocationLayerOptions options,
LocationComponentOptions options,
OnCameraMoveInvalidateListener onCameraMoveInvalidateListener) {
this.mapboxMap = mapboxMap;
mapboxMap.setGesturesManager(
new PluginsGesturesManager(context), true, true);
new LocationGesturesManager(context), true, true);
moveGestureDetector = mapboxMap.getGesturesManager().getMoveGestureDetector();
mapboxMap.addOnMoveListener(onMoveListener);
mapboxMap.addOnRotateListener(onRotateListener);
@@ -48,17 +48,17 @@ final class LocationLayerCamera implements PluginAnimator.OnCameraAnimationsValu
}
// Package private for testing purposes
LocationLayerCamera(MapboxMap mapboxMap,
MoveGestureDetector moveGestureDetector,
OnCameraTrackingChangedListener internalCameraTrackingChangedListener,
OnCameraMoveInvalidateListener onCameraMoveInvalidateListener) {
LocationCameraController(MapboxMap mapboxMap,
MoveGestureDetector moveGestureDetector,
OnCameraTrackingChangedListener internalCameraTrackingChangedListener,
OnCameraMoveInvalidateListener onCameraMoveInvalidateListener) {
this.mapboxMap = mapboxMap;
this.moveGestureDetector = moveGestureDetector;
this.internalCameraTrackingChangedListener = internalCameraTrackingChangedListener;
this.onCameraMoveInvalidateListener = onCameraMoveInvalidateListener;
}
void initializeOptions(LocationLayerOptions options) {
void initializeOptions(LocationComponentOptions options) {
this.options = options;
}
@@ -230,22 +230,22 @@ final class LocationLayerCamera implements PluginAnimator.OnCameraAnimationsValu
}
};
private class PluginsGesturesManager extends AndroidGesturesManager {
private class LocationGesturesManager extends AndroidGesturesManager {
public PluginsGesturesManager(Context context) {
public LocationGesturesManager(Context context) {
super(context);
}
public PluginsGesturesManager(Context context, boolean applyDefaultThresholds) {
public LocationGesturesManager(Context context, boolean applyDefaultThresholds) {
super(context, applyDefaultThresholds);
}
public PluginsGesturesManager(Context context, Set<Integer>[] exclusiveGestures) {
public LocationGesturesManager(Context context, Set<Integer>[] exclusiveGestures) {
super(context, exclusiveGestures);
}
public PluginsGesturesManager(Context context, List<Set<Integer>> exclusiveGestures,
boolean applyDefaultThresholds) {
public LocationGesturesManager(Context context, List<Set<Integer>> exclusiveGestures,
boolean applyDefaultThresholds) {
super(context, exclusiveGestures, applyDefaultThresholds);
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -20,25 +20,25 @@ import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.location.modes.CameraMode;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener;
import com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveListener;
import com.mapbox.mapboxsdk.maps.MapboxMap.OnMapClickListener;
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.CameraMode;
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode;
import java.util.concurrent.CopyOnWriteArrayList;
import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.DEFAULT_TRACKING_TILT_ANIM_DURATION;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.DEFAULT_TRACKING_ZOOM_ANIM_DURATION;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.STATE_LOCATION_CAMERA_MODE;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.STATE_LOCATION_ENABLED;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.STATE_LOCATION_LAST_LOCATION;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.STATE_LOCATION_OPTIONS;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.STATE_LOCATION_RENDER_MODE;
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
@@ -48,13 +48,13 @@ import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.
* represented as a dot. {@link RenderMode#COMPASS} mode allows you to display an arrow icon
* (by default) that points in the direction the device is pointing in.
* {@link RenderMode#GPS} can be used in conjunction with our Navigation SDK to
* display a larger icon (customized with {@link LocationLayerOptions#gpsDrawable()}) we call the user puck.
* 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
* location. These different {@link CameraMode}s will track, stop tracking the location based on the
* mode set with {@link LocationLayerPlugin#setCameraMode(int)}.
* mode set with {@link LocationComponent#setCameraMode(int)}.
* <p>
* Lastly, {@link LocationLayerPlugin#setLocationLayerEnabled(boolean)} can be used
* Lastly, {@link LocationComponent#setLocationComponentEnabled(boolean)} can be used
* to disable the Location Layer but keep the instance around till the activity is destroyed.
* <p>
* Using this plugin requires you to request permission beforehand manually or using
@@ -63,8 +63,9 @@ import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.
* 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
* {@link LocationLayerOptions#MAX_ZOOM_DEFAULT} and {@link LocationLayerOptions#MIN_ZOOM_DEFAULT} respectively.
* You can adjust the zoom range with {@link LocationLayerOptions#maxZoom()} and {@link LocationLayerOptions#minZoom()}.
* {@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:
@@ -74,21 +75,21 @@ import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.
* <br/>
* - {@link CameraMode} and {@link RenderMode} will be restored.
* <br/>
* - {@link LocationLayerOptions} will be restored.
* - {@link LocationComponentOptions} will be restored.
*/
public final class LocationLayerPlugin {
private static final String TAG = "Mbgl-LocationLayerPlugin";
public final class LocationComponent {
private static final String TAG = "Mbgl-LocationComponent";
private final MapboxMap mapboxMap;
private LocationLayerOptions options;
private LocationComponentOptions options;
private LocationEngine locationEngine;
private CompassEngine compassEngine;
private boolean usingInternalLocationEngine;
private LocationLayer locationLayer;
private LocationLayerCamera locationLayerCamera;
private LocationLayerController locationLayerController;
private LocationCameraController locationCameraController;
private PluginAnimatorCoordinator pluginAnimatorCoordinator;
private LocationAnimatorCoordinator locationAnimatorCoordinator;
/**
* Holds last location which is being returned in the {@link #getLastKnownLocation()}
@@ -106,39 +107,39 @@ public final class LocationLayerPlugin {
/**
* Indicated that plugin's lifecycle {@link #onStart()} method has been called or the plugin is initialized..
* This allows Mapbox components enter started state and display data, and adds state safety for methods like
* {@link #setLocationLayerEnabled(boolean)}
* {@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 isPluginStarted;
private boolean isComponentStarted;
/**
* Indicates if Mapbox components are ready to be interacted with. This can differ from {@link #isPluginStarted}
* Indicates if Mapbox components are ready to be interacted with. This can differ from {@link #isComponentStarted}
* if the Mapbox style is being reloaded.
*/
private boolean isLocationLayerStarted;
private boolean isLayerReady;
private StaleStateManager staleStateManager;
private final CopyOnWriteArrayList<OnLocationStaleListener> onLocationStaleListeners
= new CopyOnWriteArrayList<>();
private final CopyOnWriteArrayList<OnLocationLayerClickListener> onLocationLayerClickListeners
private final CopyOnWriteArrayList<OnLocationComponentClickListener> onLocationComponentClickListeners
= new CopyOnWriteArrayList<>();
private final CopyOnWriteArrayList<OnLocationLayerLongClickListener> onLocationLayerLongClickListeners
private final CopyOnWriteArrayList<OnLocationComponentLongClickListener> onLocationComponentLongClickListeners
= new CopyOnWriteArrayList<>();
private final CopyOnWriteArrayList<OnCameraTrackingChangedListener> onCameraTrackingChangedListeners
= new CopyOnWriteArrayList<>();
/**
* Construct a LocationLayerPlugin. In order to display location,
* the location layer has to be activated with {@link LocationLayerPlugin#activateLocationLayerPlugin(Context)},
* 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 LocationLayerPlugin with
* @param mapboxMap the MapboxMap to apply the LocationComponent with
*/
public LocationLayerPlugin(@NonNull Context context, @NonNull MapboxMap mapboxMap) {
public LocationComponent(@NonNull Context context, @NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
options = LocationLayerOptions.createFromAttributes(context, R.style.mapbox_LocationLayer);
options = LocationComponentOptions.createFromAttributes(context, R.style.mapbox_LocationComponent);
initialize(context);
}
@@ -148,11 +149,11 @@ public final class LocationLayerPlugin {
*
* @param isEnabled true to show layers and enable camera, false otherwise
*/
private void setLocationLayerEnabled(boolean isEnabled) {
private void setLocationComponentEnabled(boolean isEnabled) {
if (isEnabled) {
enableLocationLayerPlugin();
enableLocationComponent();
} else {
disableLocationLayerPlugin();
disableLocationComponent();
}
}
@@ -164,9 +165,9 @@ public final class LocationLayerPlugin {
* @param context the context
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
public void activateLocationLayerPlugin(@NonNull Context context) {
activateLocationLayerPlugin(context, LocationLayerOptions.createFromAttributes(context, R.style
.mapbox_LocationLayer));
public void activateLocationComponent(@NonNull Context context) {
activateLocationComponent(context, LocationComponentOptions.createFromAttributes(context, R.style
.mapbox_LocationComponent));
}
/**
@@ -177,11 +178,11 @@ public final class LocationLayerPlugin {
* there should be no location engine initialized
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
public void activateLocationLayerPlugin(@NonNull Context context, boolean useDefaultLocationEngine) {
public void activateLocationComponent(@NonNull Context context, boolean useDefaultLocationEngine) {
if (useDefaultLocationEngine) {
activateLocationLayerPlugin(context, R.style.mapbox_LocationLayer);
activateLocationComponent(context, R.style.mapbox_LocationComponent);
} else {
activateLocationLayerPlugin(context, null, R.style.mapbox_LocationLayer);
activateLocationComponent(context, null, R.style.mapbox_LocationComponent);
}
}
@@ -191,11 +192,11 @@ public final class LocationLayerPlugin {
* <strong>Note</strong>: This method will initialize and use an internal {@link LocationEngine}.
*
* @param context the context
* @param styleRes the LocationLayerPlugin style res
* @param styleRes the LocationComponent style res
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
public void activateLocationLayerPlugin(@NonNull Context context, @StyleRes int styleRes) {
activateLocationLayerPlugin(context, LocationLayerOptions.createFromAttributes(context, styleRes));
public void activateLocationComponent(@NonNull Context context, @StyleRes int styleRes) {
activateLocationComponent(context, LocationComponentOptions.createFromAttributes(context, styleRes));
}
/**
@@ -208,10 +209,10 @@ public final class LocationLayerPlugin {
* @param options the options
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
public void activateLocationLayerPlugin(@NonNull Context context, @NonNull LocationLayerOptions options) {
public void activateLocationComponent(@NonNull Context context, @NonNull LocationComponentOptions options) {
applyStyle(options);
initializeLocationEngine(context);
setLocationLayerEnabled(true);
setLocationComponentEnabled(true);
}
/**
@@ -219,11 +220,11 @@ public final class LocationLayerPlugin {
*
* @param context the context
* @param locationEngine the engine, or null if you'd like to only force location updates
* @param styleRes the LocationLayerPlugin style res
* @param styleRes the LocationComponent style res
*/
public void activateLocationLayerPlugin(@NonNull Context context, @Nullable LocationEngine locationEngine,
@StyleRes int styleRes) {
activateLocationLayerPlugin(locationEngine, LocationLayerOptions.createFromAttributes(context, styleRes));
public void activateLocationComponent(@NonNull Context context, @Nullable LocationEngine locationEngine,
@StyleRes int styleRes) {
activateLocationComponent(locationEngine, LocationComponentOptions.createFromAttributes(context, styleRes));
}
/**
@@ -232,8 +233,8 @@ public final class LocationLayerPlugin {
* @param context the context
* @param locationEngine the engine
*/
public void activateLocationLayerPlugin(@NonNull Context context, @NonNull LocationEngine locationEngine) {
activateLocationLayerPlugin(context, locationEngine, R.style.mapbox_LocationLayer);
public void activateLocationComponent(@NonNull Context context, @NonNull LocationEngine locationEngine) {
activateLocationComponent(context, locationEngine, R.style.mapbox_LocationComponent);
}
/**
@@ -242,18 +243,18 @@ public final class LocationLayerPlugin {
* @param locationEngine the engine, or null if you'd like to only force location updates
* @param options the options
*/
public void activateLocationLayerPlugin(@Nullable LocationEngine locationEngine,
@NonNull LocationLayerOptions options) {
public void activateLocationComponent(@Nullable LocationEngine locationEngine,
@NonNull LocationComponentOptions options) {
setLocationEngine(locationEngine);
applyStyle(options);
setLocationLayerEnabled(true);
setLocationComponentEnabled(true);
}
/**
* This method will hide the location icon and disable the camera tracking the location.
*/
public void deactivateLocationLayerPlugin() {
setLocationLayerEnabled(false);
public void deactivateLocationComponent() {
setLocationComponentEnabled(false);
}
/**
@@ -281,9 +282,9 @@ public final class LocationLayerPlugin {
* @param cameraMode one of the modes found in {@link CameraMode}
*/
public void setCameraMode(@CameraMode.Mode int cameraMode) {
locationLayerCamera.setCameraMode(cameraMode);
locationCameraController.setCameraMode(cameraMode);
boolean isGpsNorth = cameraMode == CameraMode.TRACKING_GPS_NORTH;
pluginAnimatorCoordinator.resetAllCameraAnimations(mapboxMap.getCameraPosition(), isGpsNorth);
locationAnimatorCoordinator.resetAllCameraAnimations(mapboxMap.getCameraPosition(), isGpsNorth);
}
/**
@@ -294,7 +295,7 @@ public final class LocationLayerPlugin {
*/
@CameraMode.Mode
public int getCameraMode() {
return locationLayerCamera.getCameraMode();
return locationCameraController.getCameraMode();
}
/**
@@ -309,7 +310,7 @@ public final class LocationLayerPlugin {
* @param renderMode one of the modes found in {@link RenderMode}
*/
public void setRenderMode(@RenderMode.Mode int renderMode) {
locationLayer.setRenderMode(renderMode);
locationLayerController.setRenderMode(renderMode);
updateLayerOffsets(true);
}
@@ -321,35 +322,35 @@ public final class LocationLayerPlugin {
*/
@RenderMode.Mode
public int getRenderMode() {
return locationLayer.getRenderMode();
return locationLayerController.getRenderMode();
}
/**
* Returns the current location options being used.
*
* @return the current {@link LocationLayerOptions}
* @return the current {@link LocationComponentOptions}
*/
public LocationLayerOptions getLocationLayerOptions() {
public LocationComponentOptions getLocationComponentOptions() {
return options;
}
/**
* Apply a new LocationLayer style with a style resource.
* Apply a new LocationLayerController style with a style resource.
*
* @param styleRes a XML style overriding some or all the options
*/
public void applyStyle(@NonNull Context context, @StyleRes int styleRes) {
applyStyle(LocationLayerOptions.createFromAttributes(context, styleRes));
applyStyle(LocationComponentOptions.createFromAttributes(context, styleRes));
}
/**
* Apply a new LocationLayer style with location layer options.
* Apply a new LocationLayerController style with location layer options.
*
* @param options to update the current style
*/
public void applyStyle(LocationLayerOptions options) {
public void applyStyle(LocationComponentOptions options) {
this.options = options;
locationLayer.applyStyle(options);
locationLayerController.applyStyle(options);
staleStateManager.setEnabled(options.enableStaleState());
staleStateManager.setDelayTime(options.staleStateTimeout());
updateMapWithOptions(options);
@@ -368,15 +369,15 @@ public final class LocationLayerPlugin {
*/
public void zoomWhileTracking(double zoomLevel, long animationDuration,
@Nullable MapboxMap.CancelableCallback callback) {
if (!isLocationLayerStarted) {
if (!isLayerReady) {
return;
} else if (getCameraMode() == CameraMode.NONE) {
Logger.e(TAG, String.format("%s%s",
"LocationLayerPlugin#zoomWhileTracking method can only be used",
"LocationComponent#zoomWhileTracking method can only be used",
" when a camera mode other than CameraMode#NONE is engaged."));
return;
}
pluginAnimatorCoordinator.feedNewZoomLevel(zoomLevel, mapboxMap.getCameraPosition(), animationDuration, callback);
locationAnimatorCoordinator.feedNewZoomLevel(zoomLevel, mapboxMap.getCameraPosition(), animationDuration, callback);
}
/**
@@ -410,7 +411,7 @@ public final class LocationLayerPlugin {
* Cancels animation started by {@link #zoomWhileTracking(double, long, MapboxMap.CancelableCallback)}.
*/
public void cancelZoomWhileTrackingAnimation() {
pluginAnimatorCoordinator.cancelZoomAnimation();
locationAnimatorCoordinator.cancelZoomAnimation();
}
/**
@@ -426,15 +427,15 @@ public final class LocationLayerPlugin {
*/
public void tiltWhileTracking(double tilt, long animationDuration,
@Nullable MapboxMap.CancelableCallback callback) {
if (!isLocationLayerStarted) {
if (!isLayerReady) {
return;
} else if (getCameraMode() == CameraMode.NONE) {
Logger.e(TAG, String.format("%s%s",
"LocationLayerPlugin#tiltWhileTracking method can only be used",
"LocationComponent#tiltWhileTracking method can only be used",
" when a camera mode other than CameraMode#NONE is engaged."));
return;
}
pluginAnimatorCoordinator.feedNewTilt(tilt, mapboxMap.getCameraPosition(), animationDuration, callback);
locationAnimatorCoordinator.feedNewTilt(tilt, mapboxMap.getCameraPosition(), animationDuration, callback);
}
/**
@@ -468,7 +469,7 @@ public final class LocationLayerPlugin {
* Cancels animation started by {@link #tiltWhileTracking(double, long, MapboxMap.CancelableCallback)}.
*/
public void cancelTiltWhileTrackingAnimation() {
pluginAnimatorCoordinator.cancelTiltAnimation();
locationAnimatorCoordinator.cancelTiltAnimation();
}
/**
@@ -485,7 +486,7 @@ public final class LocationLayerPlugin {
* Set the location engine to update the current user location.
* <p>
* If {@code null} is passed in, all updates will occur through the
* {@link LocationLayerPlugin#forceLocationUpdate(Location)} method.
* {@link LocationComponent#forceLocationUpdate(Location)} method.
*
* @param locationEngine a {@link LocationEngine} this plugin should use to handle updates
*/
@@ -594,8 +595,8 @@ public final class LocationLayerPlugin {
* @param listener The location layer click listener that is invoked when the
* location layer is clicked
*/
public void addOnLocationClickListener(@NonNull OnLocationLayerClickListener listener) {
onLocationLayerClickListeners.add(listener);
public void addOnLocationClickListener(@NonNull OnLocationComponentClickListener listener) {
onLocationComponentClickListeners.add(listener);
}
/**
@@ -603,8 +604,8 @@ public final class LocationLayerPlugin {
*
* @param listener to be removed
*/
public void removeOnLocationClickListener(@NonNull OnLocationLayerClickListener listener) {
onLocationLayerClickListeners.remove(listener);
public void removeOnLocationClickListener(@NonNull OnLocationComponentClickListener listener) {
onLocationComponentClickListeners.remove(listener);
}
/**
@@ -613,8 +614,8 @@ public final class LocationLayerPlugin {
* @param listener The location layer click listener that is invoked when the
* location layer is clicked
*/
public void addOnLocationLongClickListener(@NonNull OnLocationLayerLongClickListener listener) {
onLocationLayerLongClickListeners.add(listener);
public void addOnLocationLongClickListener(@NonNull OnLocationComponentLongClickListener listener) {
onLocationComponentLongClickListeners.add(listener);
}
/**
@@ -622,8 +623,8 @@ public final class LocationLayerPlugin {
*
* @param listener to be removed
*/
public void removeOnLocationLongClickListener(@NonNull OnLocationLayerLongClickListener listener) {
onLocationLayerLongClickListeners.remove(listener);
public void removeOnLocationLongClickListener(@NonNull OnLocationComponentLongClickListener listener) {
onLocationComponentLongClickListeners.remove(listener);
}
/**
@@ -648,7 +649,7 @@ public final class LocationLayerPlugin {
* Adds the passed listener that gets invoked when user updates have stopped long enough for the last update
* to be considered stale.
* <p>
* This timeout is set by {@link LocationLayerOptions#staleStateTimeout()}.
* This timeout is set by {@link LocationComponentOptions#staleStateTimeout()}.
*
* @param listener invoked when last update is considered stale
*/
@@ -669,7 +670,7 @@ public final class LocationLayerPlugin {
* Internal use.
*/
public void onStart() {
isPluginStarted = true;
isComponentStarted = true;
onLocationLayerStart();
}
@@ -678,7 +679,7 @@ public final class LocationLayerPlugin {
*/
public void onStop() {
onLocationLayerStop();
isPluginStarted = false;
isComponentStarted = false;
}
/**
@@ -687,8 +688,8 @@ public final class LocationLayerPlugin {
public void onSaveInstanceState(@NonNull Bundle outState) {
outState.putBoolean(STATE_LOCATION_ENABLED, isEnabled);
outState.putParcelable(STATE_LOCATION_OPTIONS, options);
outState.putInt(STATE_LOCATION_RENDER_MODE, locationLayer.getRenderMode());
outState.putInt(STATE_LOCATION_CAMERA_MODE, locationLayerCamera.getCameraMode());
outState.putInt(STATE_LOCATION_RENDER_MODE, locationLayerController.getRenderMode());
outState.putInt(STATE_LOCATION_CAMERA_MODE, locationCameraController.getCameraMode());
outState.putParcelable(STATE_LOCATION_LAST_LOCATION, lastLocation);
}
@@ -700,7 +701,7 @@ public final class LocationLayerPlugin {
setCameraMode(savedInstanceState.getInt(STATE_LOCATION_CAMERA_MODE));
setRenderMode(savedInstanceState.getInt(STATE_LOCATION_RENDER_MODE));
applyStyle(savedInstanceState.getParcelable(STATE_LOCATION_OPTIONS));
setLocationLayerEnabled(savedInstanceState.getBoolean(STATE_LOCATION_ENABLED));
setLocationComponentEnabled(savedInstanceState.getBoolean(STATE_LOCATION_ENABLED));
}
/**
@@ -723,19 +724,19 @@ public final class LocationLayerPlugin {
* Internal use.
*/
public void onFinishLoadingStyle() {
locationLayer.initializeComponents(options);
locationLayerCamera.initializeOptions(options);
locationLayerController.initializeComponents(options);
locationCameraController.initializeOptions(options);
onLocationLayerStart();
}
@SuppressLint("MissingPermission")
private void onLocationLayerStart() {
if (!isPluginStarted) {
if (!isComponentStarted) {
return;
}
if (!isLocationLayerStarted) {
isLocationLayerStarted = true;
if (!isLayerReady) {
isLayerReady = true;
if (mapboxMap != null) {
mapboxMap.addOnCameraMoveListener(onCameraMoveListener);
mapboxMap.addOnCameraIdleListener(onCameraIdleListener);
@@ -753,22 +754,22 @@ public final class LocationLayerPlugin {
locationEngine.requestLocationUpdates();
}
}
setCameraMode(locationLayerCamera.getCameraMode());
setCameraMode(locationCameraController.getCameraMode());
setLastLocation();
setLastCompassHeading();
}
}
private void onLocationLayerStop() {
if (!isLocationLayerStarted || !isPluginStarted) {
if (!isLayerReady || !isComponentStarted) {
return;
}
isLocationLayerStarted = false;
locationLayer.hide();
isLayerReady = false;
locationLayerController.hide();
staleStateManager.onStop();
compassEngine.onStop();
pluginAnimatorCoordinator.cancelAllAnimations();
locationAnimatorCoordinator.cancelAllAnimations();
if (locationEngine != null) {
if (usingInternalLocationEngine) {
locationEngine.removeLocationUpdates();
@@ -790,16 +791,17 @@ public final class LocationLayerPlugin {
LayerSourceProvider sourceProvider = new LayerSourceProvider();
LayerFeatureProvider featureProvider = new LayerFeatureProvider();
LayerBitmapProvider bitmapProvider = new LayerBitmapProvider(context);
locationLayer = new LocationLayer(mapboxMap, sourceProvider, featureProvider, bitmapProvider, options);
locationLayerCamera = new LocationLayerCamera(
locationLayerController = new LocationLayerController(mapboxMap, sourceProvider, featureProvider, bitmapProvider,
options);
locationCameraController = new LocationCameraController(
context, mapboxMap, cameraTrackingChangedListener, options, onCameraMoveInvalidateListener);
pluginAnimatorCoordinator = new PluginAnimatorCoordinator();
pluginAnimatorCoordinator.addLayerListener(locationLayer);
pluginAnimatorCoordinator.addCameraListener(locationLayerCamera);
locationAnimatorCoordinator = new LocationAnimatorCoordinator();
locationAnimatorCoordinator.addLayerListener(locationLayerController);
locationAnimatorCoordinator.addCameraListener(locationCameraController);
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
compassEngine = new LocationLayerCompassEngine(windowManager, sensorManager);
compassEngine = new LocationComponentCompassEngine(windowManager, sensorManager);
compassEngine.addCompassListener(compassListener);
staleStateManager = new StaleStateManager(onLocationStaleListener, options);
@@ -826,17 +828,17 @@ public final class LocationLayerPlugin {
locationEngine.activate();
}
private void enableLocationLayerPlugin() {
private void enableLocationComponent() {
isEnabled = true;
onLocationLayerStart();
}
private void disableLocationLayerPlugin() {
private void disableLocationComponent() {
isEnabled = false;
onLocationLayerStop();
}
private void updateMapWithOptions(final LocationLayerOptions options) {
private void updateMapWithOptions(final LocationComponentOptions options) {
mapboxMap.setPadding(
options.padding()[0], options.padding()[1], options.padding()[2], options.padding()[3]
);
@@ -853,13 +855,13 @@ public final class LocationLayerPlugin {
private void updateLocation(final Location location, boolean fromLastLocation) {
if (location == null) {
return;
} else if (!isLocationLayerStarted) {
} else if (!isLayerReady) {
lastLocation = location;
return;
}
if (isEnabled && isPluginStarted) {
locationLayer.show();
if (isEnabled && isComponentStarted) {
locationLayerController.show();
}
if (!fromLastLocation) {
@@ -867,13 +869,13 @@ public final class LocationLayerPlugin {
}
CameraPosition currentCameraPosition = mapboxMap.getCameraPosition();
boolean isGpsNorth = getCameraMode() == CameraMode.TRACKING_GPS_NORTH;
pluginAnimatorCoordinator.feedNewLocation(location, currentCameraPosition, isGpsNorth);
locationAnimatorCoordinator.feedNewLocation(location, currentCameraPosition, isGpsNorth);
updateAccuracyRadius(location, false);
lastLocation = location;
}
private void updateCompassHeading(float heading) {
pluginAnimatorCoordinator.feedNewCompassBearing(heading, mapboxMap.getCameraPosition());
locationAnimatorCoordinator.feedNewCompassBearing(heading, mapboxMap.getCameraPosition());
}
/**
@@ -894,17 +896,17 @@ public final class LocationLayerPlugin {
CameraPosition position = mapboxMap.getCameraPosition();
if (lastCameraPosition == null || forceUpdate) {
lastCameraPosition = position;
locationLayer.updateForegroundBearing((float) position.bearing);
locationLayer.updateForegroundOffset(position.tilt);
locationLayerController.updateForegroundBearing((float) position.bearing);
locationLayerController.updateForegroundOffset(position.tilt);
updateAccuracyRadius(getLastKnownLocation(), true);
return;
}
if (position.bearing != lastCameraPosition.bearing) {
locationLayer.updateForegroundBearing((float) position.bearing);
locationLayerController.updateForegroundBearing((float) position.bearing);
}
if (position.tilt != lastCameraPosition.tilt) {
locationLayer.updateForegroundOffset(position.tilt);
locationLayerController.updateForegroundOffset(position.tilt);
}
if (position.zoom != lastCameraPosition.zoom) {
updateAccuracyRadius(getLastKnownLocation(), true);
@@ -913,7 +915,7 @@ public final class LocationLayerPlugin {
}
private void updateAccuracyRadius(Location location, boolean noAnimation) {
pluginAnimatorCoordinator.feedNewAccuracyRadius(Utils.calculateZoomLevelRadius(mapboxMap, location), noAnimation);
locationAnimatorCoordinator.feedNewAccuracyRadius(Utils.calculateZoomLevelRadius(mapboxMap, location), noAnimation);
}
private OnCameraMoveListener onCameraMoveListener = new OnCameraMoveListener() {
@@ -933,9 +935,9 @@ public final class LocationLayerPlugin {
private OnMapClickListener onMapClickListener = new OnMapClickListener() {
@Override
public void onMapClick(@NonNull LatLng point) {
if (!onLocationLayerClickListeners.isEmpty() && locationLayer.onMapClick(point)) {
for (OnLocationLayerClickListener listener : onLocationLayerClickListeners) {
listener.onLocationLayerClick();
if (!onLocationComponentClickListeners.isEmpty() && locationLayerController.onMapClick(point)) {
for (OnLocationComponentClickListener listener : onLocationComponentClickListeners) {
listener.onLocationComponentClick();
}
}
}
@@ -944,9 +946,9 @@ public final class LocationLayerPlugin {
private MapboxMap.OnMapLongClickListener onMapLongClickListener = new MapboxMap.OnMapLongClickListener() {
@Override
public void onMapLongClick(@NonNull LatLng point) {
if (!onLocationLayerLongClickListeners.isEmpty() && locationLayer.onMapClick(point)) {
for (OnLocationLayerLongClickListener listener : onLocationLayerLongClickListeners) {
listener.onLocationLayerLongClick();
if (!onLocationComponentLongClickListeners.isEmpty() && locationLayerController.onMapClick(point)) {
for (OnLocationComponentLongClickListener listener : onLocationComponentLongClickListeners) {
listener.onLocationComponentLongClick();
}
}
}
@@ -955,7 +957,7 @@ public final class LocationLayerPlugin {
private OnLocationStaleListener onLocationStaleListener = new OnLocationStaleListener() {
@Override
public void onStaleStateChange(boolean isStale) {
locationLayer.setLocationsStale(isStale);
locationLayerController.setLocationsStale(isStale);
for (OnLocationStaleListener listener : onLocationStaleListeners) {
listener.onStaleStateChange(isStale);
@@ -986,7 +988,7 @@ public final class LocationLayerPlugin {
@Override
@SuppressWarnings( {"MissingPermission"})
public void onConnected() {
if (usingInternalLocationEngine && isLocationLayerStarted && isEnabled) {
if (usingInternalLocationEngine && isLayerReady && isEnabled) {
locationEngine.requestLocationUpdates();
}
}
@@ -1007,8 +1009,8 @@ public final class LocationLayerPlugin {
@Override
public void onCameraTrackingChanged(int currentMode) {
pluginAnimatorCoordinator.cancelZoomAnimation();
pluginAnimatorCoordinator.cancelTiltAnimation();
locationAnimatorCoordinator.cancelZoomAnimation();
locationAnimatorCoordinator.cancelTiltAnimation();
for (OnCameraTrackingChangedListener listener : onCameraTrackingChangedListeners) {
listener.onCameraTrackingChanged(currentMode);
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
@@ -19,7 +19,7 @@ import timber.log.Timber;
* This manager class handles compass events such as starting the tracking of device bearing, or
* when a new compass update occurs.
*/
class LocationLayerCompassEngine implements CompassEngine, SensorEventListener {
class LocationComponentCompassEngine implements CompassEngine, SensorEventListener {
// The rate sensor events will be delivered at. As the Android documentation states, this is only
// a hint to the system and the events might actually be received faster or slower then this
@@ -56,7 +56,7 @@ class LocationLayerCompassEngine implements CompassEngine, SensorEventListener {
* Construct a new instance of the this class. A internal compass listeners needed to separate it
* from the cleared list of public listeners.
*/
LocationLayerCompassEngine(WindowManager windowManager, SensorManager sensorManager) {
LocationComponentCompassEngine(WindowManager windowManager, SensorManager sensorManager) {
this.windowManager = windowManager;
this.sensorManager = sensorManager;
compassSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
@@ -124,7 +124,7 @@ class LocationLayerCompassEngine implements CompassEngine, SensorEventListener {
updateOrientation();
// Update the compassUpdateNextTimestamp
compassUpdateNextTimestamp = currentTime + LocationLayerConstants.COMPASS_UPDATE_RATE_MS;
compassUpdateNextTimestamp = currentTime + LocationComponentConstants.COMPASS_UPDATE_RATE_MS;
} else if (event.sensor.getType() == Sensor.TYPE_ORIENTATION) {
notifyCompassChangeListeners((event.values[0] + 360) % 360);
} else if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
/**
* Contains all the constants being used for the Location layer.
*/
final class LocationLayerConstants {
final class LocationComponentConstants {
static final String STATE_LOCATION_ENABLED = "mapbox_location_locationEnabled";
static final String STATE_LOCATION_OPTIONS = "mapbox_location_options";
@@ -60,7 +60,7 @@ final class LocationLayerConstants {
static final String SHADOW_ICON = "mapbox-location-shadow-icon";
static final String BEARING_ICON = "mapbox-location-bearing-icon";
private LocationLayerConstants() {
private LocationComponentConstants() {
// Class should not be initialized
}
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.content.Context;
import android.content.res.TypedArray;
@@ -19,24 +19,24 @@ import java.util.Arrays;
/**
* This class exposes options for the Location Layer Plugin. The options can be set by defining a
* style in your apps style.xml file and passing in directly into the {@link LocationLayerPlugin}
* 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 LocationLayerPlugin} constructor (if it isn't initialized yet) or
* {@link LocationLayerPlugin#applyStyle(LocationLayerOptions)}.
* either the {@link LocationComponent} constructor (if it isn't initialized yet) or
* {@link LocationComponent#applyStyle(LocationComponentOptions)}.
* <p>
* When the {@link #createFromAttributes(Context, int)} methods called, any attributes not found
* inside the style will revert back to using their default set values. Likewise, when building a
* new {@link LocationLayerOptions} class using the builder, any options neglecting to be set will
* new {@link LocationComponentOptions} class using the builder, any options neglecting to be set will
* reset to their default values.
* <p>
* If you would like to keep your custom style changes while modifying a single attribute, you can
* get the currently used options object using {@link LocationLayerPlugin#getLocationLayerOptions()}
* 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 LocationLayerPlugin#applyStyle(LocationLayerOptions)}.
* layer plugin using {@link LocationComponent#applyStyle(LocationComponentOptions)}.
*/
public class LocationLayerOptions implements Parcelable {
public class LocationComponentOptions implements Parcelable {
/**
* Default accuracy alpha
@@ -104,7 +104,7 @@ public class LocationLayerOptions implements Parcelable {
private float trackingMultiFingerMoveThreshold;
private String layerBelow;
public LocationLayerOptions(
public LocationComponentOptions(
float accuracyAlpha,
int accuracyColor,
int backgroundDrawableStale,
@@ -177,16 +177,16 @@ public class LocationLayerOptions implements Parcelable {
*
* @param context your activity's context used for acquiring resources
* @param styleRes the style id where your custom attributes are defined
* @return a new {@link LocationLayerOptions} object with the settings you defined in your style
* @return a new {@link LocationComponentOptions} object with the settings you defined in your style
* resource
*/
public static LocationLayerOptions createFromAttributes(@NonNull Context context,
@StyleRes int styleRes) {
public static LocationComponentOptions createFromAttributes(@NonNull Context context,
@StyleRes int styleRes) {
TypedArray typedArray = context.obtainStyledAttributes(
styleRes, R.styleable.mapbox_LocationLayer);
styleRes, R.styleable.mapbox_LocationComponent);
LocationLayerOptions.Builder builder = new LocationLayerOptions.Builder()
LocationComponentOptions.Builder builder = new LocationComponentOptions.Builder()
.enableStaleState(true)
.staleStateTimeout(STALE_STATE_DELAY_MS)
.maxZoom(MAX_ZOOM_DEFAULT)
@@ -196,77 +196,77 @@ public class LocationLayerOptions implements Parcelable {
.padding(PADDING_DEFAULT);
builder.foregroundDrawable(typedArray.getResourceId(
R.styleable.mapbox_LocationLayer_mapbox_foregroundDrawable, -1));
if (typedArray.hasValue(R.styleable.mapbox_LocationLayer_mapbox_foregroundTintColor)) {
R.styleable.mapbox_LocationComponent_mapbox_foregroundDrawable, -1));
if (typedArray.hasValue(R.styleable.mapbox_LocationComponent_mapbox_foregroundTintColor)) {
builder.foregroundTintColor(typedArray.getColor(
R.styleable.mapbox_LocationLayer_mapbox_foregroundTintColor, -1));
R.styleable.mapbox_LocationComponent_mapbox_foregroundTintColor, -1));
}
builder.backgroundDrawable(typedArray.getResourceId(
R.styleable.mapbox_LocationLayer_mapbox_backgroundDrawable, -1));
if (typedArray.hasValue(R.styleable.mapbox_LocationLayer_mapbox_backgroundTintColor)) {
R.styleable.mapbox_LocationComponent_mapbox_backgroundDrawable, -1));
if (typedArray.hasValue(R.styleable.mapbox_LocationComponent_mapbox_backgroundTintColor)) {
builder.backgroundTintColor(typedArray.getColor(
R.styleable.mapbox_LocationLayer_mapbox_backgroundTintColor, -1));
R.styleable.mapbox_LocationComponent_mapbox_backgroundTintColor, -1));
}
builder.foregroundDrawableStale(typedArray.getResourceId(
R.styleable.mapbox_LocationLayer_mapbox_foregroundDrawableStale, -1));
if (typedArray.hasValue(R.styleable.mapbox_LocationLayer_mapbox_foregroundStaleTintColor)) {
R.styleable.mapbox_LocationComponent_mapbox_foregroundDrawableStale, -1));
if (typedArray.hasValue(R.styleable.mapbox_LocationComponent_mapbox_foregroundStaleTintColor)) {
builder.foregroundStaleTintColor(typedArray.getColor(
R.styleable.mapbox_LocationLayer_mapbox_foregroundStaleTintColor, -1));
R.styleable.mapbox_LocationComponent_mapbox_foregroundStaleTintColor, -1));
}
builder.backgroundDrawableStale(typedArray.getResourceId(
R.styleable.mapbox_LocationLayer_mapbox_backgroundDrawableStale, -1));
if (typedArray.hasValue(R.styleable.mapbox_LocationLayer_mapbox_backgroundStaleTintColor)) {
R.styleable.mapbox_LocationComponent_mapbox_backgroundDrawableStale, -1));
if (typedArray.hasValue(R.styleable.mapbox_LocationComponent_mapbox_backgroundStaleTintColor)) {
builder.backgroundStaleTintColor(typedArray.getColor(
R.styleable.mapbox_LocationLayer_mapbox_backgroundStaleTintColor, -1));
R.styleable.mapbox_LocationComponent_mapbox_backgroundStaleTintColor, -1));
}
builder.bearingDrawable(typedArray.getResourceId(
R.styleable.mapbox_LocationLayer_mapbox_bearingDrawable, -1));
if (typedArray.hasValue(R.styleable.mapbox_LocationLayer_mapbox_bearingTintColor)) {
R.styleable.mapbox_LocationComponent_mapbox_bearingDrawable, -1));
if (typedArray.hasValue(R.styleable.mapbox_LocationComponent_mapbox_bearingTintColor)) {
builder.bearingTintColor(typedArray.getColor(
R.styleable.mapbox_LocationLayer_mapbox_bearingTintColor, -1));
R.styleable.mapbox_LocationComponent_mapbox_bearingTintColor, -1));
}
if (typedArray.hasValue(R.styleable.mapbox_LocationLayer_mapbox_enableStaleState)) {
if (typedArray.hasValue(R.styleable.mapbox_LocationComponent_mapbox_enableStaleState)) {
builder.enableStaleState(typedArray.getBoolean(
R.styleable.mapbox_LocationLayer_mapbox_enableStaleState, true));
R.styleable.mapbox_LocationComponent_mapbox_enableStaleState, true));
}
if (typedArray.hasValue(R.styleable.mapbox_LocationLayer_mapbox_staleStateTimeout)) {
if (typedArray.hasValue(R.styleable.mapbox_LocationComponent_mapbox_staleStateTimeout)) {
builder.staleStateTimeout(typedArray.getInteger(
R.styleable.mapbox_LocationLayer_mapbox_staleStateTimeout, (int) STALE_STATE_DELAY_MS));
R.styleable.mapbox_LocationComponent_mapbox_staleStateTimeout, (int) STALE_STATE_DELAY_MS));
}
builder.gpsDrawable(typedArray.getResourceId(
R.styleable.mapbox_LocationLayer_mapbox_gpsDrawable, -1));
R.styleable.mapbox_LocationComponent_mapbox_gpsDrawable, -1));
float elevation = typedArray.getDimension(
R.styleable.mapbox_LocationLayer_mapbox_elevation, 0);
R.styleable.mapbox_LocationComponent_mapbox_elevation, 0);
builder.accuracyColor(typedArray.getColor(
R.styleable.mapbox_LocationLayer_mapbox_accuracyColor, -1));
R.styleable.mapbox_LocationComponent_mapbox_accuracyColor, -1));
builder.accuracyAlpha(typedArray.getFloat(
R.styleable.mapbox_LocationLayer_mapbox_accuracyAlpha, ACCURACY_ALPHA_DEFAULT));
R.styleable.mapbox_LocationComponent_mapbox_accuracyAlpha, ACCURACY_ALPHA_DEFAULT));
builder.elevation(elevation);
builder.trackingInitialMoveThreshold(typedArray.getDimension(
R.styleable.mapbox_LocationLayer_mapbox_trackingInitialMoveThreshold,
context.getResources().getDimension(R.dimen.mapbox_locationLayerTrackingInitialMoveThreshold)));
R.styleable.mapbox_LocationComponent_mapbox_trackingInitialMoveThreshold,
context.getResources().getDimension(R.dimen.mapbox_locationComponentTrackingInitialMoveThreshold)));
builder.trackingMultiFingerMoveThreshold(typedArray.getDimension(
R.styleable.mapbox_LocationLayer_mapbox_trackingMultiFingerMoveThreshold,
context.getResources().getDimension(R.dimen.mapbox_locationLayerTrackingMultiFingerMoveThreshold)));
R.styleable.mapbox_LocationComponent_mapbox_trackingMultiFingerMoveThreshold,
context.getResources().getDimension(R.dimen.mapbox_locationComponentTrackingMultiFingerMoveThreshold)));
builder.padding(new int[] {
typedArray.getInt(R.styleable.mapbox_LocationLayer_mapbox_iconPaddingLeft, 0),
typedArray.getInt(R.styleable.mapbox_LocationLayer_mapbox_iconPaddingTop, 0),
typedArray.getInt(R.styleable.mapbox_LocationLayer_mapbox_iconPaddingRight, 0),
typedArray.getInt(R.styleable.mapbox_LocationLayer_mapbox_iconPaddingBottom, 0),
typedArray.getInt(R.styleable.mapbox_LocationComponent_mapbox_iconPaddingLeft, 0),
typedArray.getInt(R.styleable.mapbox_LocationComponent_mapbox_iconPaddingTop, 0),
typedArray.getInt(R.styleable.mapbox_LocationComponent_mapbox_iconPaddingRight, 0),
typedArray.getInt(R.styleable.mapbox_LocationComponent_mapbox_iconPaddingBottom, 0),
});
float maxZoom
= typedArray.getFloat(R.styleable.mapbox_LocationLayer_mapbox_maxZoom, MAX_ZOOM_DEFAULT);
= typedArray.getFloat(R.styleable.mapbox_LocationComponent_mapbox_maxZoom, MAX_ZOOM_DEFAULT);
if (maxZoom < MapboxConstants.MINIMUM_ZOOM || maxZoom > MapboxConstants.MAXIMUM_ZOOM) {
throw new IllegalArgumentException("Max zoom value must be within "
+ MapboxConstants.MINIMUM_ZOOM + " and " + MapboxConstants.MAXIMUM_ZOOM);
}
float minZoom
= typedArray.getFloat(R.styleable.mapbox_LocationLayer_mapbox_minZoom, MIN_ZOOM_DEFAULT);
= typedArray.getFloat(R.styleable.mapbox_LocationComponent_mapbox_minZoom, MIN_ZOOM_DEFAULT);
if (minZoom < MapboxConstants.MINIMUM_ZOOM || minZoom > MapboxConstants.MAXIMUM_ZOOM) {
throw new IllegalArgumentException("Min zoom value must be within "
+ MapboxConstants.MINIMUM_ZOOM + " and " + MapboxConstants.MAXIMUM_ZOOM);
@@ -276,12 +276,12 @@ public class LocationLayerOptions implements Parcelable {
builder.minZoom(minZoom);
builder.layerBelow(
typedArray.getString(R.styleable.mapbox_LocationLayer_mapbox_layer_below));
typedArray.getString(R.styleable.mapbox_LocationComponent_mapbox_layer_below));
float minScale = typedArray.getFloat(
R.styleable.mapbox_LocationLayer_mapbox_minZoomIconScale, MIN_ZOOM_ICON_SCALE_DEFAULT);
R.styleable.mapbox_LocationComponent_mapbox_minZoomIconScale, MIN_ZOOM_ICON_SCALE_DEFAULT);
float maxScale = typedArray.getFloat(
R.styleable.mapbox_LocationLayer_mapbox_maxZoomIconScale, MAX_ZOOM_ICON_SCALE_DEFAULT);
R.styleable.mapbox_LocationComponent_mapbox_maxZoomIconScale, MAX_ZOOM_ICON_SCALE_DEFAULT);
builder.minZoomIconScale(minScale);
builder.maxZoomIconScale(maxScale);
@@ -291,7 +291,7 @@ public class LocationLayerOptions implements Parcelable {
}
/**
* Takes the currently constructed {@link LocationLayerOptions} object and provides it's builder
* Takes the currently constructed {@link LocationComponentOptions} object and provides it's builder
* with all the values set matching the values in this instance. This allows you to modify a
* single attribute and then rebuild the object.
*
@@ -303,7 +303,7 @@ public class LocationLayerOptions implements Parcelable {
}
/**
* Build a new instance of the {@link LocationLayerOptions} class with all the attributes set
* Build a new instance of the {@link LocationComponentOptions} class with all the attributes set
* automatically to their defined defaults in this library. This allows you to adjust a few
* attributes while leaving the rest alone and maintaining their default behavior.
*
@@ -312,8 +312,8 @@ public class LocationLayerOptions implements Parcelable {
* resource
*/
public static Builder builder(Context context) {
return LocationLayerOptions.createFromAttributes(context,
R.style.mapbox_LocationLayer).toBuilder();
return LocationComponentOptions.createFromAttributes(context,
R.style.mapbox_LocationComponent).toBuilder();
}
/**
@@ -682,7 +682,7 @@ public class LocationLayerOptions implements Parcelable {
@Override
public String toString() {
return "LocationLayerOptions{"
return "LocationComponentOptions{"
+ "accuracyAlpha=" + accuracyAlpha + ", "
+ "accuracyColor=" + accuracyColor + ", "
+ "backgroundDrawableStale=" + backgroundDrawableStale + ", "
@@ -721,8 +721,8 @@ public class LocationLayerOptions implements Parcelable {
if (o == this) {
return true;
}
if (o instanceof LocationLayerOptions) {
LocationLayerOptions that = (LocationLayerOptions) o;
if (o instanceof LocationComponentOptions) {
LocationComponentOptions that = (LocationComponentOptions) o;
return (Float.floatToIntBits(this.accuracyAlpha) == Float.floatToIntBits(that.accuracyAlpha()))
&& (this.accuracyColor == that.accuracyColor())
&& (this.backgroundDrawableStale == that.backgroundDrawableStale())
@@ -833,11 +833,11 @@ public class LocationLayerOptions implements Parcelable {
return h$;
}
public static final Parcelable.Creator<LocationLayerOptions> CREATOR =
new Parcelable.Creator<LocationLayerOptions>() {
public static final Parcelable.Creator<LocationComponentOptions> CREATOR =
new Parcelable.Creator<LocationComponentOptions>() {
@Override
public LocationLayerOptions createFromParcel(Parcel in) {
return new LocationLayerOptions(
public LocationComponentOptions createFromParcel(Parcel in) {
return new LocationComponentOptions(
in.readFloat(),
in.readInt(),
in.readInt(),
@@ -872,8 +872,8 @@ public class LocationLayerOptions implements Parcelable {
}
@Override
public LocationLayerOptions[] newArray(int size) {
return new LocationLayerOptions[size];
public LocationComponentOptions[] newArray(int size) {
return new LocationComponentOptions[size];
}
};
@@ -972,28 +972,28 @@ public class LocationLayerOptions implements Parcelable {
}
/**
* Builder class for constructing a new instance of {@link LocationLayerOptions}.
* Builder class for constructing a new instance of {@link LocationComponentOptions}.
*/
public static class Builder {
/**
* Build a new instance of this {@link LocationLayerOptions} class.
* Build a new instance of this {@link LocationComponentOptions} class.
*
* @return a new instance of {@link LocationLayerOptions}
* @return a new instance of {@link LocationComponentOptions}
*/
public LocationLayerOptions build() {
LocationLayerOptions locationLayerOptions = autoBuild();
if (locationLayerOptions.accuracyAlpha() < 0 || locationLayerOptions.accuracyAlpha() > 1) {
public LocationComponentOptions build() {
LocationComponentOptions locationComponentOptions = autoBuild();
if (locationComponentOptions.accuracyAlpha() < 0 || locationComponentOptions.accuracyAlpha() > 1) {
throw new IllegalArgumentException(
"Location layer accuracy alpha value must be between 0.0 and 1.0.");
"Accuracy alpha value must be between 0.0 and 1.0.");
}
if (locationLayerOptions.elevation() < 0f) {
if (locationComponentOptions.elevation() < 0f) {
throw new IllegalArgumentException("Invalid shadow size "
+ locationLayerOptions.elevation() + ". Must be >= 0");
+ locationComponentOptions.elevation() + ". Must be >= 0");
}
return locationLayerOptions;
return locationComponentOptions;
}
private Float accuracyAlpha;
@@ -1030,7 +1030,7 @@ public class LocationLayerOptions implements Parcelable {
Builder() {
}
private Builder(LocationLayerOptions source) {
private Builder(LocationComponentOptions source) {
this.accuracyAlpha = source.accuracyAlpha();
this.accuracyColor = source.accuracyColor();
this.backgroundDrawableStale = source.backgroundDrawableStale();
@@ -1071,7 +1071,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_accuracyAlpha
*/
public LocationLayerOptions.Builder accuracyAlpha(float accuracyAlpha) {
public LocationComponentOptions.Builder accuracyAlpha(float accuracyAlpha) {
this.accuracyAlpha = accuracyAlpha;
return this;
}
@@ -1083,7 +1083,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_accuracyColor
*/
public LocationLayerOptions.Builder accuracyColor(int accuracyColor) {
public LocationComponentOptions.Builder accuracyColor(int accuracyColor) {
this.accuracyColor = accuracyColor;
return this;
}
@@ -1095,7 +1095,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_backgroundDrawableStale
*/
public LocationLayerOptions.Builder backgroundDrawableStale(int backgroundDrawableStale) {
public LocationComponentOptions.Builder backgroundDrawableStale(int backgroundDrawableStale) {
this.backgroundDrawableStale = backgroundDrawableStale;
return this;
}
@@ -1112,7 +1112,7 @@ public class LocationLayerOptions implements Parcelable {
* @param backgroundStaleName String icon or maki-icon name
* @return this builder for chaining options together
*/
public LocationLayerOptions.Builder backgroundStaleName(@Nullable String backgroundStaleName) {
public LocationComponentOptions.Builder backgroundStaleName(@Nullable String backgroundStaleName) {
this.backgroundStaleName = backgroundStaleName;
return this;
}
@@ -1124,7 +1124,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_foregroundDrawableStale
*/
public LocationLayerOptions.Builder foregroundDrawableStale(int foregroundDrawableStale) {
public LocationComponentOptions.Builder foregroundDrawableStale(int foregroundDrawableStale) {
this.foregroundDrawableStale = foregroundDrawableStale;
return this;
}
@@ -1141,7 +1141,7 @@ public class LocationLayerOptions implements Parcelable {
* @param foregroundStaleName String icon or maki-icon name
* @return this builder for chaining options together
*/
public LocationLayerOptions.Builder foregroundStaleName(@Nullable String foregroundStaleName) {
public LocationComponentOptions.Builder foregroundStaleName(@Nullable String foregroundStaleName) {
this.foregroundStaleName = foregroundStaleName;
return this;
}
@@ -1153,7 +1153,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_gpsDrawable
*/
public LocationLayerOptions.Builder gpsDrawable(int gpsDrawable) {
public LocationComponentOptions.Builder gpsDrawable(int gpsDrawable) {
this.gpsDrawable = gpsDrawable;
return this;
}
@@ -1170,7 +1170,7 @@ public class LocationLayerOptions implements Parcelable {
* @param gpsName String icon or maki-icon name
* @return this builder for chaining options together
*/
public LocationLayerOptions.Builder gpsName(@Nullable String gpsName) {
public LocationComponentOptions.Builder gpsName(@Nullable String gpsName) {
this.gpsName = gpsName;
return this;
}
@@ -1183,7 +1183,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_foregroundDrawable
*/
public LocationLayerOptions.Builder foregroundDrawable(int foregroundDrawable) {
public LocationComponentOptions.Builder foregroundDrawable(int foregroundDrawable) {
this.foregroundDrawable = foregroundDrawable;
return this;
}
@@ -1200,7 +1200,7 @@ public class LocationLayerOptions implements Parcelable {
* @param foregroundName String icon or maki-icon name
* @return this builder for chaining options together
*/
public LocationLayerOptions.Builder foregroundName(@Nullable String foregroundName) {
public LocationComponentOptions.Builder foregroundName(@Nullable String foregroundName) {
this.foregroundName = foregroundName;
return this;
}
@@ -1212,7 +1212,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_backgroundDrawable
*/
public LocationLayerOptions.Builder backgroundDrawable(int backgroundDrawable) {
public LocationComponentOptions.Builder backgroundDrawable(int backgroundDrawable) {
this.backgroundDrawable = backgroundDrawable;
return this;
}
@@ -1229,7 +1229,7 @@ public class LocationLayerOptions implements Parcelable {
* @param backgroundName String icon or maki-icon name
* @return this builder for chaining options together
*/
public LocationLayerOptions.Builder backgroundName(@Nullable String backgroundName) {
public LocationComponentOptions.Builder backgroundName(@Nullable String backgroundName) {
this.backgroundName = backgroundName;
return this;
}
@@ -1241,7 +1241,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_bearingDrawable
*/
public LocationLayerOptions.Builder bearingDrawable(int bearingDrawable) {
public LocationComponentOptions.Builder bearingDrawable(int bearingDrawable) {
this.bearingDrawable = bearingDrawable;
return this;
}
@@ -1258,7 +1258,7 @@ public class LocationLayerOptions implements Parcelable {
* @param bearingName String icon or maki-icon name
* @return this builder for chaining options together
*/
public LocationLayerOptions.Builder bearingName(@Nullable String bearingName) {
public LocationComponentOptions.Builder bearingName(@Nullable String bearingName) {
this.bearingName = bearingName;
return this;
}
@@ -1270,7 +1270,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_bearingTintColor
*/
public LocationLayerOptions.Builder bearingTintColor(@Nullable Integer bearingTintColor) {
public LocationComponentOptions.Builder bearingTintColor(@Nullable Integer bearingTintColor) {
this.bearingTintColor = bearingTintColor;
return this;
}
@@ -1282,7 +1282,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_foregroundTintColor
*/
public LocationLayerOptions.Builder foregroundTintColor(@Nullable Integer foregroundTintColor) {
public LocationComponentOptions.Builder foregroundTintColor(@Nullable Integer foregroundTintColor) {
this.foregroundTintColor = foregroundTintColor;
return this;
}
@@ -1294,7 +1294,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_backgroundTintColor
*/
public LocationLayerOptions.Builder backgroundTintColor(@Nullable Integer backgroundTintColor) {
public LocationComponentOptions.Builder backgroundTintColor(@Nullable Integer backgroundTintColor) {
this.backgroundTintColor = backgroundTintColor;
return this;
}
@@ -1306,7 +1306,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_foregroundStaleTintColor
*/
public LocationLayerOptions.Builder foregroundStaleTintColor(@Nullable Integer foregroundStaleTintColor) {
public LocationComponentOptions.Builder foregroundStaleTintColor(@Nullable Integer foregroundStaleTintColor) {
this.foregroundStaleTintColor = foregroundStaleTintColor;
return this;
}
@@ -1318,7 +1318,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_backgroundStaleTintColor
*/
public LocationLayerOptions.Builder backgroundStaleTintColor(@Nullable Integer backgroundStaleTintColor) {
public LocationComponentOptions.Builder backgroundStaleTintColor(@Nullable Integer backgroundStaleTintColor) {
this.backgroundStaleTintColor = backgroundStaleTintColor;
return this;
}
@@ -1330,7 +1330,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_elevation
*/
public LocationLayerOptions.Builder elevation(float elevation) {
public LocationComponentOptions.Builder elevation(float elevation) {
this.elevation = elevation;
return this;
}
@@ -1343,7 +1343,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_enableStaleState
*/
public LocationLayerOptions.Builder enableStaleState(boolean enabled) {
public LocationComponentOptions.Builder enableStaleState(boolean enabled) {
this.enableStaleState = enabled;
return this;
}
@@ -1358,7 +1358,7 @@ public class LocationLayerOptions implements Parcelable {
* @return this builder for chaining options together
* @attr ref R.styleable#LocationLayer_staleStateTimeout
*/
public LocationLayerOptions.Builder staleStateTimeout(long timeout) {
public LocationComponentOptions.Builder staleStateTimeout(long timeout) {
this.staleStateTimeout = timeout;
return this;
}
@@ -1377,7 +1377,7 @@ public class LocationLayerOptions implements Parcelable {
*
* @param padding The margins for the map in pixels (left, top, right, bottom).
*/
public LocationLayerOptions.Builder padding(int[] padding) {
public LocationComponentOptions.Builder padding(int[] padding) {
if (padding == null) {
throw new NullPointerException("Null padding");
}
@@ -1392,7 +1392,7 @@ public class LocationLayerOptions implements Parcelable {
*
* @param maxZoom The new maximum zoom level.
*/
public LocationLayerOptions.Builder maxZoom(double maxZoom) {
public LocationComponentOptions.Builder maxZoom(double maxZoom) {
this.maxZoom = maxZoom;
return this;
}
@@ -1402,7 +1402,7 @@ public class LocationLayerOptions implements Parcelable {
*
* @param minZoom The new minimum zoom level.
*/
public LocationLayerOptions.Builder minZoom(double minZoom) {
public LocationComponentOptions.Builder minZoom(double minZoom) {
this.minZoom = minZoom;
return this;
}
@@ -1416,7 +1416,7 @@ public class LocationLayerOptions implements Parcelable {
*
* @param maxZoomIconScale icon scale factor
*/
public LocationLayerOptions.Builder maxZoomIconScale(float maxZoomIconScale) {
public LocationComponentOptions.Builder maxZoomIconScale(float maxZoomIconScale) {
this.maxZoomIconScale = maxZoomIconScale;
return this;
}
@@ -1430,7 +1430,7 @@ public class LocationLayerOptions implements Parcelable {
*
* @param minZoomIconScale icon scale factor
*/
public LocationLayerOptions.Builder minZoomIconScale(float minZoomIconScale) {
public LocationComponentOptions.Builder minZoomIconScale(float minZoomIconScale) {
this.minZoomIconScale = minZoomIconScale;
return this;
}
@@ -1440,7 +1440,7 @@ public class LocationLayerOptions implements Parcelable {
*
* @param moveThreshold the minimum movement
*/
public LocationLayerOptions.Builder trackingInitialMoveThreshold(float moveThreshold) {
public LocationComponentOptions.Builder trackingInitialMoveThreshold(float moveThreshold) {
this.trackingInitialMoveThreshold = moveThreshold;
return this;
}
@@ -1451,7 +1451,7 @@ public class LocationLayerOptions implements Parcelable {
*
* @param moveThreshold the minimum movement
*/
public LocationLayerOptions.Builder trackingMultiFingerMoveThreshold(float moveThreshold) {
public LocationComponentOptions.Builder trackingMultiFingerMoveThreshold(float moveThreshold) {
this.trackingMultiFingerMoveThreshold = moveThreshold;
return this;
}
@@ -1461,12 +1461,12 @@ public class LocationLayerOptions implements Parcelable {
*
* @param layerBelow the id to set the location layer plugin below to.
*/
public LocationLayerOptions.Builder layerBelow(String layerBelow) {
public LocationComponentOptions.Builder layerBelow(String layerBelow) {
this.layerBelow = layerBelow;
return this;
}
LocationLayerOptions autoBuild() {
LocationComponentOptions autoBuild() {
String missing = "";
if (this.accuracyAlpha == null) {
missing += " accuracyAlpha";
@@ -1525,7 +1525,7 @@ public class LocationLayerOptions implements Parcelable {
if (!missing.isEmpty()) {
throw new IllegalStateException("Missing required properties:" + missing);
}
return new LocationLayerOptions(
return new LocationComponentOptions(
this.accuracyAlpha,
this.accuracyColor,
this.backgroundDrawableStale,

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.graphics.Bitmap;
import android.graphics.PointF;
@@ -12,7 +12,7 @@ import com.mapbox.geojson.Feature;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
@@ -20,31 +20,31 @@ import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import java.util.ArrayList;
import java.util.List;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.ACCURACY_LAYER;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BACKGROUND_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BACKGROUND_LAYER;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BACKGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BEARING_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BEARING_LAYER;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.FOREGROUND_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.FOREGROUND_LAYER;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.FOREGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.LOCATION_SOURCE;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_ACCURACY_ALPHA;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_ACCURACY_COLOR;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_ACCURACY_RADIUS;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_BACKGROUND_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_BACKGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_BEARING_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_FOREGROUND_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_FOREGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_GPS_BEARING;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_LOCATION_STALE;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_SHADOW_ICON_OFFSET;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.SHADOW_ICON;
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.SHADOW_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.ACCURACY_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.LOCATION_SOURCE;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_ALPHA;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_COLOR;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_RADIUS;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BACKGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BACKGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BEARING_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_GPS_BEARING;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_LOCATION_STALE;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_SHADOW_ICON_OFFSET;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_LAYER;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.linear;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
@@ -55,7 +55,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.colorToRgbaStrin
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
final class LocationLayer implements PluginAnimator.OnLayerAnimationsValuesChangeListener {
final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsValuesChangeListener {
@RenderMode.Mode
private int renderMode;
@@ -63,7 +63,7 @@ final class LocationLayer implements PluginAnimator.OnLayerAnimationsValuesChang
private final MapboxMap mapboxMap;
private final LayerSourceProvider layerSourceProvider;
private final LayerBitmapProvider bitmapProvider;
private LocationLayerOptions options;
private LocationComponentOptions options;
private final List<String> layerMap = new ArrayList<>();
private Feature locationFeature;
@@ -71,9 +71,9 @@ final class LocationLayer implements PluginAnimator.OnLayerAnimationsValuesChang
private boolean isHidden = true;
LocationLayer(MapboxMap mapboxMap, LayerSourceProvider layerSourceProvider,
LayerFeatureProvider featureProvider, LayerBitmapProvider bitmapProvider,
LocationLayerOptions options) {
LocationLayerController(MapboxMap mapboxMap, LayerSourceProvider layerSourceProvider,
LayerFeatureProvider featureProvider, LayerBitmapProvider bitmapProvider,
LocationComponentOptions options) {
this.mapboxMap = mapboxMap;
this.layerSourceProvider = layerSourceProvider;
this.bitmapProvider = bitmapProvider;
@@ -82,7 +82,7 @@ final class LocationLayer implements PluginAnimator.OnLayerAnimationsValuesChang
setRenderMode(RenderMode.NORMAL);
}
void initializeComponents(LocationLayerOptions options) {
void initializeComponents(LocationComponentOptions options) {
addLocationSource();
addLayers(options.layerBelow());
applyStyle(options);
@@ -94,7 +94,7 @@ final class LocationLayer implements PluginAnimator.OnLayerAnimationsValuesChang
}
}
void applyStyle(@NonNull LocationLayerOptions options) {
void applyStyle(@NonNull LocationComponentOptions options) {
this.options = options;
float elevation = options.elevation();
@@ -261,7 +261,7 @@ final class LocationLayer implements PluginAnimator.OnLayerAnimationsValuesChang
// Styling
//
private void styleBackground(LocationLayerOptions options) {
private void styleBackground(LocationComponentOptions options) {
Bitmap backgroundBitmap = bitmapProvider.generateBitmap(
options.backgroundDrawable(), options.backgroundTintColor()
);
@@ -272,11 +272,11 @@ final class LocationLayer implements PluginAnimator.OnLayerAnimationsValuesChang
mapboxMap.addImage(BACKGROUND_STALE_ICON, backgroundStaleBitmap);
}
private void styleShadow(LocationLayerOptions options) {
private void styleShadow(LocationComponentOptions options) {
mapboxMap.addImage(SHADOW_ICON, bitmapProvider.generateShadowBitmap(options));
}
private void styleBearing(LocationLayerOptions options) {
private void styleBearing(LocationComponentOptions options) {
Bitmap bearingBitmap = bitmapProvider.generateBitmap(options.bearingDrawable(), options.bearingTintColor());
mapboxMap.addImage(BEARING_ICON, bearingBitmap);
}
@@ -287,7 +287,7 @@ final class LocationLayer implements PluginAnimator.OnLayerAnimationsValuesChang
refreshSource();
}
private void styleForeground(LocationLayerOptions options) {
private void styleForeground(LocationComponentOptions options) {
Bitmap foregroundBitmap = bitmapProvider.generateBitmap(
options.foregroundDrawable(), options.foregroundTintColor()
);
@@ -306,7 +306,7 @@ final class LocationLayer implements PluginAnimator.OnLayerAnimationsValuesChang
mapboxMap.addImage(FOREGROUND_STALE_ICON, foregroundBitmapStale);
}
private void styleScaling(LocationLayerOptions options) {
private void styleScaling(LocationComponentOptions options) {
for (String layerId : layerMap) {
Layer layer = mapboxMap.getLayer(layerId);
if (layer != null && layer instanceof SymbolLayer) {
@@ -322,7 +322,7 @@ final class LocationLayer implements PluginAnimator.OnLayerAnimationsValuesChang
}
}
private void determineIconsSource(LocationLayerOptions options) {
private void determineIconsSource(LocationComponentOptions options) {
String foregroundIconString = buildIconString(
renderMode == RenderMode.GPS ? options.gpsName() : options.foregroundName(), FOREGROUND_ICON);
String foregroundStaleIconString = buildIconString(options.foregroundStaleName(), FOREGROUND_STALE_ICON);

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
@@ -16,7 +16,7 @@ import java.util.List;
* @param <K> Data type that will be animated.
* @param <L> Listener of animation updates.
*/
abstract class PluginAnimator<K, L> extends ValueAnimator implements ValueAnimator.AnimatorUpdateListener {
abstract class MapboxAnimator<K, L> extends ValueAnimator implements ValueAnimator.AnimatorUpdateListener {
@Retention(RetentionPolicy.SOURCE)
@IntDef( {
ANIMATOR_LAYER_LATLNG,
@@ -46,7 +46,7 @@ abstract class PluginAnimator<K, L> extends ValueAnimator implements ValueAnimat
final List<L> updateListeners;
private final K target;
PluginAnimator(K previous, K target, List<L> updateListeners) {
MapboxAnimator(K previous, K target, List<L> updateListeners) {
setObjectValues(previous, target);
setEvaluator(provideEvaluator());
this.updateListeners = updateListeners;

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -9,7 +9,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
import java.util.List;
abstract class MapboxCameraAnimatorAdapter extends
PluginFloatAnimator<PluginAnimator.OnCameraAnimationsValuesChangeListener> {
MapboxFloatAnimator<MapboxAnimator.OnCameraAnimationsValuesChangeListener> {
private final MapboxMap.CancelableCallback cancelableCallback;
MapboxCameraAnimatorAdapter(Float previous, Float target,

View File

@@ -1,12 +1,12 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.FloatEvaluator;
import android.animation.TypeEvaluator;
import java.util.List;
abstract class PluginFloatAnimator<L> extends PluginAnimator<Float, L> {
PluginFloatAnimator(Float previous, Float target, List<L> updateListeners) {
abstract class MapboxFloatAnimator<L> extends MapboxAnimator<Float, L> {
MapboxFloatAnimator(Float previous, Float target, List<L> updateListeners) {
super(previous, target, updateListeners);
}

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.TypeEvaluator;
@@ -6,9 +6,9 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import java.util.List;
abstract class PluginLatLngAnimator<L> extends PluginAnimator<LatLng, L> {
abstract class MapboxLatLngAnimator<L> extends MapboxAnimator<LatLng, L> {
PluginLatLngAnimator(LatLng previous, LatLng target, List<L> updateListeners) {
MapboxLatLngAnimator(LatLng previous, LatLng target, List<L> updateListeners) {
super(previous, target, updateListeners);
}

View File

@@ -1,6 +1,6 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.CameraMode;
import com.mapbox.mapboxsdk.location.modes.CameraMode;
/**
* Listener that gets invoked when camera tracking state changes.

View File

@@ -1,11 +1,11 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
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 #onLocationLayerClick()} method
* layer icon visible on the map. when this event occurs, the {@link #onLocationComponentClick()} method
* gets invoked.
*/
public interface OnLocationLayerClickListener {
public interface OnLocationComponentClickListener {
void onLocationLayerClick();
void onLocationComponentClick();
}

View File

@@ -1,11 +1,11 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
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 #onLocationLayerLongClick()} method
* layer icon visible on the map. when this event occurs, the {@link #onLocationComponentLongClick()} method
* gets invoked.
*/
public interface OnLocationLayerLongClickListener {
public interface OnLocationComponentLongClickListener {
void onLocationLayerLongClick();
void onLocationComponentLongClick();
}

View File

@@ -1,11 +1,11 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
/**
* Listener that can be added as a callback when the last location update
* is considered stale.
* <p>
* The time from the last location update that determines if a location update
* is stale or not is provided by {@link LocationLayerOptions#staleStateTimeout()}.
* is stale or not is provided by {@link LocationComponentOptions#staleStateTimeout()}.
*/
public interface OnLocationStaleListener {

View File

@@ -1,12 +1,12 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.os.Handler;
/**
* Class controls the location layer stale state when the {@link android.location.Location} hasn't
* been updated in 'x' amount of time. {@link LocationLayerOptions#staleStateTimeout()} can be used to
* been updated in 'x' amount of time. {@link LocationComponentOptions#staleStateTimeout()} can be used to
* control the amount of time before the locations considered stale.
* {@link LocationLayerOptions#enableStaleState()} is available for disabling this behaviour.
* {@link LocationComponentOptions#enableStaleState()} is available for disabling this behaviour.
*/
class StaleStateManager {
@@ -16,7 +16,7 @@ class StaleStateManager {
private boolean isStale = true;
private long delayTime;
StaleStateManager(OnLocationStaleListener innerListener, LocationLayerOptions options) {
StaleStateManager(OnLocationStaleListener innerListener, LocationComponentOptions options) {
innerOnLocationStaleListeners = innerListener;
handler = new Handler();
isEnabled = options.enableStaleState();

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.ValueAnimator;
import android.support.annotation.Nullable;

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.content.Context;
import android.graphics.Bitmap;

View File

@@ -1,4 +1,4 @@
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;
import android.animation.ValueAnimator;
import android.support.annotation.Nullable;

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.plugins.locationlayer.modes;
package com.mapbox.mapboxsdk.location.modes;
import android.location.Location;
import android.support.annotation.IntDef;
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
import com.mapbox.mapboxsdk.location.LocationComponent;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -19,7 +19,7 @@ public final class CameraMode {
}
/**
* Determine the camera tracking behavior in the {@link LocationLayerPlugin}.
* Determine the camera tracking behavior in the {@link LocationComponent}.
*/
@IntDef( {NONE, NONE_COMPASS, NONE_GPS, TRACKING, TRACKING_COMPASS, TRACKING_GPS, TRACKING_GPS_NORTH})
@Retention(RetentionPolicy.SOURCE)

View File

@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.plugins.locationlayer.modes;
package com.mapbox.mapboxsdk.location.modes;
import android.support.annotation.IntDef;
import com.mapbox.mapboxsdk.plugins.locationlayer.CompassEngine;
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
import com.mapbox.mapboxsdk.location.CompassEngine;
import com.mapbox.mapboxsdk.location.LocationComponent;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -18,7 +18,7 @@ public final class RenderMode {
}
/**
* One of these constants should be used with {@link LocationLayerPlugin#setRenderMode(int)}.
* 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
* in the new mode you'd like the location layer to be in.
*/

View File

@@ -1,4 +1,4 @@
/**
* Contains the Mapbox Location layer plugin.
*/
package com.mapbox.mapboxsdk.plugins.locationlayer;
package com.mapbox.mapboxsdk.location;

View File

@@ -44,7 +44,7 @@ import com.mapbox.mapboxsdk.net.ConnectivityReceiver;
import com.mapbox.mapboxsdk.offline.OfflineGeometryRegionDefinition;
import com.mapbox.mapboxsdk.offline.OfflineRegionDefinition;
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition;
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.storage.FileSource;
import com.mapbox.mapboxsdk.utils.BitmapUtils;
@@ -199,8 +199,8 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
compassView.injectCompassAnimationListener(createCompassAnimationListener(cameraChangeDispatcher));
compassView.setOnClickListener(createCompassClickListener(cameraChangeDispatcher));
// LocationLayerPlugin
mapboxMap.injectLocationLayerPlugin(new LocationLayerPlugin(context, mapboxMap));
// LocationComponent
mapboxMap.injectLocationComponent(new LocationComponent(context, mapboxMap));
// inject widgets with MapboxMap
attrView.setOnClickListener(new AttributionClickListener(context, mapboxMap));

View File

@@ -43,7 +43,7 @@ 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.plugins.locationlayer.LocationLayerPlugin;
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.light.Light;
@@ -76,7 +76,7 @@ public final class MapboxMap {
private final OnGesturesManagerInteractionListener onGesturesManagerInteractionListener;
private LocationLayerPlugin locationLayerPlugin;
private LocationComponent locationComponent;
private MapboxMap.OnFpsChangedListener onFpsChangedListener;
MapboxMap(NativeMapView map, Transform transform, UiSettings ui, Projection projection,
@@ -112,14 +112,14 @@ public final class MapboxMap {
// if user hasn't loaded a Style yet
nativeMapView.setStyleUrl(Style.MAPBOX_STREETS);
}
locationLayerPlugin.onStart();
locationComponent.onStart();
}
/**
* Called when the hosting Activity/Fragment onStop() method is called.
*/
void onStop() {
locationLayerPlugin.onStop();
locationComponent.onStop();
}
/**
@@ -132,7 +132,7 @@ public final class MapboxMap {
outState.putBoolean(MapboxConstants.STATE_DEBUG_ACTIVE, nativeMapView.getDebug());
outState.putString(MapboxConstants.STATE_STYLE_URL, nativeMapView.getStyleUrl());
uiSettings.onSaveInstanceState(outState);
locationLayerPlugin.onSaveInstanceState(outState);
locationComponent.onSaveInstanceState(outState);
}
/**
@@ -157,14 +157,14 @@ public final class MapboxMap {
if (!TextUtils.isEmpty(styleUrl)) {
nativeMapView.setStyleUrl(savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL));
}
locationLayerPlugin.onRestoreInstanceState(savedInstanceState);
locationComponent.onRestoreInstanceState(savedInstanceState);
}
/**
* Called when the hosting Activity/Fragment onDestroy()/onDestroyView() method is called.
*/
void onDestroy() {
locationLayerPlugin.onDestroy();
locationComponent.onDestroy();
}
/**
@@ -191,14 +191,14 @@ public final class MapboxMap {
* Called when the map will start loading style.
*/
void onStartLoadingMap() {
locationLayerPlugin.onStartLoadingMap();
locationComponent.onStartLoadingMap();
}
/**
* Called the map finished loading style.
*/
void onFinishLoadingStyle() {
locationLayerPlugin.onFinishLoadingStyle();
locationComponent.onFinishLoadingStyle();
}
/**
@@ -2311,11 +2311,11 @@ public final class MapboxMap {
}
//
// LocationLayerPlugin
// LocationComponent
//
void injectLocationLayerPlugin(LocationLayerPlugin locationLayerPlugin) {
this.locationLayerPlugin = locationLayerPlugin;
void injectLocationComponent(LocationComponent locationComponent) {
this.locationComponent = locationComponent;
}
/**
@@ -2323,8 +2323,8 @@ public final class MapboxMap {
* @return the location layer
*/
@NonNull
public LocationLayerPlugin getLocationLayerPlugin() {
return locationLayerPlugin;
public LocationComponent getLocationComponent() {
return locationComponent;
}
//