[android] - cleanup old style java constants file, migrate style transition to Style.java

This commit is contained in:
Tobrun
2018-11-08 12:49:02 +01:00
committed by Tobrun
parent fbef604546
commit 1374535e63
29 changed files with 136 additions and 163 deletions

View File

@@ -1,87 +0,0 @@
package com.mapbox.mapboxsdk.constants;
import android.support.annotation.StringDef;
import com.mapbox.mapboxsdk.maps.MapView;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* <p>
* Style provides URLs to several professional styles designed by Mapbox.
* </p>
* These styles are all ready to go in your app. To load one, pass it into {@link MapView#setStyleUrl(String)}
*
* @see MapView#setStyleUrl(String)
*/
public class Style {
/**
* Indicates the parameter accepts one of the values from Style. Using one of these
* constants means your map style will always use the latest version and may change as we
* improve the style
*/
@StringDef( {MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS, TRAFFIC_DAY, TRAFFIC_NIGHT})
@Retention(RetentionPolicy.SOURCE)
public @interface StyleUrl {
}
// IMPORTANT: If you change any of these you also need to edit them in strings.xml
/**
* Mapbox Streets: A complete basemap, perfect for incorporating your own data. Using this
* constant means your map style will always use the latest version and may change as we
* improve the style.
*/
public static final String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v10";
/**
* Outdoors: A general-purpose style tailored to outdoor activities. Using this constant means
* your map style will always use the latest version and may change as we improve the style.
*/
public static final String OUTDOORS = "mapbox://styles/mapbox/outdoors-v10";
/**
* Light: Subtle light backdrop for data visualizations. Using this constant means your map
* style will always use the latest version and may change as we improve the style.
*/
public static final String LIGHT = "mapbox://styles/mapbox/light-v9";
/**
* Dark: Subtle dark backdrop for data visualizations. Using this constant means your map style
* will always use the latest version and may change as we improve the style.
*/
public static final String DARK = "mapbox://styles/mapbox/dark-v9";
/**
* Satellite: A beautiful global satellite and aerial imagery layer. Using this constant means
* your map style will always use the latest version and may change as we improve the style.
*/
public static final String SATELLITE = "mapbox://styles/mapbox/satellite-v9";
/**
* Satellite Streets: Global satellite and aerial imagery with unobtrusive labels. Using this
* constant means your map style will always use the latest version and may change as we
* improve the style.
*/
public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-streets-v10";
/**
* Traffic Day: Color-coded roads based on live traffic congestion data. Traffic data is currently
* available in
* <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select
* countries</a>. Using this constant means your map style will always use the latest version and
* may change as we improve the style.
*/
public static final String TRAFFIC_DAY = "mapbox://styles/mapbox/traffic-day-v2";
/**
* Traffic Night: Color-coded roads based on live traffic congestion data, designed to maximize
* legibility in low-light situations. Traffic data is currently available in
* <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select
* countries</a>. Using this constant means your map style will always use the latest version and
* may change as we improve the style.
*/
public static final String TRAFFIC_NIGHT = "mapbox://styles/mapbox/traffic-night-v2";
}

View File

@@ -28,7 +28,7 @@ import com.mapbox.mapboxsdk.annotations.Annotation;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer;

View File

@@ -34,7 +34,7 @@ import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.location.LocationComponent;
@@ -76,13 +76,13 @@ public final class MapboxMap {
@Nullable
private MapboxMap.OnFpsChangedListener onFpsChangedListener;
private com.mapbox.mapboxsdk.maps.Style style;
private Style style;
MapboxMap(NativeMapView map, Transform transform, UiSettings ui, Projection projection,
OnGesturesManagerInteractionListener listener, AnnotationManager annotations,
CameraChangeDispatcher cameraChangeDispatcher, MapChangeReceiver mapChangeReceiver) {
this.nativeMapView = map;
this.style = new com.mapbox.mapboxsdk.maps.Style(nativeMapView);
this.style = new Style(nativeMapView);
this.uiSettings = ui;
this.projection = projection;
this.annotationManager = annotations.bind(this);
@@ -104,7 +104,7 @@ public final class MapboxMap {
setPrefetchesTiles(options);
}
public com.mapbox.mapboxsdk.maps.Style getStyle(){
public Style getStyle(){
return style;
}
@@ -212,48 +212,6 @@ public final class MapboxMap {
// Style
/**
* <p>
* Get the animation duration for style changes.
* </p>
* The default value is zero, so any changes take effect without animation.
*
* @return Duration in milliseconds
*/
public long getTransitionDuration() {
return nativeMapView.getTransitionDuration();
}
/**
* Set the animation duration for style changes.
*
* @param durationMs Duration in milliseconds
*/
public void setTransitionDuration(long durationMs) {
nativeMapView.setTransitionDuration(durationMs);
}
/**
* <p>
* Get the animation delay for style changes.
* </p>
* The default value is zero, so any changes begin to animate immediately.
*
* @return Delay in milliseconds
*/
public long getTransitionDelay() {
return nativeMapView.getTransitionDelay();
}
/**
* Set the animation delay for style changes.
*
* @param delayMs Delay in milliseconds
*/
public void setTransitionDelay(long delayMs) {
nativeMapView.setTransitionDelay(delayMs);
}
/**
* Sets tile pre-fetching from MapboxOptions.
*

View File

@@ -1,8 +1,12 @@
package com.mapbox.mapboxsdk.maps;
import android.support.annotation.StringDef;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.style.sources.Source;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
public class Style {
@@ -15,7 +19,7 @@ public class Style {
this.nativeMapView = nativeMapView;
}
public void loadStyle(@com.mapbox.mapboxsdk.constants.Style.StyleUrl String styleUrl) {
public void loadStyle(@StyleUrl String styleUrl) {
for (Source source : sources.values()) {
if (source != null) {
source.setDetached();
@@ -67,5 +71,105 @@ public class Style {
return layer;
}
//
// Transition
//
/**
* <p>
* Set the transition duration for style changes.
* </p>
* The default value for delay and duration is zero, so any changes take effect without animation.
*
* @param transitionOptions the transition options
*/
public void setTransition(TransitionOptions transitionOptions) {
nativeMapView.setTransitionDuration(transitionOptions.getDuration());
nativeMapView.setTransitionDelay(transitionOptions.getDelay());
}
/**
* <p>
* Get the transition for style changes.
* </p>
* The default value for delay and transition is zero, so any changes take effect without animation.
*
* @return TransitionOptions the transition options
*/
public TransitionOptions getTransition() {
return new TransitionOptions(nativeMapView.getTransitionDuration(), nativeMapView.getTransitionDelay());
}
//
// Style constants
//
/**
* Indicates the parameter accepts one of the values from Style. Using one of these
* constants means your map style will always use the latest version and may change as we
* improve the style
*/
@StringDef( {MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS, TRAFFIC_DAY, TRAFFIC_NIGHT})
@Retention(RetentionPolicy.SOURCE)
public @interface StyleUrl {
}
// IMPORTANT: If you change any of these you also need to edit them in strings.xml
/**
* Mapbox Streets: A complete basemap, perfect for incorporating your own data. Using this
* constant means your map style will always use the latest version and may change as we
* improve the style.
*/
public static final String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v10";
/**
* Outdoors: A general-purpose style tailored to outdoor activities. Using this constant means
* your map style will always use the latest version and may change as we improve the style.
*/
public static final String OUTDOORS = "mapbox://styles/mapbox/outdoors-v10";
/**
* Light: Subtle light backdrop for data visualizations. Using this constant means your map
* style will always use the latest version and may change as we improve the style.
*/
public static final String LIGHT = "mapbox://styles/mapbox/light-v9";
/**
* Dark: Subtle dark backdrop for data visualizations. Using this constant means your map style
* will always use the latest version and may change as we improve the style.
*/
public static final String DARK = "mapbox://styles/mapbox/dark-v9";
/**
* Satellite: A beautiful global satellite and aerial imagery layer. Using this constant means
* your map style will always use the latest version and may change as we improve the style.
*/
public static final String SATELLITE = "mapbox://styles/mapbox/satellite-v9";
/**
* Satellite Streets: Global satellite and aerial imagery with unobtrusive labels. Using this
* constant means your map style will always use the latest version and may change as we
* improve the style.
*/
public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-streets-v10";
/**
* Traffic Day: Color-coded roads based on live traffic congestion data. Traffic data is currently
* available in
* <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select
* countries</a>. Using this constant means your map style will always use the latest version and
* may change as we improve the style.
*/
public static final String TRAFFIC_DAY = "mapbox://styles/mapbox/traffic-day-v2";
/**
* Traffic Night: Color-coded roads based on live traffic congestion data, designed to maximize
* legibility in low-light situations. Traffic data is currently available in
* <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select
* countries</a>. Using this constant means your map style will always use the latest version and
* may change as we improve the style.
*/
public static final String TRAFFIC_NIGHT = "mapbox://styles/mapbox/traffic-night-v2";
}

View File

@@ -25,7 +25,7 @@ import com.mapbox.mapboxsdk.attribution.AttributionLayout;
import com.mapbox.mapboxsdk.attribution.AttributionMeasure;
import com.mapbox.mapboxsdk.attribution.AttributionParser;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.maps.TelemetryDefinition;