[android] #4800 - correct background offsets from attributes
This commit is contained in:
@@ -268,19 +268,15 @@ public class MapView extends FrameLayout {
|
||||
// MyLocationView
|
||||
MyLocationViewSettings myLocationViewSettings = mMapboxMap.getMyLocationViewSettings();
|
||||
myLocationViewSettings.setForegroundDrawable(options.getMyLocationForegroundDrawable(), options.getMyLocationForegroundBearingDrawable());
|
||||
myLocationViewSettings.setBackgroundDrawable(options.getMyLocationBackgroundDrawable());
|
||||
if(options.getMyLocationForegroundTintColor()!=-1) {
|
||||
myLocationViewSettings.setBackgroundDrawable(options.getMyLocationBackgroundDrawable(), options.getMyLocationBackgroundPadding());
|
||||
if (options.getMyLocationForegroundTintColor() != -1) {
|
||||
myLocationViewSettings.setForegroundTintColor(options.getMyLocationForegroundTintColor());
|
||||
}
|
||||
if(options.getMyLocationBackgroundTintColor()!=-1) {
|
||||
if (options.getMyLocationBackgroundTintColor() != -1) {
|
||||
myLocationViewSettings.setBackgroundTintColor(options.getMyLocationBackgroundTintColor());
|
||||
}
|
||||
myLocationViewSettings.setAccuracyAlpha(options.getMyLocationAccuracyAlpha());
|
||||
myLocationViewSettings.setAccuracyTintColor(options.getMyLocationAccuracyTintColor());
|
||||
int[] myLocationPadding = options.getMyLocationBackgroundPadding();
|
||||
if (myLocationPadding != null) {
|
||||
myLocationViewSettings.setPadding(myLocationPadding[0], myLocationPadding[1], myLocationPadding[2], myLocationPadding[3]);
|
||||
}
|
||||
mMapboxMap.setMyLocationEnabled(options.getLocationEnabled());
|
||||
|
||||
// Enable gestures
|
||||
@@ -2366,7 +2362,7 @@ public class MapView extends FrameLayout {
|
||||
LocationServices.getLocationServices(getContext()).addLocationListener(new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
if(listener!=null) {
|
||||
if (listener != null) {
|
||||
listener.onMyLocationChange(location);
|
||||
}
|
||||
}
|
||||
@@ -2479,7 +2475,7 @@ public class MapView extends FrameLayout {
|
||||
ColorUtils.setTintList(mAttributionsView, tintColor);
|
||||
}
|
||||
|
||||
int getAttributionTintColor(){
|
||||
int getAttributionTintColor() {
|
||||
return mMapboxMap.getUiSettings().getAttributionTintColor();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -10,9 +9,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.util.Log;
|
||||
import android.view.Gravity;
|
||||
|
||||
import com.mapbox.mapboxsdk.R;
|
||||
@@ -174,10 +171,8 @@ 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.myLocationForegroundDrawable(typedArray.getDrawable(R.styleable.MapView_my_location_foreground));
|
||||
mapboxMapOptions.myLocationForegroundBearingDrawable(typedArray.getDrawable(R.styleable.MapView_my_location_foreground_bearing));
|
||||
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.myLocationForegroundDrawable(typedArray.getDrawable(R.styleable.MapView_my_location_foreground));
|
||||
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.myLocationBackgroundPadding(new int[]{(int) (typedArray.getDimension(R.styleable.MapView_my_location_background_left, 0) * screenDensity)
|
||||
@@ -435,19 +430,13 @@ public class MapboxMapOptions implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param myLocationForegroundDrawable
|
||||
* @return This
|
||||
*/
|
||||
public MapboxMapOptions myLocationForegroundDrawable(Drawable myLocationForegroundDrawable) {
|
||||
this.myLocationForegroundDrawable = myLocationForegroundDrawable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param myLocationBearingDrawable
|
||||
* @return This
|
||||
*/
|
||||
public MapboxMapOptions myLocationForegroundBearingDrawable(Drawable myLocationBearingDrawable) {
|
||||
public MapboxMapOptions myLocationForegroundDrawables(Drawable myLocationForegroundDrawable, Drawable myLocationBearingDrawable ) {
|
||||
this.myLocationForegroundDrawable = myLocationForegroundDrawable;
|
||||
this.myLocationForegroundBearingDrawable = myLocationBearingDrawable;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -146,14 +146,15 @@ public class MyLocationView extends View {
|
||||
}
|
||||
|
||||
public final void setShadowDrawable(Drawable drawable, int left, int top, int right, int bottom) {
|
||||
if (drawable == null) {
|
||||
return;
|
||||
if (drawable != null) {
|
||||
backgroundDrawable = drawable;
|
||||
}
|
||||
backgroundDrawable = drawable;
|
||||
|
||||
backgroundOffsetLeft = left;
|
||||
backgroundOffsetTop = top;
|
||||
backgroundOffsetRight = right;
|
||||
backgroundOffsetBottom = bottom;
|
||||
|
||||
invalidateBounds();
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,14 @@ public class MyLocationViewSettings {
|
||||
return foregroundTintColor;
|
||||
}
|
||||
|
||||
public void setBackgroundDrawable(Drawable backgroundDrawable) {
|
||||
public void setBackgroundDrawable(Drawable backgroundDrawable, int[] padding) {
|
||||
this.backgroundDrawable = backgroundDrawable;
|
||||
myLocationView.setShadowDrawable(backgroundDrawable);
|
||||
this.backgroundOffset = padding;
|
||||
if (padding != null && padding.length == 4) {
|
||||
myLocationView.setShadowDrawable(backgroundDrawable, padding[0], padding[1], padding[2], padding[3]);
|
||||
} else {
|
||||
myLocationView.setShadowDrawable(backgroundDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
public Drawable getBackgroundDrawable() {
|
||||
@@ -107,11 +112,6 @@ public class MyLocationViewSettings {
|
||||
return backgroundTintColor;
|
||||
}
|
||||
|
||||
public void setBackgroundOffset(int left, int top, int right, int bottom) {
|
||||
backgroundOffset = new int[]{left, top, right, bottom};
|
||||
myLocationView.setShadowDrawable(backgroundDrawable, left, top, right, bottom);
|
||||
}
|
||||
|
||||
public int[] getBackgroundOffset() {
|
||||
return backgroundOffset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user