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

[android] - derived source attribution #8630

Merged
merged 1 commit into from
Apr 13, 2017

Conversation

tobrun
Copy link
Member

@tobrun tobrun commented Apr 4, 2017

Closes #2723

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Apr 4, 2017
@tobrun tobrun added this to the android-v5.1.0 milestone Apr 4, 2017
@tobrun tobrun self-assigned this Apr 4, 2017
@tobrun tobrun requested a review from ivovandongen April 4, 2017 13:41
@tobrun tobrun force-pushed the 2723-derived-source-attribution branch from b4bbbb3 to 3688cf2 Compare April 4, 2017 14:01
@tobrun
Copy link
Member Author

tobrun commented Apr 4, 2017

It seems we need some additional logic here, currently attribution for digital globe when using a satellite map shows up under Improve this map while on iOS it's placed above.

@1ec5 1ec5 added the GL JS parity For feature parity with Mapbox GL JS label Apr 4, 2017
@1ec5
Copy link
Contributor

1ec5 commented Apr 4, 2017

It seems we need some additional logic here, currently attribution for digital globe when using a satellite map shows up under Improve this map while on iOS it's placed above.

“Improve This Map” should appear before DigitalGlobe. (This screenshot is outdated.)

ios


private void parseAttribution(String attributionSource) {
if (!TextUtils.isEmpty(attributionSource)) {
SpannableStringBuilder htmlBuilder = (SpannableStringBuilder) Html.fromHtml(attributionSource);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you characterize the HTML parser being used here? fromHtml(String) doesn’t say anything about which tags it supports, what encoding it uses, whether it attempts to load external images, etc. fromHtml(String, int) mentions TagSoup, but I don’t know if it’s also the case with this older API.

Copy link
Member Author

@tobrun tobrun Apr 4, 2017

Choose a reason for hiding this comment

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

They use TagSoup underneath. With current design there isn't any possibility of icon placement though the API support it with an ImageGetter https://developer.android.com/reference/android/text/Html.html#fromHtml(java.lang.String,%20android.text.Html.ImageGetter,%20android.text.Html.TagHandler.

Copy link
Contributor

Choose a reason for hiding this comment

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

No external icon support is perfectly fine. I just wanted to double-check because the use of HTML in attribution has been problematic for GL JS and mapbox.js, mostly concerning XSS risk.

private void rebuildAttributionMap() {
attributionMap = new LinkedHashMap<>();
for (Source source : mapboxMap.getSources()) {
parseAttribution(source.getAttribution());
Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation doesn’t attempt to deduplicate copyright notices that appear redundantly in multiple sources. For example, the Mapbox Streets and Mapbox Satellite sources both credit OpenStreetMap, so “© OpenStreetMap” would probably appear twice in the dialog when viewing the Mapbox Satellite Streets style.

You may want to adapt the logic used on iOS and macOS or alternatively the GL JS implementation. Both implementations come with plenty of unit tests as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

A map collection cannot contain duplicate keys so this solves the issues of duplicate entries. Is there a use-case that I'm a not supporting with not implementing // remove any entries that are substrings of another entry.?

Copy link
Contributor

Choose a reason for hiding this comment

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

That logic was originally implemented in GL JS in mapbox/mapbox-gl-js#2453. I guess it’s meant to avoid “© OpenStreetMap contributors © OpenStreetMap” or somesuch, not sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think what you’ve got should be fine when it comes to the Mapbox default styles at least. None of the sources ultimately loaded by Mapbox Streets or Mapbox Satellite Streets have any links whose texts differ but overlap.

<array name="mapbox_attribution_links" formatted="false" translatable="false">
<item>https://www.mapbox.com/about/maps/</item>
<item>http://www.openstreetmap.org/about/</item>
<item>https://www.mapbox.com/map-feedback/#/%1$f/%2$f/%3$d</item>
Copy link
Contributor

Choose a reason for hiding this comment

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

The iOS, macOS, and JS implementations automatically append this hash to the feedback URL. That way, the Map Feedback tool starts out at the right location, which makes their feedback much more actionable. The feedback link has a class attribute of mapbox-improve-map.

Copy link
Member Author

Choose a reason for hiding this comment

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

That got lost, will readd

@tobrun tobrun force-pushed the 2723-derived-source-attribution branch from 3688cf2 to 9111e42 Compare April 11, 2017 09:28
@tobrun
Copy link
Member Author

tobrun commented Apr 11, 2017

Fixed up @1ec5 comment about improving this map, did a cleanup and is ready for review.

Copy link
Contributor

@ivovandongen ivovandongen left a comment

Choose a reason for hiding this comment

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

👍

@@ -43,6 +43,10 @@ namespace android {
return jni::Make<jni::String>(env, source.getID());
}

jni::String Source::getAttribution(jni::JNIEnv& env) {
return source.getAttribution() ? jni::Make<jni::String>(env, source.getAttribution().value()) : jni::Make<jni::String>(env,"");
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing, but maybe invoke source.getAttribution() only once. Now it doesn't really do much, but if the implementation gets more complex it's a bit wasteful.

Copy link
Member Author

Choose a reason for hiding this comment

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

done in 527ffbe#diff-8a5300c6fbc51b88f2e971461adcb513R33. re-review that part of the code?

import java.util.LinkedHashMap;
import java.util.Locale;

class AttributionDialogManager implements View.OnClickListener, DialogInterface.OnClickListener {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit; some class level javadoc?

Copy link
Member Author

Choose a reason for hiding this comment

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

@tobrun tobrun force-pushed the 2723-derived-source-attribution branch from 9111e42 to 527ffbe Compare April 11, 2017 15:22
*/
class AttributionDialogManager implements View.OnClickListener, DialogInterface.OnClickListener {

private static final String MAP_FEEDBACK_URL = "https://www.mapbox.com/map-feedback";
Copy link
Contributor

@1ec5 1ec5 Apr 11, 2017

Choose a reason for hiding this comment

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

We shouldn’t hard-code this URL, because sources other than Mapbox Streets are free to provide their own map feedback URLs. Look for <a> tags with class set to mapbox-improve-map.

Copy link
Contributor

Choose a reason for hiding this comment

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

I ticketed this out as tail work in #8730, since custom feedback links are admittedly quite an edge case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for ticketing that out, will fix it separately from this PR.

@tobrun tobrun force-pushed the 2723-derived-source-attribution branch from 527ffbe to a70febf Compare April 13, 2017 12:09
@tobrun tobrun force-pushed the 2723-derived-source-attribution branch from a70febf to 4e01377 Compare April 13, 2017 14:12
@tobrun tobrun merged commit f045559 into master Apr 13, 2017
@tobrun tobrun deleted the 2723-derived-source-attribution branch April 13, 2017 15:24
@tobrun tobrun mentioned this pull request May 2, 2017
12 tasks
@tobrun tobrun mentioned this pull request Jun 9, 2017
12 tasks
@tobrun tobrun mentioned this pull request Jun 21, 2017
11 tasks
@tobrun tobrun mentioned this pull request Jun 30, 2017
16 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android GL JS parity For feature parity with Mapbox GL JS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants