[android] #4878 - fix default color of accuracy circle to match primary color, removed old resources, introduced drawable density folders for new resources, enforced consistent naming.
This commit is contained in:
@@ -270,13 +270,9 @@ public class MapView extends FrameLayout {
|
||||
// MyLocationView
|
||||
MyLocationViewSettings myLocationViewSettings = mMapboxMap.getMyLocationViewSettings();
|
||||
myLocationViewSettings.setForegroundDrawable(options.getMyLocationForegroundDrawable(), options.getMyLocationForegroundBearingDrawable());
|
||||
myLocationViewSettings.setForegroundTintColor(options.getMyLocationForegroundTintColor());
|
||||
myLocationViewSettings.setBackgroundDrawable(options.getMyLocationBackgroundDrawable(), options.getMyLocationBackgroundPadding());
|
||||
if (options.getMyLocationForegroundTintColor() != -1) {
|
||||
myLocationViewSettings.setForegroundTintColor(options.getMyLocationForegroundTintColor());
|
||||
}
|
||||
if (options.getMyLocationBackgroundTintColor() != -1) {
|
||||
myLocationViewSettings.setBackgroundTintColor(options.getMyLocationBackgroundTintColor());
|
||||
}
|
||||
myLocationViewSettings.setBackgroundTintColor(options.getMyLocationBackgroundTintColor());
|
||||
myLocationViewSettings.setAccuracyAlpha(options.getMyLocationAccuracyAlpha());
|
||||
myLocationViewSettings.setAccuracyTintColor(options.getMyLocationAccuracyTintColor());
|
||||
mMapboxMap.setMyLocationEnabled(options.getLocationEnabled());
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.maps;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -9,6 +10,7 @@ import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
|
||||
@@ -65,8 +67,8 @@ public class MapboxMapOptions implements Parcelable {
|
||||
private Drawable myLocationForegroundDrawable;
|
||||
private Drawable myLocationForegroundBearingDrawable;
|
||||
private Drawable myLocationBackgroundDrawable;
|
||||
private int myLocationForegroundTintColor = -1;
|
||||
private int myLocationBackgroundTintColor = -1;
|
||||
private int myLocationForegroundTintColor;
|
||||
private int myLocationBackgroundTintColor;
|
||||
private int[] myLocationBackgroundPadding;
|
||||
private int myLocationAccuracyTintColor;
|
||||
private int myLocationAccuracyAlpha;
|
||||
@@ -171,16 +173,32 @@ public class MapboxMapOptions implements Parcelable {
|
||||
, (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_bottom, DIMENSION_SEVEN_DP) * screenDensity)});
|
||||
|
||||
mapboxMapOptions.locationEnabled(typedArray.getBoolean(R.styleable.MapView_my_location_enabled, false));
|
||||
mapboxMapOptions.myLocationForegroundDrawables(typedArray.getDrawable(R.styleable.MapView_my_location_foreground), typedArray.getDrawable(R.styleable.MapView_my_location_foreground_bearing));
|
||||
mapboxMapOptions.myLocationBackgroundDrawable(typedArray.getDrawable(R.styleable.MapView_my_location_background));
|
||||
mapboxMapOptions.myLocationForegroundTintColor(typedArray.getColor(R.styleable.MapView_my_location_foreground_tint, -1));
|
||||
mapboxMapOptions.myLocationBackgroundTintColor(typedArray.getColor(R.styleable.MapView_my_location_background_tint, -1));
|
||||
mapboxMapOptions.myLocationForegroundTintColor(typedArray.getColor(R.styleable.MapView_my_location_foreground_tint, Color.TRANSPARENT));
|
||||
mapboxMapOptions.myLocationBackgroundTintColor(typedArray.getColor(R.styleable.MapView_my_location_background_tint, Color.TRANSPARENT));
|
||||
|
||||
Drawable foregroundDrawable = typedArray.getDrawable(R.styleable.MapView_my_location_foreground);
|
||||
if(foregroundDrawable==null){
|
||||
foregroundDrawable = ContextCompat.getDrawable(context,R.drawable.ic_mylocationview_normal);
|
||||
}
|
||||
|
||||
Drawable foregroundBearingDrawable = typedArray.getDrawable(R.styleable.MapView_my_location_foreground_bearing);
|
||||
if(foregroundBearingDrawable==null){
|
||||
foregroundBearingDrawable = ContextCompat.getDrawable(context,R.drawable.ic_mylocationview_bearing);
|
||||
}
|
||||
|
||||
Drawable backgroundDrawable = typedArray.getDrawable(R.styleable.MapView_my_location_background);
|
||||
if(backgroundDrawable==null){
|
||||
backgroundDrawable = ContextCompat.getDrawable(context, R.drawable.ic_mylocationview_background);
|
||||
}
|
||||
|
||||
mapboxMapOptions.myLocationForegroundDrawables(foregroundDrawable, foregroundBearingDrawable);
|
||||
mapboxMapOptions.myLocationBackgroundDrawable(backgroundDrawable);
|
||||
mapboxMapOptions.myLocationBackgroundPadding(new int[]{(int) (typedArray.getDimension(R.styleable.MapView_my_location_background_left, 0) * screenDensity)
|
||||
, (int) (typedArray.getDimension(R.styleable.MapView_my_location_background_top, 0) * screenDensity)
|
||||
, (int) (typedArray.getDimension(R.styleable.MapView_my_location_background_right, 0) * screenDensity)
|
||||
, (int) (typedArray.getDimension(R.styleable.MapView_my_location_background_bottom, 0) * screenDensity)});
|
||||
mapboxMapOptions.myLocationAccuracyAlpha(typedArray.getInt(R.styleable.MapView_my_location_accuracy_alpha, 100));
|
||||
mapboxMapOptions.myLocationAccuracyTint(typedArray.getColor(R.styleable.MapView_my_location_accuracy_tint, ColorUtils.getAccentColor(context)));
|
||||
mapboxMapOptions.myLocationAccuracyTint(typedArray.getColor(R.styleable.MapView_my_location_accuracy_tint, ColorUtils.getPrimaryColor(context)));
|
||||
} finally {
|
||||
typedArray.recycle();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.maps.widgets;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff;
|
||||
@@ -19,16 +20,13 @@ import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.FloatRange;
|
||||
import android.support.annotation.IntRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.animation.FastOutLinearInInterpolator;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.R;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.MapboxConstants;
|
||||
import com.mapbox.mapboxsdk.constants.MyBearingTracking;
|
||||
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
@@ -37,7 +35,6 @@ import com.mapbox.mapboxsdk.location.LocationServices;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.Projection;
|
||||
import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.utils.ColorUtils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
@@ -72,6 +69,9 @@ public class MyLocationView extends View {
|
||||
private Drawable foregroundBearingDrawable;
|
||||
private Drawable backgroundDrawable;
|
||||
|
||||
private int foregroundTintColor;
|
||||
private int backgroundTintColor;
|
||||
|
||||
private Rect foregroundBounds;
|
||||
private Rect backgroundBounds;
|
||||
|
||||
@@ -106,38 +106,36 @@ public class MyLocationView extends View {
|
||||
|
||||
private void init(Context context) {
|
||||
setEnabled(false);
|
||||
|
||||
// behavioural model
|
||||
myLocationBehaviour = new MyLocationBehaviourFactory().getBehaviouralModel(MyLocationTracking.TRACKING_NONE);
|
||||
compassListener = new CompassListener(context);
|
||||
maxSize = (int) context.getResources().getDimension(R.dimen.userlocationview_size);
|
||||
|
||||
// default implementation
|
||||
setShadowDrawable(ContextCompat.getDrawable(context, R.drawable.ic_userlocationview_shadow));
|
||||
setForegroundDrawables(ContextCompat.getDrawable(context, R.drawable.ic_userlocationview_normal), ContextCompat.getDrawable(context, R.drawable.ic_userlocationview_bearing));
|
||||
setAccuracyTint(ColorUtils.getAccentColor(context));
|
||||
setAccuracyAlpha(100);
|
||||
maxSize = (int) context.getResources().getDimension(R.dimen.my_locationview_size);
|
||||
}
|
||||
|
||||
public final void setForegroundDrawables(Drawable defaultDrawable, Drawable bearingDrawable) {
|
||||
if (defaultDrawable == null || bearingDrawable == null) {
|
||||
Log.e(MapboxConstants.TAG, "Not setting foreground drawables MyLocationView: default = " + defaultDrawable + " bearing = " + bearingDrawable);
|
||||
return;
|
||||
}
|
||||
if (defaultDrawable.getIntrinsicWidth() != bearingDrawable.getIntrinsicWidth() || defaultDrawable.getIntrinsicHeight() != bearingDrawable.getIntrinsicHeight()) {
|
||||
throw new RuntimeException("The dimensions from location and bearing drawables should be match");
|
||||
}
|
||||
|
||||
|
||||
foregroundDrawable = defaultDrawable;
|
||||
foregroundBearingDrawable = bearingDrawable;
|
||||
setForegroundDrawableTint(foregroundTintColor);
|
||||
|
||||
invalidateBounds();
|
||||
}
|
||||
|
||||
public final void setForegroundDrawableTint(@ColorInt int color) {
|
||||
if (foregroundDrawable != null) {
|
||||
foregroundDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
if (foregroundBearingDrawable != null) {
|
||||
foregroundBearingDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
if (color != Color.TRANSPARENT) {
|
||||
foregroundTintColor = color;
|
||||
if (foregroundDrawable != null) {
|
||||
foregroundDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
if (foregroundBearingDrawable != null) {
|
||||
foregroundBearingDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,15 +153,19 @@ public class MyLocationView extends View {
|
||||
backgroundOffsetRight = right;
|
||||
backgroundOffsetBottom = bottom;
|
||||
|
||||
setShadowDrawableTint(backgroundTintColor);
|
||||
|
||||
invalidateBounds();
|
||||
}
|
||||
|
||||
public final void setShadowDrawableTint(@ColorInt int color) {
|
||||
if (backgroundDrawable == null) {
|
||||
return;
|
||||
if (color != Color.TRANSPARENT) {
|
||||
backgroundTintColor = color;
|
||||
if (backgroundDrawable == null) {
|
||||
return;
|
||||
}
|
||||
backgroundDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
|
||||
backgroundDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
|
||||
public final void setAccuracyTint(@ColorInt int color) {
|
||||
|
||||
Reference in New Issue
Block a user