summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2016-04-26 20:54:57 +0200
committerTobrun <tobrun@mapbox.com>2016-04-26 22:24:18 +0200
commitbf493f96cddc9c85400d845f1a899b274f200edd (patch)
tree1663c4519532acff058d37260680021b01dab76f /platform/android/MapboxGLAndroidSDK/src/main
parente2510fce79d9a90bad71bcfc5a73c248a9c7c3d1 (diff)
downloadqtlocation-mapboxgl-bf493f96cddc9c85400d845f1a899b274f200edd.tar.gz
[android] #4800 - correct background offsets from attributes
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java14
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java19
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java7
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java14
4 files changed, 20 insertions, 34 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
index 734f3f8947..f5e9a74415 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
@@ -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();
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
index c6b9aa7bfc..c5040f40dc 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
@@ -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;
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
index 430ebfe443..21a981bb24 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
@@ -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();
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java
index c048d0f57e..9ae96ebf7b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java
@@ -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;
}