summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2018-08-31 11:07:01 +0200
committerTobrun <tobrun@mapbox.com>2018-09-04 10:18:50 +0200
commite7642f28fe6abf07c4e92db3dca63eb20811f477 (patch)
tree8befae7723ec5e5817fe1633a5589944d66ee5f1 /platform/android
parentaf0de6e015e803c33c1d24e25b34bea4778ecd20 (diff)
downloadqtlocation-mapboxgl-e7642f28fe6abf07c4e92db3dca63eb20811f477.tar.gz
[android] - make improve this map translatable
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/AttributionParser.java28
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java6
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/attribution/AttributionParseTest.java10
3 files changed, 38 insertions, 6 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
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 a56e964294..8510806e79 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<String> 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 7eacda43c3..6838138e55 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());