summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/attribution/Attribution.java
blob: e7ee5b6130b93a1167db2791cc8b8817147adb72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.mapbox.mapboxsdk.attribution;

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 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;

  Attribution(String title, String url) {
    this.title = title;
    this.url = url;
  }

  public String getTitle() {
    return title;
  }

  public String getTitleAbbreviated() {
    if (title.equals(OPENSTREETMAP)) {
      return OPENSTREETMAP_ABBR;
    }
    return title;
  }

  public String getUrl() {
    return url;
  }

  @Override
  public boolean equals(@Nullable Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    Attribution that = (Attribution) o;

    if (title != null ? !title.equals(that.title) : that.title != null) {
      return false;
    }
    return url != null ? url.equals(that.url) : that.url == null;
  }

  @Override
  public int hashCode() {
    int result = title != null ? title.hashCode() : 0;
    result = 31 * result + (url != null ? url.hashCode() : 0);
    return result;
  }
}