[android] #4702 - upgrade default styles, deprecate Style string definition in favour versioned styling methods.
This commit is contained in:
@@ -17,6 +17,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -43,7 +44,7 @@ public class PolygonActivity extends AppCompatActivity {
|
||||
MapboxMapOptions options = new MapboxMapOptions()
|
||||
.attributionTintColor(Color.RED)
|
||||
.accessToken(getString(R.string.mapbox_access_token))
|
||||
.styleUrl(Style.MAPBOX_STREETS)
|
||||
.styleUrl(Style.getMapboxStreetsUrl(AppConstant.STYLE_VERSION))
|
||||
.camera(new CameraPosition.Builder()
|
||||
.target(new LatLng(45.520486, -122.673541))
|
||||
.zoom(12)
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant;
|
||||
|
||||
public class LatLngBoundsActivity extends AppCompatActivity {
|
||||
|
||||
@@ -43,7 +44,7 @@ public class LatLngBoundsActivity extends AppCompatActivity {
|
||||
|
||||
mMapView = (MapView) findViewById(R.id.mapView);
|
||||
mMapView.setAccessToken(getString(R.string.mapbox_access_token));
|
||||
mMapView.setStyle(Style.DARK);
|
||||
mMapView.setStyleUrl(Style.getDarkStyleUrl(AppConstant.STYLE_VERSION));
|
||||
mMapView.onCreate(savedInstanceState);
|
||||
mMapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
@@ -78,8 +79,6 @@ public class LatLngBoundsActivity extends AppCompatActivity {
|
||||
Log.v(MapboxConstants.TAG, mapboxMap.getProjection().getVisibleRegion().latLngBounds.toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant;
|
||||
|
||||
public class ManualZoomActivity extends AppCompatActivity {
|
||||
|
||||
@@ -39,7 +40,7 @@ public class ManualZoomActivity extends AppCompatActivity {
|
||||
|
||||
mMapView = (MapView) findViewById(R.id.manualZoomMapView);
|
||||
mMapView.setAccessToken(getString(R.string.mapbox_access_token));
|
||||
mMapView.setStyleUrl(Style.SATELLITE_STREETS);
|
||||
mMapView.setStyleUrl(Style.getSatelliteStyleUrl(AppConstant.STYLE_VERSION));
|
||||
mMapView.onCreate(savedInstanceState);
|
||||
mMapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant;
|
||||
|
||||
public class MapFragmentActivity extends AppCompatActivity {
|
||||
|
||||
@@ -40,7 +41,7 @@ public class MapFragmentActivity extends AppCompatActivity {
|
||||
|
||||
MapboxMapOptions options = new MapboxMapOptions();
|
||||
options.accessToken(getString(R.string.mapbox_access_token));
|
||||
options.styleUrl(Style.EMERALD);
|
||||
options.styleUrl(Style.getOutdoorsStyleUrl(AppConstant.STYLE_VERSION));
|
||||
|
||||
options.scrollGesturesEnabled(false);
|
||||
options.zoomGesturesEnabled(false);
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.maps.SupportMapFragment;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant;
|
||||
|
||||
public class SupportMapFragmentActivity extends AppCompatActivity {
|
||||
|
||||
@@ -40,7 +41,7 @@ public class SupportMapFragmentActivity extends AppCompatActivity {
|
||||
|
||||
MapboxMapOptions options = new MapboxMapOptions();
|
||||
options.accessToken(getString(R.string.mapbox_access_token));
|
||||
options.styleUrl(Style.SATELLITE_STREETS);
|
||||
options.styleUrl(Style.getSatelliteStreetsStyleUrl(AppConstant.STYLE_VERSION));
|
||||
|
||||
options.scrollGesturesEnabled(false);
|
||||
options.zoomGesturesEnabled(false);
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.maps.Projection;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -60,7 +61,7 @@ public class GeocoderActivity extends AppCompatActivity {
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.setAccessToken(getString(R.string.mapbox_access_token));
|
||||
mapView.setStyle(Style.MAPBOX_STREETS);
|
||||
mapView.setStyleUrl(Style.getMapboxStreetsUrl(AppConstant.STYLE_VERSION));
|
||||
mapView.onCreate(savedInstanceState);
|
||||
|
||||
final ImageView dropPinView = new ImageView(this);
|
||||
|
||||
@@ -9,20 +9,31 @@ import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant;
|
||||
|
||||
public class DebugModeActivity extends AppCompatActivity {
|
||||
public class DebugModeActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = "DebugModeActivity";
|
||||
|
||||
private MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
private String currentStyle = Style.MAPBOX_STREETS;
|
||||
private int currentStyleIndex = 0;
|
||||
|
||||
private static final String[] STYLES = new String[]{
|
||||
Style.getMapboxStreetsUrl(AppConstant.STYLE_VERSION),
|
||||
Style.getOutdoorsStyleUrl(AppConstant.STYLE_VERSION),
|
||||
Style.getLightStyleUrl(AppConstant.STYLE_VERSION),
|
||||
Style.getDarkStyleUrl(AppConstant.STYLE_VERSION),
|
||||
Style.getSatelliteStyleUrl(AppConstant.STYLE_VERSION),
|
||||
Style.getSatelliteStreetsStyleUrl(AppConstant.STYLE_VERSION)
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -41,6 +52,7 @@ public class DebugModeActivity extends AppCompatActivity {
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.setTag(true);
|
||||
mapView.setAccessToken(getString(R.string.mapbox_access_token));
|
||||
mapView.setStyleUrl(STYLES[currentStyleIndex]);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@@ -65,20 +77,13 @@ public class DebugModeActivity extends AppCompatActivity {
|
||||
fabStyles.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (currentStyle.equals(Style.MAPBOX_STREETS)) {
|
||||
currentStyle = Style.EMERALD;
|
||||
} else if (currentStyle.equals(Style.EMERALD)) {
|
||||
currentStyle = Style.DARK;
|
||||
} else if (currentStyle.equals(Style.DARK)) {
|
||||
currentStyle = Style.LIGHT;
|
||||
} else if (currentStyle.equals(Style.LIGHT)) {
|
||||
currentStyle = Style.SATELLITE;
|
||||
} else if (currentStyle.equals(Style.SATELLITE)) {
|
||||
currentStyle = Style.SATELLITE_STREETS;
|
||||
} else {
|
||||
currentStyle = Style.MAPBOX_STREETS;
|
||||
if (mapboxMap != null) {
|
||||
currentStyleIndex++;
|
||||
if (currentStyleIndex == STYLES.length) {
|
||||
currentStyleIndex = 0;
|
||||
}
|
||||
mapboxMap.setStyleUrl(STYLES[currentStyleIndex]);
|
||||
}
|
||||
mapboxMap.setStyle(currentStyle);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.maps.TrackingSettings;
|
||||
import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant;
|
||||
|
||||
public class DoubleMapActivity extends AppCompatActivity {
|
||||
|
||||
@@ -72,7 +73,7 @@ public class DoubleMapActivity extends AppCompatActivity {
|
||||
mMapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
mapboxMap.setStyle(Style.DARK);
|
||||
mapboxMap.setStyleUrl(Style.getDarkStyleUrl(AppConstant.STYLE_VERSION));
|
||||
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(18));
|
||||
try {
|
||||
@@ -91,7 +92,7 @@ public class DoubleMapActivity extends AppCompatActivity {
|
||||
mMapViewMini.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull MapboxMap mapboxMap) {
|
||||
mapboxMap.setStyle(Style.LIGHT);
|
||||
mapboxMap.setStyleUrl(Style.getLightStyleUrl(AppConstant.STYLE_VERSION));
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4));
|
||||
|
||||
UiSettings uiSettings = mapboxMap.getUiSettings();
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.mapbox.mapboxsdk.offline.OfflineRegionError;
|
||||
import com.mapbox.mapboxsdk.offline.OfflineRegionStatus;
|
||||
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant;
|
||||
import com.mapbox.mapboxsdk.testapp.model.other.OfflineDownloadRegionDialog;
|
||||
import com.mapbox.mapboxsdk.testapp.model.other.OfflineListRegionsDialog;
|
||||
|
||||
@@ -77,7 +78,7 @@ public class OfflineActivity extends AppCompatActivity
|
||||
// Set up map
|
||||
mMapView = (MapView) findViewById(R.id.mapView);
|
||||
mMapView.setAccessToken(getString(R.string.mapbox_access_token));
|
||||
mMapView.setStyle(Style.MAPBOX_STREETS);
|
||||
mMapView.setStyleUrl(Style.getMapboxStreetsUrl(AppConstant.STYLE_VERSION));
|
||||
mMapView.onCreate(savedInstanceState);
|
||||
mMapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant;
|
||||
|
||||
public class MyLocationCustomizationActivity extends AppCompatActivity implements LocationListener {
|
||||
|
||||
@@ -48,7 +49,7 @@ public class MyLocationCustomizationActivity extends AppCompatActivity implement
|
||||
|
||||
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
|
||||
mapboxMapOptions.accessToken(getString(R.string.mapbox_access_token));
|
||||
mapboxMapOptions.styleUrl(Style.MAPBOX_STREETS);
|
||||
mapboxMapOptions.styleUrl(Style.getMapboxStreetsUrl(AppConstant.STYLE_VERSION));
|
||||
mapboxMapOptions.locationEnabled(true);
|
||||
mapboxMapOptions.camera(new CameraPosition.Builder()
|
||||
.target(location != null ? new LatLng(location) : new LatLng(0, 0))
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.testapp.model.constants;
|
||||
|
||||
public class AppConstant {
|
||||
|
||||
public final static int STYLE_VERSION = 9;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mapbox.mapboxsdk.constants;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
public class StyleVersionTest {
|
||||
|
||||
private static final double DELTA = 1e-15;
|
||||
|
||||
@Test
|
||||
public void testSanity() {
|
||||
assertEquals("Style version should match, when upgrading, verify that integers.xml is updated",
|
||||
AppConstant.STYLE_VERSION,
|
||||
9,
|
||||
DELTA);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user