[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:
Tobrun
2016-04-28 11:03:47 +02:00
committed by Brad Leege
parent 8507b8663d
commit 25af12b647
34 changed files with 75 additions and 62 deletions

View File

@@ -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());

View File

@@ -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();
}

View File

@@ -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) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="?attr/colorPrimaryDark" />
<size
android:width="@dimen/my_locationview_outer_circle"
android:height="@dimen/my_locationview_outer_circle" />
</shape>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="@color/white"/>
<size
android:width="@dimen/userlocationview_outer_circle"
android:height="@dimen/userlocationview_outer_circle"/>
</shape>

View File

@@ -9,7 +9,6 @@
<dimen name="ten_dp">10dp</dimen>
<dimen name="sixteen_dp">16dp</dimen>
<dimen name="seventy_six_dp">76dp</dimen>
<dimen name="userlocationview_size">64dp</dimen>
<dimen name="userlocationview_inner_circle">18dp</dimen>
<dimen name="userlocationview_outer_circle">22dp</dimen>
<dimen name="my_locationview_size">64dp</dimen>
<dimen name="my_locationview_outer_circle">18dp</dimen>
</resources>

View File

@@ -1,29 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:id="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:id="@id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:access_token="@string/mapbox_access_token"
/>
mapbox:my_location_background_tint="@android:color/white"
mapbox:access_token="@string/mapbox_access_token" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabLocationToggle"