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

Update to latest of gl-native #9

Merged
merged 2 commits into from
Oct 9, 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
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,62 @@
Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started.

## master

### Performance improvements
- Improved rendering performance for the styles with multiple sources [#15756](https://github.com/mapbox/mapbox-gl-native/pull/15756)

## 8.5.0-alpha.1 - October 3, 2019
[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.4.0...android-v8.5.0-alpha.1) since [Mapbox Maps SDK for Android v8.4.0](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.4.0):
### Bug fixes
- Suppress network requests for expired tiles update, if these tiles are invisible. [#15741](https://github.com/mapbox/mapbox-gl-native/pull/15741)
- Fixed opacity interpolation for composition expressions [#15738](https://github.com/mapbox/mapbox-gl-native/pull/15738)
- Fixed an issue where `Projection#getMetersPerPixelAtLatitude` returned a value incorrectly divided by the pixel ratio. This also fixes an issue where `LocationComponent` accuracy circle's radius was artificially increased. [#15742](https://github.com/mapbox/mapbox-gl-native/pull/15742)

## 8.4.0 - September 25, 2019
[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.4.0-beta.1...android-v8.4.0) since [Mapbox Maps SDK for Android v8.4.0-beta.1](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.4.0-beta.1):

### Bug fixes
- Fixing a crash when `CameraPosition` padding is set when using `MapSnapshotter`. [#15699](https://github.com/mapbox/mapbox-gl-native/pull/15699)

### Other Changes
- Bumped Java SDK dependency to stable 4.9.0 [#15700](https://github.com/mapbox/mapbox-gl-native/pull/15700)
- Migrate map feedback to GL JS–powered feedback form [#15623](https://github.com/mapbox/mapbox-gl-native/pull/15623)

## 8.4.0-beta.1 - September 19, 2019
[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.4.0-alpha.2...android-v8.4.0-beta.1) since [Mapbox Maps SDK for Android v8.4.0-alpha.2](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.4.0-alpha.2):

### Bug fixes
- Fixed an issue that `maxzoom` in style `Sources` option was ignored when URL resource is provided. It may cause problems such as extra tiles downloading at higher zoom level than `maxzoom`, or problems that wrong setting of `overscaledZ` in `OverscaledTileID` that will be passed to `SymbolLayout`, leading wrong rendering appearance. [#15581](https://github.com/mapbox/mapbox-gl-native/pull/15581)
- Fixed constant repainting for the sources with invisible layers, caused by `RenderSource::hasFadingTiles()` returning `true` all the time. [#15600](https://github.com/mapbox/mapbox-gl-native/pull/15600)
- Fixed an issue that caused the state of CompassView not up to date when `UiSettings.setCompassEnabled()` is set to true. [#15606](https://github.com/mapbox/mapbox-gl-native/pull/15606)
- Ignore location tracking mode based animations when the camera is transitioning. [#15641](https://github.com/mapbox/mapbox-gl-native/pull/15641)
- Fixed MapSnapshotter so that `MapSnapshotter.withApiBaseUri` works again. [#15642](https://github.com/mapbox/mapbox-gl-native/pull/15642)
- Fixed an assertion hit caused by possibility of adding a layer to an incompatible source. [#15644](https://github.com/mapbox/mapbox-gl-native/pull/15644)

## 8.3.2 - September 19, 2019
[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.3.1...android-v8.3.2) since [Mapbox Maps SDK for Android v8.3.1](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.3.1):

### Bug fixes
- Fixed an issue of integer overflow when converting `tileCoordinates` to `LatLon`, which caused issues such as `queryRenderedFeatures` and `querySourceFeatures` returning incorrect coordinates at zoom levels 20 and higher. [#15560](https://github.com/mapbox/mapbox-gl-native/pull/15560)

## 8.3.1 - September 18, 2019
[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.3.0...android-v8.3.1) since [Mapbox Maps SDK for Android v8.3.0](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.3.0):

### Bug fixes
- Updated earcut.hpp submodule file [#15660](https://github.com/mapbox/mapbox-gl-native/pull/15660)
- Fixed a wrong variable assignment of `MapSnapshotter.Options.withApiBaseUri`. [#15642](https://github.com/mapbox/mapbox-gl-native/pull/15642)

## 8.4.0-alpha.2 - September 11, 2019
[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.4.0-alpha.1...android-v8.4.0-alpha.2) since [Mapbox Maps SDK for Android v8.4.0-alpha.1](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.4.0-alpha.1):

### Performance improvements
- Newly loaded labels appear faster on the screen. [#15308](https://github.com/mapbox/mapbox-gl-native/pull/15308)

### Bug fixes
- Fixed an issue of integer overflow when converting `tileCoordinates` to `LatLon`, which caused issues such as `queryRenderedFeatures` and `querySourceFeatures` returning incorrect coordinates at zoom levels 20 and higher. [#15560](https://github.com/mapbox/mapbox-gl-native/pull/15560)

### Other Changes
- Bumped Java SDK dependency to 4.9.0-alpha.1 [#15570](https://github.com/mapbox/mapbox-gl-native/pull/15570)

## 8.4.0-alpha.1 - September 4, 2019
[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.3.0...android-v8.4.0-alpha.1) since [Mapbox Maps SDK for Android v8.3.0](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.3.0):
Expand Down
12 changes: 12 additions & 0 deletions MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.AssetManager;
import android.support.annotation.Keep;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
Expand All @@ -24,6 +26,7 @@
*/
@UiThread
@SuppressLint("StaticFieldLeak")
@Keep
public final class Mapbox {

private static final String TAG = "Mbgl-Mapbox";
Expand Down Expand Up @@ -222,4 +225,13 @@ static boolean isAccessTokenValid(@Nullable String accessToken) {
public static boolean hasInstance() {
return INSTANCE != null;
}

/**
* Internal use. Returns AssetManager.
*
* @return the asset manager
*/
private static AssetManager getAssetManager() {
return getApplicationContext().getResources().getAssets();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,10 @@ public void applyStyle(@NonNull final LocationComponentOptions options) {
* If you are not using any of {@link CameraMode} modes,
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
* <p>
* If the camera is transitioning when the zoom change is requested, the call is going to be ignored.
* Use {@link CameraTransitionListener} to chain the animations, or provide the zoom as a camera change argument.
* </p>
*
* @param zoomLevel The desired zoom level.
* @param animationDuration The zoom animation duration.
Expand All @@ -741,6 +745,10 @@ public void zoomWhileTracking(double zoomLevel, long animationDuration,
"LocationComponent#zoomWhileTracking method can only be used",
" when a camera mode other than CameraMode#NONE is engaged."));
return;
} else if (locationCameraController.isTransitioning()) {
Logger.e(TAG,
"LocationComponent#zoomWhileTracking method call is ignored because the camera mode is transitioning");
return;
}
locationAnimatorCoordinator.feedNewZoomLevel(zoomLevel, mapboxMap.getCameraPosition(), animationDuration, callback);
}
Expand All @@ -751,6 +759,10 @@ public void zoomWhileTracking(double zoomLevel, long animationDuration,
* If you are not using any of {@link CameraMode} modes,
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
* <p>
* If the camera is transitioning when the zoom change is requested, the call is going to be ignored.
* Use {@link CameraTransitionListener} to chain the animations, or provide the zoom as a camera change argument.
* </p>
*
* @param zoomLevel The desired zoom level.
* @param animationDuration The zoom animation duration.
Expand All @@ -766,6 +778,10 @@ public void zoomWhileTracking(double zoomLevel, long animationDuration) {
* If you are not using any of {@link CameraMode} modes,
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
* <p>
* If the camera is transitioning when the zoom change is requested, the call is going to be ignored.
* Use {@link CameraTransitionListener} to chain the animations, or provide the zoom as a camera change argument.
* </p>
*
* @param zoomLevel The desired zoom level.
*/
Expand All @@ -788,6 +804,10 @@ public void cancelZoomWhileTrackingAnimation() {
* If you are not using any of {@link CameraMode} modes,
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
* <p>
* If the camera is transitioning when the tilt change is requested, the call is going to be ignored.
* Use {@link CameraTransitionListener} to chain the animations, or provide the tilt as a camera change argument.
* </p>
*
* @param tilt The desired camera tilt.
* @param animationDuration The tilt animation duration.
Expand All @@ -803,6 +823,10 @@ public void tiltWhileTracking(double tilt, long animationDuration,
"LocationComponent#tiltWhileTracking method can only be used",
" when a camera mode other than CameraMode#NONE is engaged."));
return;
} else if (locationCameraController.isTransitioning()) {
Logger.e(TAG,
"LocationComponent#tiltWhileTracking method call is ignored because the camera mode is transitioning");
return;
}
locationAnimatorCoordinator.feedNewTilt(tilt, mapboxMap.getCameraPosition(), animationDuration, callback);
}
Expand All @@ -813,6 +837,10 @@ public void tiltWhileTracking(double tilt, long animationDuration,
* If you are not using any of {@link CameraMode} modes,
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
* <p>
* If the camera is transitioning when the tilt change is requested, the call is going to be ignored.
* Use {@link CameraTransitionListener} to chain the animations, or provide the tilt as a camera change argument.
* </p>
*
* @param tilt The desired camera tilt.
* @param animationDuration The tilt animation duration.
Expand All @@ -828,6 +856,10 @@ public void tiltWhileTracking(double tilt, long animationDuration) {
* If you are not using any of {@link CameraMode} modes,
* use one of {@link MapboxMap#moveCamera(CameraUpdate)},
* {@link MapboxMap#easeCamera(CameraUpdate)} or {@link MapboxMap#animateCamera(CameraUpdate)} instead.
* <p>
* If the camera is transitioning when the tilt change is requested, the call is going to be ignored.
* Use {@link CameraTransitionListener} to chain the animations, or provide the tilt as a camera change argument.
* </p>
*
* @param tilt The desired camera tilt.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* Responsible for managing attribution interactions on the map.
Expand All @@ -36,9 +38,10 @@
* </p>
*/
public class AttributionDialogManager implements View.OnClickListener, DialogInterface.OnClickListener {

private static final String MAP_FEEDBACK_URL = "https://apps.mapbox.com/feedback";
private static final String MAP_FEEDBACK_LOCATION_FORMAT = MAP_FEEDBACK_URL + "/#/%f/%f/%d";
private static final String MAP_FEEDBACK_URL_OLD = "https://www.mapbox.com/map-feedback";
private static final String MAP_FEEDBACK_URL_LOCATION_FRAGMENT_FORMAT = "/%f/%f/%f/%f/%d";
private static final String MAP_FEEDBACK_STYLE_URI_REGEX = "^(.*://[^:^/]*)/(.*)/(.*)";

@NonNull
private final Context context;
Expand Down Expand Up @@ -90,7 +93,7 @@ public void onClick(DialogInterface dialog, int which) {
if (isLatestEntry(which)) {
showTelemetryDialog();
} else {
showMapFeedbackWebPage(which);
showMapAttributionWebPage(which);
}
}

Expand Down Expand Up @@ -138,21 +141,54 @@ public void onClick(@NonNull DialogInterface dialog, int which) {
builder.show();
}

private void showMapFeedbackWebPage(int which) {
private void showMapAttributionWebPage(int which) {
Attribution[] attributions = attributionSet.toArray(new Attribution[attributionSet.size()]);
String url = attributions[which].getUrl();
if (url.contains(MAP_FEEDBACK_URL)) {
url = buildMapFeedbackMapUrl(mapboxMap.getCameraPosition());
if (url.contains(MAP_FEEDBACK_URL_OLD) || url.contains(MAP_FEEDBACK_URL)) {
url = buildMapFeedbackMapUrl(Mapbox.getAccessToken());
}
showWebPage(url);
}

@NonNull
private String buildMapFeedbackMapUrl(@Nullable CameraPosition cameraPosition) {
// appends current location to the map feedback url if available
return cameraPosition != null ? String.format(Locale.getDefault(),
MAP_FEEDBACK_LOCATION_FORMAT, cameraPosition.target.getLongitude(), cameraPosition.target.getLatitude(),
(int) cameraPosition.zoom) : MAP_FEEDBACK_URL;
String buildMapFeedbackMapUrl(@Nullable String accessToken) {
// TODO Add Android Maps SDK version to the query parameter, currently the version API is not available.
// TODO Keep track of this issue at [#15632](https://github.com/mapbox/mapbox-gl-native/issues/15632)

Uri.Builder builder = Uri.parse(MAP_FEEDBACK_URL).buildUpon();

CameraPosition cameraPosition = mapboxMap.getCameraPosition();
if (cameraPosition != null) {
builder.encodedFragment(String.format(Locale.getDefault(), MAP_FEEDBACK_URL_LOCATION_FRAGMENT_FORMAT,
cameraPosition.target.getLongitude(), cameraPosition.target.getLatitude(),
cameraPosition.zoom, cameraPosition.bearing, (int) cameraPosition.tilt));
}

String packageName = context.getApplicationContext().getPackageName();
if (packageName != null) {
builder.appendQueryParameter("referrer", packageName);
}

if (accessToken != null) {
builder.appendQueryParameter("access_token", accessToken);
}

Style style = mapboxMap.getStyle();
if (style != null) {
String styleUri = style.getUri();
Pattern pattern = Pattern.compile(MAP_FEEDBACK_STYLE_URI_REGEX);
Matcher matcher = pattern.matcher(styleUri);

if (matcher.find()) {
String styleOwner = matcher.group(2);
String styleId = matcher.group(3);

builder.appendQueryParameter("owner", styleOwner)
.appendQueryParameter("id", styleId);
}
}

return builder.build().toString();
}

private void showWebPage(@NonNull String url) {
Expand Down Expand Up @@ -189,10 +225,10 @@ private Set<Attribution> build() {

Style style = mapboxMap.getStyle();
if (style != null) {
for (Source source : mapboxMap.getStyle().getSources()) {
for (Source source : style.getSources()) {
attribution = source.getAttribution();
if (!attribution.isEmpty()) {
attributions.add(source.getAttribution());
attributions.add(attribution);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.graphics.RectF;
import android.os.Bundle;
import android.support.annotation.FloatRange;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
Expand Down Expand Up @@ -246,20 +247,26 @@ long getNativeMapPtr() {
// Style

/**
* Sets tile pre-fetching from MapboxOptions.
* Sets tile pre-fetching zoom delta from MapboxOptions.
*
* @param options the options object
*/
private void setPrefetchesTiles(@NonNull MapboxMapOptions options) {
setPrefetchesTiles(options.getPrefetchesTiles());
if (!options.getPrefetchesTiles()) {
setPrefetchZoomDelta(0);
} else {
setPrefetchZoomDelta(options.getPrefetchZoomDelta());
}
}

/**
* Enable or disable tile pre-fetching. Pre-fetching makes sure that a low-resolution
* tile is rendered as soon as possible at the expense of a little bandwidth.
*
* @param enable true to enable
* @deprecated Use {@link #setPrefetchZoomDelta(int)} instead.
*/
@Deprecated
public void setPrefetchesTiles(boolean enable) {
nativeMapView.setPrefetchTiles(enable);
}
Expand All @@ -269,11 +276,38 @@ public void setPrefetchesTiles(boolean enable) {
*
* @return true if enabled
* @see MapboxMap#setPrefetchesTiles(boolean)
* @deprecated Use {@link #getPrefetchZoomDelta()} instead.
*/
@Deprecated
public boolean getPrefetchesTiles() {
return nativeMapView.getPrefetchTiles();
}

/**
* Set the tile pre-fetching zoom delta. Pre-fetching makes sure that a low-resolution
* tile at the (current_zoom_level - delta) is rendered as soon as possible at the
* expense of a little bandwidth.
* Note: This operation will override the MapboxMapOptions#setPrefetchesTiles(boolean)
* Setting zoom delta to 0 will disable pre-fetching.
* Default zoom delta is 4.
*
* @param delta zoom delta
*/
public void setPrefetchZoomDelta(@IntRange(from = 0) int delta) {
nativeMapView.setPrefetchZoomDelta(delta);
}

/**
* Check current pre-fetching zoom delta.
*
* @return current zoom delta.
* @see MapboxMap#setPrefetchZoomDelta(int)
*/
@IntRange(from = 0)
public int getPrefetchZoomDelta() {
return nativeMapView.getPrefetchZoomDelta();
}

//
// MinZoom
//
Expand Down
Loading