[android] updated naming scheme and packages structure for LocationLayerPlugin, now called LocationComponent
This commit is contained in:
committed by
Łukasz Paczos
parent
cf7752c80c
commit
907612e93d
@@ -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);
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import android.animation.TypeEvaluator;
|
||||
|
||||
@@ -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);
|
||||
@@ -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());
|
||||
}
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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();
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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) {
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
@@ -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,
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
interface OnCameraMoveInvalidateListener {
|
||||
|
||||
@@ -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.
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -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)
|
||||
@@ -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.
|
||||
*/
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Contains the Mapbox Location layer plugin.
|
||||
*/
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
<!-- Exposed colors -->
|
||||
<public name="mapbox_blue" type="color" />
|
||||
|
||||
<public name="mapbox_LocationLayer" type="style"/>
|
||||
<public name="mapbox_LocationComponent" type="style"/>
|
||||
|
||||
<public name="mapbox_foregroundDrawable" format="reference" type="attr"/>
|
||||
<public name="mapbox_foregroundTintColor" format="color" type="attr"/>
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="mapbox_LocationLayer">
|
||||
<declare-styleable name="mapbox_LocationComponent">
|
||||
<attr name="mapbox_foregroundDrawable" format="reference"/>
|
||||
<attr name="mapbox_foregroundTintColor" format="color"/>
|
||||
<attr name="mapbox_backgroundDrawable" format="reference"/>
|
||||
|
||||
@@ -16,6 +16,6 @@
|
||||
<!--Minimum angular velocity required to start rotation animation-->
|
||||
<dimen name="mapbox_minimum_angular_velocity">0.025dp</dimen>
|
||||
|
||||
<dimen name="mapbox_locationLayerTrackingInitialMoveThreshold">25dp</dimen>
|
||||
<dimen name="mapbox_locationLayerTrackingMultiFingerMoveThreshold">125dp</dimen>
|
||||
<dimen name="mapbox_locationComponentTrackingInitialMoveThreshold">25dp</dimen>
|
||||
<dimen name="mapbox_locationComponentTrackingMultiFingerMoveThreshold">125dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="mapbox_LocationLayer">
|
||||
<style name="mapbox_LocationComponent">
|
||||
<item name="mapbox_foregroundDrawable">@drawable/mapbox_user_icon</item>
|
||||
<item name="mapbox_backgroundDrawable">@drawable/mapbox_user_stroke_icon</item>
|
||||
<item name="mapbox_bearingDrawable">@drawable/mapbox_user_bearing_icon</item>
|
||||
@@ -34,12 +34,8 @@
|
||||
<item name="mapbox_minZoomIconScale">0.6</item>
|
||||
|
||||
<!-- Camera tracking settings -->
|
||||
<item name="mapbox_trackingInitialMoveThreshold">
|
||||
@dimen/mapbox_locationLayerTrackingInitialMoveThreshold
|
||||
</item>
|
||||
<item name="mapbox_trackingMultiFingerMoveThreshold">
|
||||
@dimen/mapbox_locationLayerTrackingMultiFingerMoveThreshold
|
||||
</item>
|
||||
<item name="mapbox_trackingInitialMoveThreshold">@dimen/mapbox_locationComponentTrackingInitialMoveThreshold</item>
|
||||
<item name="mapbox_trackingMultiFingerMoveThreshold">@dimen/mapbox_locationComponentTrackingMultiFingerMoveThreshold</item>
|
||||
|
||||
</style>
|
||||
</resources>
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
@@ -19,7 +19,7 @@ import static org.mockito.Mockito.when;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CompassEngineTest {
|
||||
|
||||
private LocationLayerCompassEngine compassEngine;
|
||||
private LocationComponentCompassEngine compassEngine;
|
||||
|
||||
@Mock
|
||||
private WindowManager windowManager;
|
||||
@@ -29,7 +29,7 @@ public class CompassEngineTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
compassEngine = new LocationLayerCompassEngine(windowManager, sensorManager);
|
||||
compassEngine = new LocationComponentCompassEngine(windowManager, sensorManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,7 +48,7 @@ public class CompassEngineTest {
|
||||
public void whenGyroscopeIsNull_fallbackToGravity() {
|
||||
SensorManager sensorManager = mock(SensorManager.class);
|
||||
when(sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE)).thenReturn(null);
|
||||
new LocationLayerCompassEngine(windowManager, sensorManager);
|
||||
new LocationComponentCompassEngine(windowManager, sensorManager);
|
||||
|
||||
verify(sensorManager, times(1)).getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class CompassEngineTest {
|
||||
public void whenGyroscopeIsNull_fallbackToMagneticField() {
|
||||
SensorManager sensorManager = mock(SensorManager.class);
|
||||
when(sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE)).thenReturn(null);
|
||||
new LocationLayerCompassEngine(windowManager, sensorManager);
|
||||
new LocationComponentCompassEngine(windowManager, sensorManager);
|
||||
|
||||
verify(sensorManager, times(1)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import android.graphics.PointF;
|
||||
|
||||
@@ -6,10 +6,10 @@ import com.mapbox.android.gestures.MoveGestureDetector;
|
||||
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.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.Projection;
|
||||
import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.CameraMode;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -19,13 +19,13 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class LocationLayerCameraTest {
|
||||
public class LocationCameraControllerTest {
|
||||
|
||||
@Test
|
||||
public void setCameraMode_mapTransitionsAreCancelled() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
|
||||
@@ -35,8 +35,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void setCameraMode_gestureThresholdIsAdjusted() {
|
||||
MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
|
||||
LocationLayerCamera camera = buildCamera(moveGestureDetector);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationCameraController camera = buildCamera(moveGestureDetector);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
float moveThreshold = 5f;
|
||||
when(options.trackingInitialMoveThreshold()).thenReturn(moveThreshold);
|
||||
camera.initializeOptions(options);
|
||||
@@ -49,8 +49,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void setCameraMode_gestureThresholdIsResetWhenNotTracking() {
|
||||
MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
|
||||
LocationLayerCamera camera = buildCamera(moveGestureDetector);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(moveGestureDetector);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
|
||||
@@ -61,8 +61,8 @@ public class LocationLayerCameraTest {
|
||||
public void setCameraMode_notTrackingAdjustsFocalPoint() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
@@ -73,8 +73,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void setCameraMode_trackingChangeListenerCameraDismissedIsCalled() {
|
||||
OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
|
||||
LocationLayerCamera camera = buildCamera(internalTrackingChangedListener);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(internalTrackingChangedListener);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
@@ -85,8 +85,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void setCameraMode_internalCameraTrackingChangeListenerIsCalled() {
|
||||
OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
|
||||
LocationLayerCamera camera = buildCamera(internalTrackingChangedListener);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(internalTrackingChangedListener);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
int cameraMode = CameraMode.NONE;
|
||||
|
||||
camera.setCameraMode(cameraMode);
|
||||
@@ -99,8 +99,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -114,8 +114,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS_NORTH);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -129,8 +129,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -144,8 +144,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_COMPASS);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -159,8 +159,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -178,8 +178,8 @@ public class LocationLayerCameraTest {
|
||||
PointF pointF = mock(PointF.class);
|
||||
when(projection.toScreenLocation(any(LatLng.class))).thenReturn(pointF);
|
||||
when(mapboxMap.getProjection()).thenReturn(projection);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -191,8 +191,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewGpsBearingValue_cameraModeTrackingGpsUpdatesBearing() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
float gpsBearing = 5f;
|
||||
|
||||
@@ -204,8 +204,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewGpsBearingValue_cameraModeNoneGpsUpdatesBearing() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.NONE_GPS);
|
||||
float gpsBearing = 5f;
|
||||
|
||||
@@ -219,8 +219,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder().bearing(7d).build();
|
||||
when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS_NORTH);
|
||||
float gpsBearing = 5f;
|
||||
|
||||
@@ -234,8 +234,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder().bearing(0d).build();
|
||||
when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS_NORTH);
|
||||
float gpsBearing = 5f;
|
||||
|
||||
@@ -247,8 +247,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewGpsBearingValue_cameraModeNoneIgnored() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
float gpsBearing = 5f;
|
||||
|
||||
@@ -260,8 +260,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewCompassBearingValue_cameraModeTrackingCompassUpdatesBearing() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_COMPASS);
|
||||
float compassBearing = 5f;
|
||||
|
||||
@@ -273,8 +273,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewCompassBearingValue_cameraModeNoneCompassUpdatesBearing() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.NONE_COMPASS);
|
||||
float compassBearing = 5f;
|
||||
|
||||
@@ -286,8 +286,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewCompassBearingValue_cameraModeNoneIgnored() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
float compassBearing = 5f;
|
||||
|
||||
@@ -299,8 +299,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewZoomValue_cameraIsUpdated() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING);
|
||||
float zoom = 5f;
|
||||
|
||||
@@ -309,29 +309,29 @@ public class LocationLayerCameraTest {
|
||||
verify(mapboxMap).moveCamera(any(CameraUpdate.class));
|
||||
}
|
||||
|
||||
private LocationLayerCamera buildCamera(OnCameraTrackingChangedListener onCameraTrackingChangedListener) {
|
||||
private LocationCameraController buildCamera(OnCameraTrackingChangedListener onCameraTrackingChangedListener) {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
|
||||
OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
|
||||
return new LocationLayerCamera(mapboxMap, moveGestureDetector,
|
||||
return new LocationCameraController(mapboxMap, moveGestureDetector,
|
||||
onCameraTrackingChangedListener, onCameraMoveInvalidateListener);
|
||||
}
|
||||
|
||||
private LocationLayerCamera buildCamera(MoveGestureDetector moveGestureDetector) {
|
||||
private LocationCameraController buildCamera(MoveGestureDetector moveGestureDetector) {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
OnCameraTrackingChangedListener onCameraTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
|
||||
OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
|
||||
return new LocationLayerCamera(mapboxMap, moveGestureDetector,
|
||||
return new LocationCameraController(mapboxMap, moveGestureDetector,
|
||||
onCameraTrackingChangedListener, onCameraMoveInvalidateListener);
|
||||
}
|
||||
|
||||
private LocationLayerCamera buildCamera(MapboxMap mapboxMap) {
|
||||
private LocationCameraController buildCamera(MapboxMap mapboxMap) {
|
||||
MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
|
||||
OnCameraTrackingChangedListener onCameraTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
|
||||
OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
|
||||
return new LocationLayerCamera(mapboxMap, moveGestureDetector,
|
||||
return new LocationCameraController(mapboxMap, moveGestureDetector,
|
||||
onCameraTrackingChangedListener, onCameraMoveInvalidateListener);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class LocationLayerOptionsTest {
|
||||
public class LocationComponentOptionsTest {
|
||||
|
||||
@Mock
|
||||
private Context context;
|
||||
@@ -32,27 +32,27 @@ public class LocationLayerOptionsTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
when(context.obtainStyledAttributes(R.style.mapbox_LocationLayer, R.styleable.mapbox_LocationLayer))
|
||||
when(context.obtainStyledAttributes(R.style.mapbox_LocationComponent, R.styleable.mapbox_LocationComponent))
|
||||
.thenReturn(array);
|
||||
when(array.getResourceId(R.styleable.mapbox_LocationLayer_mapbox_foregroundDrawable, -1))
|
||||
when(array.getResourceId(R.styleable.mapbox_LocationComponent_mapbox_foregroundDrawable, -1))
|
||||
.thenReturn(R.drawable.mapbox_user_icon);
|
||||
when(context.getResources()).thenReturn(resources);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sanity() throws Exception {
|
||||
LocationLayerOptions locationLayerOptions = LocationLayerOptions.builder(context)
|
||||
LocationComponentOptions locationComponentOptions = LocationComponentOptions.builder(context)
|
||||
.accuracyAlpha(0.5f)
|
||||
.build();
|
||||
assertNotNull(locationLayerOptions);
|
||||
assertNotNull(locationComponentOptions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void passingOutOfRangeAccuracyAlpha_throwsException() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Location layer accuracy alpha value must be between 0.0 and "
|
||||
thrown.expectMessage("Accuracy alpha value must be between 0.0 and "
|
||||
+ "1.0.");
|
||||
LocationLayerOptions.builder(context)
|
||||
LocationComponentOptions.builder(context)
|
||||
.accuracyAlpha(2f)
|
||||
.build();
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class LocationLayerOptionsTest {
|
||||
public void negativeElevation_causesExceptionToBeThrown() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid shadow size -500.0. Must be >= 0");
|
||||
LocationLayerOptions.builder(context)
|
||||
LocationComponentOptions.builder(context)
|
||||
.elevation(-500)
|
||||
.build();
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.mapbox.geojson.Feature;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.location.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
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_RADIUS;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_COMPASS_BEARING;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_GPS_BEARING;
|
||||
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.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_RADIUS;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_COMPASS_BEARING;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_GPS_BEARING;
|
||||
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 org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class LocationLayerTest {
|
||||
public class LocationLayerControllerTest {
|
||||
|
||||
@Test
|
||||
public void onInitialization_locationSourceIsAdded() {
|
||||
@@ -44,9 +44,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addSource(locationSource);
|
||||
}
|
||||
@@ -60,9 +60,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addLayerBelow(shadowLayer, BACKGROUND_LAYER);
|
||||
}
|
||||
@@ -76,9 +76,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addLayerBelow(backgroundLayer, FOREGROUND_LAYER);
|
||||
}
|
||||
@@ -92,9 +92,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addLayerBelow(foregroundLayer, BEARING_LAYER);
|
||||
}
|
||||
@@ -108,11 +108,11 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
String layerBelow = "layer-below";
|
||||
when(options.layerBelow()).thenReturn(layerBelow);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addLayerBelow(bearingLayer, layerBelow);
|
||||
}
|
||||
@@ -126,9 +126,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addLayerBelow(accuracyLayer, BACKGROUND_LAYER);
|
||||
}
|
||||
@@ -140,12 +140,12 @@ public class LocationLayerTest {
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateShadowBitmap(any(LocationLayerOptions.class))).thenReturn(bitmap);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
when(bitmapProvider.generateShadowBitmap(any(LocationComponentOptions.class))).thenReturn(bitmap);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
when(options.elevation()).thenReturn(2f);
|
||||
|
||||
// Style is applied on initialization
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(SHADOW_ICON, bitmap);
|
||||
}
|
||||
@@ -157,11 +157,11 @@ public class LocationLayerTest {
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateShadowBitmap(any(LocationLayerOptions.class))).thenReturn(bitmap);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
when(bitmapProvider.generateShadowBitmap(any(LocationComponentOptions.class))).thenReturn(bitmap);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
when(options.elevation()).thenReturn(0f);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap, times(0)).addImage(SHADOW_ICON, bitmap);
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public class LocationLayerTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
int drawableResId = 123;
|
||||
int tintColor = 456;
|
||||
when(options.foregroundDrawable()).thenReturn(drawableResId);
|
||||
@@ -180,7 +180,7 @@ public class LocationLayerTest {
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(FOREGROUND_ICON, bitmap);
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class LocationLayerTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
int drawableResId = 123;
|
||||
int tintColor = 456;
|
||||
when(options.foregroundDrawableStale()).thenReturn(drawableResId);
|
||||
@@ -199,7 +199,7 @@ public class LocationLayerTest {
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(FOREGROUND_STALE_ICON, bitmap);
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class LocationLayerTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
int drawableResId = 123;
|
||||
int tintColor = 456;
|
||||
when(options.backgroundDrawable()).thenReturn(drawableResId);
|
||||
@@ -218,7 +218,7 @@ public class LocationLayerTest {
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(BACKGROUND_ICON, bitmap);
|
||||
}
|
||||
@@ -228,7 +228,7 @@ public class LocationLayerTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
int drawableResId = 123;
|
||||
int tintColor = 456;
|
||||
when(options.backgroundDrawableStale()).thenReturn(drawableResId);
|
||||
@@ -237,7 +237,7 @@ public class LocationLayerTest {
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(BACKGROUND_STALE_ICON, bitmap);
|
||||
}
|
||||
@@ -247,7 +247,7 @@ public class LocationLayerTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
int drawableResId = 123;
|
||||
int tintColor = 456;
|
||||
when(options.bearingDrawable()).thenReturn(drawableResId);
|
||||
@@ -256,7 +256,7 @@ public class LocationLayerTest {
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(BEARING_ICON, bitmap);
|
||||
}
|
||||
@@ -268,9 +268,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
|
||||
@@ -286,9 +286,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
|
||||
@@ -305,9 +305,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
|
||||
@@ -325,9 +325,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
layer.setRenderMode(RenderMode.GPS);
|
||||
@@ -346,9 +346,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
layer.setRenderMode(RenderMode.COMPASS);
|
||||
@@ -367,9 +367,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
layer.setRenderMode(RenderMode.COMPASS);
|
||||
@@ -388,9 +388,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
layer.setRenderMode(RenderMode.GPS);
|
||||
@@ -409,9 +409,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
float accuracyRadiusValue = 2f;
|
||||
@@ -429,9 +429,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
layer.setRenderMode(RenderMode.GPS);
|
||||
@@ -442,13 +442,13 @@ public class LocationLayerTest {
|
||||
verify(locationFeature, times(0)).addNumberProperty(PROPERTY_ACCURACY_RADIUS, accuracyRadiusValue);
|
||||
}
|
||||
|
||||
private LayerFeatureProvider buildFeatureProvider(LocationLayerOptions options) {
|
||||
private LayerFeatureProvider buildFeatureProvider(LocationComponentOptions options) {
|
||||
LayerFeatureProvider provider = mock(LayerFeatureProvider.class);
|
||||
when(provider.generateLocationFeature(null, options)).thenReturn(mock(Feature.class));
|
||||
return provider;
|
||||
}
|
||||
|
||||
private LayerFeatureProvider buildFeatureProvider(Feature feature, LocationLayerOptions options) {
|
||||
private LayerFeatureProvider buildFeatureProvider(Feature feature, LocationComponentOptions options) {
|
||||
LayerFeatureProvider provider = mock(LayerFeatureProvider.class);
|
||||
when(provider.generateLocationFeature(null, options)).thenReturn(feature);
|
||||
return provider;
|
||||
@@ -0,0 +1,284 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
|
||||
import android.location.Location
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_TRACKING_TILT_ANIM_DURATION
|
||||
import com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_TRACKING_ZOOM_ANIM_DURATION
|
||||
import com.mapbox.mapboxsdk.location.MapboxAnimator.*
|
||||
import junit.framework.Assert.assertEquals
|
||||
import junit.framework.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class MapboxAnimatorCoordinatorTest {
|
||||
|
||||
private lateinit var locationAnimatorCoordinator: LocationAnimatorCoordinator
|
||||
private val cameraPosition: CameraPosition = CameraPosition.DEFAULT
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
locationAnimatorCoordinator = LocationAnimatorCoordinator()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_animatorsAreCreated() {
|
||||
locationAnimatorCoordinator.feedNewLocation(Location(""), cameraPosition, false)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_animatorValue() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
|
||||
|
||||
val cameraLatLngTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG]?.target as LatLng
|
||||
assertEquals(cameraLatLngTarget.latitude, cameraLatLngTarget.latitude)
|
||||
|
||||
val layerLatLngTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG]?.target as LatLng
|
||||
assertEquals(layerLatLngTarget.latitude, layerLatLngTarget.latitude)
|
||||
|
||||
val cameraBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_isNorth_animatorsAreCreated() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_isNorth_animatorValue() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, true)
|
||||
|
||||
val cameraLatLngTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG]?.target as LatLng
|
||||
assertEquals(cameraLatLngTarget.latitude, cameraLatLngTarget.latitude)
|
||||
|
||||
val layerLatLngTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG]?.target as LatLng
|
||||
assertEquals(layerLatLngTarget.latitude, layerLatLngTarget.latitude)
|
||||
|
||||
val cameraBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING]?.target as Float
|
||||
assertEquals(0f, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewCompassBearing_animatorsAreCreated() {
|
||||
locationAnimatorCoordinator.feedNewCompassBearing(77f, cameraPosition)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_COMPASS_BEARING] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_COMPASS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewCompassBearing_animatorValue() {
|
||||
val bearing = 77f
|
||||
locationAnimatorCoordinator.feedNewCompassBearing(bearing, cameraPosition)
|
||||
|
||||
val cameraBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_COMPASS_BEARING]?.target as Float
|
||||
assertEquals(bearing, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_COMPASS_BEARING]?.target as Float
|
||||
assertEquals(bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_animatorsCreated() {
|
||||
locationAnimatorCoordinator.feedNewAccuracyRadius(150f, false)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_animatorValue() {
|
||||
val accuracy = 150f
|
||||
locationAnimatorCoordinator.feedNewAccuracyRadius(accuracy, false)
|
||||
|
||||
val layerAccuracy = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.target as Float
|
||||
assertEquals(layerAccuracy, accuracy)
|
||||
|
||||
val animationDuration = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.duration as Long
|
||||
assertEquals(LocationComponentConstants.ACCURACY_RADIUS_ANIMATION_DURATION, animationDuration)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_noAnimation_animatorsCreated() {
|
||||
locationAnimatorCoordinator.feedNewAccuracyRadius(150f, true)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_noAnimation_animatorValue() {
|
||||
val accuracy = 150f
|
||||
locationAnimatorCoordinator.feedNewAccuracyRadius(accuracy, true)
|
||||
|
||||
val layerAccuracy = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.target as Float
|
||||
assertEquals(layerAccuracy, accuracy)
|
||||
|
||||
val animationDuration = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.duration as Long
|
||||
assertEquals(0L, animationDuration)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewZoomLevel_animatorsCreated() {
|
||||
locationAnimatorCoordinator.feedNewZoomLevel(
|
||||
15.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewZoomLevel_animatorValue() {
|
||||
val zoom = 15.0f
|
||||
locationAnimatorCoordinator.feedNewZoomLevel(
|
||||
zoom.toDouble(),
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
val animationDuration = locationAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM]?.duration as Long
|
||||
assertEquals(DEFAULT_TRACKING_ZOOM_ANIM_DURATION, animationDuration)
|
||||
|
||||
val target = locationAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM]?.target as Float
|
||||
assertEquals(zoom, target)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewTiltLevel_animatorsCreated() {
|
||||
locationAnimatorCoordinator.feedNewTilt(
|
||||
30.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_TILT] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewTiltLevel_animatorValue() {
|
||||
val tilt = 30.0f
|
||||
locationAnimatorCoordinator.feedNewTilt(
|
||||
tilt.toDouble(),
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
val animationDuration = locationAnimatorCoordinator.animatorMap[ANIMATOR_TILT]?.duration as Long
|
||||
assertEquals(DEFAULT_TRACKING_TILT_ANIM_DURATION, animationDuration)
|
||||
|
||||
val target = locationAnimatorCoordinator.animatorMap[ANIMATOR_TILT]?.target as Float
|
||||
assertEquals(tilt, target)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelAllAnimators() {
|
||||
locationAnimatorCoordinator.feedNewLocation(Location(""), cameraPosition, true)
|
||||
locationAnimatorCoordinator.cancelAllAnimations()
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelZoomAnimators() {
|
||||
locationAnimatorCoordinator.feedNewZoomLevel(
|
||||
15.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
locationAnimatorCoordinator.cancelZoomAnimation()
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelTiltAnimation() {
|
||||
locationAnimatorCoordinator.feedNewTilt(
|
||||
30.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
locationAnimatorCoordinator.cancelTiltAnimation()
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_TILT] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resetAllCameraAnimations_empty() {
|
||||
locationAnimatorCoordinator.resetAllCameraAnimations(cameraPosition, false)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addLayerListener() {
|
||||
val layerListener = Mockito.mock(OnLayerAnimationsValuesChangeListener::class.java)
|
||||
locationAnimatorCoordinator.addLayerListener(layerListener)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.layerListeners.contains(layerListener))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun removeLayerListener() {
|
||||
val layerListener = Mockito.mock(OnLayerAnimationsValuesChangeListener::class.java)
|
||||
locationAnimatorCoordinator.addLayerListener(layerListener)
|
||||
locationAnimatorCoordinator.removeLayerListener(layerListener)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.layerListeners.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addCameraListener() {
|
||||
val cameraListener = Mockito.mock(OnCameraAnimationsValuesChangeListener::class.java)
|
||||
locationAnimatorCoordinator.addCameraListener(cameraListener)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.cameraListeners.contains(cameraListener))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun removeCameraListener() {
|
||||
val cameraListener = Mockito.mock(OnCameraAnimationsValuesChangeListener::class.java)
|
||||
locationAnimatorCoordinator.addCameraListener(cameraListener)
|
||||
locationAnimatorCoordinator.removeCameraListener(cameraListener)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.cameraListeners.isEmpty())
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -6,7 +6,6 @@ import static junit.framework.Assert.assertEquals;
|
||||
|
||||
public final class UtilsTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void shortestRotation_doesReturnValueDistanceQuickestToZero() throws Exception {
|
||||
float value = Utils.shortestRotation(0, 181);
|
||||
@@ -1,284 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer
|
||||
|
||||
import android.location.Location
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.DEFAULT_TRACKING_TILT_ANIM_DURATION
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.DEFAULT_TRACKING_ZOOM_ANIM_DURATION
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.PluginAnimator.*
|
||||
import junit.framework.Assert.assertEquals
|
||||
import junit.framework.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class PluginAnimatorCoordinatorTest {
|
||||
|
||||
private lateinit var pluginAnimatorCoordinator: PluginAnimatorCoordinator
|
||||
private val cameraPosition: CameraPosition = CameraPosition.DEFAULT
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
pluginAnimatorCoordinator = PluginAnimatorCoordinator()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_animatorsAreCreated() {
|
||||
pluginAnimatorCoordinator.feedNewLocation(Location(""), cameraPosition, false)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_animatorValue() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
pluginAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
|
||||
|
||||
val cameraLatLngTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG]?.target as LatLng
|
||||
assertEquals(cameraLatLngTarget.latitude, cameraLatLngTarget.latitude)
|
||||
|
||||
val layerLatLngTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG]?.target as LatLng
|
||||
assertEquals(layerLatLngTarget.latitude, layerLatLngTarget.latitude)
|
||||
|
||||
val cameraBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_isNorth_animatorsAreCreated() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
pluginAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_isNorth_animatorValue() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
pluginAnimatorCoordinator.feedNewLocation(location, cameraPosition, true)
|
||||
|
||||
val cameraLatLngTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG]?.target as LatLng
|
||||
assertEquals(cameraLatLngTarget.latitude, cameraLatLngTarget.latitude)
|
||||
|
||||
val layerLatLngTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG]?.target as LatLng
|
||||
assertEquals(layerLatLngTarget.latitude, layerLatLngTarget.latitude)
|
||||
|
||||
val cameraBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING]?.target as Float
|
||||
assertEquals(0f, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewCompassBearing_animatorsAreCreated() {
|
||||
pluginAnimatorCoordinator.feedNewCompassBearing(77f, cameraPosition)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_COMPASS_BEARING] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_COMPASS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewCompassBearing_animatorValue() {
|
||||
val bearing = 77f
|
||||
pluginAnimatorCoordinator.feedNewCompassBearing(bearing, cameraPosition)
|
||||
|
||||
val cameraBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_COMPASS_BEARING]?.target as Float
|
||||
assertEquals(bearing, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_COMPASS_BEARING]?.target as Float
|
||||
assertEquals(bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_animatorsCreated() {
|
||||
pluginAnimatorCoordinator.feedNewAccuracyRadius(150f, false)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_animatorValue() {
|
||||
val accuracy = 150f
|
||||
pluginAnimatorCoordinator.feedNewAccuracyRadius(accuracy, false)
|
||||
|
||||
val layerAccuracy = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.target as Float
|
||||
assertEquals(layerAccuracy, accuracy)
|
||||
|
||||
val animationDuration = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.duration as Long
|
||||
assertEquals(LocationLayerConstants.ACCURACY_RADIUS_ANIMATION_DURATION, animationDuration)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_noAnimation_animatorsCreated() {
|
||||
pluginAnimatorCoordinator.feedNewAccuracyRadius(150f, true)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_noAnimation_animatorValue() {
|
||||
val accuracy = 150f
|
||||
pluginAnimatorCoordinator.feedNewAccuracyRadius(accuracy, true)
|
||||
|
||||
val layerAccuracy = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.target as Float
|
||||
assertEquals(layerAccuracy, accuracy)
|
||||
|
||||
val animationDuration = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.duration as Long
|
||||
assertEquals(0L, animationDuration)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewZoomLevel_animatorsCreated() {
|
||||
pluginAnimatorCoordinator.feedNewZoomLevel(
|
||||
15.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewZoomLevel_animatorValue() {
|
||||
val zoom = 15.0f
|
||||
pluginAnimatorCoordinator.feedNewZoomLevel(
|
||||
zoom.toDouble(),
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
val animationDuration = pluginAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM]?.duration as Long
|
||||
assertEquals(DEFAULT_TRACKING_ZOOM_ANIM_DURATION, animationDuration)
|
||||
|
||||
val target = pluginAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM]?.target as Float
|
||||
assertEquals(zoom, target)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewTiltLevel_animatorsCreated() {
|
||||
pluginAnimatorCoordinator.feedNewTilt(
|
||||
30.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_TILT] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewTiltLevel_animatorValue() {
|
||||
val tilt = 30.0f
|
||||
pluginAnimatorCoordinator.feedNewTilt(
|
||||
tilt.toDouble(),
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
val animationDuration = pluginAnimatorCoordinator.animatorMap[ANIMATOR_TILT]?.duration as Long
|
||||
assertEquals(DEFAULT_TRACKING_TILT_ANIM_DURATION, animationDuration)
|
||||
|
||||
val target = pluginAnimatorCoordinator.animatorMap[ANIMATOR_TILT]?.target as Float
|
||||
assertEquals(tilt, target)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelAllAnimators() {
|
||||
pluginAnimatorCoordinator.feedNewLocation(Location(""), cameraPosition, true)
|
||||
pluginAnimatorCoordinator.cancelAllAnimations()
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelZoomAnimators() {
|
||||
pluginAnimatorCoordinator.feedNewZoomLevel(
|
||||
15.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
pluginAnimatorCoordinator.cancelZoomAnimation()
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelTiltAnimation() {
|
||||
pluginAnimatorCoordinator.feedNewTilt(
|
||||
30.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
pluginAnimatorCoordinator.cancelTiltAnimation()
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_TILT] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resetAllCameraAnimations_empty() {
|
||||
pluginAnimatorCoordinator.resetAllCameraAnimations(cameraPosition, false)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addLayerListener() {
|
||||
val layerListener = Mockito.mock(OnLayerAnimationsValuesChangeListener::class.java)
|
||||
pluginAnimatorCoordinator.addLayerListener(layerListener)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.layerListeners.contains(layerListener))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun removeLayerListener() {
|
||||
val layerListener = Mockito.mock(OnLayerAnimationsValuesChangeListener::class.java)
|
||||
pluginAnimatorCoordinator.addLayerListener(layerListener)
|
||||
pluginAnimatorCoordinator.removeLayerListener(layerListener)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.layerListeners.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addCameraListener() {
|
||||
val cameraListener = Mockito.mock(OnCameraAnimationsValuesChangeListener::class.java)
|
||||
pluginAnimatorCoordinator.addCameraListener(cameraListener)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.cameraListeners.contains(cameraListener))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun removeCameraListener() {
|
||||
val cameraListener = Mockito.mock(OnCameraAnimationsValuesChangeListener::class.java)
|
||||
pluginAnimatorCoordinator.addCameraListener(cameraListener)
|
||||
pluginAnimatorCoordinator.removeCameraListener(cameraListener)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.cameraListeners.isEmpty())
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer
|
||||
package com.mapbox.mapboxsdk.location
|
||||
|
||||
import android.Manifest
|
||||
import android.R
|
||||
@@ -17,13 +17,13 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
|
||||
import com.mapbox.mapboxsdk.constants.Style
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.*
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode
|
||||
import com.mapbox.mapboxsdk.plugins.utils.*
|
||||
import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAPBOX_HEAVY_STYLE
|
||||
import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAP_CONNECTION_DELAY
|
||||
import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.MAP_RENDER_DELAY
|
||||
import com.mapbox.mapboxsdk.plugins.utils.MapboxTestingUtils.Companion.pushSourceUpdates
|
||||
import com.mapbox.mapboxsdk.location.LocationComponentConstants.*
|
||||
import com.mapbox.mapboxsdk.location.modes.RenderMode
|
||||
import com.mapbox.mapboxsdk.location.utils.*
|
||||
import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAPBOX_HEAVY_STYLE
|
||||
import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAP_CONNECTION_DELAY
|
||||
import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.MAP_RENDER_DELAY
|
||||
import com.mapbox.mapboxsdk.location.utils.MapboxTestingUtils.Companion.pushSourceUpdates
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest
|
||||
import com.mapbox.mapboxsdk.testapp.activity.SingleActivity
|
||||
@@ -39,7 +39,7 @@ import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LocationLayerTest : BaseActivityTest() {
|
||||
class LocationLayerControllerTest : BaseActivityTest() {
|
||||
|
||||
@Rule
|
||||
@JvmField
|
||||
@@ -51,7 +51,7 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
|
||||
private lateinit var styleChangeIdlingResource: StyleChangeIdlingResource
|
||||
private val location: Location by lazy {
|
||||
val initLocation = Location("test")
|
||||
val initLocation = Location("")
|
||||
initLocation.latitude = 15.0
|
||||
initLocation.longitude = 17.0
|
||||
initLocation.bearing = 10f
|
||||
@@ -72,16 +72,16 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
|
||||
@Test
|
||||
fun renderModeNormal_sourceDoesGetAdded() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.NORMAL
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
assertThat(mapboxMap.getSource(LOCATION_SOURCE), notNullValue())
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
//
|
||||
@@ -90,12 +90,12 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
|
||||
@Test
|
||||
fun renderModeNormal_trackingNormalLayersDoGetAdded() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.NORMAL
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
|
||||
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
|
||||
@@ -104,17 +104,17 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun renderModeCompass_bearingLayersDoGetAdded() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.COMPASS
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.COMPASS
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
|
||||
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
|
||||
@@ -123,17 +123,17 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(true))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun renderModeGps_navigationLayersDoGetAdded() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.GPS
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.GPS
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(true))
|
||||
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(true))
|
||||
@@ -142,20 +142,20 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dontShowPuckWhenRenderModeSetAndPluginDisabled() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
fun dontShowPuckWhenRenderModeSetAndComponentDisabled() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
plugin.deactivateLocationLayerPlugin()
|
||||
component.deactivateLocationComponent()
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER, shouldDisappear = true)
|
||||
plugin.renderMode = RenderMode.GPS
|
||||
component.renderMode = RenderMode.GPS
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
assertThat(mapboxMap.isLayerVisible(FOREGROUND_LAYER), `is`(false))
|
||||
assertThat(mapboxMap.isLayerVisible(BACKGROUND_LAYER), `is`(false))
|
||||
@@ -164,19 +164,19 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenLocationLayerPluginDisabled_doesSetAllLayersToVisibilityNone() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
fun whenLocationComponentDisabled_doesSetAllLayersToVisibilityNone() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.NORMAL
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
plugin.deactivateLocationLayerPlugin()
|
||||
component.deactivateLocationComponent()
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER, shouldDisappear = true)
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
|
||||
@@ -188,24 +188,24 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onMapChange_locationLayerLayersDoGetRedrawn() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
fun onMapChange_locationComponentLayersDoGetRedrawn() {
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.renderMode = RenderMode.NORMAL
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.renderMode = RenderMode.NORMAL
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
mapboxMap.setStyleUrl(Style.LIGHT)
|
||||
uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY)
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
|
||||
assertThat(plugin.renderMode, `is`(equalTo(RenderMode.NORMAL)))
|
||||
assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL)))
|
||||
|
||||
// Check that the Source has been re-added to the new map style
|
||||
val source: GeoJsonSource? = mapboxMap.getSourceAs(LOCATION_SOURCE)
|
||||
@@ -219,17 +219,17 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.isLayerVisible(BEARING_LAYER), `is`(false))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenStyleChanged_continuesUsingStaleIcons() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.applyStyle(LocationLayerOptions.builder(context).staleStateTimeout(100).build())
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(100).build())
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
uiController.loopMainThreadForAtLeast(150)
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
@@ -243,23 +243,23 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true))
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenStyleChanged_staleStateChanges() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.applyStyle(LocationLayerOptions.builder(context).staleStateTimeout(1).build())
|
||||
component.activateLocationComponent(context, false)
|
||||
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(1).build())
|
||||
styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
|
||||
pushSourceUpdates(styleChangeIdlingResource) {
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.forceLocationUpdate(location)
|
||||
}
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
|
||||
// Waiting for style to finish loading while pushing updates
|
||||
onView(withId(R.id.content)).check(matches(isDisplayed()))
|
||||
@@ -267,16 +267,16 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
|
||||
@Test
|
||||
fun whenStyleChanged_layerVisibilityUpdates() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
|
||||
var show = true
|
||||
pushSourceUpdates(styleChangeIdlingResource) {
|
||||
if (show) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
component.activateLocationComponent(context, false)
|
||||
} else {
|
||||
plugin.deactivateLocationLayerPlugin()
|
||||
component.deactivateLocationComponent()
|
||||
}
|
||||
show = !show
|
||||
}
|
||||
@@ -284,7 +284,7 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
uiController.loopMainThreadForAtLeast(MAP_CONNECTION_DELAY)
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
|
||||
// Waiting for style to finish loading while pushing updates
|
||||
onView(withId(R.id.content)).check(matches(isDisplayed()))
|
||||
@@ -292,12 +292,12 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
|
||||
@Test
|
||||
fun accuracy_visibleWithNewLocation() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
component.activateLocationComponent(context, false)
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0))
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
uiController.loopMainThreadForAtLeast(ACCURACY_RADIUS_ANIMATION_DURATION)
|
||||
|
||||
@@ -306,16 +306,16 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
.getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(), 0.1f)
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun accuracy_visibleWhenCameraEased() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.activateLocationComponent(context, false)
|
||||
component.forceLocationUpdate(location)
|
||||
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0), 300)
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY + 300)
|
||||
@@ -325,17 +325,17 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
.getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(), 0.1f)
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun accuracy_visibleWhenCameraMoved() {
|
||||
val pluginAction = object : LocationLayerPluginAction.OnPerformLocationLayerPluginAction {
|
||||
override fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap,
|
||||
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
|
||||
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
|
||||
uiController: UiController, context: Context) {
|
||||
plugin.activateLocationLayerPlugin(context, false)
|
||||
component.activateLocationComponent(context, false)
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
plugin.forceLocationUpdate(location)
|
||||
component.forceLocationUpdate(location)
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0))
|
||||
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY + 300)
|
||||
@@ -345,7 +345,7 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
.getNumberProperty(PROPERTY_ACCURACY_RADIUS).toFloat(), 0.1f)
|
||||
}
|
||||
}
|
||||
executePluginTest(pluginAction)
|
||||
executeComponentTest(componentAction)
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -354,7 +354,7 @@ class LocationLayerTest : BaseActivityTest() {
|
||||
IdlingRegistry.getInstance().unregister(styleChangeIdlingResource)
|
||||
}
|
||||
|
||||
private fun executePluginTest(listener: LocationLayerPluginAction.OnPerformLocationLayerPluginAction) {
|
||||
onView(withId(R.id.content)).perform(LocationLayerPluginAction(mapboxMap, listener))
|
||||
private fun executeComponentTest(listener: LocationComponentAction.OnPerformLocationComponentAction) {
|
||||
onView(withId(R.id.content)).perform(LocationComponentAction(mapboxMap, listener))
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils
|
||||
package com.mapbox.mapboxsdk.location.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.support.test.espresso.UiController
|
||||
@@ -6,11 +6,11 @@ import android.support.test.espresso.ViewAction
|
||||
import android.support.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import android.view.View
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin
|
||||
import com.mapbox.mapboxsdk.location.LocationComponent
|
||||
import org.hamcrest.Matcher
|
||||
|
||||
class LocationLayerPluginAction(private val mapboxMap: MapboxMap,
|
||||
private val onPerformLocationLayerPluginAction: OnPerformLocationLayerPluginAction) : ViewAction {
|
||||
class LocationComponentAction(private val mapboxMap: MapboxMap,
|
||||
private val onPerformLocationComponentAction: OnPerformLocationComponentAction) : ViewAction {
|
||||
|
||||
override fun getConstraints(): Matcher<View> {
|
||||
return isDisplayed()
|
||||
@@ -21,20 +21,20 @@ class LocationLayerPluginAction(private val mapboxMap: MapboxMap,
|
||||
}
|
||||
|
||||
override fun perform(uiController: UiController, view: View) {
|
||||
val plugin = mapboxMap.locationLayerPlugin
|
||||
val component = mapboxMap.locationComponent
|
||||
|
||||
while (mapboxMap.getSource("mapbox-location-source") == null) {
|
||||
uiController.loopMainThreadForAtLeast(MapboxTestingUtils.MAP_RENDER_DELAY)
|
||||
}
|
||||
|
||||
onPerformLocationLayerPluginAction.onLocationLayerPluginAction(
|
||||
plugin,
|
||||
onPerformLocationComponentAction.onLocationComponentAction(
|
||||
component,
|
||||
mapboxMap,
|
||||
uiController,
|
||||
view.context)
|
||||
}
|
||||
|
||||
interface OnPerformLocationLayerPluginAction {
|
||||
fun onLocationLayerPluginAction(plugin: LocationLayerPlugin, mapboxMap: MapboxMap, uiController: UiController, context: Context)
|
||||
interface OnPerformLocationComponentAction {
|
||||
fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, uiController: UiController, context: Context)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils
|
||||
package com.mapbox.mapboxsdk.location.utils
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils
|
||||
package com.mapbox.mapboxsdk.location.utils
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils;
|
||||
package com.mapbox.mapboxsdk.location.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Handler;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.utils
|
||||
package com.mapbox.mapboxsdk.location.utils
|
||||
|
||||
import android.support.test.espresso.IdlingResource
|
||||
import com.mapbox.mapboxsdk.maps.MapView
|
||||
@@ -816,7 +816,7 @@
|
||||
android:value="com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.location.LocationLayerMapChangeActivity"
|
||||
android:name=".activity.location.LocationMapChangeActivity"
|
||||
android:description="@string/description_location_map_change"
|
||||
android:label="@string/activity_location_map_change">
|
||||
<meta-data
|
||||
@@ -827,7 +827,7 @@
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.location.LocationLayerModesActivity"
|
||||
android:name=".activity.location.LocationModesActivity"
|
||||
android:description="@string/description_location_modes"
|
||||
android:label="@string/activity_location_modes">
|
||||
<meta-data
|
||||
@@ -838,7 +838,7 @@
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.location.LocationLayerFragmentActivity"
|
||||
android:name=".activity.location.LocationFragmentActivity"
|
||||
android:description="@string/description_location_fragment"
|
||||
android:label="@string/activity_location_fragment">
|
||||
<meta-data
|
||||
|
||||
@@ -17,11 +17,11 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.maps.MapView
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin
|
||||
import com.mapbox.mapboxsdk.location.LocationComponent
|
||||
import com.mapbox.mapboxsdk.testapp.R
|
||||
import kotlinx.android.synthetic.main.activity_location_layer_fragment.*
|
||||
|
||||
class LocationLayerFragmentActivity : AppCompatActivity() {
|
||||
class LocationFragmentActivity : AppCompatActivity() {
|
||||
private lateinit var permissionsManager: PermissionsManager
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -46,13 +46,13 @@ class LocationLayerFragmentActivity : AppCompatActivity() {
|
||||
if (savedInstanceState == null) {
|
||||
fragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.container, LocationLayerFragment.newInstance(), LocationLayerFragment.TAG)
|
||||
.replace(R.id.container, LocationFragment.newInstance(), LocationFragment.TAG)
|
||||
.commit()
|
||||
}
|
||||
} else {
|
||||
permissionsManager = PermissionsManager(object : PermissionsListener {
|
||||
override fun onExplanationNeeded(permissionsToExplain: MutableList<String>?) {
|
||||
Toast.makeText(this@LocationLayerFragmentActivity, "You need to accept location permissions.",
|
||||
Toast.makeText(this@LocationFragmentActivity, "You need to accept location permissions.",
|
||||
Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class LocationLayerFragmentActivity : AppCompatActivity() {
|
||||
if (savedInstanceState == null) {
|
||||
fragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.container, LocationLayerFragment.newInstance(), LocationLayerFragment.TAG)
|
||||
.replace(R.id.container, LocationFragment.newInstance(), LocationFragment.TAG)
|
||||
.commit()
|
||||
}
|
||||
} else {
|
||||
@@ -78,17 +78,17 @@ class LocationLayerFragmentActivity : AppCompatActivity() {
|
||||
permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
}
|
||||
|
||||
class LocationLayerFragment : Fragment(), LocationEngineListener {
|
||||
class LocationFragment : Fragment(), LocationEngineListener {
|
||||
companion object {
|
||||
const val TAG = "LLFragment"
|
||||
fun newInstance(): LocationLayerFragment {
|
||||
return LocationLayerFragment()
|
||||
const val TAG = "LFragment"
|
||||
fun newInstance(): LocationFragment {
|
||||
return LocationFragment()
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var mapView: MapView
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var plugin: LocationLayerPlugin? = null
|
||||
private var component: LocationComponent? = null
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
mapView = MapView(inflater.context)
|
||||
@@ -100,16 +100,16 @@ class LocationLayerFragmentActivity : AppCompatActivity() {
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync {
|
||||
mapboxMap = it
|
||||
plugin = mapboxMap.locationLayerPlugin
|
||||
plugin?.activateLocationLayerPlugin(activity)
|
||||
plugin?.locationEngine?.addLocationEngineListener(this)
|
||||
component = mapboxMap.locationComponent
|
||||
component?.activateLocationComponent(activity)
|
||||
component?.locationEngine?.addLocationEngineListener(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLocationChanged(location: Location?) {
|
||||
if (location != null) {
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 12.0))
|
||||
plugin?.locationEngine?.removeLocationEngineListener(this)
|
||||
component?.locationEngine?.removeLocationEngineListener(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class LocationLayerFragmentActivity : AppCompatActivity() {
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
mapView.onDestroy()
|
||||
plugin?.locationEngine?.removeLocationEngineListener(this)
|
||||
component?.locationEngine?.removeLocationEngineListener(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ import com.mapbox.android.core.permissions.PermissionsManager;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.location.LocationComponent;
|
||||
import com.mapbox.mapboxsdk.location.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LocationLayerMapChangeActivity extends AppCompatActivity implements OnMapReadyCallback {
|
||||
public class LocationMapChangeActivity extends AppCompatActivity implements OnMapReadyCallback {
|
||||
|
||||
private MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
@@ -51,14 +51,14 @@ public class LocationLayerMapChangeActivity extends AppCompatActivity implements
|
||||
permissionsManager = new PermissionsManager(new PermissionsListener() {
|
||||
@Override
|
||||
public void onExplanationNeeded(List<String> permissionsToExplain) {
|
||||
Toast.makeText(LocationLayerMapChangeActivity.this, "You need to accept location permissions.",
|
||||
Toast.makeText(LocationMapChangeActivity.this, "You need to accept location permissions.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionResult(boolean granted) {
|
||||
if (granted) {
|
||||
mapView.getMapAsync(LocationLayerMapChangeActivity.this);
|
||||
mapView.getMapAsync(LocationMapChangeActivity.this);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
@@ -77,14 +77,14 @@ public class LocationLayerMapChangeActivity extends AppCompatActivity implements
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
this.mapboxMap = mapboxMap;
|
||||
activateLocationLayer();
|
||||
activateLocationComponent();
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private void activateLocationLayer() {
|
||||
LocationLayerPlugin locationPlugin = mapboxMap.getLocationLayerPlugin();
|
||||
locationPlugin.activateLocationLayerPlugin(this);
|
||||
locationPlugin.setRenderMode(RenderMode.COMPASS);
|
||||
private void activateLocationComponent() {
|
||||
LocationComponent locationComponent = mapboxMap.getLocationComponent();
|
||||
locationComponent.activateLocationComponent(this);
|
||||
locationComponent.setRenderMode(RenderMode.COMPASS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,19 +25,19 @@ import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerOptions;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.OnCameraTrackingChangedListener;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.OnLocationLayerClickListener;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.CameraMode;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.location.LocationComponentOptions;
|
||||
import com.mapbox.mapboxsdk.location.LocationComponent;
|
||||
import com.mapbox.mapboxsdk.location.OnCameraTrackingChangedListener;
|
||||
import com.mapbox.mapboxsdk.location.OnLocationComponentClickListener;
|
||||
import com.mapbox.mapboxsdk.location.modes.CameraMode;
|
||||
import com.mapbox.mapboxsdk.location.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LocationLayerModesActivity extends AppCompatActivity implements OnMapReadyCallback,
|
||||
LocationEngineListener, OnLocationLayerClickListener, OnCameraTrackingChangedListener {
|
||||
public class LocationModesActivity extends AppCompatActivity implements OnMapReadyCallback,
|
||||
LocationEngineListener, OnLocationComponentClickListener, OnCameraTrackingChangedListener {
|
||||
|
||||
private MapView mapView;
|
||||
private Button locationModeBtn;
|
||||
@@ -45,7 +45,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
|
||||
private PermissionsManager permissionsManager;
|
||||
|
||||
private LocationLayerPlugin locationLayerPlugin;
|
||||
private LocationComponent locationComponent;
|
||||
private LocationEngine locationEngine;
|
||||
private MapboxMap mapboxMap;
|
||||
private boolean customStyle;
|
||||
@@ -63,7 +63,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
locationModeBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (locationLayerPlugin == null) {
|
||||
if (locationComponent == null) {
|
||||
return;
|
||||
}
|
||||
showModeListDialog();
|
||||
@@ -74,7 +74,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
locationTrackingBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (locationLayerPlugin == null) {
|
||||
if (locationComponent == null) {
|
||||
return;
|
||||
}
|
||||
showTrackingListDialog();
|
||||
@@ -89,14 +89,14 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
permissionsManager = new PermissionsManager(new PermissionsListener() {
|
||||
@Override
|
||||
public void onExplanationNeeded(List<String> permissionsToExplain) {
|
||||
Toast.makeText(LocationLayerModesActivity.this, "You need to accept location permissions.",
|
||||
Toast.makeText(LocationModesActivity.this, "You need to accept location permissions.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionResult(boolean granted) {
|
||||
if (granted) {
|
||||
mapView.getMapAsync(LocationLayerModesActivity.this);
|
||||
mapView.getMapAsync(LocationModesActivity.this);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
@@ -125,11 +125,11 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
locationEngine.addLocationEngineListener(this);
|
||||
locationEngine.activate();
|
||||
|
||||
locationLayerPlugin = mapboxMap.getLocationLayerPlugin();
|
||||
locationLayerPlugin.addOnLocationClickListener(this);
|
||||
locationLayerPlugin.addOnCameraTrackingChangedListener(this);
|
||||
locationComponent = mapboxMap.getLocationComponent();
|
||||
locationComponent.addOnLocationClickListener(this);
|
||||
locationComponent.addOnCameraTrackingChangedListener(this);
|
||||
|
||||
activateLocationLayer();
|
||||
activateLocationComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,7 +141,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (locationLayerPlugin == null) {
|
||||
if (locationComponent == null) {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@@ -152,19 +152,19 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
} else if (id == R.id.action_map_style_change) {
|
||||
toggleMapStyle();
|
||||
return true;
|
||||
} else if (id == R.id.action_plugin_disable) {
|
||||
locationLayerPlugin.deactivateLocationLayerPlugin();
|
||||
} else if (id == R.id.action_component_disable) {
|
||||
locationComponent.deactivateLocationComponent();
|
||||
return true;
|
||||
} else if (id == R.id.action_plugin_enabled) {
|
||||
activateLocationLayer();
|
||||
} else if (id == R.id.action_component_enabled) {
|
||||
activateLocationComponent();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void activateLocationLayer() {
|
||||
if (locationLayerPlugin != null) {
|
||||
private void activateLocationComponent() {
|
||||
if (locationComponent != null) {
|
||||
int[] padding;
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
padding = new int[] {0, 750, 0, 0};
|
||||
@@ -173,30 +173,30 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
}
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
LocationLayerOptions options = LocationLayerOptions.builder(this)
|
||||
LocationComponentOptions options = LocationComponentOptions.builder(this)
|
||||
.padding(padding)
|
||||
.layerBelow("waterway-label")
|
||||
.build();
|
||||
|
||||
locationLayerPlugin.activateLocationLayerPlugin(locationEngine, options);
|
||||
locationComponent.activateLocationComponent(locationEngine, options);
|
||||
} else {
|
||||
LocationLayerOptions options = locationLayerPlugin
|
||||
.getLocationLayerOptions()
|
||||
LocationComponentOptions options = locationComponent
|
||||
.getLocationComponentOptions()
|
||||
.toBuilder()
|
||||
.padding(padding)
|
||||
.build();
|
||||
|
||||
locationLayerPlugin.setLocationEngine(locationEngine);
|
||||
locationLayerPlugin.applyStyle(options);
|
||||
locationComponent.setLocationEngine(locationEngine);
|
||||
locationComponent.applyStyle(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleStyle() {
|
||||
customStyle = !customStyle;
|
||||
locationLayerPlugin.applyStyle(
|
||||
locationComponent.applyStyle(
|
||||
this,
|
||||
customStyle ? R.style.CustomLocationLayer : R.style.mapbox_LocationLayer);
|
||||
customStyle ? R.style.CustomLocationComponent : R.style.mapbox_LocationComponent);
|
||||
}
|
||||
|
||||
public void toggleMapStyle() {
|
||||
@@ -274,8 +274,8 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationLayerClick() {
|
||||
Toast.makeText(this, "OnLocationLayerClick", Toast.LENGTH_LONG).show();
|
||||
public void onLocationComponentClick() {
|
||||
Toast.makeText(this, "OnlocationComponentClick", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void showModeListDialog() {
|
||||
@@ -304,7 +304,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
}
|
||||
|
||||
private void setRendererMode(@RenderMode.Mode int mode) {
|
||||
locationLayerPlugin.setRenderMode(mode);
|
||||
locationComponent.setRenderMode(mode);
|
||||
if (mode == RenderMode.NORMAL) {
|
||||
locationModeBtn.setText("Normal");
|
||||
} else if (mode == RenderMode.COMPASS) {
|
||||
@@ -330,20 +330,20 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
String selectedTrackingType = trackingTypes.get(position);
|
||||
locationTrackingBtn.setText(selectedTrackingType);
|
||||
if (selectedTrackingType.contentEquals("None")) {
|
||||
locationLayerPlugin.setCameraMode(CameraMode.NONE);
|
||||
locationComponent.setCameraMode(CameraMode.NONE);
|
||||
} else if (selectedTrackingType.contentEquals("Tracking")) {
|
||||
locationLayerPlugin.setCameraMode(CameraMode.TRACKING);
|
||||
locationComponent.setCameraMode(CameraMode.TRACKING);
|
||||
} else if (selectedTrackingType.contentEquals("Tracking Compass")) {
|
||||
locationLayerPlugin.setCameraMode(CameraMode.TRACKING_COMPASS);
|
||||
locationComponent.setCameraMode(CameraMode.TRACKING_COMPASS);
|
||||
} else if (selectedTrackingType.contentEquals("Tracking GPS")) {
|
||||
locationLayerPlugin.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
locationComponent.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
} else if (selectedTrackingType.contentEquals("Tracking GPS North")) {
|
||||
locationLayerPlugin.setCameraMode(CameraMode.TRACKING_GPS_NORTH);
|
||||
locationComponent.setCameraMode(CameraMode.TRACKING_GPS_NORTH);
|
||||
}
|
||||
listPopup.dismiss();
|
||||
|
||||
if (locationLayerPlugin.getCameraMode() != CameraMode.NONE) {
|
||||
locationLayerPlugin.zoomWhileTracking(15, 750, new MapboxMap.CancelableCallback() {
|
||||
if (locationComponent.getCameraMode() != CameraMode.NONE) {
|
||||
locationComponent.zoomWhileTracking(15, 750, new MapboxMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
// No impl
|
||||
@@ -351,7 +351,7 @@ public class LocationLayerModesActivity extends AppCompatActivity implements OnM
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
locationLayerPlugin.tiltWhileTracking(45);
|
||||
locationComponent.tiltWhileTracking(45);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -18,8 +18,8 @@ import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.location.LocationComponent;
|
||||
import com.mapbox.mapboxsdk.location.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import java.util.List;
|
||||
@@ -30,7 +30,7 @@ public class ManualLocationUpdatesActivity extends AppCompatActivity implements
|
||||
LocationEngineListener {
|
||||
|
||||
private MapView mapView;
|
||||
private LocationLayerPlugin locationLayerPlugin;
|
||||
private LocationComponent locationComponent;
|
||||
private LocationEngine locationEngine;
|
||||
private PermissionsManager permissionsManager;
|
||||
|
||||
@@ -43,8 +43,8 @@ public class ManualLocationUpdatesActivity extends AppCompatActivity implements
|
||||
fabManualUpdate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (locationLayerPlugin != null && locationLayerPlugin.getLocationEngine() == null) {
|
||||
locationLayerPlugin.forceLocationUpdate(
|
||||
if (locationComponent != null && locationComponent.getLocationEngine() == null) {
|
||||
locationComponent.forceLocationUpdate(
|
||||
Utils.getRandomLocation(LatLngBounds.from(60, 25, 40, -5)));
|
||||
}
|
||||
}
|
||||
@@ -55,11 +55,11 @@ public class ManualLocationUpdatesActivity extends AppCompatActivity implements
|
||||
fabToggle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (locationLayerPlugin != null) {
|
||||
locationLayerPlugin.setLocationEngine(locationLayerPlugin.getLocationEngine() == null ? locationEngine :
|
||||
if (locationComponent != null) {
|
||||
locationComponent.setLocationEngine(locationComponent.getLocationEngine() == null ? locationEngine :
|
||||
null);
|
||||
|
||||
if (locationLayerPlugin.getLocationEngine() == null) {
|
||||
if (locationComponent.getLocationEngine() == null) {
|
||||
fabToggle.setImageResource(R.drawable.ic_layers_clear);
|
||||
fabManualUpdate.setEnabled(true);
|
||||
fabManualUpdate.setAlpha(1f);
|
||||
@@ -118,9 +118,9 @@ public class ManualLocationUpdatesActivity extends AppCompatActivity implements
|
||||
locationEngine.addLocationEngineListener(this);
|
||||
locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
|
||||
locationEngine.activate();
|
||||
locationLayerPlugin = mapboxMap.getLocationLayerPlugin();
|
||||
locationLayerPlugin.activateLocationLayerPlugin(this, locationEngine);
|
||||
locationLayerPlugin.setRenderMode(RenderMode.COMPASS);
|
||||
locationComponent = mapboxMap.getLocationComponent();
|
||||
locationComponent.activateLocationComponent(this, locationEngine);
|
||||
locationComponent.setRenderMode(RenderMode.COMPASS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
android:title="Toggle custom Map style"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item android:id="@+id/action_plugin_disable"
|
||||
<item android:id="@+id/action_component_disable"
|
||||
android:title="Disable"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
|
||||
<item android:id="@+id/action_plugin_enabled"
|
||||
<item android:id="@+id/action_component_enabled"
|
||||
android:title="Enabled"
|
||||
app:showAsAction="never"/>
|
||||
</menu>
|
||||
@@ -73,6 +73,6 @@
|
||||
<string name="description_draggable_marker">Click to add a marker, long-click to drag</string>
|
||||
<string name="description_location_map_change">Change map\'s style while location is displayed</string>
|
||||
<string name="description_location_modes">Showcases location render and tracking modes</string>
|
||||
<string name="description_location_fragment">Uses LocationLayer in a Fragment</string>
|
||||
<string name="description_location_fragment">Uses LocationComponent in a Fragment</string>
|
||||
<string name="description_location_manual">Force location updates and don\'t rely on the engine</string>
|
||||
</resources>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
<style name="AppTheme" parent="AppBaseTheme" />
|
||||
|
||||
<style name="CustomLocationLayer" parent="mapbox_LocationLayer">
|
||||
<style name="CustomLocationComponent" parent="mapbox_LocationComponent">
|
||||
<item name="mapbox_foregroundDrawable">@drawable/custom_user_icon</item>
|
||||
|
||||
<item name="mapbox_bearingDrawable">@drawable/custom_user_arrow</item>
|
||||
|
||||
Reference in New Issue
Block a user