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

Rename URL API to URI #14836

Merged
merged 1 commit into from
Jun 5, 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 @@ -704,7 +704,7 @@ public void setOfflineRegionDefinition(@NonNull OfflineRegionDefinition definiti
moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
setMinZoomPreference(minZoom);
setMaxZoomPreference(maxZoom);
setStyle(new Style.Builder().fromUrl(definition.getStyleURL()), callback);
setStyle(new Style.Builder().fromUri(definition.getStyleURL()), callback);
}

//
Expand Down Expand Up @@ -793,7 +793,7 @@ public void setStyle(@Style.StyleUrl String style) {
* @see Style
*/
public void setStyle(@Style.StyleUrl String style, final Style.OnStyleLoaded callback) {
this.setStyle(new Style.Builder().fromUrl(style), callback);
this.setStyle(new Style.Builder().fromUri(style), callback);
}

/**
Expand Down Expand Up @@ -831,8 +831,8 @@ public void setStyle(Style.Builder builder, final Style.OnStyleLoaded callback)
}

style = builder.build(nativeMapView);
if (!TextUtils.isEmpty(builder.getUrl())) {
nativeMapView.setStyleUrl(builder.getUrl());
if (!TextUtils.isEmpty(builder.getUri())) {
nativeMapView.setStyleUri(builder.getUri());
} else if (!TextUtils.isEmpty(builder.getJson())) {
nativeMapView.setStyleJson(builder.getJson());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.res.ResourcesCompat;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;

import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
Expand Down Expand Up @@ -70,7 +70,7 @@ public class MapboxMapOptions implements Parcelable {
private boolean zMediaOverlay = false;
private String localIdeographFontFamily = "sans-serif";

private String apiBaseUrl;
private String apiBaseUri;

private boolean textureMode;
private boolean translucentTextureSurface;
Expand All @@ -84,6 +84,7 @@ public class MapboxMapOptions implements Parcelable {

/**
* Creates a new MapboxMapOptions object.
*
* @deprecated Use {@link #createFromAttributes(Context, AttributeSet)} instead.
*/
@Deprecated
Expand Down Expand Up @@ -123,7 +124,7 @@ private MapboxMapOptions(Parcel in) {
doubleTapGesturesEnabled = in.readByte() != 0;
quickZoomGesturesEnabled = in.readByte() != 0;

apiBaseUrl = in.readString();
apiBaseUri = in.readString();
textureMode = in.readByte() != 0;
translucentTextureSurface = in.readByte() != 0;
prefetchesTiles = in.readByte() != 0;
Expand All @@ -148,8 +149,16 @@ public static MapboxMapOptions createFromAttributes(@NonNull Context context, @N
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.mapbox_MapView, 0, 0);
try {
mapboxMapOptions.camera(new CameraPosition.Builder(typedArray).build());

// deprecated
mapboxMapOptions.apiBaseUrl(typedArray.getString(R.styleable.mapbox_MapView_mapbox_apiBaseUrl));

String baseUri = typedArray.getString(R.styleable.mapbox_MapView_mapbox_apiBaseUri);
if (!TextUtils.isEmpty(baseUri)) {
// override deprecated property if a value of the new type was provided
mapboxMapOptions.apiBaseUri(baseUri);
}

mapboxMapOptions.zoomGesturesEnabled(
typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiZoomGestures, true));
mapboxMapOptions.scrollGesturesEnabled(
Expand Down Expand Up @@ -246,10 +255,24 @@ public static MapboxMapOptions createFromAttributes(@NonNull Context context, @N
*
* @param apiBaseUrl The base of our API endpoint
* @return This
* @deprecated use {@link #apiBaseUri} instead
*/
@Deprecated
@NonNull
public MapboxMapOptions apiBaseUrl(String apiBaseUrl) {
this.apiBaseUrl = apiBaseUrl;
this.apiBaseUri = apiBaseUrl;
return this;
}

/**
* Specifies the URI used for API endpoint.
*
* @param apiBaseUri The base of our API endpoint
* @return This
*/
@NonNull
public MapboxMapOptions apiBaseUri(String apiBaseUri) {
this.apiBaseUri = apiBaseUri;
return this;
}

Expand Down Expand Up @@ -660,9 +683,20 @@ public boolean getRenderSurfaceOnTop() {
* Get the current configured API endpoint base URL.
*
* @return Base URL to be used API endpoint.
* @deprecated use {@link #getApiBaseUri()} instead
*/
@Deprecated
public String getApiBaseUrl() {
return apiBaseUrl;
return apiBaseUri;
}

/**
* Get the current configured API endpoint base URI.
*
* @return Base URI to be used API endpoint.
*/
public String getApiBaseUri() {
return apiBaseUri;
}

/**
Expand Down Expand Up @@ -953,7 +987,7 @@ public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeByte((byte) (doubleTapGesturesEnabled ? 1 : 0));
dest.writeByte((byte) (quickZoomGesturesEnabled ? 1 : 0));

dest.writeString(apiBaseUrl);
dest.writeString(apiBaseUri);
dest.writeByte((byte) (textureMode ? 1 : 0));
dest.writeByte((byte) (translucentTextureSurface ? 1 : 0));
dest.writeByte((byte) (prefetchesTiles ? 1 : 0));
Expand Down Expand Up @@ -1044,7 +1078,7 @@ public boolean equals(@Nullable Object o) {
return false;
}

if (apiBaseUrl != null ? !apiBaseUrl.equals(options.apiBaseUrl) : options.apiBaseUrl != null) {
if (apiBaseUri != null ? !apiBaseUri.equals(options.apiBaseUri) : options.apiBaseUri != null) {
return false;
}
if (prefetchesTiles != options.prefetchesTiles) {
Expand Down Expand Up @@ -1095,7 +1129,7 @@ public int hashCode() {
result = 31 * result + (zoomGesturesEnabled ? 1 : 0);
result = 31 * result + (doubleTapGesturesEnabled ? 1 : 0);
result = 31 * result + (quickZoomGesturesEnabled ? 1 : 0);
result = 31 * result + (apiBaseUrl != null ? apiBaseUrl.hashCode() : 0);
result = 31 * result + (apiBaseUri != null ? apiBaseUri.hashCode() : 0);
result = 31 * result + (textureMode ? 1 : 0);
result = 31 * result + (translucentTextureSurface ? 1 : 0);
result = 31 * result + (prefetchesTiles ? 1 : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ void setVisibleCoordinateBounds(@NonNull LatLng[] coordinates, @NonNull RectF pa
// Style API
//

void setStyleUrl(String url);
void setStyleUri(String url);

@NonNull
String getStyleUrl();
String getStyleUri();

void setStyleJson(String newStyleJson);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,17 @@ public void resizeView(int width, int height) {
}

@Override
public void setStyleUrl(String url) {
if (checkState("setStyleUrl")) {
public void setStyleUri(String url) {
if (checkState("setStyleUri")) {
return;
}
nativeSetStyleUrl(url);
}

@Override
@NonNull
public String getStyleUrl() {
if (checkState("getStyleUrl")) {
public String getStyleUri() {
if (checkState("getStyleUri")) {
return "";
}
return nativeGetStyleUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,24 @@ private Style(@NonNull Builder builder, @NonNull NativeMap nativeMap) {
* Returns the current style url.
*
* @return the style url
* @deprecated use {@link #getUri()} instead
*/
@NonNull
@Deprecated
public String getUrl() {
validateState("getUrl");
return nativeMap.getStyleUrl();
return nativeMap.getStyleUri();
}

/**
* Returns the current style uri.
*
* @return the style uri
*/
@NonNull
public String getUri() {
validateState("getUri");
return nativeMap.getStyleUri();
}

/**
Expand Down Expand Up @@ -600,7 +613,7 @@ public static class Builder {
private final List<ImageWrapper> images = new ArrayList<>();

private TransitionOptions transitionOptions;
private String styleUrl;
private String styleUri;
private String styleJson;

/**
Expand Down Expand Up @@ -637,17 +650,60 @@ public static class Builder {
* @param url The URL of the map style
* @return this
* @see Style
* @deprecated use {@link #fromUri(String)} instead
*/
@Deprecated
@NonNull
public Builder fromUrl(@NonNull String url) {
this.styleUrl = url;
this.styleUri = url;
return this;
}

/**
* <p>
* Will loads a new map style asynchronous from the specified URI.
* </p>
* {@code uri} can take the following forms:
* <ul>
* <li>{@code Style#StyleUrl}: load one of the bundled styles in {@link Style}.</li>
* <li>{@code mapbox://styles/<user>/<style>}:
* loads the style from a <a href="https://www.mapbox.com/account/">Mapbox account.</a>
* {@code user} is your username. {@code style} is the ID of your custom
* style created in <a href="https://www.mapbox.com/studio">Mapbox Studio</a>.</li>
* <li>{@code http://...} or {@code https://...}:
* loads the style over the Internet from any web server.</li>
* <li>{@code asset://...}:
* loads the style from the APK {@code assets/} directory.
* This is used to load a style bundled with your app.</li>
* <li>{@code file://...}:
* loads the style from a file path. This is used to load a style from disk.
* </li>
* </li>
* <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li>
* </ul>
* <p>
* This method is asynchronous and will return before the style finishes loading.
* If you wish to wait for the map to finish loading, listen to the {@link MapView.OnDidFinishLoadingStyleListener}
* callback or use {@link MapboxMap#setStyle(String, OnStyleLoaded)} instead.
* </p>
* If the style fails to load or an invalid style URI is set, the map view will become blank.
* An error message will be logged in the Android logcat and {@link MapView.OnDidFailLoadingMapListener} callback
* will be triggered.
*
* @param uri The URI of the map style
* @return this
* @see Style
*/
@NonNull
public Builder fromUri(@NonNull String uri) {
this.styleUri = uri;
return this;
}

/**
* Will load a new map style from a json string.
* <p>
* If the style fails to load or an invalid style URL is set, the map view will become blank.
* If the style fails to load or an invalid style URI is set, the map view will become blank.
* An error message will be logged in the Android logcat and {@link MapView.OnDidFailLoadingMapListener} callback
* will be triggered.
* </p>
Expand Down Expand Up @@ -876,8 +932,8 @@ public Builder withBitmapImages(boolean sdf, @NonNull Pair<String, Bitmap>... va
return this;
}

String getUrl() {
return styleUrl;
String getUri() {
return styleUri;
}

String getJson() {
Expand Down
Loading