summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java28
1 files changed, 28 insertions, 0 deletions
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 3e75a34b4a..ccba0f9300 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> context;
private final Set<Attribution> 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));
}
}
@@ -119,6 +123,30 @@ public class AttributionParser {
}
/**
+ * 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.
*
* @param url the url to be validated