Skip to content

Commit

Permalink
Allow setting of custom destination marker in theme (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
danesfeder authored Mar 16, 2018
1 parent 7d92ea0 commit 42018cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ static void setMapStyle(Context context, MapboxMap map, MapboxMap.OnStyleLoadedL
* @return {@link Icon} map marker dark or light
*/
static Icon retrieveMapMarker(Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean darkThemeEnabled = preferences.getBoolean(context.getString(R.string.dark_theme_enabled), false);
TypedValue destinationMarkerResId = obtainTypedValue(context, R.attr.navigationViewDestinationMarker);
int markerResId = destinationMarkerResId.resourceId;
IconFactory iconFactory = IconFactory.getInstance(context);
return iconFactory.fromResource(darkThemeEnabled ? R.drawable.map_marker_dark : R.drawable.map_marker_light);
return iconFactory.fromResource(markerResId);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions libandroid-navigation-ui/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<!-- Location layer style -->
<attr name="navigationViewLocationLayerStyle" format="reference"/>

<!-- Destination marker drawable -->
<attr name="navigationViewDestinationMarker" format="reference"/>

<!-- For setting the styles in XML -->
<attr name="navigationLightTheme" format="reference"/>
<attr name="navigationDarkTheme" format="reference"/>
Expand Down
4 changes: 4 additions & 0 deletions libandroid-navigation-ui/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

<item name="navigationViewLocationLayerStyle">@style/mapbox_LocationLayer</item>

<item name="navigationViewDestinationMarker">@drawable/map_marker_light</item>

<item name="navigationViewMapStyle">@string/navigation_guidance_day_v2</item>
</style>

Expand All @@ -59,6 +61,8 @@

<item name="navigationViewLocationLayerStyle">@style/mapbox_LocationLayer</item>

<item name="navigationViewDestinationMarker">@drawable/map_marker_dark</item>

<item name="navigationViewMapStyle">@string/navigation_guidance_night_v2</item>
</style>

Expand Down

0 comments on commit 42018cc

Please sign in to comment.