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

Snapshot attribution #13732

Merged
merged 2 commits into from
Jan 15, 2019
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 @@ -2,15 +2,23 @@

import android.support.annotation.Nullable;

import java.util.ArrayList;
import java.util.List;

public class Attribution {

private static final String OPENSTREETMAP = "OpenStreetMap";
private static final String OPENSTREETMAP_ABBR = "OSM";
static final String TELEMETRY = "Telemetry Settings";

static final String IMPROVE_MAP_URL = "https://www.mapbox.com/feedback/";
static final String MAPBOX_URL = "https://www.mapbox.com/about/maps/";
static final String TELEMETRY_URL = "https://www.mapbox.com/telemetry/";
static final List<String> IMPROVE_MAP_URLS = new ArrayList<>();

static {
// Using a List makes URL backwards compatible
IMPROVE_MAP_URLS.add("https://www.mapbox.com/feedback/");
IMPROVE_MAP_URLS.add("https://www.mapbox.com/map-feedback/");
}

private String title;
private String url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private String translateImproveThisMapAnchor(String anchor) {
* @return if the url is valid for improve this map
*/
private boolean isValidForImproveThisMap(@NonNull String url) {
return withImproveMap || !url.equals(Attribution.IMPROVE_MAP_URL);
return withImproveMap || !(Attribution.IMPROVE_MAP_URLS.contains(url));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
@Config(constants = BuildConfig.class)
public class AttributionParseTest {

private static final String STREETS_ATTRIBUTION = "<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">&copy; Mapbox</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap</a> <a class=\"mapbox-improve-map\" href=\"https://www.mapbox.com/feedback/\" target=\"_blank\">Improve this map</a>\n";
private static final String SATELLITE_ATTRIBUTION = "<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">&copy; Mapbox</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap</a> <a class=\"mapbox-improve-map\" href=\"https://www.mapbox.com/feedback/\" target=\"_blank\">Improve this map</a> <a href=\"https://www.digitalglobe.com/\" target=\"_blank\">&copy; DigitalGlobe</a>\n";
private static final String STREETS_ATTRIBUTION = "<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">&copy; Mapbox</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap</a> <a class=\"mapbox-improve-map\" href=\"https://www.mapbox.com/map-feedback/\" target=\"_blank\">Improve this map</a>\n";
private static final String SATELLITE_ATTRIBUTION = "<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">&copy; Mapbox</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap</a> <a class=\"mapbox-improve-map\" href=\"https://www.mapbox.com/map-feedback/\" target=\"_blank\">Improve this map</a> <a href=\"https://www.digitalglobe.com/\" target=\"_blank\">&copy; DigitalGlobe</a>\n";

@Test
public void testParseAttributionStringSatellite() throws Exception {
Expand All @@ -39,7 +39,7 @@ public void testParseAttributionStringSatellite() throws Exception {
assertEquals("Title openstreetmap should match", "© OpenStreetMap", attribution.getTitle());
break;
case 2:
assertEquals("URL improve map should match", "https://www.mapbox.com/feedback/", attribution.getUrl());
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());
break;
case 3:
Expand Down Expand Up @@ -72,7 +72,7 @@ public void testParseAttributionStringStreets() throws Exception {
assertEquals("Title openstreetmap should match", "© OpenStreetMap", attribution.getTitle());
break;
case 2:
assertEquals("URL improve map should match", "https://www.mapbox.com/feedback/", attribution.getUrl());
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());
break;
}
Expand All @@ -98,7 +98,7 @@ public void testParseAttributionWithoutMapbox() throws Exception {
assertEquals("Title openstreetmap should match", "© OpenStreetMap", attribution.getTitle());
break;
case 1:
assertEquals("URL improve map should match", "https://www.mapbox.com/feedback/", attribution.getUrl());
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());
break;
}
Expand Down Expand Up @@ -126,7 +126,7 @@ public void testParseAttributionArrayString() throws Exception {
assertEquals("Title openstreetmap should match", "© OpenStreetMap", attribution.getTitle());
break;
case 2:
assertEquals("URL improve map should match", "https://www.mapbox.com/feedback/", attribution.getUrl());
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());
break;
case 3:
Expand Down Expand Up @@ -188,7 +188,7 @@ public void testParseHideCopyrightAttributionArrayString() throws Exception {
assertEquals("Title openstreetmap should match", "OpenStreetMap", attribution.getTitle());
break;
case 2:
assertEquals("URL improve map should match", "https://www.mapbox.com/feedback/", attribution.getUrl());
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());
break;
case 3:
Expand Down Expand Up @@ -307,4 +307,19 @@ public void testShortOpenStreetMapWithoutCopyrightString() throws Exception {
attributionParser.createAttributionString(true)
);
}

@Test
public void testWithImproveThisMapString() throws Exception {
AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
.withAttributionData(STREETS_ATTRIBUTION, "blabla", "")
.withImproveMap(true)
.withCopyrightSign(false)
.build();

assertEquals(
"Attribution string should match",
"© Mapbox / OSM / Improve This Map",
attributionParser.createAttributionString(true)
);
}
}