diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java index 3e75a34b4..ccba0f930 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java @@ -20,6 +20,7 @@ import java.util.Set; */ public class AttributionParser { + private static final String IMPROVE_THIS_MAP = "Improve this map"; private final WeakReference context; private final Set attributions = new LinkedHashSet<>(); private final String attributionData; @@ -104,6 +105,9 @@ public class AttributionParser { String url = urlSpan.getURL(); if (isUrlValid(url)) { String anchor = parseAnchorValue(htmlBuilder, urlSpan); + if (isImproveThisMapAnchor(anchor)) { + anchor = translateImproveThisMapAnchor(anchor); + } attributions.add(new Attribution(anchor, url)); } } @@ -118,6 +122,30 @@ public class AttributionParser { return isValidForImproveThisMap(url) && isValidForMapbox(url); } + /** + * Invoked to validate if an anchor is equal to Improve this map coming from tilesets. + * + * @param anchor the anchor to be validated + * @return if the url is valid + */ + private boolean isImproveThisMapAnchor(String anchor) { + return anchor.equals(IMPROVE_THIS_MAP); + } + + /** + * Invoked to replace the english Improve this map with localized variant. + * + * @param anchor the anchor to be translated + * @return the translated anchor + */ + private String translateImproveThisMapAnchor(String anchor) { + Context context = this.context.get(); + if (context != null) { + anchor = context.getString(R.string.mapbox_telemetryImproveMap); + } + return anchor; + } + /** * Invoked to validate if an url is valid for the improve map configuration. * diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java index a56e96429..8510806e7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java @@ -171,8 +171,12 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt } List attributions = new ArrayList<>(); + String attribution; for (Source source : mapboxMap.getSources()) { - attributions.add(source.getAttribution()); + attribution = source.getAttribution(); + if (!attribution.isEmpty()) { + attributions.add(source.getAttribution()); + } } return new AttributionParser.Options() diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/attribution/AttributionParseTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/attribution/AttributionParseTest.java index 7eacda43c..6838138e5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/attribution/AttributionParseTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/attribution/AttributionParseTest.java @@ -41,7 +41,7 @@ public class AttributionParseTest { break; case 2: assertEquals("URL improve map should match", "https://www.mapbox.com/map-feedback/", attribution.getUrl()); - assertEquals("Title improve map should match", "Improve this map", attribution.getTitle()); + assertEquals("Title improve map should match", "Improve This Map", attribution.getTitle()); break; case 3: assertEquals("URL digital globe should match", "https://www.digitalglobe.com/", attribution.getUrl()); @@ -75,7 +75,7 @@ public class AttributionParseTest { break; case 2: assertEquals("URL improve map should match", "https://www.mapbox.com/map-feedback/", attribution.getUrl()); - assertEquals("Title improve map should match", "Improve this map", attribution.getTitle()); + assertEquals("Title improve map should match", "Improve This Map", attribution.getTitle()); break; } counter++; @@ -102,7 +102,7 @@ public class AttributionParseTest { break; case 1: assertEquals("URL improve map should match", "https://www.mapbox.com/map-feedback/", attribution.getUrl()); - assertEquals("Title improve map should match", "Improve this map", attribution.getTitle()); + assertEquals("Title improve map should match", "Improve This Map", attribution.getTitle()); break; } counter++; @@ -131,7 +131,7 @@ public class AttributionParseTest { break; case 2: assertEquals("URL improve map should match", "https://www.mapbox.com/map-feedback/", attribution.getUrl()); - assertEquals("Title improve map should match", "Improve this map", attribution.getTitle()); + assertEquals("Title improve map should match", "Improve This Map", attribution.getTitle()); break; case 3: assertEquals("URL digital globe should match", "https://www.digitalglobe.com/", attribution.getUrl()); @@ -195,7 +195,7 @@ public class AttributionParseTest { break; case 2: assertEquals("URL improve map should match", "https://www.mapbox.com/map-feedback/", attribution.getUrl()); - assertEquals("Title improve map should match", "Improve this map", attribution.getTitle()); + assertEquals("Title improve map should match", "Improve This Map", attribution.getTitle()); break; case 3: assertEquals("URL digital globe should match", "https://www.digitalglobe.com/", attribution.getUrl());