Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting of custom destination marker in theme #763

Merged
merged 1 commit into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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