Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] Allow apps to override map resources
Browse files Browse the repository at this point in the history
Fixes #2858
  • Loading branch information
Leith Bade committed Oct 29, 2015
1 parent dd56e83 commit 665fdc0
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ final class UserLocationView extends View {

private MapView mMapView;

private static final int BLUE_COLOR = 0x39ACCBFF;

private float mDensity;

private boolean mShowMarker;
Expand Down Expand Up @@ -137,6 +135,8 @@ private void initialize(Context context) {

// Setup the custom paint
Resources resources = context.getResources();
int accuracyColor = resources.getColor(R.color.user_location_ring);

mDensity = resources.getDisplayMetrics().density;
mMarkerCoordinate = new LatLng(0.0, 0.0);
mMarkerScreenPoint = new PointF();
Expand All @@ -145,14 +145,14 @@ private void initialize(Context context) {
mAccuracyPaintFill = new Paint();
mAccuracyPaintFill.setAntiAlias(true);
mAccuracyPaintFill.setStyle(Paint.Style.FILL);
mAccuracyPaintFill.setColor(BLUE_COLOR);
mAccuracyPaintFill.setColor(accuracyColor);
mAccuracyPaintFill.setAlpha((int) (255 * 0.25f));

mAccuracyPaintStroke = new Paint();
mAccuracyPaintStroke.setAntiAlias(true);
mAccuracyPaintStroke.setStyle(Paint.Style.STROKE);
mAccuracyPaintStroke.setStrokeWidth(0.5f * mDensity);
mAccuracyPaintStroke.setColor(BLUE_COLOR);
mAccuracyPaintStroke.setColor(accuracyColor);
mAccuracyPaintStroke.setAlpha((int) (255 * 0.5f));

mAccuracyPath = new Path();
Expand Down
12 changes: 12 additions & 0 deletions android/MapboxGLAndroidSDK/src/main/res-public/values/public.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,16 @@
<public name="attribution_margin_right" type="attr" />
<public name="attribution_margin_bottom" type="attr" />
<public name="attribution_visibility" type="attr" />

<public name="attribution_logo" type="drawable" />
<public name="compass" type="drawable" />
<public name="default_marker" type="drawable" />
<public name="attribution_button_pressed_selector" type="drawable" />
<public name="attribution_button_pressed_normal" type="drawable" />
<public name="attribution_button_pressed_pressed" type="drawable" />
<public name="user_location" type="drawable" />
<public name="user_location_bearing" type="drawable" />
<public name="user_location_stale" type="drawable" />
<public name="user_location_ring" type="color" />

This comment has been minimized.

Copy link
@tobrun

tobrun Oct 29, 2015

Member

user_location or my_location?

for the rest looks good to merge 👍

<public name="mapbox_blue" type="color" />
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/attribution_button_pressed" android:state_pressed="true" />
<item android:drawable="@drawable/attribution_button_normal" />
</selector>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:clickable="true"
android:contentDescription="@string/attributionsIconContentDescription"
android:padding="7dp"
android:src="@drawable/ic_info_selector" />
android:src="@drawable/attribution_button_selector" />

<com.mapbox.mapboxsdk.views.UserLocationView
android:id="@+id/userLocationView"
Expand Down
1 change: 1 addition & 0 deletions android/MapboxGLAndroidSDK/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
<color name="mapbox_blue">#1E8CAB</color>
<color name="user_location_ring">@color/mapbox_blue</color>
</resources>

1 comment on commit 665fdc0

@ljbade
Copy link
Contributor

@ljbade ljbade commented on 665fdc0 Oct 29, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh true yeah if public we should rename it.

Please sign in to comment.