diff --git a/android/build.gradle b/android/build.gradle index 16d9ca386..6eae794cf 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -62,7 +62,6 @@ android { buildConfigField "boolean", "ROBOLECTRIC", "false" buildConfigField "String", "MOZILLA_API_KEY", "\"\"" - buildConfigField "String", "TILE_SERVER_URL", "\"\"" buildConfigField "boolean", "LABEL_MAP_TILES", "false" diff --git a/android/src/main/java/org/mozilla/mozstumbler/client/mapview/MapFragment.java b/android/src/main/java/org/mozilla/mozstumbler/client/mapview/MapFragment.java index a4ed8d0c3..f3be669c8 100644 --- a/android/src/main/java/org/mozilla/mozstumbler/client/mapview/MapFragment.java +++ b/android/src/main/java/org/mozilla/mozstumbler/client/mapview/MapFragment.java @@ -26,7 +26,6 @@ import org.json.JSONException; import org.json.JSONObject; -import org.mozilla.mozstumbler.BuildConfig; import org.mozilla.mozstumbler.R; import org.mozilla.mozstumbler.client.ClientPrefs; import org.mozilla.mozstumbler.client.MainApp; @@ -53,7 +52,6 @@ import org.mozilla.osmdroid.tileprovider.MapTile; import org.mozilla.osmdroid.tileprovider.tilesource.ITileSource; import org.mozilla.osmdroid.tileprovider.tilesource.OnlineTileSourceBase; -import org.mozilla.osmdroid.tileprovider.tilesource.TileSourceFactory; import org.mozilla.osmdroid.tileprovider.tilesource.XYTileSource; import org.mozilla.osmdroid.util.GeoPoint; import org.mozilla.osmdroid.views.MapView; @@ -362,7 +360,6 @@ void setHighBandwidthMap(boolean hasNetwork, boolean isHighBandwidth) { isHighBandwidth = true; // use this as initial default } - final boolean isMLSTileStore = (BuildConfig.TILE_SERVER_URL != null); final boolean hasHighResMap = mLowResMapOverlayHighZoom == null && mMap.getTileProvider().getTileSource() == mHighResMapSource; final boolean hasLowResMap = mLowResMapOverlayHighZoom != null; @@ -381,16 +378,17 @@ void setHighBandwidthMap(boolean hasNetwork, boolean isHighBandwidth) { // Force GC to cleanup underlying LRU caches in overlay System.gc(); - if (!isMLSTileStore) { - mHighResMapSource = TileSourceFactory.MAPQUESTOSM; - } else { - mHighResMapSource = new XYTileSource(AbstractMapOverlay.MLS_MAP_TILE_BASE_NAME, + + mHighResMapSource = new XYTileSource(AbstractMapOverlay.MLS_MAP_TILE_BASE_NAME, null, 1, AbstractMapOverlay.MAX_ZOOM_LEVEL_OF_MAP, AbstractMapOverlay.TILE_PIXEL_SIZE, AbstractMapOverlay.FILE_TYPE_SUFFIX_PNG, - new String[]{BuildConfig.TILE_SERVER_URL}); - } - System.gc(); + AppGlobals.MAPBOX_TILE_URLS) { + public String getTileURLString(MapTile aTile) { + return super.getTileURLString(aTile) + "?access_token=" + AppGlobals.MAPBOX_ACCESS_CODE; + } + }; + System.gc(); mMap.setTileSource(mHighResMapSource); } else if (!isHighBandwidth && !hasLowResMap) { // Unhooking the highres map means we should nullify it and force GC @@ -401,9 +399,9 @@ void setHighBandwidthMap(boolean hasNetwork, boolean isHighBandwidth) { mMap.setTileSource(new BlankTileSource()); mLowResMapOverlayLowZoom = new LowResMapOverlay(AbstractMapOverlay.TileResType.LOWER_ZOOM, - this.getActivity(), isMLSTileStore, mMap); + this.getActivity(), mMap); mLowResMapOverlayHighZoom = new LowResMapOverlay(AbstractMapOverlay.TileResType.HIGHER_ZOOM, - this.getActivity(), isMLSTileStore, mMap); + this.getActivity(), mMap); updateOverlayBaseLayer(mMap.getZoomLevel()); } @@ -508,11 +506,7 @@ public void toggleScanning(MenuItem menuItem) { private void showCopyright() { TextView copyrightArea = (TextView) mRootView.findViewById(R.id.copyright_area); - if (BuildConfig.TILE_SERVER_URL == null) { - copyrightArea.setText(getActivity().getString(R.string.map_copyright_fdroid)); - } else { - copyrightArea.setText(getActivity().getString(R.string.map_copyright_moz)); - } + copyrightArea.setText(getActivity().getString(R.string.map_copyright_moz)); } private void updateCenterButtonIcon() { diff --git a/android/src/main/java/org/mozilla/mozstumbler/client/mapview/tiles/LowResMapOverlay.java b/android/src/main/java/org/mozilla/mozstumbler/client/mapview/tiles/LowResMapOverlay.java index 0eb9561c2..df04f09e5 100644 --- a/android/src/main/java/org/mozilla/mozstumbler/client/mapview/tiles/LowResMapOverlay.java +++ b/android/src/main/java/org/mozilla/mozstumbler/client/mapview/tiles/LowResMapOverlay.java @@ -7,38 +7,34 @@ import android.content.Context; import android.graphics.Color; -import org.mozilla.mozstumbler.BuildConfig; -import org.mozilla.osmdroid.ResourceProxy; +import org.mozilla.mozstumbler.service.AppGlobals; import org.mozilla.osmdroid.tileprovider.tilesource.ITileSource; import org.mozilla.osmdroid.tileprovider.tilesource.XYTileSource; import org.mozilla.osmdroid.tileprovider.util.SimpleInvalidationHandler; import org.mozilla.osmdroid.views.MapView; +import org.mozilla.osmdroid.tileprovider.MapTile; + public class LowResMapOverlay extends AbstractMapOverlay { public static final int LOW_ZOOM_LEVEL = 11; - public LowResMapOverlay(TileResType type, final Context aContext, boolean isMLSTileStore, MapView mapView) { + public LowResMapOverlay(TileResType type, final Context aContext, MapView mapView) { super(aContext); final int zoomLevel = (type == TileResType.HIGHER_ZOOM) ? AbstractMapOverlay.getDisplaySizeBasedMinZoomLevel() : LOW_ZOOM_LEVEL; - ITileSource mapTileSource; - if (isMLSTileStore) { - mapTileSource = new XYTileSource(MLS_MAP_TILE_BASE_NAME, null, - zoomLevel, zoomLevel, - AbstractMapOverlay.TILE_PIXEL_SIZE, - AbstractMapOverlay.FILE_TYPE_SUFFIX_PNG, - new String[]{BuildConfig.TILE_SERVER_URL}); - } else { - mapTileSource = new XYTileSource("MapquestOSM", ResourceProxy.string.mapquest_osm, - zoomLevel, zoomLevel, - AbstractMapOverlay.TILE_PIXEL_SIZE, ".jpg", new String[]{ - "http://otile1.mqcdn.com/tiles/1.0.0/map/", - "http://otile2.mqcdn.com/tiles/1.0.0/map/", - "http://otile3.mqcdn.com/tiles/1.0.0/map/", - "http://otile4.mqcdn.com/tiles/1.0.0/map/"}); - } + + ITileSource mapTileSource = new XYTileSource(MLS_MAP_TILE_BASE_NAME, null, + zoomLevel, zoomLevel, + AbstractMapOverlay.TILE_PIXEL_SIZE, + AbstractMapOverlay.FILE_TYPE_SUFFIX_PNG, + AppGlobals.MAPBOX_TILE_URLS) { + public String getTileURLString(MapTile aTile) { + return super.getTileURLString(aTile) + "?access_token=" + AppGlobals.MAPBOX_ACCESS_CODE; + } + }; + this.setLoadingBackgroundColor(Color.TRANSPARENT); mTileProvider.setTileRequestCompleteHandler(new SimpleInvalidationHandler(mapView)); mTileProvider.setTileSource(mapTileSource); diff --git a/libraries/stumbler/src/main/java/org/mozilla/mozstumbler/service/AppGlobals.java b/libraries/stumbler/src/main/java/org/mozilla/mozstumbler/service/AppGlobals.java index 75b6920f6..7557feb33 100644 --- a/libraries/stumbler/src/main/java/org/mozilla/mozstumbler/service/AppGlobals.java +++ b/libraries/stumbler/src/main/java/org/mozilla/mozstumbler/service/AppGlobals.java @@ -10,6 +10,15 @@ public class AppGlobals { + public static final String MAPBOX_ACCESS_CODE = "pk.eyJ1IjoibW96aWxsYS13ZWJwcm9kIiwiYSI6ImNqMml4MXNhaTAwMjgzM28yYXRqbjlmZmkifQ.OfL6NY7noQth9mbbN_tDbA"; + public static final String MAPBOX_LAYER_TYPE = "mapbox.streets"; + public static final String[] MAPBOX_TILE_URLS = new String[]{ + "http://a.tiles.mapbox.com/v4/" + AppGlobals.MAPBOX_LAYER_TYPE + "/", + "http://b.tiles.mapbox.com/v4/" + AppGlobals.MAPBOX_LAYER_TYPE + "/", + "http://c.tiles.mapbox.com/v4/" + AppGlobals.MAPBOX_LAYER_TYPE + "/", + "http://d.tiles.mapbox.com/v4/" + AppGlobals.MAPBOX_LAYER_TYPE + "/" + }; + /* All intent actions start with this string. Only locally broadcasted. */ public static final String ACTION_NAMESPACE = "org.mozilla.mozstumbler.intent.action";