diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src')
5 files changed, 499 insertions, 243 deletions
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 c09c926eb5..d15d5eddf8 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 @@ -14,6 +14,7 @@ import com.mapbox.mapboxsdk.R; 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.Marker; import com.mapbox.mapboxsdk.annotations.MarkerView; import com.mapbox.mapboxsdk.annotations.MarkerViewManager; @@ -44,11 +45,12 @@ class AnnotationManager { private static final String LAYER_ID_SHAPE_ANNOTATIONS = "com.mapbox.annotations.shape."; private static final long NO_ANNOTATION_ID = -1; + private final NativeMapView nativeMapView; private final MapView mapView; private final IconManager iconManager; private final InfoWindowManager infoWindowManager = new InfoWindowManager(); private final MarkerViewManager markerViewManager; - private final LongSparseArray<Annotation> annotationsArray; + private final LongSparseArray<Annotation> annotations = new LongSparseArray<>(); private final List<Marker> selectedMarkers = new ArrayList<>(); private final List<String> shapeAnnotationIds = new ArrayList<>(); @@ -57,22 +59,11 @@ class AnnotationManager { private MapboxMap.OnPolygonClickListener onPolygonClickListener; private MapboxMap.OnPolylineClickListener onPolylineClickListener; - private Annotations annotations; - private Markers markers; - private Polygons polygons; - private Polylines polylines; - - AnnotationManager(NativeMapView view, MapView mapView, LongSparseArray<Annotation> annotationsArray, - MarkerViewManager markerViewManager, IconManager iconManager, Annotations annotations, - Markers markers, Polygons polygons, Polylines polylines) { + AnnotationManager(NativeMapView view, MapView mapView, MarkerViewManager markerViewManager) { + this.nativeMapView = view; this.mapView = mapView; - this.annotationsArray = annotationsArray; + this.iconManager = new IconManager(nativeMapView); this.markerViewManager = markerViewManager; - this.iconManager = iconManager; - this.annotations = annotations; - this.markers = markers; - this.polygons = polygons; - this.polylines = polylines; if (view != null) { // null checking needed for unit tests view.addOnMapChangedListener(markerViewManager); @@ -97,15 +88,15 @@ class AnnotationManager { // Annotation getAnnotation(long id) { - return annotations.obtainBy(id); + return annotations.get(id); } List<Annotation> getAnnotations() { - return annotations.obtainAll(); - } - - void removeAnnotation(long id) { - annotations.removeBy(id); + List<Annotation> annotations = new ArrayList<>(); + for (int i = 0; i < this.annotations.size(); i++) { + annotations.add(this.annotations.get(this.annotations.keyAt(i))); + } + return annotations; } void removeAnnotation(@NonNull Annotation annotation) { @@ -118,19 +109,30 @@ class AnnotationManager { if (marker instanceof MarkerView) { markerViewManager.removeMarkerView((MarkerView) marker); - } else { - // do icon cleanup - iconManager.iconCleanup(marker.getIcon()); } } else { // instanceOf Polygon/Polyline shapeAnnotationIds.remove(annotation.getId()); } - annotations.removeBy(annotation); + long id = annotation.getId(); + if (nativeMapView != null) { + nativeMapView.removeAnnotation(id); + } + annotations.remove(id); + } + + void removeAnnotation(long id) { + if (nativeMapView != null) { + nativeMapView.removeAnnotation(id); + } + annotations.remove(id); } void removeAnnotations(@NonNull List<? extends Annotation> annotationList) { - for (Annotation annotation : annotationList) { + int count = annotationList.size(); + long[] ids = new long[count]; + for (int i = 0; i < count; i++) { + Annotation annotation = annotationList.get(i); if (annotation instanceof Marker) { Marker marker = (Marker) annotation; marker.hideInfoWindow(); @@ -140,39 +142,48 @@ class AnnotationManager { if (marker instanceof MarkerView) { markerViewManager.removeMarkerView((MarkerView) marker); - } else { - iconManager.iconCleanup(marker.getIcon()); } } else { // instanceOf Polygon/Polyline shapeAnnotationIds.remove(annotation.getId()); } + ids[i] = annotationList.get(i).getId(); + } + + if (nativeMapView != null) { + nativeMapView.removeAnnotations(ids); + } + + for (long id : ids) { + annotations.remove(id); } - annotations.removeBy(annotationList); } void removeAnnotations() { Annotation annotation; - int count = annotationsArray.size(); + int count = annotations.size(); long[] ids = new long[count]; selectedMarkers.clear(); for (int i = 0; i < count; i++) { - ids[i] = annotationsArray.keyAt(i); - annotation = annotationsArray.get(ids[i]); + ids[i] = annotations.keyAt(i); + annotation = annotations.get(ids[i]); if (annotation instanceof Marker) { Marker marker = (Marker) annotation; marker.hideInfoWindow(); if (marker instanceof MarkerView) { markerViewManager.removeMarkerView((MarkerView) marker); - } else { - iconManager.iconCleanup(marker.getIcon()); } } else { // instanceOf Polygon/Polyline shapeAnnotationIds.remove(annotation.getId()); } } - annotations.removeAll(); + + if (nativeMapView != null) { + nativeMapView.removeAnnotations(ids); + } + + annotations.clear(); } // @@ -180,109 +191,134 @@ class AnnotationManager { // Marker addMarker(@NonNull BaseMarkerOptions markerOptions, @NonNull MapboxMap mapboxMap) { - return markers.addBy(markerOptions, mapboxMap); + Marker marker = prepareMarker(markerOptions); + long id = nativeMapView != null ? nativeMapView.addMarker(marker) : 0; + marker.setMapboxMap(mapboxMap); + marker.setId(id); + annotations.put(id, marker); + return marker; } List<Marker> addMarkers(@NonNull List<? extends BaseMarkerOptions> markerOptionsList, @NonNull MapboxMap mapboxMap) { - return markers.addBy(markerOptionsList, mapboxMap); - } + int count = markerOptionsList.size(); + List<Marker> markers = new ArrayList<>(count); + if (count > 0) { + BaseMarkerOptions markerOptions; + Marker marker; + for (int i = 0; i < count; i++) { + markerOptions = markerOptionsList.get(i); + marker = prepareMarker(markerOptions); + markers.add(marker); + } - void updateMarker(@NonNull Marker updatedMarker, @NonNull MapboxMap mapboxMap) { - if (!isAddedToMap(updatedMarker)) { - logNonAdded(updatedMarker); - return; - } - markers.update(updatedMarker, mapboxMap); - } + if (markers.size() > 0) { + long[] ids; + if (nativeMapView != null) { + ids = nativeMapView.addMarkers(markers); + } else { + ids = new long[markers.size()]; + } - List<Marker> getMarkers() { - return markers.obtainAll(); + long id; + Marker m; + for (int i = 0; i < ids.length; i++) { + m = markers.get(i); + m.setMapboxMap(mapboxMap); + id = ids[i]; + m.setId(id); + annotations.put(id, m); + } + + } + } + return markers; } - @NonNull - List<Marker> getMarkersInRect(@NonNull RectF rectangle) { - return markers.obtainAllIn(rectangle); + private Marker prepareMarker(BaseMarkerOptions markerOptions) { + Marker marker = markerOptions.getMarker(); + Icon icon = iconManager.loadIconForMarker(marker); + marker.setTopOffsetPixels(iconManager.getTopOffsetPixelsForIcon(icon)); + return marker; } MarkerView addMarker(@NonNull BaseMarkerViewOptions markerOptions, @NonNull MapboxMap mapboxMap, @Nullable MarkerViewManager.OnMarkerViewAddedListener onMarkerViewAddedListener) { - return markers.addViewBy(markerOptions, mapboxMap, onMarkerViewAddedListener); - } + final MarkerView marker = prepareViewMarker(markerOptions); - List<MarkerView> addMarkerViews(@NonNull List<? extends BaseMarkerViewOptions> markerViewOptions, - @NonNull MapboxMap mapboxMap) { - return markers.addViewsBy(markerViewOptions, mapboxMap); - } - - List<MarkerView> getMarkerViewsInRect(@NonNull RectF rectangle) { - return markers.obtainViewsIn(rectangle); - } + // add marker to map + marker.setMapboxMap(mapboxMap); + long id = nativeMapView.addMarker(marker); + marker.setId(id); + annotations.put(id, marker); - void reloadMarkers() { - markers.reload(); + if (onMarkerViewAddedListener != null) { + markerViewManager.addOnMarkerViewAddedListener(marker, onMarkerViewAddedListener); + } + markerViewManager.setEnabled(true); + markerViewManager.setWaitingForRenderInvoke(true); + return marker; } - // - // Polygons - // - - Polygon addPolygon(@NonNull PolygonOptions polygonOptions, @NonNull MapboxMap mapboxMap) { - Polygon polygon = polygons.addBy(polygonOptions, mapboxMap); - shapeAnnotationIds.add(LAYER_ID_SHAPE_ANNOTATIONS + polygon.getId()); - return polygon; + List<MarkerView> addMarkerViews(@NonNull List<? extends BaseMarkerViewOptions> markerViewOptions, + @NonNull MapboxMap mapboxMap) { + List<MarkerView> markers = new ArrayList<>(); + for (BaseMarkerViewOptions markerViewOption : markerViewOptions) { + // if last marker + if (markerViewOptions.indexOf(markerViewOption) == markerViewOptions.size() - 1) { + // get notified when render occurs to invalidate and draw MarkerViews + markerViewManager.setWaitingForRenderInvoke(true); + } + // add marker to map + MarkerView marker = prepareViewMarker(markerViewOption); + marker.setMapboxMap(mapboxMap); + long id = nativeMapView.addMarker(marker); + marker.setId(id); + annotations.put(id, marker); + markers.add(marker); + } + markerViewManager.setEnabled(true); + markerViewManager.update(); + return markers; } - List<Polygon> addPolygons(@NonNull List<PolygonOptions> polygonOptionsList, @NonNull MapboxMap mapboxMap) { - List<Polygon> polygonList = polygons.addBy(polygonOptionsList, mapboxMap); - for (Polygon polygon : polygonList) { - shapeAnnotationIds.add(LAYER_ID_SHAPE_ANNOTATIONS + polygon.getId()); - } - return polygonList; + private MarkerView prepareViewMarker(BaseMarkerViewOptions markerViewOptions) { + MarkerView marker = markerViewOptions.getMarker(); + iconManager.loadIconForMarkerView(marker); + return marker; } - void updatePolygon(Polygon polygon) { - if (!isAddedToMap(polygon)) { - logNonAdded(polygon); + void updateMarker(@NonNull Marker updatedMarker) { + if (!isAddedToMap(updatedMarker)) { + Timber.w("Attempting to update non-added Marker with value %s", updatedMarker); return; } - polygons.update(polygon); + ensureIconLoaded(updatedMarker); + nativeMapView.updateMarker(updatedMarker); + annotations.setValueAt(annotations.indexOfKey(updatedMarker.getId()), updatedMarker); } - List<Polygon> getPolygons() { - return polygons.obtainAll(); - } - - // - // Polylines - // - - Polyline addPolyline(@NonNull PolylineOptions polylineOptions, @NonNull MapboxMap mapboxMap) { - Polyline polyline = polylines.addBy(polylineOptions, mapboxMap); - shapeAnnotationIds.add(LAYER_ID_SHAPE_ANNOTATIONS + polyline.getId()); - return polyline; + private boolean isAddedToMap(Annotation annotation) { + return annotation != null && annotation.getId() != -1 && annotations.indexOfKey(annotation.getId()) > -1; } - List<Polyline> addPolylines(@NonNull List<PolylineOptions> polylineOptionsList, @NonNull MapboxMap mapboxMap) { - List<Polyline> polylineList = polylines.addBy(polylineOptionsList, mapboxMap); - for (Polyline polyline : polylineList) { - shapeAnnotationIds.add(LAYER_ID_SHAPE_ANNOTATIONS + polyline.getId()); + private void ensureIconLoaded(Marker marker) { + if (!(marker instanceof MarkerView)) { + iconManager.ensureIconLoaded(marker, mapboxMap); } - return polylineList; } - void updatePolyline(Polyline polyline) { - if (!isAddedToMap(polyline)) { - logNonAdded(polyline); - return; + List<Marker> getMarkers() { + List<Marker> markers = new ArrayList<>(); + Annotation annotation; + for (int i = 0; i < annotations.size(); i++) { + annotation = annotations.get(annotations.keyAt(i)); + if (annotation instanceof Marker) { + markers.add((Marker) annotation); + } } - polylines.update(polyline); + return markers; } - List<Polyline> getPolylines() { - return polylines.obtainAll(); - } - - // TODO Refactor from here still in progress void setOnMarkerClickListener(@Nullable MapboxMap.OnMarkerClickListener listener) { onMarkerClickListener = listener; } @@ -357,6 +393,205 @@ class AnnotationManager { return selectedMarkers; } + @NonNull + List<Marker> getMarkersInRect(@NonNull RectF rectangle) { + // convert Rectangle to be density dependent + float pixelRatio = nativeMapView.getPixelRatio(); + RectF rect = new RectF(rectangle.left / pixelRatio, + rectangle.top / pixelRatio, + rectangle.right / pixelRatio, + rectangle.bottom / pixelRatio); + + long[] ids = nativeMapView.queryPointAnnotations(rect); + + List<Long> idsList = new ArrayList<>(ids.length); + for (long id : ids) { + idsList.add(id); + } + + List<Marker> annotations = new ArrayList<>(ids.length); + List<Annotation> annotationList = getAnnotations(); + int count = annotationList.size(); + for (int i = 0; i < count; i++) { + Annotation annotation = annotationList.get(i); + if (annotation instanceof com.mapbox.mapboxsdk.annotations.Marker && idsList.contains(annotation.getId())) { + annotations.add((com.mapbox.mapboxsdk.annotations.Marker) annotation); + } + } + + return new ArrayList<>(annotations); + } + + List<MarkerView> getMarkerViewsInRect(@NonNull RectF rectangle) { + float pixelRatio = nativeMapView.getPixelRatio(); + RectF rect = new RectF(rectangle.left / pixelRatio, + rectangle.top / pixelRatio, + rectangle.right / pixelRatio, + rectangle.bottom / pixelRatio); + + long[] ids = nativeMapView.queryPointAnnotations(rect); + + List<Long> idsList = new ArrayList<>(ids.length); + for (long id : ids) { + idsList.add(id); + } + + List<MarkerView> annotations = new ArrayList<>(ids.length); + List<Annotation> annotationList = getAnnotations(); + int count = annotationList.size(); + for (int i = 0; i < count; i++) { + Annotation annotation = annotationList.get(i); + if (annotation instanceof MarkerView && idsList.contains(annotation.getId())) { + annotations.add((MarkerView) annotation); + } + } + + return new ArrayList<>(annotations); + } + + // + // Polygons + // + + Polygon addPolygon(@NonNull PolygonOptions polygonOptions, @NonNull MapboxMap mapboxMap) { + Polygon polygon = polygonOptions.getPolygon(); + if (!polygon.getPoints().isEmpty()) { + long id = nativeMapView != null ? nativeMapView.addPolygon(polygon) : 0; + polygon.setId(id); + polygon.setMapboxMap(mapboxMap); + shapeAnnotationIds.add(LAYER_ID_SHAPE_ANNOTATIONS + id); + annotations.put(id, polygon); + } + return polygon; + } + + List<Polygon> addPolygons(@NonNull List<PolygonOptions> polygonOptionsList, @NonNull MapboxMap mapboxMap) { + int count = polygonOptionsList.size(); + + Polygon polygon; + List<Polygon> polygons = new ArrayList<>(count); + if (count > 0) { + for (PolygonOptions polygonOptions : polygonOptionsList) { + polygon = polygonOptions.getPolygon(); + if (!polygon.getPoints().isEmpty()) { + polygons.add(polygon); + } + } + + long[] ids; + if (nativeMapView != null) { + ids = nativeMapView.addPolygons(polygons); + } else { + ids = new long[polygons.size()]; + } + + long id; + for (int i = 0; i < ids.length; i++) { + polygon = polygons.get(i); + polygon.setMapboxMap(mapboxMap); + id = ids[i]; + polygon.setId(id); + shapeAnnotationIds.add(LAYER_ID_SHAPE_ANNOTATIONS + id); + annotations.put(id, polygon); + } + } + return polygons; + } + + void updatePolygon(@NonNull Polygon polygon) { + if (!isAddedToMap(polygon)) { + Timber.w("Attempting to update non-added Polygon with value %s", polygon); + return; + } + + nativeMapView.updatePolygon(polygon); + annotations.setValueAt(annotations.indexOfKey(polygon.getId()), polygon); + } + + List<Polygon> getPolygons() { + List<Polygon> polygons = new ArrayList<>(); + Annotation annotation; + for (int i = 0; i < annotations.size(); i++) { + annotation = annotations.get(annotations.keyAt(i)); + if (annotation instanceof Polygon) { + polygons.add((Polygon) annotation); + } + } + return polygons; + } + + // + // Polylines + // + + Polyline addPolyline(@NonNull PolylineOptions polylineOptions, @NonNull MapboxMap mapboxMap) { + Polyline polyline = polylineOptions.getPolyline(); + if (!polyline.getPoints().isEmpty()) { + long id = nativeMapView != null ? nativeMapView.addPolyline(polyline) : 0; + polyline.setMapboxMap(mapboxMap); + polyline.setId(id); + shapeAnnotationIds.add(LAYER_ID_SHAPE_ANNOTATIONS + id); + annotations.put(id, polyline); + } + return polyline; + } + + List<Polyline> addPolylines(@NonNull List<PolylineOptions> polylineOptionsList, @NonNull MapboxMap mapboxMap) { + int count = polylineOptionsList.size(); + Polyline polyline; + List<Polyline> polylines = new ArrayList<>(count); + + if (count > 0) { + for (PolylineOptions options : polylineOptionsList) { + polyline = options.getPolyline(); + if (!polyline.getPoints().isEmpty()) { + polylines.add(polyline); + } + } + + long[] ids; + if (nativeMapView != null) { + ids = nativeMapView.addPolylines(polylines); + } else { + ids = new long[polylines.size()]; + } + + long id; + Polyline p; + for (int i = 0; i < ids.length; i++) { + p = polylines.get(i); + p.setMapboxMap(mapboxMap); + id = ids[i]; + p.setId(id); + shapeAnnotationIds.add(LAYER_ID_SHAPE_ANNOTATIONS + id); + annotations.put(id, p); + } + } + return polylines; + } + + void updatePolyline(@NonNull Polyline polyline) { + if (!isAddedToMap(polyline)) { + Timber.w("Attempting to update non-added Polyline with value %s", polyline); + return; + } + + nativeMapView.updatePolyline(polyline); + annotations.setValueAt(annotations.indexOfKey(polyline.getId()), polyline); + } + + List<Polyline> getPolylines() { + List<Polyline> polylines = new ArrayList<>(); + Annotation annotation; + for (int i = 0; i < annotations.size(); i++) { + annotation = annotations.get(annotations.keyAt(i)); + if (annotation instanceof Polyline) { + polylines.add((Polyline) annotation); + } + } + return polylines; + } + InfoWindowManager getInfoWindowManager() { return infoWindowManager; } @@ -366,9 +601,9 @@ class AnnotationManager { } void adjustTopOffsetPixels(MapboxMap mapboxMap) { - int count = annotationsArray.size(); + int count = annotations.size(); for (int i = 0; i < count; i++) { - Annotation annotation = annotationsArray.get(i); + Annotation annotation = annotations.get(i); if (annotation instanceof Marker) { Marker marker = (Marker) annotation; marker.setTopOffsetPixels( @@ -384,12 +619,18 @@ class AnnotationManager { } } - private boolean isAddedToMap(Annotation annotation) { - return annotation != null && annotation.getId() != -1 && annotationsArray.indexOfKey(annotation.getId()) > -1; - } - - private void logNonAdded(Annotation annotation) { - Timber.w("Attempting to update non-added %s with value %s", annotation.getClass().getCanonicalName(), annotation); + void reloadMarkers() { + iconManager.reloadIcons(); + int count = annotations.size(); + for (int i = 0; i < count; i++) { + Annotation annotation = annotations.get(i); + if (annotation instanceof Marker) { + Marker marker = (Marker) annotation; + nativeMapView.removeAnnotation(annotation.getId()); + long newId = nativeMapView.addMarker(marker); + marker.setId(newId); + } + } } // 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 affbf48267..18eecfd9c3 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 @@ -1,17 +1,16 @@ package com.mapbox.mapboxsdk.maps; import android.graphics.Bitmap; -import android.os.Build; import com.mapbox.mapboxsdk.Mapbox; 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.exceptions.IconBitmapChangedException; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; /** * Responsible for managing icons added to the Map. @@ -26,14 +25,15 @@ import java.util.Map; */ class IconManager { - private final Map<Icon, Integer> iconMap = new HashMap<>(); - private NativeMapView nativeMapView; + private List<Icon> icons; + private int highestIconWidth; private int highestIconHeight; IconManager(NativeMapView nativeMapView) { this.nativeMapView = nativeMapView; + this.icons = new ArrayList<>(); // load transparent icon for MarkerView to trace actual markers, see #6352 loadIcon(IconFactory.recreate(IconFactory.ICON_MARKERVIEW_ID, IconFactory.ICON_MARKERVIEW_BITMAP)); } @@ -83,13 +83,13 @@ class IconManager { } private void addIcon(Icon icon, boolean addIconToMap) { - if (!iconMap.keySet().contains(icon)) { - iconMap.put(icon, 1); + if (!icons.contains(icon)) { + icons.add(icon); if (addIconToMap) { loadIcon(icon); } } else { - iconMap.put(icon, iconMap.get(icon) + 1); + validateIconChanged(icon); } } @@ -121,11 +121,18 @@ class IconManager { } void reloadIcons() { - for (Icon icon : iconMap.keySet()) { + for (Icon icon : icons) { loadIcon(icon); } } + private void validateIconChanged(Icon icon) { + Icon oldIcon = icons.get(icons.indexOf(icon)); + if (!oldIcon.getBitmap().sameAs(icon.getBitmap())) { + throw new IconBitmapChangedException(); + } + } + void ensureIconLoaded(Marker marker, MapboxMap mapboxMap) { Icon icon = marker.getIcon(); if (icon == null) { @@ -142,31 +149,4 @@ class IconManager { marker.setTopOffsetPixels(getTopOffsetPixelsForIcon(icon)); } } - - public void iconCleanup(Icon icon) { - int refCounter = iconMap.get(icon) - 1; - if (refCounter == 0) { - remove(icon); - } else { - updateIconRefCounter(icon, refCounter); - } - } - - private void remove(Icon icon) { - nativeMapView.removeAnnotationIcon(icon.getId()); - iconMap.remove(icon); - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - recycleBitmap(icon.getBitmap()); - } - } - - private void updateIconRefCounter(Icon icon, int refCounter) { - iconMap.put(icon, refCounter); - } - - private void recycleBitmap(Bitmap bitmap) { - if (!bitmap.isRecycled()) { - bitmap.recycle(); - } - } } 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 0d1d0e03b5..e074d938fd 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 @@ -59,7 +59,6 @@ import timber.log.Timber; * Note: Similar to a View object, a MapboxMap should only be read and modified from the main thread. * </p> */ -@UiThread public final class MapboxMap { private final NativeMapView nativeMapView; @@ -100,7 +99,6 @@ public final class MapboxMap { setDebugActive(options.getDebugActive()); setApiBaseUrl(options); setStyleUrl(options); - setPrefetchesTiles(options); } /** @@ -211,6 +209,7 @@ public final class MapboxMap { * * @return Duration in milliseconds */ + @UiThread public long getTransitionDuration() { return nativeMapView.getTransitionDuration(); } @@ -220,6 +219,7 @@ public final class MapboxMap { * * @param durationMs Duration in milliseconds */ + @UiThread public void setTransitionDuration(long durationMs) { nativeMapView.setTransitionDuration(durationMs); } @@ -232,6 +232,7 @@ public final class MapboxMap { * * @return Delay in milliseconds */ + @UiThread public long getTransitionDelay() { return nativeMapView.getTransitionDelay(); } @@ -241,44 +242,17 @@ public final class MapboxMap { * * @param delayMs Delay in milliseconds */ + @UiThread public void setTransitionDelay(long delayMs) { nativeMapView.setTransitionDelay(delayMs); } /** - * Sets tile pre-fetching from MapboxOptions. - * - * @param options the options object - */ - private void setPrefetchesTiles(@NonNull MapboxMapOptions options) { - setPrefetchesTiles(options.getPrefetchesTiles()); - } - - /** - * 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 - */ - public void setPrefetchesTiles(boolean enable) { - nativeMapView.setPrefetchesTiles(enable); - } - - /** - * Check whether tile pre-fetching is enabled or not. - * - * @return true if enabled - * @see MapboxMap#setPrefetchesTiles(boolean) - */ - public boolean getPrefetchesTiles() { - return nativeMapView.getPrefetchesTiles(); - } - - /** * Retrieve all the layers in the style * * @return all the layers in the current style */ + @UiThread public List<Layer> getLayers() { return nativeMapView.getLayers(); } @@ -290,6 +264,7 @@ public final class MapboxMap { * @return the layer, if present in the style */ @Nullable + @UiThread public Layer getLayer(@NonNull String layerId) { return nativeMapView.getLayer(layerId); } @@ -302,12 +277,13 @@ public final class MapboxMap { * @return the casted Layer, null if another type */ @Nullable + @UiThread public <T extends Layer> T getLayerAs(@NonNull String layerId) { try { // noinspection unchecked return (T) nativeMapView.getLayer(layerId); } catch (ClassCastException exception) { - Timber.e(exception, "Layer: %s is a different type: ", layerId); + Timber.e(String.format("Layer: %s is a different type: %s", layerId, exception)); return null; } } @@ -317,6 +293,7 @@ public final class MapboxMap { * * @param layer the layer to add */ + @UiThread public void addLayer(@NonNull Layer layer) { nativeMapView.addLayer(layer); } @@ -327,6 +304,7 @@ public final class MapboxMap { * @param layer the layer to add * @param below the layer id to add this layer before */ + @UiThread public void addLayerBelow(@NonNull Layer layer, @NonNull String below) { nativeMapView.addLayerBelow(layer, below); } @@ -337,6 +315,7 @@ public final class MapboxMap { * @param layer the layer to add * @param above the layer id to add this layer above */ + @UiThread public void addLayerAbove(@NonNull Layer layer, @NonNull String above) { nativeMapView.addLayerAbove(layer, above); } @@ -348,6 +327,7 @@ public final class MapboxMap { * @param layer the layer to add * @param index the index to insert the layer at */ + @UiThread public void addLayerAt(@NonNull Layer layer, @IntRange(from = 0) int index) { nativeMapView.addLayerAt(layer, index); } @@ -358,6 +338,7 @@ public final class MapboxMap { * @param layerId the layer to remove * @return the removed layer or null if not found */ + @UiThread @Nullable public Layer removeLayer(@NonNull String layerId) { return nativeMapView.removeLayer(layerId); @@ -369,6 +350,7 @@ public final class MapboxMap { * @param layer the layer to remove * @return the layer */ + @UiThread @Nullable public Layer removeLayer(@NonNull Layer layer) { return nativeMapView.removeLayer(layer); @@ -380,6 +362,7 @@ public final class MapboxMap { * @param index the layer index * @return the removed layer or null if not found */ + @UiThread @Nullable public Layer removeLayerAt(@IntRange(from = 0) int index) { return nativeMapView.removeLayerAt(index); @@ -390,6 +373,7 @@ public final class MapboxMap { * * @return all the sources in the current style */ + @UiThread public List<Source> getSources() { return nativeMapView.getSources(); } @@ -401,6 +385,7 @@ public final class MapboxMap { * @return the source if present in the current style */ @Nullable + @UiThread public Source getSource(@NonNull String sourceId) { return nativeMapView.getSource(sourceId); } @@ -413,12 +398,13 @@ public final class MapboxMap { * @return the casted Source, null if another type */ @Nullable + @UiThread public <T extends Source> T getSourceAs(@NonNull String sourceId) { try { // noinspection unchecked return (T) nativeMapView.getSource(sourceId); } catch (ClassCastException exception) { - Timber.e(exception, "Source: %s is a different type: ", sourceId); + Timber.e(String.format("Source: %s is a different type: %s", sourceId, exception)); return null; } } @@ -428,6 +414,7 @@ public final class MapboxMap { * * @param source the source to add */ + @UiThread public void addSource(@NonNull Source source) { nativeMapView.addSource(source); } @@ -438,6 +425,7 @@ public final class MapboxMap { * @param sourceId the source to remove * @return the source handle or null if the source was not present */ + @UiThread @Nullable public Source removeSource(@NonNull String sourceId) { return nativeMapView.removeSource(sourceId); @@ -449,6 +437,7 @@ public final class MapboxMap { * @param source the source to remove * @return the source */ + @UiThread @Nullable public Source removeSource(@NonNull Source source) { return nativeMapView.removeSource(source); @@ -460,6 +449,7 @@ public final class MapboxMap { * @param name the name of the image * @param image the pre-multiplied Bitmap */ + @UiThread public void addImage(@NonNull String name, @NonNull Bitmap image) { nativeMapView.addImage(name, image); } @@ -469,14 +459,11 @@ public final class MapboxMap { * * @param name the name of the image to remove */ + @UiThread public void removeImage(String name) { nativeMapView.removeImage(name); } - public Bitmap getImage(@NonNull String name) { - return nativeMapView.getImage(name); - } - // // MinZoom // @@ -488,6 +475,7 @@ public final class MapboxMap { * * @param minZoom The new minimum zoom level. */ + @UiThread public void setMinZoomPreference( @FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = MapboxConstants.MAXIMUM_ZOOM) double minZoom) { transform.setMinZoom(minZoom); @@ -495,11 +483,12 @@ public final class MapboxMap { /** * <p> - * Gets the minimum zoom level the map can be displayed at. + * Gets the maximum zoom level the map can be displayed at. * </p> * * @return The minimum zoom level. */ + @UiThread public double getMinZoomLevel() { return transform.getMinZoom(); } @@ -512,11 +501,10 @@ public final class MapboxMap { * <p> * Sets the maximum zoom level the map can be displayed at. * </p> - * <p> - * The default maximum zoomn level is 22. The upper bound for this value is 25.5. - * </p> + * * @param maxZoom The new maximum zoom level. */ + @UiThread public void setMaxZoomPreference(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = MapboxConstants.MAXIMUM_ZOOM) double maxZoom) { transform.setMaxZoom(maxZoom); @@ -529,6 +517,7 @@ public final class MapboxMap { * * @return The maximum zoom level. */ + @UiThread public double getMaxZoomLevel() { return transform.getMaxZoom(); } @@ -554,10 +543,7 @@ public final class MapboxMap { * Gets the tracking interface settings for the map. * * @return the TrackingSettings asssociated with this map - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. */ - @Deprecated public TrackingSettings getTrackingSettings() { return trackingSettings; } @@ -570,10 +556,7 @@ public final class MapboxMap { * Gets the settings of the user location for the map. * * @return the MyLocationViewSettings associated with this map - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. */ - @Deprecated public MyLocationViewSettings getMyLocationViewSettings() { return myLocationViewSettings; } @@ -649,6 +632,7 @@ public final class MapboxMap { * * @param update The change that should be applied to the camera. */ + @UiThread public final void moveCamera(CameraUpdate update) { moveCamera(update, null); } @@ -661,6 +645,7 @@ public final class MapboxMap { * @param update The change that should be applied to the camera * @param callback the callback to be invoked when an animation finishes or is canceled */ + @UiThread public final void moveCamera(final CameraUpdate update, final MapboxMap.CancelableCallback callback) { new Handler().post(new Runnable() { @Override @@ -681,6 +666,7 @@ public final class MapboxMap { * @param update The change that should be applied to the camera. * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ + @UiThread public final void easeCamera(CameraUpdate update) { easeCamera(update, MapboxConstants.ANIMATION_DURATION); } @@ -695,6 +681,7 @@ public final class MapboxMap { * positive, otherwise an IllegalArgumentException will be thrown. * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ + @UiThread public final void easeCamera(CameraUpdate update, int durationMs) { easeCamera(update, durationMs, null); } @@ -718,6 +705,7 @@ public final class MapboxMap { * Do not update or ease the camera from within onCancel(). * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ + @UiThread public final void easeCamera(CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) { easeCamera(update, durationMs, true, callback); } @@ -736,6 +724,7 @@ public final class MapboxMap { * positive, otherwise an IllegalArgumentException will be thrown. * @param easingInterpolator True for easing interpolator, false for linear. */ + @UiThread public final void easeCamera(CameraUpdate update, int durationMs, boolean easingInterpolator) { easeCamera(update, durationMs, easingInterpolator, null); } @@ -761,6 +750,7 @@ public final class MapboxMap { * by a later camera movement or a user gesture, onCancel() will be called. * Do not update or ease the camera from within onCancel(). */ + @UiThread public final void easeCamera(final CameraUpdate update, final int durationMs, final boolean easingInterpolator, final MapboxMap.CancelableCallback callback) { easeCamera(update, durationMs, easingInterpolator, callback, false); @@ -788,6 +778,7 @@ public final class MapboxMap { * Do not update or ease the camera from within onCancel(). * @param isDismissable true will allow animated camera changes dismiss a tracking mode. */ + @UiThread public final void easeCamera(final CameraUpdate update, final int durationMs, final boolean easingInterpolator, final MapboxMap.CancelableCallback callback, final boolean isDismissable) { new Handler().post(new Runnable() { @@ -807,6 +798,7 @@ public final class MapboxMap { * @param update The change that should be applied to the camera. * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ + @UiThread public final void animateCamera(CameraUpdate update) { animateCamera(update, MapboxConstants.ANIMATION_DURATION, null); } @@ -823,6 +815,7 @@ public final class MapboxMap { * called. Do not update or animate the camera from within onCancel(). * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ + @UiThread public final void animateCamera(CameraUpdate update, MapboxMap.CancelableCallback callback) { animateCamera(update, MapboxConstants.ANIMATION_DURATION, callback); } @@ -838,6 +831,7 @@ public final class MapboxMap { * positive, otherwise an IllegalArgumentException will be thrown. * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ + @UiThread public final void animateCamera(CameraUpdate update, int durationMs) { animateCamera(update, durationMs, null); } @@ -860,6 +854,7 @@ public final class MapboxMap { * isn't required, leave it as null. * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ + @UiThread public final void animateCamera(final CameraUpdate update, final int durationMs, final MapboxMap.CancelableCallback callback) { new Handler().post(new Runnable() { @@ -930,6 +925,7 @@ public final class MapboxMap { * * @return If true, map debug information is currently shown. */ + @UiThread public boolean isDebugActive() { return nativeMapView.getDebug(); } @@ -942,6 +938,7 @@ public final class MapboxMap { * * @param debugActive If true, map debug information is shown. */ + @UiThread public void setDebugActive(boolean debugActive) { nativeMapView.setDebug(debugActive); } @@ -955,6 +952,7 @@ public final class MapboxMap { * * @see #isDebugActive() */ + @UiThread public void cycleDebugOptions() { nativeMapView.cycleDebugOptions(); } @@ -1004,6 +1002,7 @@ public final class MapboxMap { * @param url The URL of the map style * @see Style */ + @UiThread public void setStyleUrl(@NonNull String url) { setStyleUrl(url, null); } @@ -1036,6 +1035,7 @@ public final class MapboxMap { * @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() { @@ -1067,6 +1067,7 @@ public final class MapboxMap { * @param style The bundled style. * @see Style */ + @UiThread public void setStyle(@Style.StyleUrl String style) { setStyleUrl(style); } @@ -1083,6 +1084,7 @@ public final class MapboxMap { * @param callback The callback to be invoked when the style has finished loading * @see Style */ + @UiThread public void setStyle(@Style.StyleUrl String style, @Nullable OnStyleLoadedListener callback) { setStyleUrl(style, callback); } @@ -1100,36 +1102,16 @@ public final class MapboxMap { } /** - * Returns the map style url currently displayed in the map view. + * Returns the map style currently displayed in the map view. * * @return The URL of the map style */ + @UiThread @Nullable public String getStyleUrl() { return nativeMapView.getStyleUrl(); } - /** - * Loads a new map style from a json string. - * <p> - * If the style fails to load or an invalid style URL is set, the map view will become blank. - * An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be - * sent. - * </p> - */ - public void setStyleJson(@NonNull String styleJson) { - nativeMapView.setStyleJson(styleJson); - } - - /** - * Returns the map style json currently displayed in the map view. - * - * @return The json of the map style - */ - public String getStyleJson() { - return nativeMapView.getStyleJson(); - } - // // Annotations // @@ -1144,6 +1126,7 @@ public final class MapboxMap { * @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 public Marker addMarker(@NonNull MarkerOptions markerOptions) { return annotationManager.addMarker(markerOptions, this); @@ -1159,6 +1142,7 @@ public final class MapboxMap { * @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 public Marker addMarker(@NonNull BaseMarkerOptions markerOptions) { return annotationManager.addMarker(markerOptions, this); @@ -1174,6 +1158,7 @@ public final class MapboxMap { * @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 public MarkerView addMarker(@NonNull BaseMarkerViewOptions markerOptions) { return annotationManager.addMarker(markerOptions, this, null); @@ -1190,6 +1175,7 @@ public final class MapboxMap { * @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 public MarkerView addMarker(@NonNull BaseMarkerViewOptions markerOptions, final MarkerViewManager.OnMarkerViewAddedListener onMarkerViewAddedListener) { @@ -1206,6 +1192,7 @@ public final class MapboxMap { * @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 public List<MarkerView> addMarkerViews(@NonNull List<? extends BaseMarkerViewOptions> markerViewOptions) { @@ -1218,6 +1205,7 @@ public final class MapboxMap { * @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 public List<MarkerView> getMarkerViewsInRect(@NonNull RectF rect) { return annotationManager.getMarkerViewsInRect(rect); @@ -1233,6 +1221,7 @@ public final class MapboxMap { * @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 public List<Marker> addMarkers(@NonNull List<? extends BaseMarkerOptions> markerOptionsList) { @@ -1246,8 +1235,9 @@ public final class MapboxMap { * * @param updatedMarker An updated marker object */ + @UiThread public void updateMarker(@NonNull Marker updatedMarker) { - annotationManager.updateMarker(updatedMarker, this); + annotationManager.updateMarker(updatedMarker); } /** @@ -1256,6 +1246,7 @@ public final class MapboxMap { * @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 public Polyline addPolyline(@NonNull PolylineOptions polylineOptions) { return annotationManager.addPolyline(polylineOptions, this); @@ -1267,6 +1258,7 @@ public final class MapboxMap { * @param polylineOptionsList A list of polyline options objects that defines how to render the polylines. * @return A list of the {@code Polyline}s that were added to the map. */ + @UiThread @NonNull public List<Polyline> addPolylines(@NonNull List<PolylineOptions> polylineOptionsList) { return annotationManager.addPolylines(polylineOptionsList, this); @@ -1277,6 +1269,7 @@ public final class MapboxMap { * * @param polyline An updated polyline object. */ + @UiThread public void updatePolyline(Polyline polyline) { annotationManager.updatePolyline(polyline); } @@ -1287,6 +1280,7 @@ public final class MapboxMap { * @param polygonOptions A polygon options object that defines how to render the polygon. * @return The {@code Polygon} that was added to the map. */ + @UiThread @NonNull public Polygon addPolygon(@NonNull PolygonOptions polygonOptions) { return annotationManager.addPolygon(polygonOptions, this); @@ -1298,6 +1292,7 @@ public final class MapboxMap { * @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 public List<Polygon> addPolygons(@NonNull List<PolygonOptions> polygonOptionsList) { return annotationManager.addPolygons(polygonOptionsList, this); @@ -1308,6 +1303,7 @@ public final class MapboxMap { * * @param polygon An updated polygon object */ + @UiThread public void updatePolygon(Polygon polygon) { annotationManager.updatePolygon(polygon); } @@ -1320,6 +1316,7 @@ public final class MapboxMap { * * @param marker Marker to remove */ + @UiThread public void removeMarker(@NonNull Marker marker) { annotationManager.removeAnnotation(marker); } @@ -1332,6 +1329,7 @@ public final class MapboxMap { * * @param polyline Polyline to remove */ + @UiThread public void removePolyline(@NonNull Polyline polyline) { annotationManager.removeAnnotation(polyline); } @@ -1344,6 +1342,7 @@ public final class MapboxMap { * * @param polygon Polygon to remove */ + @UiThread public void removePolygon(@NonNull Polygon polygon) { annotationManager.removeAnnotation(polygon); } @@ -1353,6 +1352,7 @@ public final class MapboxMap { * * @param annotation The annotation object to remove. */ + @UiThread public void removeAnnotation(@NonNull Annotation annotation) { annotationManager.removeAnnotation(annotation); } @@ -1362,6 +1362,7 @@ public final class MapboxMap { * * @param id The identifier associated to the annotation to be removed */ + @UiThread public void removeAnnotation(long id) { annotationManager.removeAnnotation(id); } @@ -1371,6 +1372,7 @@ public final class MapboxMap { * * @param annotationList A list of annotation objects to remove. */ + @UiThread public void removeAnnotations(@NonNull List<? extends Annotation> annotationList) { annotationManager.removeAnnotations(annotationList); } @@ -1378,6 +1380,7 @@ public final class MapboxMap { /** * Removes all annotations from the map. */ + @UiThread public void removeAnnotations() { annotationManager.removeAnnotations(); } @@ -1385,6 +1388,7 @@ public final class MapboxMap { /** * Removes all markers, polylines, polygons, overlays, etc from the map. */ + @UiThread public void clear() { annotationManager.removeAnnotations(); } @@ -1450,6 +1454,7 @@ public final class MapboxMap { * @param listener The callback that's invoked when the user clicks on a marker. * To unset the callback, use null. */ + @UiThread public void setOnMarkerClickListener(@Nullable OnMarkerClickListener listener) { annotationManager.setOnMarkerClickListener(listener); } @@ -1460,6 +1465,7 @@ public final class MapboxMap { * @param listener The callback that's invoked when the user clicks on a polygon. * To unset the callback, use null. */ + @UiThread public void setOnPolygonClickListener(@Nullable OnPolygonClickListener listener) { annotationManager.setOnPolygonClickListener(listener); } @@ -1470,6 +1476,7 @@ public final class MapboxMap { * @param listener The callback that's invoked when the user clicks on a polyline. * To unset the callback, use null. */ + @UiThread public void setOnPolylineClickListener(@Nullable OnPolylineClickListener listener) { annotationManager.setOnPolylineClickListener(listener); } @@ -1484,6 +1491,7 @@ public final class MapboxMap { * * @param marker The marker to select. */ + @UiThread public void selectMarker(@NonNull Marker marker) { if (marker == null) { Timber.w("marker was null, so just returning"); @@ -1495,6 +1503,7 @@ public final class MapboxMap { /** * Deselects any currently selected marker. All markers will have it's info window closed. */ + @UiThread public void deselectMarkers() { annotationManager.deselectMarkers(); } @@ -1504,6 +1513,7 @@ public final class MapboxMap { * * @param marker the marker to deselect */ + @UiThread public void deselectMarker(@NonNull Marker marker) { annotationManager.deselectMarker(marker); } @@ -1513,6 +1523,7 @@ public final class MapboxMap { * * @return The currently selected marker. */ + @UiThread public List<Marker> getSelectedMarkers() { return annotationManager.getSelectedMarkers(); } @@ -1540,6 +1551,7 @@ public final class MapboxMap { * @param infoWindowAdapter The callback to be invoked when an info window will be shown. * To unset the callback, use null. */ + @UiThread public void setInfoWindowAdapter(@Nullable InfoWindowAdapter infoWindowAdapter) { annotationManager.getInfoWindowManager().setInfoWindowAdapter(infoWindowAdapter); } @@ -1549,6 +1561,7 @@ public final class MapboxMap { * * @return The callback to be invoked when an info window will be shown. */ + @UiThread @Nullable public InfoWindowAdapter getInfoWindowAdapter() { return annotationManager.getInfoWindowManager().getInfoWindowAdapter(); @@ -1559,6 +1572,7 @@ public final class MapboxMap { * * @param allow If true, map allows concurrent multiple infowindows to be shown. */ + @UiThread public void setAllowConcurrentMultipleOpenInfoWindows(boolean allow) { annotationManager.getInfoWindowManager().setAllowConcurrentMultipleOpenInfoWindows(allow); } @@ -1568,6 +1582,7 @@ public final class MapboxMap { * * @return If true, map allows concurrent multiple infowindows to be shown. */ + @UiThread public boolean isAllowConcurrentMultipleOpenInfoWindows() { return annotationManager.getInfoWindowManager().isAllowConcurrentMultipleOpenInfoWindows(); } @@ -1661,6 +1676,7 @@ public final class MapboxMap { * @param listener The callback that's invoked on every camera change position. * To unset the callback, use null. */ + @UiThread @Deprecated public void setOnCameraChangeListener(@Nullable OnCameraChangeListener listener) { transform.setOnCameraChangeListener(listener); @@ -1671,6 +1687,7 @@ public final class MapboxMap { * * @param listener the listener to notify */ + @UiThread public void setOnCameraIdleListener(@Nullable OnCameraIdleListener listener) { cameraChangeDispatcher.setOnCameraIdleListener(listener); } @@ -1680,6 +1697,7 @@ public final class MapboxMap { * * @param listener the listener to notify */ + @UiThread public void setOnCameraMoveCancelListener(@Nullable OnCameraMoveCanceledListener listener) { cameraChangeDispatcher.setOnCameraMoveCanceledListener(listener); } @@ -1689,6 +1707,7 @@ public final class MapboxMap { * * @param listener the listener to notify */ + @UiThread public void setOnCameraMoveStartedListener(@Nullable OnCameraMoveStartedListener listener) { cameraChangeDispatcher.setOnCameraMoveStartedListener(listener); } @@ -1698,6 +1717,7 @@ public final class MapboxMap { * * @param listener the listener to notify */ + @UiThread public void setOnCameraMoveListener(@Nullable OnCameraMoveListener listener) { cameraChangeDispatcher.setOnCameraMoveListener(listener); } @@ -1708,6 +1728,7 @@ public final class MapboxMap { * @param listener The callback that's invoked on every frame rendered to the map view. * To unset the callback, use null. */ + @UiThread public void setOnFpsChangedListener(@Nullable OnFpsChangedListener listener) { onFpsChangedListener = listener; } @@ -1723,6 +1744,7 @@ public final class MapboxMap { * @param listener The callback that's invoked when the map is scrolled. * To unset the callback, use null. */ + @UiThread public void setOnScrollListener(@Nullable OnScrollListener listener) { onRegisterTouchListener.onRegisterScrollListener(listener); } @@ -1733,6 +1755,7 @@ public final class MapboxMap { * @param listener The callback that's invoked when the map is flinged. * To unset the callback, use null. */ + @UiThread public void setOnFlingListener(@Nullable OnFlingListener listener) { onRegisterTouchListener.onRegisterFlingListener(listener); } @@ -1743,6 +1766,7 @@ public final class MapboxMap { * @param listener The callback that's invoked when the user clicks on the map view. * To unset the callback, use null. */ + @UiThread public void setOnMapClickListener(@Nullable OnMapClickListener listener) { onRegisterTouchListener.onRegisterMapClickListener(listener); } @@ -1753,6 +1777,7 @@ public final class MapboxMap { * @param listener The callback that's invoked when the user long clicks on the map view. * To unset the callback, use null. */ + @UiThread public void setOnMapLongClickListener(@Nullable OnMapLongClickListener listener) { onRegisterTouchListener.onRegisterMapLongClickListener(listener); } @@ -1763,6 +1788,7 @@ public final class MapboxMap { * @param listener The callback that's invoked when the user clicks on an info window. * To unset the callback, use null. */ + @UiThread public void setOnInfoWindowClickListener(@Nullable OnInfoWindowClickListener listener) { annotationManager.getInfoWindowManager().setOnInfoWindowClickListener(listener); } @@ -1772,6 +1798,7 @@ public final class MapboxMap { * * @return Current active InfoWindow Click Listener */ + @UiThread public OnInfoWindowClickListener getOnInfoWindowClickListener() { return annotationManager.getInfoWindowManager().getOnInfoWindowClickListener(); } @@ -1782,6 +1809,7 @@ public final class MapboxMap { * @param listener The callback that's invoked when a marker's info window is long pressed. To unset the callback, * use null. */ + @UiThread public void setOnInfoWindowLongClickListener(@Nullable OnInfoWindowLongClickListener listener) { annotationManager.getInfoWindowManager().setOnInfoWindowLongClickListener(listener); @@ -1810,6 +1838,7 @@ public final class MapboxMap { * * @return Current active InfoWindow Close Listener */ + @UiThread public OnInfoWindowCloseListener getOnInfoWindowCloseListener() { return annotationManager.getInfoWindowManager().getOnInfoWindowCloseListener(); } @@ -1822,10 +1851,8 @@ public final class MapboxMap { * Returns the status of the my-location layer. * * @return True if the my-location layer is enabled, false otherwise. - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. */ - @Deprecated + @UiThread public boolean isMyLocationEnabled() { return trackingSettings.isMyLocationEnabled(); } @@ -1840,10 +1867,8 @@ public final class MapboxMap { * android.Manifest.permission#ACCESS_COARSE_LOCATION or android.Manifest.permission#ACCESS_FINE_LOCATION. * * @param enabled True to enable; false to disable. - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. */ - @Deprecated + @UiThread public void setMyLocationEnabled(boolean enabled) { trackingSettings.setMyLocationEnabled(enabled); } @@ -1852,11 +1877,9 @@ public final class MapboxMap { * Returns the currently displayed user location, or null if there is no location data available. * * @return The currently displayed user location. - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. */ + @UiThread @Nullable - @Deprecated public Location getMyLocation() { return trackingSettings.getMyLocation(); } @@ -1867,10 +1890,8 @@ public final class MapboxMap { * * @param listener The callback that's invoked when the user clicks on a marker. * To unset the callback, use null. - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. */ - @Deprecated + @UiThread public void setOnMyLocationChangeListener(@Nullable MapboxMap.OnMyLocationChangeListener listener) { trackingSettings.setOnMyLocationChangeListener(listener); @@ -1880,10 +1901,8 @@ public final class MapboxMap { * Replaces the location source of the my-location layer. * * @param locationSource A {@link LocationEngine} location source to use in the my-location layer. - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. */ - @Deprecated + @UiThread public void setLocationSource(@Nullable LocationEngine locationSource) { trackingSettings.setLocationSource(locationSource); } @@ -1893,10 +1912,8 @@ public final class MapboxMap { * * @param listener The callback that's invoked when the location tracking mode changes. * To unset the callback, use null. - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. */ - @Deprecated + @UiThread public void setOnMyLocationTrackingModeChangeListener( @Nullable MapboxMap.OnMyLocationTrackingModeChangeListener listener) { trackingSettings.setOnMyLocationTrackingModeChangeListener(listener); @@ -1907,10 +1924,8 @@ public final class MapboxMap { * * @param listener The callback that's invoked when the bearing tracking mode changes. * To unset the callback, use null. - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. */ - @Deprecated + @UiThread public void setOnMyBearingTrackingModeChangeListener(@Nullable OnMyBearingTrackingModeChangeListener listener) { trackingSettings.setOnMyBearingTrackingModeChangeListener(listener); } @@ -1924,6 +1939,7 @@ public final class MapboxMap { * * @param callback Callback method invoked when the snapshot is taken. */ + @UiThread public void snapshot(@NonNull SnapshotReadyCallback callback) { nativeMapView.addSnapshotCallback(callback); } @@ -1935,6 +1951,7 @@ public final class MapboxMap { * @param layerIds optionally - only query these layers * @return the list of feature */ + @UiThread @NonNull public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates, @Nullable String... layerIds) { @@ -1949,6 +1966,7 @@ public final class MapboxMap { * @param layerIds optionally - only query these layers * @return the list of feature */ + @UiThread @NonNull public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates, @Nullable Filter.Statement filter, @@ -1963,6 +1981,7 @@ public final class MapboxMap { * @param layerIds optionally - only query these layers * @return the list of feature */ + @UiThread @NonNull public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates, @Nullable String... layerIds) { @@ -1977,6 +1996,7 @@ public final class MapboxMap { * @param layerIds optionally - only query these layers * @return the list of feature */ + @UiThread @NonNull public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates, @Nullable Filter.Statement filter, diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values-fr/strings.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values-fr/strings.xml new file mode 100644 index 0000000000..48d90c3324 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values-fr/strings.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="mapbox_compassContentDescription">Boussole. Activer pour rétablir l\'orientation de la carte vers le nord.</string> + <string name="mapbox_attributionsIconContentDescription">Icone d\'attribution. Activer pour montrer le dialogue d\'attribution.</string> + <string name="mapbox_myLocationViewContentDescription">Vue de géolocalisation. Ceci affiche votre localisation sur la carte.</string> + <string name="mapbox_mapActionDescription">Affichage d\'une carte créée avec Mapbox. Faites la glisser en traînant deux doigts. Zoomez ou dézoomez en écartant ou rapprochant deux doigts.</string> + <string name="mapbox_attributionsDialogTitle">SDK Mapbox pour Android</string> + <string name="mapbox_attributionTelemetryTitle">Faire de meilleures cartes Mapbox</string> + <string name="mapbox_attributionTelemetryMessage">Vous aidez à améliorer les cartes OpenStreetMap et Mapbox en contribuant des données d\'utilisation anonymes.</string> + <string name="mapbox_attributionTelemetryPositive">D\'accord</string> + <string name="mapbox_attributionTelemetryNegative">Pas d\'accord</string> + <string name="mapbox_attributionTelemetryNeutral">Plus d\'informations</string> + <string name="mapbox_offline_error_region_definition_invalid">Le cadre OfflineRegionDefinition pour définir la région de navigation ne tient pas dans les limites du monde : %s</string> + + </resources> 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 029d25e046..81e0e5d7a8 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=5.1.0 +fabric-version=5.1.3 fabric-build-type=binary |