diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-03-21 11:55:02 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-03-21 12:04:20 -0700 |
commit | e488ca702e8f822ba6297a2f3c933ee22ca6ce42 (patch) | |
tree | 2efe93d84722f37a61b83155510a3da444fc171b /platform/android | |
parent | 1f8910de186f35216791a17a683a55f01031ec81 (diff) | |
parent | e0fe42d8321d19a4a9cb46edac9fbdb035e70a0c (diff) | |
download | qtlocation-mapboxgl-e488ca702e8f822ba6297a2f3c933ee22ca6ce42.tar.gz |
Merge branch 'release-ios-v3.5.0-android-v5.0.0'
Diffstat (limited to 'platform/android')
46 files changed, 532 insertions, 261 deletions
diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index 1186d392d0..d8338347c2 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -2,6 +2,83 @@ 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. +## 5.0.0 - March 17th, 2017 + +5.0.0 final release contains: + +* Support for data-driven styles [#7752](https://github.com/mapbox/mapbox-gl-native/pull/7752) +* Additional APIs to manage runtime styling layers [#8195](https://github.com/mapbox/mapbox-gl-native/pull/8195) +* Allow query all features in sources (`querySourceFeatures`) [#5792](https://github.com/mapbox/mapbox-gl-native/issues/5792) +* Improve accessibility TalkBack support by including content description in views [#8230](https://github.com/mapbox/mapbox-gl-native/pull/8230) +* Consistent double tap zoom acceleration [#7514](https://github.com/mapbox/mapbox-gl-native/issues/7514) +* Allow zooming/scaling to use `AnimationOptions` [#8181](https://github.com/mapbox/mapbox-gl-native/pull/8181) +* Cleanup inconsistencies `float` vs `double` [#4445](https://github.com/mapbox/mapbox-gl-native/issues/4445) +* Add `mapbox_` prefix to attributes [#6482](https://github.com/mapbox/mapbox-gl-native/issues/6482) +* Update LOST to 2.x [#6573](https://github.com/mapbox/mapbox-gl-native/issues/6537) +* MAS submodules (`geojson`, `telemetry`) are now smaller to reduce the overall method count [#7642](https://github.com/mapbox/mapbox-gl-native/pull/7642) +* Telemetry Service is now include automatically via Manifest merge to simplify set up [#8338](https://github.com/mapbox/mapbox-gl-native/pull/8338) +* Support for Android Nougat [#5910](5910-move-listener-logic-for-nougat) + - Move location listening logic to `onStart`/`onStop` activity lifecylce methods +* Removal of `accessToken` on `MapView` and `MapboxMap` [#5621](https://github.com/mapbox/mapbox-gl-native/issues/5621) +* Introduction of new make targets [#5940](https://github.com/mapbox/mapbox-gl-native/issues/5940) + - Targets for testing, running and using external tools directly from the command line +* Cleanup Gradle files [#6009](https://github.com/mapbox/mapbox-gl-native/issues/6009) + - Introducing single purpose `.gradle` files +* Checkstyle integration [#7442](https://github.com/mapbox/mapbox-gl-native/pull/7442) +* Transform refactor [#6532](https://github.com/mapbox/mapbox-gl-native/issues/6532) + - All camera related code is moved to a dedicated transform class cfr. core architecture +* Encapsulate gestures [#6557](https://github.com/mapbox/mapbox-gl-native/issues/6557) + - All gesture event code is encapsulated in `MapGestureDetector` + - All key event code is encapsulated in `MapKeyListener` +* Transparent background for `MyLocationView` [#7116](https://github.com/mapbox/mapbox-gl-native/issues/7116) +* Correctly scale accuracy circle for `MyLocationView` [#8255](https://github.com/mapbox/mapbox-gl-native/pull/8255) +* Update documentation on generate sanity tests [#7147](https://github.com/mapbox/mapbox-gl-native/issues/7147) +* Update documentation on style templates [#7157](https://github.com/mapbox/mapbox-gl-native/issues/7157) +* Fix `NullPointerException` during save instance state [#7157](https://github.com/mapbox/mapbox-gl-native/issues/7157) +* Move management style to core [#7275](https://github.com/mapbox/mapbox-gl-native/issues/7275) +* Fix `OnCameraChange` not called for the final position of animation bug [#7350](https://github.com/mapbox/mapbox-gl-native/issues/7350) +* `MapboxAccountManager` refactor [#6534](https://github.com/mapbox/mapbox-gl-native/issues/6534) + - Consolidating the location where tokens are set + - Rename to reflect the increased responsibilities introduced in prior releases +* AnnotationManager refactor [#6067](https://github.com/mapbox/mapbox-gl-native/issues/6067) + - Extracting all business logic related to annotations into a separate class cfr. to core and the iOS codebase +* Gesture handling improvements: + - Fix missing call to `onFling` when while pinch zooming [#7666](https://github.com/mapbox/mapbox-gl-native/issues/7666) + - Round tap-zoom gestures to nearest integer [#8027](https://github.com/mapbox/mapbox-gl-native/pull/8027) +* Support for style-wide transition animation duration and delay [#6779](https://github.com/mapbox/mapbox-gl-native/issues/6779) +* Allow callback parameter for style setting [#8262](https://github.com/mapbox/mapbox-gl-native/issues/8262) +* Support for all animated camera changes to configure dismissing tracking modes [#7854](https://github.com/mapbox/mapbox-gl-native/issues/7854) +* Avoid disabling location tracking on all gestures [#7878](https://github.com/mapbox/mapbox-gl-native/issues/7878) +* `LatLng` objects produced by the SDK are wrapped by default [#4522](https://github.com/mapbox/mapbox-gl-native/issues/4522) +* Proguard update for new SDK packages [#8437](https://github.com/mapbox/mapbox-gl-native/pull/8437) +* Javadoc cleanup [#8438](https://github.com/mapbox/mapbox-gl-native/pull/8438) +* MarkerViewClickListener and MapClickListener called simultaneously [#8447](https://github.com/mapbox/mapbox-gl-native/pull/8447) +* Fix LOST v2.0.0 integration [#8445](https://github.com/mapbox/mapbox-gl-native/pull/8445) +* Crash with OnMapChangeListener [#8380](https://github.com/mapbox/mapbox-gl-native/pull/8380) +* Feature query crash [#8374](https://github.com/mapbox/mapbox-gl-native/pull/8374) +* flyTo fix [#8302](https://github.com/mapbox/mapbox-gl-native/pull/8302) +* Don't dispatch MarkerView motion event up to MapView [#8447](https://github.com/mapbox/mapbox-gl-native/pull/8447) + +## 5.0.0-beta.3 - March 10th, 2017 + +5.0.0-beta.3 focuses on addressing stability issues and bug fixes. It also includes: + +* Allow query all features in sources (`querySourceFeatures`) [#5792](https://github.com/mapbox/mapbox-gl-native/issues/5792) +* Improve accessibility TalkBack support by including content description in views [#8230](https://github.com/mapbox/mapbox-gl-native/pull/8230) +* Allow zooming/scaling to use `AnimationOptions` [#8181](https://github.com/mapbox/mapbox-gl-native/pull/8181) +* Telemetry Service is now include automatically via Manifest merge to simplify set up [#8338](https://github.com/mapbox/mapbox-gl-native/pull/8338) +* Correctly scale accuracy circle for `MyLocationView` [#8255](https://github.com/mapbox/mapbox-gl-native/pull/8255) +* Round tap-zoom gestures to nearest integer [#8027](https://github.com/mapbox/mapbox-gl-native/pull/8027) +* Allow callback parameter for style setting [#8262](https://github.com/mapbox/mapbox-gl-native/issues/8262) +* Avoid disabling location tracking on all gestures [#7878](https://github.com/mapbox/mapbox-gl-native/issues/7878) + +## 5.0.0-beta.2 - March 1st, 2017 + +5.0.0-beta.2 focuses on addressing stability issues and bug fixes. It also includes: + +* Data-driven styling for `{text,icon}-{color,opacity,halo-color,halo-blur,halo-width}` [#7939](https://github.com/mapbox/mapbox-gl-native/pull/7939) +* Additional APIs to manage runtime styling layers [#8195](https://github.com/mapbox/mapbox-gl-native/pull/8195) + ## 5.0.0-beta.1 - February 14th, 2017 * Support for data-driven styles [#7752](https://github.com/mapbox/mapbox-gl-native/pull/7752) diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index dd25a8d7b4..f2d28e53d1 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -27,6 +27,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion buildConfigField "String", "GIT_REVISION_SHORT", String.format("\"%s\"", getGitRevision()) + buildConfigField "String", "MAPBOX_VERSION_STRING", String.format("\"Mapbox/%s\"", project.VERSION_NAME) + buildConfigField "String", "MAPBOX_EVENTS_USER_AGENT", String.format("\"MapboxEventsAndroid/%s\"", project.VERSION_NAME) } defaultPublishConfig project.hasProperty("mapbox.buildtype") ? project.getProperty("mapbox.buildtype") : "debug" diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index 13a5f1032a..9f555da5f8 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.mapbox.mapboxsdk -VERSION_NAME=5.0.0-SNAPSHOT +VERSION_NAME=5.1.0-SNAPSHOT POM_DESCRIPTION=Mapbox GL Android SDK POM_URL=https://github.com/mapbox/mapbox-gl-native diff --git a/platform/android/MapboxGLAndroidSDK/proguard-rules.pro b/platform/android/MapboxGLAndroidSDK/proguard-rules.pro index 92ef05df68..baecd80e50 100644 --- a/platform/android/MapboxGLAndroidSDK/proguard-rules.pro +++ b/platform/android/MapboxGLAndroidSDK/proguard-rules.pro @@ -17,10 +17,10 @@ # Package camera -keep class com.mapbox.mapboxsdk.camera.** { *; } -# Package: geometry +# Package geometry -keep class com.mapbox.mapboxsdk.geometry.** { *; } -# Package: http +# Package http -keep class com.mapbox.mapboxsdk.http.** { *; } # Package maps @@ -32,9 +32,13 @@ # Package offline -keep class com.mapbox.mapboxsdk.offline.** { *; } +# Package storage +-keep class com.mapbox.mapboxsdk.storage.** { *; } + # Package style -keep class com.mapbox.mapboxsdk.style.layers.** { *; } -keep class com.mapbox.mapboxsdk.style.sources.** { *; } +-keep class com.mapbox.mapboxsdk.style.functions.** { *; } # Package telemetry -keep class com.mapbox.mapboxsdk.telemetry.** { *; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDK/src/main/AndroidManifest.xml index c848e61e6c..231e36e092 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDK/src/main/AndroidManifest.xml @@ -8,4 +8,9 @@ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> + <application> + <!-- Include the telemetry service to simplify set up (https://www.mapbox.com/telemetry) --> + <service android:name="com.mapbox.services.android.telemetry.service.TelemetryService"/> + </application> + </manifest> diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java index 296d93d0ca..83d04e7023 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java @@ -37,7 +37,8 @@ public final class Mapbox { INSTANCE = new Mapbox(appContext, accessToken); LocationEngine locationEngine = new LocationSource(appContext); locationEngine.setPriority(LocationEnginePriority.NO_POWER); - MapboxTelemetry.getInstance().initialize(appContext, accessToken, locationEngine); + MapboxTelemetry.getInstance().initialize( + appContext, accessToken, BuildConfig.MAPBOX_EVENTS_USER_AGENT, locationEngine); ConnectivityReceiver.instance(appContext); } return INSTANCE; @@ -106,4 +107,4 @@ public final class Mapbox { NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return (activeNetwork != null && activeNetwork.isConnected()); } -} +}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java index 831c1db5a3..a588ff6d23 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java @@ -6,10 +6,12 @@ import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; /** - * Annotation is an overlay on top of a {@link MapView}, - * from which {@link Polygon}, {@link Polyline} and {@link Marker} are derived. + * Annotation is an overlay on top of a Map. * <p> - * it manages attachment to a map and identification, but does not require + * Known subclasses are {@link Polygon}, {@link Polyline} and {@link Marker}. + * </p> + * <p> + * This class manages attachment to a map and identification, but does not require * content to be placed at a geographical point. * </p> */ @@ -96,6 +98,12 @@ public abstract class Annotation implements Comparable<Annotation> { return mapView; } + /** + * Compares this Annotation object with another Annotation. + * + * @param annotation Another Annotation to compare with this object. + * @return returns 0 if id's match, 1 if id is lower, -1 if id is higher of another Annotation + */ @Override public int compareTo(@NonNull Annotation annotation) { if (id < annotation.getId()) { @@ -107,12 +115,10 @@ public abstract class Annotation implements Comparable<Annotation> { } /** - * Compares this {@link PolylineOptions} object with another {@link PolylineOptions} and - * determines if their color, alpha, width, and vertices match. + * Checks if this Annotation object is equal to another Annotation. * - * @param object Another {@link PolylineOptions} to compare with this object. - * @return True if color, alpha, width, and vertices match this {@link PolylineOptions} object. - * Else, false. + * @param object Another Annotation to check equality with this object. + * @return returns true both id's match else returns false. */ @Override public boolean equals(Object object) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPoint.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BasePointCollection.java index 2bd3c82786..e57821b541 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPoint.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BasePointCollection.java @@ -8,12 +8,12 @@ import java.util.List; /** * Multipoint is an abstract annotation for combining geographical locations. */ -public abstract class MultiPoint extends Annotation { +public abstract class BasePointCollection extends Annotation { private List<LatLng> points; private float alpha = 1.0f; - protected MultiPoint() { + protected BasePointCollection() { super(); points = new ArrayList<>(); } @@ -58,7 +58,7 @@ public abstract class MultiPoint extends Annotation { } /** - * Set this {@link MultiPoint}s alpha. + * Set this {@link BasePointCollection}s alpha. * * @param alpha float value between 0 and 1. */ diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java index 2e6445170f..07e038c08c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java @@ -14,7 +14,7 @@ import com.mapbox.mapboxsdk.R; /** * Bubble View for Android with custom stroke width and color, arrow size, position and direction. */ -class BubbleLayout extends LinearLayout { +public class BubbleLayout extends LinearLayout { public static final float DEFAULT_STROKE_WIDTH = -1; private ArrowDirection arrowDirection; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewContainer.java new file mode 100644 index 0000000000..d590582f09 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewContainer.java @@ -0,0 +1,34 @@ +package com.mapbox.mapboxsdk.annotations; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.ViewGroup; +import android.widget.FrameLayout; + +/** + * ViewGroup that dispatches TouchEvents to the parent ViewGroup. + * <p> + * This allows to dispatch touch events that occur on MarkerView to MapView. + * https://github.com/mapbox/mapbox-gl-native/issues/5388 + * </p> + */ +public class MarkerViewContainer extends FrameLayout { + + public MarkerViewContainer(Context context, AttributeSet attrs) { + super(context, attrs); + setTag(false); + } + + @Override + public boolean dispatchTouchEvent(MotionEvent ev) { + super.dispatchTouchEvent(ev); + boolean actionUp = (boolean) getTag(); + if (!actionUp) { + ((ViewGroup) getParent()).onTouchEvent(ev); + } else { + setTag(false); + } + return true; + } +} diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java index 315e12d280..0f1298eeaf 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java @@ -8,6 +8,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.util.LongSparseArray; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -503,6 +504,26 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { } } + adaptedView.setOnTouchListener(new View.OnTouchListener() { + + @Override + public boolean onTouch(View v, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_UP) { + boolean clickHandled = false; + if (onMarkerViewClickListener != null) { + clickHandled = onMarkerViewClickListener.onMarkerClick(marker, v, adapter); + markerViewContainer.setTag(true); + } + + if (!clickHandled) { + ensureInfoWindowOffset(marker); + select(marker, v, adapter); + } + } + return true; + } + }); + marker.setMapboxMap(mapboxMap); markerViewMap.put(marker, adaptedView); if (convertView == null) { @@ -531,34 +552,6 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { } /** - * When the provided {@link MarkerView} is clicked on by a user, we check if a custom click - * event has been created and if not, display a {@link InfoWindow}. - * - * @param markerView that the click event occurred. - */ - public boolean onClickMarkerView(MarkerView markerView) { - boolean clickHandled = false; - - MapboxMap.MarkerViewAdapter adapter = getViewAdapter(markerView); - View view = getView(markerView); - if (adapter == null || view == null) { - // not a valid state - return true; - } - - if (onMarkerViewClickListener != null) { - clickHandled = onMarkerViewClickListener.onMarkerClick(markerView, view, adapter); - } - - if (!clickHandled) { - ensureInfoWindowOffset(markerView); - select(markerView, view, adapter); - } - - return clickHandled; - } - - /** * Handles the {@link MarkerView}'s info window offset. * * @param marker that we are ensuring info window offset. diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java index 7b9de86bc4..4a72cb7d89 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java @@ -7,7 +7,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; /** * Polygon is a geometry annotation that's a closed loop of coordinates. */ -public final class Polygon extends MultiPoint { +public final class Polygon extends BasePointCollection { private int fillColor = Color.BLACK; // default fillColor is black private int strokeColor = Color.BLACK; // default strokeColor is black diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polyline.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polyline.java index a430d11009..6cea29ef81 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polyline.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polyline.java @@ -7,7 +7,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; /** * Polyline is a geometry feature with an unclosed list of coordinates drawn as a line */ -public final class Polyline extends MultiPoint { +public final class Polyline extends BasePointCollection { private int color = Color.BLACK; // default color is black private float width = 10; // As specified by Google API Docs (in pixels) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/ConversionException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/ConversionException.java index be2b586683..0d16c53b86 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/ConversionException.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/ConversionException.java @@ -1,22 +1,11 @@ package com.mapbox.mapboxsdk.exceptions; /** - * Thrown on conversion errors + * A ConversionException is thrown when a conversion failed to execute. */ public class ConversionException extends RuntimeException { - public ConversionException() { - } - public ConversionException(String detailMessage) { super(detailMessage); } - - public ConversionException(String detailMessage, Throwable throwable) { - super(detailMessage, throwable); - } - - public ConversionException(Throwable throwable) { - super(throwable); - } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java index bd24379af3..f0f9b9236b 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java @@ -1,5 +1,8 @@ package com.mapbox.mapboxsdk.exceptions; +/** + * A InvalidMarkerPositionException is thrown when a Marker object is created with an invalid LatLng position. + */ public class InvalidMarkerPositionException extends RuntimeException { public InvalidMarkerPositionException() { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java index cedc5fe46c..9c8cda5544 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java @@ -183,7 +183,7 @@ class HTTPRequest implements Callback { return USER_AGENT_STRING = Util.toHumanReadableAscii( String.format("%s %s (%s) Android/%s (%s)", getApplicationIdentifier(), - com.mapbox.services.android.telemetry.BuildConfig.MAPBOX_VERSION_STRING, + BuildConfig.MAPBOX_VERSION_STRING, BuildConfig.GIT_REVISION_SHORT, Build.VERSION.SDK_INT, Build.CPU_ABI) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java index 5a87f6384f..f41a022fa2 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java @@ -102,6 +102,7 @@ public class LocationSource extends LocationEngine implements public void requestLocationUpdates() { // Common params LocationRequest request = LocationRequest.create() + .setInterval(1000) .setFastestInterval(1000) .setSmallestDisplacement(3.0f); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java index 0c77723354..e91779dfd1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java @@ -10,6 +10,7 @@ import com.mapbox.mapboxsdk.annotations.Annotation; import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions; import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions; import com.mapbox.mapboxsdk.annotations.Icon; +import com.mapbox.mapboxsdk.annotations.IconFactory; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.MarkerView; import com.mapbox.mapboxsdk.annotations.MarkerViewManager; @@ -256,7 +257,11 @@ class AnnotationManager { private MarkerView prepareViewMarker(BaseMarkerViewOptions markerViewOptions) { MarkerView marker = markerViewOptions.getMarker(); - iconManager.loadIconForMarkerView(marker); + Icon icon = markerViewOptions.getIcon(); + if (icon == null) { + icon = IconFactory.getInstance(mapView.getContext()).defaultMarkerView(); + } + marker.setIcon(icon); return marker; } @@ -660,24 +665,16 @@ class AnnotationManager { if (annotation.getId() == newSelectedMarkerId) { Marker marker = (Marker) annotation; - if (marker instanceof MarkerView) { - handledDefaultClick = markerViewManager.onClickMarkerView((MarkerView) marker); - } else { + if (!(marker instanceof MarkerView)) { if (onMarkerClickListener != null) { // end developer has provided a custom click listener handledDefaultClick = onMarkerClickListener.onMarkerClick(marker); } - } - - if (annotation instanceof MarkerView) { - markerViewManager.onClickMarkerView((MarkerView) annotation); - } else { if (!handledDefaultClick) { // only select marker if user didn't handle the click event themselves selectMarker(marker); } } - return true; } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java index c9d81a88bc..c152630278 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java @@ -71,27 +71,6 @@ class IconManager { return icon; } - Icon loadIconForMarkerView(MarkerView marker) { - Icon icon = marker.getIcon(); - int iconSize = icons.size() + 1; - if (icon == null) { - icon = IconFactory.getInstance(nativeMapView.getContext()).defaultMarkerView(); - marker.setIcon(icon); - } - Bitmap bitmap = icon.getBitmap(); - averageIconHeight = averageIconHeight + (bitmap.getHeight() - averageIconHeight) / iconSize; - averageIconWidth = averageIconWidth + (bitmap.getWidth() - averageIconWidth) / iconSize; - if (!icons.contains(icon)) { - icons.add(icon); - } else { - Icon oldIcon = icons.get(icons.indexOf(icon)); - if (!oldIcon.getBitmap().sameAs(icon.getBitmap())) { - throw new IconBitmapChangedException(); - } - } - return icon; - } - int getTopOffsetPixelsForIcon(Icon icon) { return (int) (nativeMapView.getTopOffsetPixelsForAnnotationSymbol(icon.getId()) * nativeMapView.getPixelRatio()); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index 0f4d3197cc..67e55352f4 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -4,13 +4,13 @@ import android.content.Context; import android.graphics.PointF; import android.location.Location; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.view.GestureDetectorCompat; import android.support.v4.view.ScaleGestureDetectorCompat; import android.view.InputDevice; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.view.ViewConfiguration; -import android.widget.ZoomButtonsController; import com.almeros.android.multitouch.gesturedetectors.RotateGestureDetector; import com.almeros.android.multitouch.gesturedetectors.ShoveGestureDetector; @@ -93,6 +93,20 @@ final class MapGestureDetector { } /** + * Get the current active gesture focal point. + * <p> + * This could be either the user provided focal point in {@link UiSettings#setFocalPoint(PointF)} or the focal point + * defined as a result of {@link TrackingSettings#setMyLocationEnabled(boolean)}. + * </p> + * + * @return the current active gesture focal point. + */ + @Nullable + PointF getFocalPoint() { + return focalPoint; + } + + /** * Given coordinates from a gesture, use the current projection to translate it into * a Location object. * @@ -159,10 +173,10 @@ final class MapGestureDetector { if (twoTap && isTap && !inProgress) { if (focalPoint != null) { - transform.zoom(false, focalPoint.x, focalPoint.y); + transform.zoom(false, focalPoint); } else { PointF focalPoint = TwoFingerGestureDetector.determineFocalPoint(event); - transform.zoom(false, focalPoint.x, focalPoint.y); + transform.zoom(false, focalPoint); } twoTap = false; return true; @@ -262,10 +276,10 @@ final class MapGestureDetector { // Single finger double tap if (focalPoint != null) { // User provided focal point - transform.zoom(true, focalPoint.x, focalPoint.y); + transform.zoom(true, focalPoint); } else { // Zoom in on gesture - transform.zoom(true, e.getX(), e.getY()); + transform.zoom(true, new PointF(e.getX(), e.getY())); } break; } @@ -636,34 +650,6 @@ final class MapGestureDetector { } } - // This class handles input events from the zoom control buttons - // Zoom controls allow single touch only devices to zoom in and out - private static class OnZoomListener implements ZoomButtonsController.OnZoomListener { - - private UiSettings uiSettings; - private Transform transform; - - OnZoomListener(UiSettings uiSettings, Transform transform) { - this.uiSettings = uiSettings; - this.transform = transform; - } - - // Not used - @Override - public void onVisibilityChanged(boolean visible) { - // Ignore - } - - // Called when user pushes a zoom button - @Override - public void onZoom(boolean zoomIn) { - if (!uiSettings.isZoomGesturesEnabled()) { - return; - } - transform.zoom(zoomIn); - } - } - void setOnMapClickListener(MapboxMap.OnMapClickListener onMapClickListener) { this.onMapClickListener = onMapClickListener; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java index c993cd3ec6..7175242282 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.maps; +import android.graphics.PointF; import android.os.Handler; import android.support.annotation.NonNull; import android.view.KeyEvent; @@ -125,7 +126,8 @@ final class MapKeyListener { } // Zoom out - transform.zoom(false, uiSettings.getWidth() / 2, uiSettings.getHeight() / 2); + PointF focalPoint = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2); + transform.zoom(false, focalPoint); return true; default: @@ -160,7 +162,8 @@ final class MapKeyListener { } // Zoom in - transform.zoom(true, uiSettings.getWidth() / 2, uiSettings.getHeight() / 2); + PointF focalPoint = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2); + transform.zoom(true, focalPoint); return true; } @@ -214,7 +217,8 @@ final class MapKeyListener { // Only handle if we have not already long pressed if (currentTrackballLongPressTimeOut != null) { // Zoom in - transform.zoom(true, uiSettings.getWidth() / 2, uiSettings.getHeight() / 2); + PointF focalPoint = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2); + transform.zoom(true, focalPoint); } return true; @@ -255,7 +259,8 @@ final class MapKeyListener { // Check if the trackball is still pressed if (!cancelled) { // Zoom out - transform.zoom(false, uiSettings.getWidth() / 2, uiSettings.getHeight() / 2); + PointF pointF = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2); + transform.zoom(false, pointF); // Ensure the up action is not run currentTrackballLongPressTimeOut = null; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 8fa2d0b152..8c8b70d788 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -31,6 +31,7 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.ZoomButtonsController; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.R; @@ -147,7 +148,9 @@ public class MapView extends FrameLayout { // user input mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings, trackingSettings, annotations); mapKeyListener = new MapKeyListener(transform, trackingSettings, uiSettings); - mapZoomButtonController = new MapZoomButtonController(this, uiSettings, transform); + + MapZoomControllerListener zoomListener = new MapZoomControllerListener(mapGestureDetector, uiSettings, transform); + mapZoomButtonController = new MapZoomButtonController(this, uiSettings, zoomListener); // inject widgets with MapboxMap compassView.setMapboxMap(mapboxMap); @@ -508,7 +511,7 @@ public class MapView extends FrameLayout { if (destroyed) { return; } - mapboxMap.onUpdate(); + mapboxMap.onUpdateRegionChange(); } } @@ -521,13 +524,15 @@ public class MapView extends FrameLayout { @CallSuper protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - mapZoomButtonController.setVisible(false); + if (mapZoomButtonController != null) { + mapZoomButtonController.setVisible(false); + } } // Called when view is hidden and shown @Override protected void onVisibilityChanged(@NonNull View changedView, int visibility) { - if (isInEditMode()) { + if (isInEditMode() || mapZoomButtonController == null) { return; } mapZoomButtonController.setVisible(visibility == View.VISIBLE); @@ -801,7 +806,7 @@ public class MapView extends FrameLayout { public static final int DID_FINISH_RENDERING_FRAME = 9; /** - * This event is triggered when the map finished rendeirng the frame fully. + * This event is triggered when the map finished rendering the frame fully. * <p> * Register to {@link MapChange} events with {@link MapView#addOnMapChangedListener(OnMapChangedListener)}. * </p> @@ -937,12 +942,59 @@ public class MapView extends FrameLayout { } } + private class MapZoomControllerListener implements ZoomButtonsController.OnZoomListener { + + private final MapGestureDetector mapGestureDetector; + private final UiSettings uiSettings; + private final Transform transform; + + MapZoomControllerListener(MapGestureDetector detector, UiSettings uiSettings, Transform transform) { + this.mapGestureDetector = detector; + this.uiSettings = uiSettings; + this.transform = transform; + } + + // Not used + @Override + public void onVisibilityChanged(boolean visible) { + // Ignore + } + + // Called when user pushes a zoom button on the ZoomButtonController + @Override + public void onZoom(boolean zoomIn) { + if (uiSettings.isZoomGesturesEnabled()) { + onZoom(zoomIn, mapGestureDetector.getFocalPoint()); + } + } + + private void onZoom(boolean zoomIn, @Nullable PointF focalPoint) { + if (focalPoint != null) { + transform.zoom(zoomIn, focalPoint); + } else { + PointF centerPoint = new PointF(getMeasuredWidth() / 2, getMeasuredHeight() / 2); + transform.zoom(zoomIn, centerPoint); + } + } + } + private class CameraZoomInvalidator implements TrackingSettings.CameraZoomInvalidator { + @Override public void zoomTo(double zoomLevel) { - double currentZoomLevel = mapboxMap.getCameraPosition().zoom; + Transform transform = mapboxMap.getTransform(); + double currentZoomLevel = transform.getCameraPosition().zoom; if (currentZoomLevel < zoomLevel) { - mapboxMap.getTransform().setZoom(zoomLevel); + setZoom(zoomLevel, mapGestureDetector.getFocalPoint(), transform); + } + } + + private void setZoom(double zoomLevel, @Nullable PointF focalPoint, @NonNull Transform transform) { + if (focalPoint != null) { + transform.setZoom(zoomLevel, focalPoint); + } else { + PointF centerPoint = new PointF(getMeasuredWidth() / 2, getMeasuredHeight() / 2); + transform.setZoom(zoomLevel, centerPoint); } } } @@ -969,8 +1021,10 @@ public class MapView extends FrameLayout { mapboxMap.onPostMapReady(); } }); + } else if (change == DID_FINISH_RENDERING_FRAME || change == DID_FINISH_RENDERING_FRAME_FULLY_RENDERED) { + mapboxMap.onUpdateFullyRendered(); } else if (change == REGION_IS_CHANGING || change == REGION_DID_CHANGE || change == DID_FINISH_LOADING_MAP) { - mapboxMap.onUpdate(); + mapboxMap.onUpdateRegionChange(); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapZoomButtonController.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapZoomButtonController.java index 06084d906e..16513904c5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapZoomButtonController.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapZoomButtonController.java @@ -16,11 +16,11 @@ final class MapZoomButtonController extends ZoomButtonsController { private UiSettings uiSettings; - MapZoomButtonController(@NonNull View ownerView, @NonNull UiSettings uiSettings, @NonNull Transform transform) { + MapZoomButtonController(@NonNull View ownerView, @NonNull UiSettings uiSettings, @NonNull OnZoomListener listener) { super(ownerView); this.uiSettings = uiSettings; setZoomSpeed(MapboxConstants.ANIMATION_DURATION); - setOnZoomListener(new OnZoomListener(uiSettings, transform)); + setOnZoomListener(listener); } @Override @@ -29,31 +29,4 @@ final class MapZoomButtonController extends ZoomButtonsController { super.setVisible(visible); } } - - // Zoom controls allow single touch only devices to zoom in and out - private static class OnZoomListener implements ZoomButtonsController.OnZoomListener { - - private final UiSettings uiSettings; - private final Transform transform; - - OnZoomListener(UiSettings uiSettings, Transform transform) { - this.uiSettings = uiSettings; - this.transform = transform; - } - - // Not used - @Override - public void onVisibilityChanged(boolean visible) { - // Ignore - } - - // Called when user pushes a zoom button - @Override - public void onZoom(boolean zoomIn) { - if (!uiSettings.isZoomGesturesEnabled()) { - return; - } - transform.zoom(zoomIn); - } - } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 46c5e269c0..6edae8b944 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -96,6 +96,9 @@ public final class MapboxMap { setStyleUrl(options); } + /** + * Called when the hosting Activity/Fragment onStart() method is called. + */ void onStart() { nativeMapView.update(); trackingSettings.onStart(); @@ -105,10 +108,18 @@ public final class MapboxMap { } } + /** + * Called when the hosting Activity/Fragment onStop() method is called. + */ void onStop() { trackingSettings.onStop(); } + /** + * Called when the hosting Activity/Fragment is going to be destroyed and map state needs to be saved. + * + * @param outState the bundle to save the state to. + */ void onSaveInstanceState(Bundle outState) { outState.putParcelable(MapboxConstants.STATE_CAMERA_POSITION, transform.getCameraPosition()); outState.putBoolean(MapboxConstants.STATE_DEBUG_ACTIVE, nativeMapView.getDebug()); @@ -117,6 +128,11 @@ public final class MapboxMap { uiSettings.onSaveInstanceState(outState); } + /** + * Called when the hosting Activity/Fragment is recreated and map state needs to be restored. + * + * @param savedInstanceState the bundle containing the saved state + */ void onRestoreInstanceState(Bundle savedInstanceState) { final CameraPosition cameraPosition = savedInstanceState.getParcelable(MapboxConstants.STATE_CAMERA_POSITION); if (cameraPosition != null) { @@ -153,16 +169,23 @@ public final class MapboxMap { } /** - * Called when the user + * Called when the region is changing or has changed. */ - void onUpdate() { - CameraPosition cameraPosition = transform.invalidateCameraPosition(); - uiSettings.update(cameraPosition); - // FIXME introduce update method with camera position + void onUpdateRegionChange() { trackingSettings.update(); annotationManager.update(); } + /** + * Called when the map frame is fully rendered. + */ + void onUpdateFullyRendered() { + CameraPosition cameraPosition = transform.invalidateCameraPosition(); + if (cameraPosition != null) { + uiSettings.update(cameraPosition); + } + } + // Style /** @@ -815,10 +838,20 @@ public final class MapboxMap { transform.setBearing(bearing, focalX, focalY, duration); } + /** + * Returns the measured height of the Map. + * + * @return the height of the map + */ public float getHeight() { return nativeMapView.getHeight(); } + /** + * Returns the measured width of the Map. + * + * @return the width of the map + */ public float getWidth() { return nativeMapView.getWidth(); } @@ -881,35 +914,80 @@ public final class MapboxMap { /** * <p> - * Loads a new map style from the specified URL. + * Loads a new map style asynchronous from the specified URL. * </p> * {@code url} can take the following forms: * <ul> * <li>{@code Style.*}: load one of the bundled styles in {@link Style}.</li> * <li>{@code mapbox://styles/<user>/<style>}: - * retrieves the style from a <a href="https://www.mapbox.com/account/">Mapbox account.</a> + * 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://...}: - * retrieves the style over the Internet from any web server.</li> + * loads the style over the Internet from any web server.</li> * <li>{@code asset://...}: - * reads the style from the APK {@code assets/} directory. + * loads the style from the APK {@code assets/} directory. * This is used to load a style bundled with your app.</li> * <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li> * </ul> * <p> - * This method is asynchronous and will return immediately before the style finishes loading. - * If you wish to wait for the map to finish loading listen for the {@link MapView#DID_FINISH_LOADING_MAP} event. + * This method is asynchronous and will return before the style finishes loading. + * If you wish to wait for the map to finish loading, listen for the {@link MapView#DID_FINISH_LOADING_MAP} event + * or use the {@link #setStyleUrl(String, OnStyleLoadedListener)} method instead. * </p> * If the style fails to load or an invalid style URL is set, the map view will become blank. * An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be - * sent. + * emitted. * * @param url The URL of the map style * @see Style */ @UiThread public void setStyleUrl(@NonNull String url) { + setStyleUrl(url, null); + } + + /** + * <p> + * Loads a new map style asynchronous from the specified URL. + * </p> + * {@code url} can take the following forms: + * <ul> + * <li>{@code Style.*}: 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 null}: loads the default {@link Style#MAPBOX_STREETS} style.</li> + * </ul> + * <p> + * If the style fails to load or an invalid style URL is set, the map view will become blank. + * An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be + * emitted. + * <p> + * + * @param url The URL of the map style + * @param callback The callback that is invoked when the style has loaded. + * @see Style + */ + @UiThread + public void setStyleUrl(@NonNull final String url, @Nullable final OnStyleLoadedListener callback) { + if (callback != null) { + nativeMapView.addOnMapChangedListener(new MapView.OnMapChangedListener() { + @Override + public void onMapChanged(@MapView.MapChange int change) { + if (change == MapView.DID_FINISH_LOADING_STYLE) { + callback.onStyleLoaded(url); + nativeMapView.removeOnMapChangedListener(this); + } + } + }); + } nativeMapView.setStyleUrl(url); } @@ -918,8 +996,9 @@ public final class MapboxMap { * Loads a new map style from the specified bundled style. * </p> * <p> - * This method is asynchronous and will return immediately before the style finishes loading. - * If you wish to wait for the map to finish loading listen for the {@link MapView#DID_FINISH_LOADING_MAP} event. + * This method is asynchronous and will return before the style finishes loading. + * If you wish to wait for the map to finish loading, listen for the {@link MapView#DID_FINISH_LOADING_MAP} event + * or use the {@link #setStyle(String, OnStyleLoadedListener)} method instead. * </p> * If the style fails to load or an invalid style URL is set, the map view will become blank. * An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be @@ -927,7 +1006,6 @@ public final class MapboxMap { * * @param style The bundled style. Accepts one of the values from {@link Style}. * @see Style - * @deprecated use {@link #setStyleUrl(String)} instead with versioned url methods from {@link Style} */ @UiThread public void setStyle(@Style.StyleUrl String style) { @@ -935,6 +1013,22 @@ public final class MapboxMap { } /** + * <p> + * Loads a new map style from the specified bundled style. + * </p> + * If the style fails to load or an invalid style URL is set, the map view will become blank. + * An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be + * sent. + * + * @param style The bundled style. Accepts one of the values from {@link Style}. + * @see Style + */ + @UiThread + public void setStyle(@Style.StyleUrl String style, @Nullable OnStyleLoadedListener callback) { + setStyleUrl(style, callback); + } + + /** * Loads a new map style from MapboxMapOptions if available. * * @param options the object containing the style url @@ -942,20 +1036,17 @@ public final class MapboxMap { private void setStyleUrl(@NonNull MapboxMapOptions options) { String style = options.getStyle(); if (!TextUtils.isEmpty(style)) { - setStyleUrl(style); + setStyleUrl(style, null); } } /** - * <p> * Returns the map style currently displayed in the map view. - * </p> - * If the default style is currently displayed, a URL will be returned instead of null. * - * @return The URL of the map style. + * @return The URL of the map style */ @UiThread - @NonNull + @Nullable public String getStyleUrl() { return nativeMapView.getStyleUrl(); } @@ -971,8 +1062,8 @@ public final class MapboxMap { * The marker's icon is rendered on the map at the location {@code Marker.position}. * If {@code Marker.title} is defined, the map shows an info box with the marker's title and snippet. * - * @param markerOptions A marker options object that defines how to render the marker. - * @return The {@code Marker} that was added to the map. + * @param markerOptions A marker options object that defines how to render the marker + * @return The {@code Marker} that was added to the map */ @UiThread @NonNull @@ -987,8 +1078,8 @@ public final class MapboxMap { * The marker's icon is rendered on the map at the location {@code Marker.position}. * If {@code Marker.title} is defined, the map shows an info box with the marker's title and snippet. * - * @param markerOptions A marker options object that defines how to render the marker. - * @return The {@code Marker} that was added to the map. + * @param markerOptions A marker options object that defines how to render the marker + * @return The {@code Marker} that was added to the map */ @UiThread @NonNull @@ -1003,8 +1094,8 @@ public final class MapboxMap { * The marker's icon is rendered on the map at the location {@code Marker.position}. * If {@code Marker.title} is defined, the map shows an info box with the marker's title and snippet. * - * @param markerOptions A marker options object that defines how to render the marker. - * @return The {@code Marker} that was added to the map. + * @param markerOptions A marker options object that defines how to render the marker + * @return The {@code Marker} that was added to the map */ @UiThread @NonNull @@ -1012,7 +1103,6 @@ public final class MapboxMap { return annotationManager.addMarker(markerOptions, this, null); } - /** * <p> * Adds a marker to this map. @@ -1020,9 +1110,9 @@ public final class MapboxMap { * The marker's icon is rendered on the map at the location {@code Marker.position}. * If {@code Marker.title} is defined, the map shows an info box with the marker's title and snippet. * - * @param markerOptions A marker options object that defines how to render the marker. - * @param onMarkerViewAddedListener Callback invoked when the View has been added to the map. - * @return The {@code Marker} that was added to the map. + * @param markerOptions A marker options object that defines how to render the marker + * @param onMarkerViewAddedListener Callback invoked when the View has been added to the map + * @return The {@code Marker} that was added to the map */ @UiThread @NonNull @@ -1032,7 +1122,14 @@ public final class MapboxMap { } /** - * FIXME javadoc + * Adds multiple markersViews to this map. + * <p> + * The marker's icon is rendered on the map at the location {@code Marker.position}. + * If {@code Marker.title} is defined, the map shows an info box with the marker's title and snippet. + * </p> + * + * @param markerViewOptions A list of markerView options objects that defines how to render the markers + * @return A list of the {@code MarkerView}s that were added to the map */ @UiThread @NonNull @@ -1042,7 +1139,10 @@ public final class MapboxMap { } /** - * FIXME javadoc + * Returns markerViews found inside of a rectangle on this map. + * + * @param rect the rectangular area on the map to query for markerViews + * @return A list of the markerViews that were found in the rectangle */ @UiThread @NonNull @@ -1057,8 +1157,8 @@ public final class MapboxMap { * The marker's icon is rendered on the map at the location {@code Marker.position}. * If {@code Marker.title} is defined, the map shows an info box with the marker's title and snippet. * - * @param markerOptionsList A list of marker options objects that defines how to render the markers. - * @return A list of the {@code Marker}s that were added to the map. + * @param markerOptionsList A list of marker options objects that defines how to render the markers + * @return A list of the {@code Marker}s that were added to the map */ @UiThread @NonNull @@ -1072,7 +1172,7 @@ public final class MapboxMap { * Updates a marker on this map. Does nothing if the marker isn't already added. * </p> * - * @param updatedMarker An updated marker object. + * @param updatedMarker An updated marker object */ @UiThread public void updateMarker(@NonNull Marker updatedMarker) { @@ -1082,8 +1182,8 @@ public final class MapboxMap { /** * Adds a polyline to this map. * - * @param polylineOptions A polyline options object that defines how to render the polyline. - * @return The {@code Polyine} that was added to the map. + * @param polylineOptions A polyline options object that defines how to render the polyline + * @return The {@code Polyine} that was added to the map */ @UiThread @NonNull @@ -1128,8 +1228,8 @@ public final class MapboxMap { /** * Adds multiple polygons to this map. * - * @param polygonOptionsList A list of polygon options objects that defines how to render the polygons. - * @return A list of the {@code Polygon}s that were added to the map. + * @param polygonOptionsList A list of polygon options objects that defines how to render the polygons + * @return A list of the {@code Polygon}s that were added to the map */ @UiThread @NonNull @@ -1137,11 +1237,10 @@ public final class MapboxMap { return annotationManager.addPolygons(polygonOptionsList, this); } - /** * Update a polygon on this map. * - * @param polygon An updated polygon object. + * @param polygon An updated polygon object */ @UiThread public void updatePolygon(Polygon polygon) { @@ -1152,7 +1251,7 @@ public final class MapboxMap { * <p> * Convenience method for removing a Marker from the map. * </p> - * Calls removeAnnotation() internally + * Calls removeAnnotation() internally. * * @param marker Marker to remove */ @@ -1165,7 +1264,7 @@ public final class MapboxMap { * <p> * Convenience method for removing a Polyline from the map. * </p> - * Calls removeAnnotation() internally + * Calls removeAnnotation() internally. * * @param polyline Polyline to remove */ @@ -1178,7 +1277,7 @@ public final class MapboxMap { * <p> * Convenience method for removing a Polygon from the map. * </p> - * Calls removeAnnotation() internally + * Calls removeAnnotation() internally. * * @param polygon Polygon to remove */ @@ -1558,6 +1657,11 @@ public final class MapboxMap { return annotationManager.getInfoWindowManager().getOnInfoWindowLongClickListener(); } + /** + * Set an callback to be invoked when an InfoWindow closes. + * + * @param listener callback invoked when an InfoWindow closes + */ public void setOnInfoWindowCloseListener(@Nullable OnInfoWindowCloseListener listener) { annotationManager.getInfoWindowManager().setOnInfoWindowCloseListener(listener); } @@ -1657,7 +1761,6 @@ public final class MapboxMap { * Takes a snapshot of the map. * * @param callback Callback method invoked when the snapshot is taken. - * @param bitmap A pre-allocated bitmap. */ @UiThread public void snapshot(@NonNull SnapshotReadyCallback callback) { @@ -2104,6 +2207,16 @@ public final class MapboxMap { void onSnapshotReady(Bitmap snapshot); } + /** + * Interface definintion for a callback to be invoked when the style has finished loading. + */ + public interface OnStyleLoadedListener { + /** + * Invoked when the style has finished loading. + */ + void onStyleLoaded(String style); + } + // // Used for instrumentation testing // diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java index bf3bd1f224..c5eaf2deb9 100755 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java @@ -378,18 +378,11 @@ final class NativeMapView { return nativeGetScale(); } - public void setZoom(double zoom) { + public void setZoom(double zoom, PointF focalPoint, long duration) { if (isDestroyedOn("setZoom")) { return; } - setZoom(zoom, 0); - } - - public void setZoom(double zoom, long duration) { - if (isDestroyedOn("setZoom")) { - return; - } - nativeSetZoom(zoom, duration); + nativeSetZoom(zoom, focalPoint.x / pixelRatio, focalPoint.y / pixelRatio, duration); } public double getZoom() { @@ -1023,7 +1016,7 @@ final class NativeMapView { private native double nativeGetScale(); - private native void nativeSetZoom(double zoom, long duration); + private native void nativeSetZoom(double zoom, double cx, double cy, long duration); private native double nativeGetZoom(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java index 38f307f149..476f4554c1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java @@ -281,7 +281,7 @@ public final class TrackingSettings { */ void resetTrackingModesIfRequired(CameraPosition cameraPosition) { if (isDismissTrackingModesForCameraPositionChange()) { - resetTrackingModesIfRequired(cameraPosition.target != null, cameraPosition.bearing != -1); + resetTrackingModesIfRequired(cameraPosition.target != null, false); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java index 0f6b146907..ec4b903a74 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.maps; +import android.graphics.PointF; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.UiThread; @@ -174,23 +175,23 @@ final class Transform implements MapView.OnMapChangedListener { return cameraPosition.zoom; } - void zoom(boolean zoomIn) { - zoom(zoomIn, -1.0f, -1.0f); - } - - void zoom(boolean zoomIn, float x, float y) { + void zoom(boolean zoomIn, @NonNull PointF focalPoint) { // Cancel any animation cancelTransitions(); - if (zoomIn) { - mapView.scaleBy(2.0, x, y, MapboxConstants.ANIMATION_DURATION); - } else { - mapView.scaleBy(0.5, x, y, MapboxConstants.ANIMATION_DURATION); + CameraPosition cameraPosition = invalidateCameraPosition(); + if (cameraPosition != null) { + int newZoom = (int) Math.round(cameraPosition.zoom + (zoomIn ? 1 : -1)); + setZoom(newZoom, focalPoint, MapboxConstants.ANIMATION_DURATION); } } - void setZoom(double zoom) { - mapView.setZoom(zoom); + void setZoom(double zoom, @NonNull PointF focalPoint) { + setZoom(zoom, focalPoint, 0); + } + + void setZoom(double zoom, @NonNull PointF focalPoint, long duration) { + mapView.setZoom(zoom, focalPoint, duration); } // Direction diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index 2c3685b862..663202eacc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -257,9 +257,7 @@ public class MyLocationView extends View { final PointF pointF = screenLocation; float metersPerPixel = (float) projection.getMetersPerPixelAtLatitude(location.getLatitude()); - float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel / 2; - float maxRadius = getWidth() / 2; - accuracyPixels = accuracyPixels <= maxRadius ? accuracyPixels : maxRadius; + float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel; // reset matrix.reset(); @@ -435,10 +433,12 @@ public class MyLocationView extends View { } locationEngine.addLocationEngineListener(userLocationListener); + locationEngine.activate(); } else { // Disable location and user dot location = null; locationEngine.removeLocationEngineListener(userLocationListener); + locationEngine.deactivate(); } locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY); @@ -573,8 +573,10 @@ public class MyLocationView extends View { public void onConnected() { MyLocationView locationView = userLocationView.get(); if (locationView != null) { - Location location = LocationSource.getLocationEngine(locationView.getContext()).getLastLocation(); + LocationEngine locationSource = LocationSource.getLocationEngine(locationView.getContext()); + Location location = locationSource.getLastLocation(); locationView.setLocation(location); + locationSource.requestLocationUpdates(); } } @@ -730,7 +732,7 @@ public class MyLocationView extends View { accuracyAnimator.end(); } - accuracyAnimator = ValueAnimator.ofFloat(accuracy * 10, location.getAccuracy() * 10); + accuracyAnimator = ValueAnimator.ofFloat(accuracy, location.getAccuracy()); accuracyAnimator.setDuration(750); accuracyAnimator.start(); accuracy = location.getAccuracy(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/package-info.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/package-info.java new file mode 100644 index 0000000000..85950735ef --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/package-info.java @@ -0,0 +1,4 @@ +/** + * Contains the Mapbox Maps Android Storage API classes. + */ +package com.mapbox.mapboxsdk.storage; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java index 27a3d5c898..1a1711e547 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonOptions.java @@ -3,8 +3,9 @@ package com.mapbox.mapboxsdk.style.sources; import java.util.HashMap; /** - * Options for the {@link GeoJsonSource} + * Builder class for composing GeoJsonSource objects. * + * @see GeoJsonSource * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">The online documentation</a> */ public class GeoJsonOptions extends HashMap<String, Object> { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java index 9f957e7727..b253595713 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java @@ -15,7 +15,7 @@ import java.util.HashMap; import java.util.List; /** - * A GeoJson source. Exposes a {@link FeatureCollection} from Json. + * GeoJson source, allows using FeatureCollections from Json. * * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">the style specification</a> */ diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java index eabbdb8395..98b74afcff 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java @@ -3,7 +3,7 @@ package com.mapbox.mapboxsdk.style.sources; import java.net.URL; /** - * Raster Source enables the use of raster tiles. + * Raster source, allows using raster tiles as source. * * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-raster">The style specification</a> */ diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java index 9f403c2fb9..54e4e5f5d3 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/TileSet.java @@ -8,7 +8,7 @@ import java.util.HashMap; import java.util.Map; /** - * Tile set + * Tile set, allows using TileJson specification as source. * * @see <a href="https://github.com/mapbox/tilejson-spec/tree/master/2.1.0">The tileset specification</a> */ diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java index 68eb81b7f4..cff5ab6353 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java @@ -14,7 +14,7 @@ import java.util.Arrays; import java.util.List; /** - * Vector source enables the use of vector tiles. + * Vector source, allows the use of vector tiles. * * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-vector">the style specification</a> */ diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml index e6a2677785..7a38437fee 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml @@ -8,7 +8,7 @@ android:contentDescription="@null" android:visibility="gone"/> - <FrameLayout + <com.mapbox.mapboxsdk.annotations.MarkerViewContainer android:id="@+id/markerViewContainer" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties index 63cccc00ef..1d436f1291 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties +++ b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties @@ -1,3 +1,3 @@ fabric-identifier=com.mapbox.mapboxsdk.mapbox-android-sdk -fabric-version=4.1.1 +fabric-version=5.0.0 fabric-build-type=binary diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 59131d89fc..e6d118692e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -2,10 +2,7 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mapbox.mapboxsdk.testapp"> - <uses-permission android:name="android.permission.INTERNET"/> - <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> - <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <application @@ -617,8 +614,6 @@ <!-- <meta-data --> <!-- android:name="com.mapbox.SetStorageExternal" --> <!-- android:value="true" /> --> - - <service android:name="com.mapbox.services.android.telemetry.service.TelemetryService"/> </application> </manifest> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java index f2f82865d1..b8a008e592 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java @@ -196,6 +196,13 @@ public class MarkerViewActivity extends AppCompatActivity { // open infowindow offscreen markers mapboxMap.selectMarker(markerRightOffScreen); mapboxMap.selectMarker(markerRightBottomOffScreen); + + mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() { + @Override + public void onMapClick(@NonNull LatLng point) { + Toast.makeText(MarkerViewActivity.this, point.toString(), Toast.LENGTH_SHORT).show(); + } + }); } }); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java index 86d5b47275..014743df96 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java @@ -1,13 +1,18 @@ package com.mapbox.mapboxsdk.testapp.activity.camera; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; +import com.mapbox.mapboxsdk.constants.Style; +import com.mapbox.mapboxsdk.geometry.LatLng; 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 timber.log.Timber; + public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyCallback { private MapView mapView; @@ -25,10 +30,21 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC } @Override - public void onMapReady(MapboxMap map) { + public void onMapReady(final MapboxMap map) { mapboxMap = map; mapboxMap.setMinZoomPreference(3); mapboxMap.setMaxZoomPreference(5); + mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() { + @Override + public void onMapClick(@NonNull LatLng point) { + map.setStyle(Style.OUTDOORS, new MapboxMap.OnStyleLoadedListener() { + @Override + public void onStyleLoaded(String style) { + Timber.d("Style Loaded %s", style); + } + }); + } + }); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java index 6ec0ccc11f..18d6fadcb8 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java @@ -5,7 +5,9 @@ import android.support.annotation.NonNull; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.view.View; +import android.widget.TextView; +import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -47,9 +49,21 @@ public class DebugModeActivity extends AppCompatActivity { @Override public void onMapReady(@NonNull MapboxMap map) { mapboxMap = map; + + mapboxMap.getUiSettings().setZoomControlsEnabled(true); + + // show current zoom level on screen + final TextView textView = (TextView) findViewById(R.id.textZoom); + mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() { + @Override + public void onCameraChange(CameraPosition position) { + textView.setText(String.format(getString(R.string.debug_zoom), position.zoom)); + } + }); } }); + FloatingActionButton fabDebug = (FloatingActionButton) findViewById(R.id.fabDebug); fabDebug.setOnClickListener(new View.OnClickListener() { @Override @@ -70,7 +84,12 @@ public class DebugModeActivity extends AppCompatActivity { if (currentStyleIndex == STYLES.length) { currentStyleIndex = 0; } - mapboxMap.setStyleUrl(STYLES[currentStyleIndex]); + mapboxMap.setStyleUrl(STYLES[currentStyleIndex], new MapboxMap.OnStyleLoadedListener() { + @Override + public void onStyleLoaded(String style) { + Timber.d("Style loaded %s", style); + } + }); } } }); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_debug_mode.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_debug_mode.xml index ffbf2e30a1..6db8b073d9 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_debug_mode.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_debug_mode.xml @@ -10,7 +10,18 @@ <com.mapbox.mapboxsdk.maps.MapView android:id="@+id/mapView" android:layout_width="match_parent" - android:layout_height="match_parent"/> + android:layout_height="match_parent" + app:mapbox_uiAttribution="false" + app:mapbox_uiCompass="false" + app:mapbox_uiLogo="false"/> + + <TextView + android:id="@+id/textZoom" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="bottom|start" + android:layout_margin="8dp" + android:textSize="14sp"/> <android.support.design.widget.FloatingActionButton android:id="@+id/fabDebug" diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index 56ac712cf8..f15ee20be6 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -162,4 +162,5 @@ <string name="dynamic_marker_chelsea_snippet">Stamford Bridge</string> <string name="dynamic_marker_arsenal_title">Arsenal</string> <string name="dynamic_marker_arsenal_snippet">Emirates Stadium</string> + <string name="debug_zoom">Zoom: %s</string> </resources> diff --git a/platform/android/bitrise.yml b/platform/android/bitrise.yml index 6e1f9a0d19..53637fd498 100644 --- a/platform/android/bitrise.yml +++ b/platform/android/bitrise.yml @@ -164,8 +164,7 @@ workflows: mkdir -p "${ANDROID_HOME}/licenses" echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license" echo "Compile libmapbox-gl.so for all supportd abi's:" - export BUILDTYPE=Release - make apackage + export BUILDTYPE=Release make apackage - script: title: Publish to maven inputs: diff --git a/platform/android/dependencies.gradle b/platform/android/dependencies.gradle index 3eb28452c6..c4ace641c3 100644 --- a/platform/android/dependencies.gradle +++ b/platform/android/dependencies.gradle @@ -16,9 +16,9 @@ ext { dep = [ // mapbox - mapboxJavaServices : 'com.mapbox.mapboxsdk:mapbox-java-services:2.0.0-beta.2@jar', - mapboxJavaGeoJSON : 'com.mapbox.mapboxsdk:mapbox-java-geojson:2.0.0-beta.2@jar', - mapboxAndroidTelemetry : 'com.mapbox.mapboxsdk:mapbox-android-telemetry:2.0.0-beta.2@aar', + mapboxJavaServices : 'com.mapbox.mapboxsdk:mapbox-java-services:2.0.0@jar', + mapboxJavaGeoJSON : 'com.mapbox.mapboxsdk:mapbox-java-geojson:2.0.0@jar', + mapboxAndroidTelemetry : 'com.mapbox.mapboxsdk:mapbox-android-telemetry:2.0.0@aar', // mapzen lost lost : 'com.mapzen.android:lost:2.1.2', diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index 1bdba67000..af8ae16bf6 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -459,8 +459,8 @@ jni::jdouble NativeMapView::getScale(jni::JNIEnv&) { return map->getScale(); } -void NativeMapView::setZoom(jni::JNIEnv&, jni::jdouble zoom, jni::jlong duration) { - map->setZoom(zoom, mbgl::AnimationOptions{mbgl::Milliseconds(duration)}); +void NativeMapView::setZoom(jni::JNIEnv&, jni::jdouble zoom, jni::jdouble x, jni::jdouble y, jni::jlong duration) { + map->setZoom(zoom, mbgl::ScreenCoordinate{x,y}, mbgl::AnimationOptions{mbgl::Milliseconds(duration)}); } jni::jdouble NativeMapView::getZoom(jni::JNIEnv&) { diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp index c762c04df3..fbfe69040e 100755 --- a/platform/android/src/native_map_view.hpp +++ b/platform/android/src/native_map_view.hpp @@ -133,7 +133,7 @@ public: jni::jdouble getScale(jni::JNIEnv&); - void setZoom(jni::JNIEnv&, jni::jdouble, jni::jlong); + void setZoom(jni::JNIEnv&, jni::jdouble, jni::jdouble, jni::jdouble, jni::jlong); jni::jdouble getZoom(jni::JNIEnv&); |