From 9e9ea9155358d971cdfdea68f43312ea70abdeb7 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Wed, 14 Feb 2018 14:01:57 +0100 Subject: [android] - remove deprecated api around location and markerview --- .../src/main/java/com/mapbox/mapboxsdk/Mapbox.java | 26 +- .../annotations/BaseMarkerViewOptions.java | 285 ----- .../com/mapbox/mapboxsdk/annotations/Marker.java | 9 - .../mapbox/mapboxsdk/annotations/MarkerView.java | 417 -------- .../mapboxsdk/annotations/MarkerViewManager.java | 682 ------------ .../mapboxsdk/annotations/MarkerViewOptions.java | 167 --- .../mapboxsdk/constants/MyBearingTracking.java | 50 - .../mapboxsdk/constants/MyLocationTracking.java | 42 - .../mapbox/mapboxsdk/maps/AnnotationManager.java | 100 +- .../com/mapbox/mapboxsdk/maps/IconManager.java | 11 +- .../mapbox/mapboxsdk/maps/MapGestureDetector.java | 34 +- .../com/mapbox/mapboxsdk/maps/MapKeyListener.java | 26 +- .../java/com/mapbox/mapboxsdk/maps/MapView.java | 57 +- .../java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 468 +-------- .../com/mapbox/mapboxsdk/maps/MarkerContainer.java | 100 +- .../java/com/mapbox/mapboxsdk/maps/Markers.java | 12 - .../java/com/mapbox/mapboxsdk/maps/Projection.java | 16 +- .../mapbox/mapboxsdk/maps/TrackingSettings.java | 419 -------- .../java/com/mapbox/mapboxsdk/maps/Transform.java | 45 +- .../mapboxsdk/maps/widgets/MyLocationView.java | 1104 -------------------- .../maps/widgets/MyLocationViewSettings.java | 389 ------- .../main/res/layout/mapbox_mapview_internal.xml | 13 - .../main/res/layout/mapbox_view_image_marker.xml | 6 - .../test/java/com/mapbox/mapboxsdk/MapboxTest.java | 5 +- .../mapboxsdk/annotations/MarkerViewTest.java | 219 ---- .../mapboxsdk/maps/AnnotationManagerTest.java | 15 +- .../mapboxsdk/maps/MapTouchListenersTest.java | 8 +- .../com/mapbox/mapboxsdk/maps/MapboxMapTest.java | 4 - .../mapboxsdk/maps/TrackingSettingsTest.java | 99 -- .../maps/widgets/MyLocationViewSettingsTest.java | 106 -- .../com/mapbox/mapboxsdk/maps/MapboxMapTest.java | 34 - .../mapboxsdk/testapp/annotations/IconTest.java | 2 +- .../testapp/annotations/MarkerViewTest.java | 79 -- .../testapp/maps/widgets/MyLocationViewTest.java | 229 ---- .../src/main/AndroidManifest.xml | 89 -- .../annotation/AnimatedMarkerActivity.java | 283 ----- .../activity/annotation/BulkMarkerActivity.java | 98 +- .../activity/annotation/MarkerViewActivity.java | 483 --------- .../annotation/MarkerViewsInRectangleActivity.java | 110 -- .../DynamicInfoWindowAdapterActivity.java | 10 +- .../activity/maplayout/BottomSheetActivity.java | 15 +- .../activity/maplayout/DoubleMapActivity.java | 19 - .../activity/maplayout/MapPaddingActivity.java | 35 +- .../activity/style/HillshadeLayerActivity.java | 2 +- .../userlocation/BaseLocationActivity.java | 66 -- .../userlocation/CustomLocationEngineActivity.java | 117 --- .../activity/userlocation/MockLocationEngine.java | 130 --- .../userlocation/MyLocationDrawableActivity.java | 114 -- .../userlocation/MyLocationTintActivity.java | 181 ---- .../userlocation/MyLocationToggleActivity.java | 91 -- .../MyLocationTrackingModeActivity.java | 296 ------ .../model/annotations/CountryMarkerView.java | 24 - .../annotations/CountryMarkerViewOptions.java | 99 -- .../testapp/model/annotations/PulseMarkerView.java | 11 - .../model/annotations/PulseMarkerViewOptions.java | 79 -- .../testapp/model/annotations/TextMarkerView.java | 18 - .../model/annotations/TextMarkerViewOptions.java | 91 -- .../src/main/res/animator/scale_down.xml | 11 - .../src/main/res/animator/scale_up.xml | 11 - .../src/main/res/drawable-hdpi/ic_android.png | Bin 1711 -> 0 bytes .../src/main/res/drawable-hdpi/ic_android_2.png | Bin 1562 -> 0 bytes .../src/main/res/drawable-hdpi/icon_burned.png | Bin 1587 -> 0 bytes .../src/main/res/drawable-mdpi/ic_android.png | Bin 1217 -> 0 bytes .../src/main/res/drawable-mdpi/ic_android_2.png | Bin 1117 -> 0 bytes .../src/main/res/drawable-mdpi/icon_burned.png | Bin 913 -> 0 bytes .../src/main/res/drawable-xhdpi/ic_android.png | Bin 2202 -> 0 bytes .../src/main/res/drawable-xhdpi/ic_android_2.png | Bin 2142 -> 0 bytes .../src/main/res/drawable-xhdpi/icon_burned.png | Bin 1587 -> 0 bytes .../src/main/res/drawable-xxhdpi/ic_android.png | Bin 3639 -> 0 bytes .../src/main/res/drawable-xxhdpi/ic_android_2.png | Bin 3495 -> 0 bytes .../src/main/res/drawable-xxhdpi/ic_us.png | Bin 418 -> 0 bytes .../src/main/res/drawable-xxhdpi/icon_burned.png | Bin 2382 -> 0 bytes .../src/main/res/drawable-xxxhdpi/ic_android.png | Bin 4936 -> 0 bytes .../src/main/res/drawable-xxxhdpi/ic_android_2.png | Bin 4883 -> 0 bytes .../src/main/res/drawable-xxxhdpi/ic_taxi_top.png | Bin 11275 -> 0 bytes .../src/main/res/drawable-xxxhdpi/icon_burned.png | Bin 3018 -> 0 bytes .../src/main/res/drawable/ic_check_box.xml | 9 - .../main/res/drawable/ic_directions_run_black.xml | 9 - .../src/main/res/drawable/ic_droppin.xml | 4 - .../src/main/res/drawable/ic_location_disabled.xml | 9 - .../main/res/layout/activity_animated_marker.xml | 18 - .../res/layout/activity_custom_location_engine.xml | 27 - .../src/main/res/layout/activity_marker_bulk.xml | 11 - .../src/main/res/layout/activity_marker_view.xml | 27 - .../res/layout/activity_marker_view_in_rect.xml | 20 - .../layout/activity_my_location_customization.xml | 11 - .../res/layout/activity_my_location_dot_color.xml | 62 -- .../res/layout/activity_my_location_toggle.xml | 23 - .../res/layout/activity_my_location_tracking.xml | 50 - .../main/res/layout/drawer_navigation_drawer.xml | 7 - .../src/main/res/layout/view_custom_marker.xml | 22 - .../src/main/res/layout/view_text_marker.xml | 17 - .../src/main/res/menu/menu_location_engine.xml | 20 - .../src/main/res/menu/menu_tracking.xml | 32 - .../src/main/res/values-v21/styles.xml | 15 +- .../src/main/res/values/actions.xml | 12 - .../src/main/res/values/arrays.xml | 12 - .../src/main/res/values/descriptions.xml | 8 - .../src/main/res/values/dimens.xml | 4 +- .../src/main/res/values/styles.xml | 10 - .../src/main/res/values/titles.xml | 8 - 101 files changed, 80 insertions(+), 8128 deletions(-) delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_view_image_marker.xml delete mode 100644 platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java delete mode 100644 platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerView.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerViewOptions.java delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_down.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_up.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android_2.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/icon_burned.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android_2.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/icon_burned.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android_2.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/icon_burned.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android_2.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_us.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/icon_burned.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android_2.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_taxi_top.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/icon_burned.png delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_check_box.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_run_black.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_droppin.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_location_engine.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view_in_rect.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_tracking.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/drawer_navigation_drawer.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_custom_marker.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_text_marker.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_location_engine.xml delete mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_tracking.xml 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 536f5d02ab..421b32da36 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 @@ -8,9 +8,6 @@ import android.support.annotation.NonNull; import android.support.annotation.UiThread; import android.text.TextUtils; -import com.mapbox.android.core.location.LocationEngine; -import com.mapbox.android.core.location.LocationEnginePriority; -import com.mapbox.android.core.location.LocationEngineProvider; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException; import com.mapbox.mapboxsdk.net.ConnectivityReceiver; @@ -31,7 +28,6 @@ public final class Mapbox { private Context context; private String accessToken; private Boolean connected; - private LocationEngine locationEngine; /** * Get an instance of Mapbox. @@ -47,21 +43,15 @@ public final class Mapbox { public static synchronized Mapbox getInstance(@NonNull Context context, @NonNull String accessToken) { if (INSTANCE == null) { Context appContext = context.getApplicationContext(); - LocationEngineProvider locationEngineProvider = new LocationEngineProvider(context); - LocationEngine locationEngine = locationEngineProvider.obtainBestLocationEngineAvailable(); - INSTANCE = new Mapbox(appContext, accessToken, locationEngine); - locationEngine.setPriority(LocationEnginePriority.NO_POWER); - + INSTANCE = new Mapbox(appContext, accessToken); ConnectivityReceiver.instance(appContext); } - return INSTANCE; } - Mapbox(@NonNull Context context, @NonNull String accessToken, LocationEngine locationEngine) { + Mapbox(@NonNull Context context, @NonNull String accessToken) { this.context = context; this.accessToken = accessToken; - this.locationEngine = locationEngine; } /** @@ -134,16 +124,4 @@ public final class Mapbox { NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return (activeNetwork != null && activeNetwork.isConnected()); } - - /** - * Returns the location engine used by the SDK. - * - * @return the location engine configured - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. - */ - @Deprecated - public static LocationEngine getLocationEngine() { - return INSTANCE.locationEngine; - } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java deleted file mode 100644 index 3fd2fa4ebf..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java +++ /dev/null @@ -1,285 +0,0 @@ -package com.mapbox.mapboxsdk.annotations; - -import android.os.Parcelable; -import android.support.annotation.FloatRange; -import android.support.annotation.NonNull; - -import com.mapbox.mapboxsdk.geometry.LatLng; - -/** - * Abstract builder class for composing custom MarkerView objects. - *

- * Extending this class requires implementing Parceable interface. - *

- * - * @param Type of the marker view to be composed. - * @param Type of the builder to be used for composing. - * @deprecated Use a {@link com.mapbox.mapboxsdk.style.layers.SymbolLayer} instead. An example of converting Android - * SDK views to be used as a symbol see https://github.com/mapbox/mapbox-gl-native/blob/68f32bc104422207c64da8d90e8411b138d87f04/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java - */ -@Deprecated -public abstract class BaseMarkerViewOptions> - implements Parcelable { - - protected LatLng position; - protected String snippet; - protected String title; - protected Icon icon; - protected boolean flat; - protected float anchorU = 0.5f; - protected float anchorV = 1f; - protected float infoWindowAnchorU = 0.5f; - protected float infoWindowAnchorV = 0.0f; - protected float rotation; - protected boolean visible = true; - protected boolean selected; - protected float alpha = 1.0f; - - /** - * Default constructor - */ - public BaseMarkerViewOptions() { - } - - /** - * Set the geographical location of the MarkerView. - * - * @param position the location to position the {@link MarkerView}. - * @return the object for which the method was called. - */ - public T position(@NonNull LatLng position) { - this.position = position; - return getThis(); - } - - /** - * Set the snippet of the MarkerView. - * - * @param snippet the snippet of the {@link MarkerView}. - * @return the object for which the method was called. - */ - public T snippet(String snippet) { - this.snippet = snippet; - return getThis(); - } - - /** - * Set the title of the MarkerView. - * - * @param title the title of the {@link MarkerView}. - * @return the object for which the method was called. - */ - public T title(String title) { - this.title = title; - return getThis(); - } - - /** - * Set the icon of the MarkerView. - * - * @param icon the icon of the {@link MarkerView}. - * @return the object for which the method was called. - */ - public T icon(Icon icon) { - this.icon = icon; - return getThis(); - } - - /** - * Set the flat state of the MarkerView. - * - * @param flat the flat state of the {@link MarkerView}. - * @return the object for which the method was called. - */ - public T flat(boolean flat) { - this.flat = flat; - return getThis(); - } - - /** - * Set the anchor of the {@link MarkerView}. - * - * @param u the u-value. - * @param v the v-value. - * @return the object for which the method was called. - */ - public T anchor(@FloatRange(from = 0.0, to = 1.0) float u, @FloatRange(from = 0.0, to = 1.0) float v) { - this.anchorU = u; - this.anchorV = v; - return getThis(); - } - - /** - * Set the InfoWindow anchor of the {@link MarkerView}. - * - * @param u the u-value. - * @param v the v-values. - * @return the object for which the method was called. - */ - public T infoWindowAnchor(@FloatRange(from = 0.0, to = 1.0) float u, @FloatRange(from = 0.0, to = 1.0) float v) { - this.infoWindowAnchorU = u; - this.infoWindowAnchorV = v; - return getThis(); - } - - /** - * Set the rotation of the {@link MarkerView}. - * - * @param rotation the rotation value. - * @return the object for which the method was called. - */ - public T rotation(float rotation) { - this.rotation = rotation; - while (this.rotation > 360) { - this.rotation -= 360; - } - while (this.rotation < 0) { - this.rotation += 360; - } - return getThis(); - } - - /** - * Set the visibility state of the {@link MarkerView}. - * - * @param visible the visible state. - * @return the object for which the method was called. - */ - public T visible(boolean visible) { - this.visible = visible; - return getThis(); - } - - /** - * Set the alpha of the {@link MarkerView}. - * - * @param alpha the alpha value. - * @return the object for which the method was called. - */ - public T alpha(float alpha) { - this.alpha = alpha; - return getThis(); - } - - /** - * Get the geographical location of the {@link MarkerView}. - * - * @return the geographical location. - */ - public LatLng getPosition() { - return position; - } - - /** - * Get the snippet of the {@link MarkerView}. - * - * @return the snippet. - */ - public String getSnippet() { - return snippet; - } - - /** - * Get the title of the {@link MarkerView}. - * - * @return the title. - */ - public String getTitle() { - return title; - } - - /** - * Get the icon of the {@link MarkerView}. - * - * @return the icon. - */ - public Icon getIcon() { - return icon; - } - - /** - * Get the flat state of the {@link MarkerView}. - * - * @return the flat state. - */ - public boolean isFlat() { - return flat; - } - - /** - * Get the u-value of the {@link MarkerView} anchor. - * - * @return the u-value. - */ - public float getAnchorU() { - return anchorU; - } - - /** - * Get the v-value of the {@link MarkerView} anchor. - * - * @return the v-value. - */ - public float getAnchorV() { - return anchorV; - } - - /** - * Get the u-value of the MarkerView InfoWindow anchor. - * - * @return the u-value. - */ - public float getInfoWindowAnchorU() { - return infoWindowAnchorU; - } - - /** - * Get the v-value of the MarkerView InfoWindow anchor. - * - * @return the v-value. - */ - public float getInfoWindowAnchorV() { - return infoWindowAnchorV; - } - - /** - * Get the rotation of the MarkerView. - * - * @return the rotation value. - */ - public float getRotation() { - return rotation; - } - - /** - * Get the visibility state of the MarkerView. - * - * @return the visibility state. - */ - public boolean isVisible() { - return visible; - } - - /** - * Get the alpha of the MarkerView. - * - * @return the alpha value. - */ - public float getAlpha() { - return alpha; - } - - /** - * Get the instance of the object for which this method was called. - * - * @return the object for which the this method was called. - */ - public abstract T getThis(); - - /** - * Get the MarkerView. - * - * @return the MarkerView created from this builder. - */ - public abstract U getMarker(); -} diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java index 18f74cd990..7200f9cd43 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java @@ -16,10 +16,6 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; * {@link LatLng} and using {@link MapboxMap#addMarker(MarkerOptions)}. The marker icon will be * centered at this position so it is common to add padding to the icon image before usage. *

- * If more customization is needed, we offer {@link MarkerView} which places a {@link View} on top - * of the map at a geographical location. - *

- *

* Markers are designed to be interactive. They receive click events by default, and are often used * with event listeners to bring up info windows. An {@link InfoWindow} is displayed by default when * either a title or snippet is provided. @@ -56,11 +52,6 @@ public class Marker extends Annotation { this(baseMarkerOptions.position, baseMarkerOptions.icon, baseMarkerOptions.title, baseMarkerOptions.snippet); } - Marker(BaseMarkerViewOptions baseMarkerViewOptions) { - this(baseMarkerViewOptions.position, baseMarkerViewOptions.icon, - baseMarkerViewOptions.title, baseMarkerViewOptions.snippet); - } - Marker(LatLng position, Icon icon, String title, String snippet) { this.position = position; this.title = title; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java deleted file mode 100644 index eb82c7bf53..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java +++ /dev/null @@ -1,417 +0,0 @@ -package com.mapbox.mapboxsdk.annotations; - -import android.support.annotation.FloatRange; -import android.support.annotation.Nullable; - -import com.mapbox.mapboxsdk.Mapbox; -import com.mapbox.mapboxsdk.constants.MapboxConstants; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.MapboxMap; - -/** - * MarkerView is an annotation that shows a {@link android.view.View} at a geographical location. The - * default marker uses a provided icon. This icon can be customized using {@link IconFactory} to - * generate an {@link Icon} using a provided image. MarkerViews are added to the map by first giving - * a {@link LatLng} and using {@link MapboxMap#addMarker(BaseMarkerViewOptions)}. The marker view icon - * by default is anchored at the center bottom. - *

- * If many markers are needed to be displayed on the map at once we suggest using {@link Marker} - * instead. This class uses {@link com.mapbox.mapboxsdk.maps.MapboxMap.MarkerViewAdapter} to adapt a - * MarkerView model to an Android SDK {@link android.view.View} object. - *

- *

- * MarkerViews are designed to be interactive. They receive click events by default, and are often - * used with event listeners to bring up info windows. An {@link InfoWindow} is displayed by default - * when either a title or snippet is provided. - *

- * @deprecated Use a {@link com.mapbox.mapboxsdk.style.layers.SymbolLayer} instead. An example of converting Android - * SDK views to be used as a symbol see https://github.com/mapbox/mapbox-gl-native/blob/68f32bc104422207c64da8d90e8411b138d87f04/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java - */ -@Deprecated -public class MarkerView extends Marker { - - private MarkerViewManager markerViewManager; - - private float width; - private float height; - - private float anchorU; - private float anchorV; - - private float offsetX = MapboxConstants.UNMEASURED; - private float offsetY = MapboxConstants.UNMEASURED; - - private float infoWindowAnchorU; - private float infoWindowAnchorV; - - private boolean flat; - private boolean visible = true; - - private float tiltValue; - private float rotation; - private float alpha = 1; - - private Icon markerViewIcon; - - private boolean selected; - - - /** - * Publicly hidden default constructor - */ - MarkerView() { - } - - /** - * Creates a instance of MarkerView using the builder of MarkerView - * - * @param baseMarkerViewOptions the builder used to construct the MarkerView - */ - public MarkerView(BaseMarkerViewOptions baseMarkerViewOptions) { - super(baseMarkerViewOptions); - this.alpha = baseMarkerViewOptions.getAlpha(); - this.anchorU = baseMarkerViewOptions.getAnchorU(); - this.anchorV = baseMarkerViewOptions.getAnchorV(); - this.infoWindowAnchorU = baseMarkerViewOptions.getInfoWindowAnchorU(); - this.infoWindowAnchorV = baseMarkerViewOptions.getInfoWindowAnchorV(); - this.flat = baseMarkerViewOptions.isFlat(); - this.rotation = baseMarkerViewOptions.getRotation(); - this.selected = baseMarkerViewOptions.selected; - } - - float getWidth() { - return width; - } - - void setWidth(float width) { - this.width = width; - } - - float getHeight() { - return height; - } - - void setHeight(float height) { - this.height = height; - } - - /** - * Specifies the anchor being set on a particular point of the MarkerView. - *

- * The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0], where (0, 0) - * is the top-left corner of the image, and (1, 1) is the bottom-right corner. - *

- * - * @param u u-coordinate of the anchor, as a ratio of the image width (in the range [0, 1]). - * @param v v-coordinate of the anchor, as a ratio of the image height (in the range [0, 1]). - */ - public void setAnchor(@FloatRange(from = 0.0, to = 1.0) float u, @FloatRange(from = 0.0, to = 1.0) float v) { - this.anchorU = u; - this.anchorV = v; - setOffset(-1, -1); - } - - /** - * Get the horizontal distance, normalized to [0, 1], of the anchor from the left edge. - * - * @return The u-value of the anchor. - */ - public float getAnchorU() { - return anchorU; - } - - /** - * Get the vertical distance, normalized to [0, 1], of the anchor from the top edge. - * - * @return the v-value of the anchor. - */ - public float getAnchorV() { - return anchorV; - } - - /** - * Internal method to set the calculated offset. - *

- * These are calculated based on the View bounds and the provided anchor. - *

- * - * @param x the x-value of the offset. - * @param y the y-value of the offset. - */ - void setOffset(float x, float y) { - offsetX = x; - offsetY = y; - } - - /** - * Internal method to get the horizontal calculated offset. - * - * @return the calculated horizontal offset. - */ - float getOffsetX() { - return offsetX; - } - - /** - * Internal method to get the vertical calculated offset. - * - * @return the calculated vertical offset. - */ - float getOffsetY() { - return offsetY; - } - - /** - * Specifies the anchor point of the info window on the View of the MarkerView. - *

- * The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0], where (0, 0) - * is the top-left corner of the image, and (1, 1) is the bottom-right corner. - *

- *

- * The default is the top middle of the View. - *

- * - * @param u u-coordinate of the info window anchor, as a ratio of the image width (in the range [0, 1]). - * @param v v-coordinate of the info window anchor, as a ratio of the image height (in the range [0, 1]). - * @see #setAnchor(float, float) for more details. - */ - public void setInfoWindowAnchor(@FloatRange(from = 0.0, to = 1.0) float u, - @FloatRange(from = 0.0, to = 1.0) float v) { - this.infoWindowAnchorU = u; - this.infoWindowAnchorV = v; - } - - /** - * Get the horizontal distance, normalized to [0, 1], of the info window anchor from the left edge. - * - * @return the u value of the InfoWindow anchor. - */ - public float getInfoWindowAnchorU() { - return infoWindowAnchorU; - } - - /** - * Get the vertical distance, normalized to [0, 1], of the info window anchor from the top edge. - * - * @return the v value of the InfoWindow anchor. - */ - public float getInfoWindowAnchorV() { - return infoWindowAnchorV; - } - - /** - * Get the flat state of a MarkerView. - * - * @return true if the MarkerView is flat; false if the MarkerView is billboard. - */ - public boolean isFlat() { - return flat; - } - - /** - * Sets whether this MarkerView should be flat against the map (true) or a billboard facing the - * camera (false). - * - * @param flat the flat state of the MarkerView. - */ - public void setFlat(boolean flat) { - this.flat = flat; - } - - /** - * Internal method to get the current tilted value of a MarkerView. - * - * @return the tilted value. - */ - float getTilt() { - return tiltValue; - } - - /** - * Internal method to set the current titled value of a MarkerView. - * - * @param tiltValue the tilted value to set. - */ - void setTilt(@FloatRange(from = 0.0, to = MapboxConstants.MAXIMUM_TILT) float tiltValue) { - this.tiltValue = tiltValue; - } - - /** - * Set the visible state of a MarkerView. - * - * @param visible true will make the MarkerView visible, false will hide the MarkerView. - */ - public void setVisible(boolean visible) { - this.visible = visible; - if (markerViewManager != null) { - markerViewManager.animateVisible(this, visible); - } - } - - /** - * Returns the visible state of the MarkerView. - * - * @return the visible state. - */ - public boolean isVisible() { - return visible; - } - - /** - * Set the rotation value of the MarkerView in degrees. - *

- * Input will be limited to 0 - 360 degrees. - *

- *

- * This will result in animating the rotation of the MarkerView using an rotation animator - * from current value to the provided parameter value. - *

- * - * @param rotation the rotation value to animate to. - */ - public void setRotation(float rotation) { - this.rotation = rotation; - if (markerViewManager != null) { - markerViewManager.setRotation(this, rotation); - } - } - - /** - * Get the rotation value of the MarkerView. - * - * @return the rotation value. - */ - public float getRotation() { - return rotation; - } - - /** - * Get the alpha value of the MarkerView. - * - * @return the alpha value. - */ - public float getAlpha() { - return alpha; - } - - /** - * Set the alpha value of the MarkerView. - *

- * This will result in animating the alpha of the MarkerView using an alpha animator - * from current value to the provided parameter value. - *

- * - * @param alpha the alpha value to animate to. - */ - public void setAlpha(@FloatRange(from = 0.0, to = 255.0) float alpha) { - this.alpha = alpha; - if (markerViewManager != null) { - markerViewManager.animateAlpha(this, alpha); - } - } - - /** - * Set the icon of the MarkerView. - * - * @param icon the {@link Icon} to be used as Marker image. - */ - @Override - public void setIcon(@Nullable Icon icon) { - if (icon != null) { - markerViewIcon = IconFactory.recreate(IconFactory.ICON_MARKERVIEW_ID, icon.getBitmap()); - } - Icon transparentIcon = IconFactory.recreate(IconFactory.ICON_MARKERVIEW_ID, - IconFactory.ICON_MARKERVIEW_BITMAP); - if (markerViewManager != null) { - markerViewManager.updateIcon(this); - } - super.setIcon(transparentIcon); - } - - /** - * Sets the location of the marker. - * - * @param position A {@link LatLng} defining the marker position. - */ - @Override - public void setPosition(LatLng position) { - super.setPosition(position); - if (markerViewManager != null) { - markerViewManager.setWaitingForRenderInvoke(true); - markerViewManager.update(); - } - } - - /** - * Determine if the {@link MarkerView} is selected or not. - * - * @return True if the MarkerView's selected, else false. - */ - public boolean isSelected() { - return selected; - } - - /** - * For internal use only, use {@link MapboxMap#selectMarker(Marker)} instead. - */ - void setSelected(boolean selected) { - this.selected = selected; - } - - /** - * Get the icon of the MarkerView. - * - * @return the icon use as Marker image. - */ - @Override - public Icon getIcon() { - if (markerViewIcon == null) { - setIcon(IconFactory.getInstance(Mapbox.getApplicationContext()).defaultMarkerView()); - } - return markerViewIcon; - } - - /** - * Set the MapboxMap associated tot the MapView containing the MarkerView. - *

- * This method is used to instantiate the MarkerView and provide an instance of - * {@link com.mapbox.mapboxsdk.maps.MapboxMap.MarkerViewAdapter} - *

- *

- * This method is used to notify that a MarkerView is no longer active by setting a null value. - *

- * - * @param mapboxMap the MapboxMap instances. - */ - @Override - public void setMapboxMap(MapboxMap mapboxMap) { - super.setMapboxMap(mapboxMap); - if (mapboxMap != null) { - if (isFlat()) { - // initial tilt value if MapboxMap is started with a tilt attribute - tiltValue = (float) mapboxMap.getCameraPosition().tilt; - } - - markerViewManager = mapboxMap.getMarkerViewManager(); - } - } - - /** - * Invalidates the MarkerView resulting in remeasuring the View. - */ - void invalidate() { - width = height = 0; - offsetX = offsetY = MapboxConstants.UNMEASURED; - markerViewManager.invalidateViewMarkersInVisibleRegion(); - } - - /** - * Get the String representation of a MarkerView. - * - * @return the String representation. - */ - @Override - public String toString() { - return "MarkerView [position[" + getPosition() + "]]"; - } -} 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 deleted file mode 100644 index 8304d0e6ed..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java +++ /dev/null @@ -1,682 +0,0 @@ -package com.mapbox.mapboxsdk.annotations; - -import android.content.Context; -import android.graphics.PointF; -import android.graphics.RectF; -import android.os.SystemClock; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.util.LongSparseArray; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewTreeObserver; -import android.widget.ImageView; - -import com.mapbox.mapboxsdk.R; -import com.mapbox.mapboxsdk.constants.MapboxConstants; -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.utils.AnimatorUtils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * Interface for interacting with ViewMarkers objects inside of a MapView. - *

- * This class is responsible for managing a {@link MarkerView} item. - *

- * @deprecated Use a {@link com.mapbox.mapboxsdk.style.layers.SymbolLayer} instead. An example of converting Android - * SDK views to be used as a symbol see https://github.com/mapbox/mapbox-gl-native/blob/68f32bc104422207c64da8d90e8411b138d87f04/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java - */ -@Deprecated -public class MarkerViewManager implements MapView.OnMapChangedListener { - - private final ViewGroup markerViewContainer; - private final ViewTreeObserver.OnPreDrawListener markerViewPreDrawObserver = - new ViewTreeObserver.OnPreDrawListener() { - @Override - public boolean onPreDraw() { - invalidateViewMarkersInVisibleRegion(); - markerViewContainer.getViewTreeObserver().removeOnPreDrawListener(markerViewPreDrawObserver); - return false; - } - }; - private final Map markerViewMap = new HashMap<>(); - private final LongSparseArray markerViewAddedListenerMap = new LongSparseArray<>(); - private final List markerViewAdapters = new ArrayList<>(); - - // TODO refactor MapboxMap out for Projection and Transform - // Requires removing MapboxMap from Annotations by using Peer model from #6912 - private MapboxMap mapboxMap; - - private boolean enabled; - private long updateTime; - private MapboxMap.OnMarkerViewClickListener onMarkerViewClickListener; - private boolean isWaitingForRenderInvoke; - - /** - * Creates an instance of MarkerViewManager. - * - * @param container the ViewGroup associated with the MarkerViewManager - */ - public MarkerViewManager(@NonNull ViewGroup container) { - this.markerViewContainer = container; - this.markerViewAdapters.add(new ImageMarkerViewAdapter(container.getContext())); - } - - // TODO refactor MapboxMap out for Projection and Transform - // Requires removing MapboxMap from Annotations by using Peer model from #6912 - public void bind(MapboxMap mapboxMap) { - this.mapboxMap = mapboxMap; - } - - @Override - public void onMapChanged(@MapView.MapChange int change) { - if (isWaitingForRenderInvoke && change == MapView.DID_FINISH_RENDERING_FRAME_FULLY_RENDERED) { - isWaitingForRenderInvoke = false; - invalidateViewMarkersInVisibleRegion(); - } - } - - /** - * Called to enable or disable MarkerView management. - * - * @param enabled true if management should be enabled - */ - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - /** - * Called with true to wait for the next render invocation. - * - * @param waitingForRenderInvoke true if waiting for next render event - */ - public void setWaitingForRenderInvoke(boolean waitingForRenderInvoke) { - isWaitingForRenderInvoke = waitingForRenderInvoke; - } - - /** - * Animate a MarkerView to a given rotation. - *

- * The {@link MarkerView} will be rotated from its current rotation to the given rotation. - *

- * - * @param marker the MarkerView to rotate. - * @param rotation the rotation value. - */ - public void animateRotation(@NonNull MarkerView marker, float rotation) { - View convertView = markerViewMap.get(marker); - if (convertView != null) { - AnimatorUtils.rotate(convertView, rotation); - } - } - - /** - * Animate a MarkerView with a given rotation. - * - * @param marker the MarkerView to rotate by. - * @param rotation the rotation by value, limited to 0 - 360 degrees. - */ - public void animateRotationBy(@NonNull MarkerView marker, float rotation) { - View convertView = markerViewMap.get(marker); - if (convertView != null) { - convertView.animate().cancel(); - // calculate new direction - float diff = rotation - convertView.getRotation(); - if (diff > 180.0f) { - diff -= 360.0f; - } else if (diff < -180.0f) { - diff += 360.f; - } - AnimatorUtils.rotateBy(convertView, diff); - } - } - - /** - * Set the rotation of a MarkerView to a given rotation value. - * - * @param marker The MarkerView to change its rotation value - * @param rotation The rotation value - */ - public void setRotation(@NonNull MarkerView marker, float rotation) { - View convertView = markerViewMap.get(marker); - if (convertView != null) { - convertView.animate().cancel(); - convertView.setRotation(rotation); - } - } - - /** - * Animate a MarkerView to a given alpha value. - *

- * The {@link MarkerView} will be transformed from its current alpha value to the given value. - *

- * - * @param marker the MarkerView to change its alpha value. - * @param alpha the alpha value. - */ - public void animateAlpha(@NonNull MarkerView marker, float alpha) { - View convertView = markerViewMap.get(marker); - if (convertView != null) { - AnimatorUtils.alpha(convertView, alpha); - } - } - - /** - * Animate a MarkerVIew to be visible or invisible - *

- * The {@link MarkerView} will be made {@link View#VISIBLE} or {@link View#GONE}. - *

- * - * @param marker the MarkerView to change its visibility - * @param visible the flag indicating if MarkerView is visible - */ - public void animateVisible(@NonNull MarkerView marker, boolean visible) { - View convertView = markerViewMap.get(marker); - if (convertView != null) { - convertView.setVisibility(visible ? View.VISIBLE : View.GONE); - } - } - - /** - * Updates the position of MarkerViews currently found in the viewport. - *

- * The collection of {@link MarkerView} will be iterated and each item position will be updated. - * If an item is View state is not visible and its related flag is set to visible, the - * {@link MarkerView} will be animated to visible using alpha animation. - *

- */ - public void updateMarkerViewsPosition() { - for (final MarkerView marker : markerViewMap.keySet()) { - final View convertView = markerViewMap.get(marker); - if (convertView != null) { - PointF point = mapboxMap.getProjection().toScreenLocation(marker.getPosition()); - if (marker.getOffsetX() == MapboxConstants.UNMEASURED) { - // ensure view is measured first - // #6805 invalidate marker views to ensure convertView width and height - // values are properly measured and up to date - if (marker.getWidth() == 0 && marker.isVisible()) { - convertView.getViewTreeObserver().addOnPreDrawListener(markerViewPreDrawObserver); - } - } - - marker.setWidth(convertView.getWidth()); - marker.setHeight(convertView.getHeight()); - - if (marker.getWidth() != 0) { - int x = (int) (marker.getAnchorU() * marker.getWidth()); - int y = (int) (marker.getAnchorV() * marker.getHeight()); - marker.setOffset(x, y); - } - - convertView.setX(point.x - marker.getOffsetX()); - convertView.setY(point.y - marker.getOffsetY()); - - // animate visibility - if (marker.isVisible() && convertView.getVisibility() == View.GONE) { - animateVisible(marker, true); - } - } - } - } - - /** - * Set tilt on every non flat MarkerView currently shown in the Viewport. - * - * @param tilt the tilt value. - */ - public void setTilt(float tilt) { - View convertView; - for (MarkerView markerView : markerViewMap.keySet()) { - if (markerView.isFlat()) { - convertView = markerViewMap.get(markerView); - if (convertView != null) { - markerView.setTilt(tilt); - convertView.setRotationX(tilt); - } - } - } - } - - /** - * Update and invalidate the MarkerView icon. - * - * @param markerView the marker view to updates. - */ - public void updateIcon(@NonNull MarkerView markerView) { - View convertView = markerViewMap.get(markerView); - if (convertView != null && convertView instanceof ImageView) { - ((ImageView) convertView).setImageBitmap(markerView.getIcon().getBitmap()); - markerView.invalidate(); - } - } - - /** - * Animate a MarkerView to a deselected state. - *

- * The {@link com.mapbox.mapboxsdk.maps.MapboxMap.MarkerViewAdapter#onDeselect(MarkerView, View)} - * will be called to execute an animation. - *

- * - * @param marker the MarkerView to deselect. - */ - public void deselect(@NonNull MarkerView marker) { - deselect(marker, true); - } - - /** - * Animate a MarkerView to a deselected state. - *

- * The {@link com.mapbox.mapboxsdk.maps.MapboxMap.MarkerViewAdapter#onDeselect(MarkerView, View)} - * will be called to execute an animation. - *

- * - * @param marker the MarkerView to deselect. - * @param callbackToMap indicates if deselect marker must be called on MapboxMap. - */ - public void deselect(@NonNull MarkerView marker, boolean callbackToMap) { - final View convertView = markerViewMap.get(marker); - if (convertView != null) { - for (MapboxMap.MarkerViewAdapter adapter : markerViewAdapters) { - if (adapter.getMarkerClass().equals(marker.getClass())) { - adapter.onDeselect(marker, convertView); - } - } - } - if (callbackToMap) { - mapboxMap.deselectMarker(marker); - } - marker.setSelected(false); - } - - /** - * Animate a MarkerView to a selected state. - * - * @param marker the MarkerView object to select. - */ - public void select(@NonNull MarkerView marker) { - select(marker, true); - } - - /** - * Animate a MarkerView to a selected state. - * - * @param marker the MarkerView object to select. - * @param callbackToMap indicates if select marker must be called on {@link MapboxMap}. - */ - public void select(@NonNull MarkerView marker, boolean callbackToMap) { - final View convertView = markerViewMap.get(marker); - for (MapboxMap.MarkerViewAdapter adapter : markerViewAdapters) { - if (adapter.getMarkerClass().equals(marker.getClass())) { - select(marker, convertView, adapter, callbackToMap); - } - } - } - - /** - * Animate a MarkerView to a selected state. - *

- * The {@link com.mapbox.mapboxsdk.maps.MapboxMap.MarkerViewAdapter#onSelect(MarkerView, View, boolean)} - * will be called to execute an animation. - *

- * - * @param marker the MarkerView object to select. - * @param convertView the View presentation of the MarkerView. - * @param adapter the adapter used to adapt the marker to the convertView. - */ - public void select(@NonNull MarkerView marker, View convertView, MapboxMap.MarkerViewAdapter adapter) { - select(marker, convertView, adapter, true); - } - - - /** - * Animate a MarkerView to a selected state. - *

- * The {@link com.mapbox.mapboxsdk.maps.MapboxMap.MarkerViewAdapter#onSelect(MarkerView, View, boolean)} - * will be called to execute an animation. - *

- * - * @param marker the MarkerView object to select. - * @param convertView the View presentation of the MarkerView. - * @param adapter the adapter used to adapt the marker to the convertView. - * @param callbackToMap indicates if select marker must be called on MapboxMap. - */ - public void select(@NonNull MarkerView marker, View convertView, MapboxMap.MarkerViewAdapter adapter, - boolean callbackToMap) { - if (convertView != null) { - if (adapter.onSelect(marker, convertView, false)) { - if (callbackToMap) { - mapboxMap.selectMarker(marker); - } - } - marker.setSelected(true); - convertView.bringToFront(); - } - } - - /** - * Get view representation from a MarkerView. If marker is not found in current viewport, - * {@code null} is returned. - * - * @param marker the marker to get the view. - * @return the Android SDK View object. - */ - @Nullable - public View getView(MarkerView marker) { - return markerViewMap.get(marker); - } - - /** - * Get the view adapter for a marker. - * - * @param markerView the marker to get the view adapter. - * @return the MarkerView adapter. - */ - @Nullable - public MapboxMap.MarkerViewAdapter getViewAdapter(MarkerView markerView) { - MapboxMap.MarkerViewAdapter adapter = null; - for (MapboxMap.MarkerViewAdapter a : markerViewAdapters) { - if (a.getMarkerClass().equals(markerView.getClass())) { - adapter = a; - } - } - return adapter; - } - - /** - * Remove a MarkerView from a map. - *

- * The {@link MarkerView} will be removed using an alpha animation and related {@link View} - * will be released to the android.support.v4.util.Pools.SimplePool from the related - * {@link com.mapbox.mapboxsdk.maps.MapboxMap.MarkerViewAdapter}. It's possible to remove - * the {@link MarkerView} from the underlying collection if needed. - *

- * - * @param marker the MarkerView to remove. - */ - public void removeMarkerView(MarkerView marker) { - final View viewHolder = markerViewMap.get(marker); - if (viewHolder != null && marker != null) { - for (final MapboxMap.MarkerViewAdapter adapter : markerViewAdapters) { - if (adapter.getMarkerClass().equals(marker.getClass())) { - if (adapter.prepareViewForReuse(marker, viewHolder)) { - // reset offset for reuse - marker.setOffset(MapboxConstants.UNMEASURED, MapboxConstants.UNMEASURED); - adapter.releaseView(viewHolder); - } - } - } - } - marker.setMapboxMap(null); - markerViewMap.remove(marker); - } - - /** - * Add a MarkerViewAdapter to the MarkerViewManager. - *

- * The provided MarkerViewAdapter must supply a generic subclass of MarkerView. - *

- * - * @param markerViewAdapter the MarkerViewAdapter to add. - */ - public void addMarkerViewAdapter(MapboxMap.MarkerViewAdapter markerViewAdapter) { - if (markerViewAdapter.getMarkerClass().equals(MarkerView.class)) { - throw new RuntimeException("Providing a custom MarkerViewAdapter requires subclassing MarkerView"); - } - - if (!markerViewAdapters.contains(markerViewAdapter)) { - markerViewAdapters.add(markerViewAdapter); - invalidateViewMarkersInVisibleRegion(); - } - } - - /** - * Get all MarkerViewAdapters associated with this MarkerViewManager. - * - * @return a List of MarkerViewAdapters. - */ - public List getMarkerViewAdapters() { - return markerViewAdapters; - } - - /** - * Register a callback to be invoked when this view is clicked. - * - * @param listener the callback to be invoked. - */ - public void setOnMarkerViewClickListener(@Nullable MapboxMap.OnMarkerViewClickListener listener) { - onMarkerViewClickListener = listener; - } - - /** - * Schedule that ViewMarkers found in the viewport are invalidated. - *

- * This method is rate limited, and {@link #invalidateViewMarkersInVisibleRegion} will only be called - * once each 250 ms. - *

- */ - public void update() { - if (enabled) { - long currentTime = SystemClock.elapsedRealtime(); - if (currentTime < updateTime) { - updateMarkerViewsPosition(); - return; - } - invalidateViewMarkersInVisibleRegion(); - updateTime = currentTime + 250; - } - } - - /** - * Invalidate the ViewMarkers found in the viewport. - *

- * This method will remove any markers that aren't in the viewport anymore and will add new - * ones for each found Marker in the changed viewport. - *

- */ - public void invalidateViewMarkersInVisibleRegion() { - RectF mapViewRect = new RectF(0, 0, markerViewContainer.getWidth(), markerViewContainer.getHeight()); - List markers = mapboxMap.getMarkerViewsInRect(mapViewRect); - View convertView; - - // remove old markers - Iterator iterator = markerViewMap.keySet().iterator(); - while (iterator.hasNext()) { - MarkerView marker = iterator.next(); - if (!markers.contains(marker)) { - // remove marker - convertView = markerViewMap.get(marker); - for (MapboxMap.MarkerViewAdapter adapter : markerViewAdapters) { - if (adapter.getMarkerClass().equals(marker.getClass())) { - adapter.prepareViewForReuse(marker, convertView); - adapter.releaseView(convertView); - iterator.remove(); - } - } - } - } - - // introduce new markers - for (final MarkerView marker : markers) { - if (!markerViewMap.containsKey(marker)) { - for (final MapboxMap.MarkerViewAdapter adapter : markerViewAdapters) { - if (adapter.getMarkerClass().equals(marker.getClass())) { - - // Inflate View - convertView = (View) adapter.getViewReusePool().acquire(); - final View adaptedView = adapter.getView(marker, convertView, markerViewContainer); - if (adaptedView != null) { - adaptedView.setRotationX(marker.getTilt()); - adaptedView.setRotation(marker.getRotation()); - adaptedView.setAlpha(marker.getAlpha()); - adaptedView.setVisibility(View.GONE); - - if (mapboxMap.getSelectedMarkers().contains(marker)) { - // if a marker to be shown was selected - // replay that animation with duration 0 - if (adapter.onSelect(marker, adaptedView, true)) { - mapboxMap.selectMarker(marker); - } - } - - marker.setMapboxMap(mapboxMap); - markerViewMap.put(marker, adaptedView); - if (convertView == null) { - adaptedView.setVisibility(View.GONE); - markerViewContainer.addView(adaptedView); - } - } - - // notify listener is marker view is rendered - OnMarkerViewAddedListener onViewAddedListener = markerViewAddedListenerMap.get(marker.getId()); - if (onViewAddedListener != null) { - onViewAddedListener.onViewAdded(marker); - markerViewAddedListenerMap.remove(marker.getId()); - } - } - } - } - } - - // clear map, don't keep references to MarkerView listeners that are not found in the bounds of the map. - markerViewAddedListenerMap.clear(); - - // trigger update to make newly added ViewMarker visible, - // these would only be updated when the map is moved. - updateMarkerViewsPosition(); - } - - /** - * When the provided MarkerView is clicked on by a user, we check if a custom click - * event has been created and if not, display a InfoWindow. - * - * @param markerView that the click event occurred - * @return true if the marker view click has been handled, false if not - */ - 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); - } - - return clickHandled; - } - - /** - * Handles the MarkerView info window offset. - * - * @param marker that we are ensuring info window offset - */ - public void ensureInfoWindowOffset(MarkerView marker) { - View view = null; - if (markerViewMap.containsKey(marker)) { - view = markerViewMap.get(marker); - } else { - for (final MapboxMap.MarkerViewAdapter adapter : markerViewAdapters) { - if (adapter.getMarkerClass().equals(marker.getClass())) { - View convertView = (View) adapter.getViewReusePool().acquire(); - view = adapter.getView(marker, convertView, markerViewContainer); - break; - } - } - } - - if (view != null) { - if (marker.getWidth() == 0) { - if (view.getMeasuredWidth() == 0) { - // Ensure the marker's view is measured first - view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); - } - marker.setWidth(view.getMeasuredWidth()); - marker.setHeight(view.getMeasuredHeight()); - } - - // update position on map - if (marker.getOffsetX() == MapboxConstants.UNMEASURED) { - int x = (int) (marker.getAnchorU() * marker.getWidth()); - int y = (int) (marker.getAnchorV() * marker.getHeight()); - marker.setOffset(x, y); - } - - // InfoWindow offset - int infoWindowOffsetX = (int) ((view.getMeasuredWidth() * marker.getInfoWindowAnchorU()) - marker.getOffsetX()); - int infoWindowOffsetY = (int) ((view.getMeasuredHeight() * marker.getInfoWindowAnchorV()) - marker.getOffsetY()); - marker.setTopOffsetPixels(infoWindowOffsetY); - marker.setRightOffsetPixels(infoWindowOffsetX); - } - } - - public ViewGroup getMarkerViewContainer() { - return markerViewContainer; - } - - public void addOnMarkerViewAddedListener(MarkerView markerView, OnMarkerViewAddedListener onMarkerViewAddedListener) { - markerViewAddedListenerMap.put(markerView.getId(), onMarkerViewAddedListener); - } - - /** - * Default MarkerViewAdapter used for base class of MarkerView to adapt a MarkerView to - * an ImageView. - */ - private static class ImageMarkerViewAdapter extends MapboxMap.MarkerViewAdapter { - - private LayoutInflater inflater; - - ImageMarkerViewAdapter(Context context) { - super(context); - inflater = LayoutInflater.from(context); - } - - @Nullable - @Override - public View getView(@NonNull MarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) { - ViewHolder viewHolder; - if (convertView == null) { - viewHolder = new ViewHolder(); - convertView = inflater.inflate(R.layout.mapbox_view_image_marker, parent, false); - viewHolder.imageView = (ImageView) convertView.findViewById(R.id.image); - convertView.setTag(viewHolder); - } else { - viewHolder = (ViewHolder) convertView.getTag(); - } - viewHolder.imageView.setImageBitmap(marker.getIcon().getBitmap()); - viewHolder.imageView.setContentDescription(marker.getTitle()); - return convertView; - } - - private static class ViewHolder { - ImageView imageView; - } - } - - /** - * Interface definition invoked when the View of a MarkerView has been added to the map. - *

- * {@link MapboxMap#addMarker(BaseMarkerOptions)} - * and only when the related MarkerView is found in the viewport of the map. - *

- */ - public interface OnMarkerViewAddedListener { - - /** - * Invoked when the View of a MarkerView has been added to the Map. - * - * @param markerView The MarkerView the View was added for - */ - void onViewAdded(@NonNull MarkerView markerView); - } -} diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java deleted file mode 100644 index 79c72e5f70..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.mapbox.mapboxsdk.annotations; - -import android.graphics.Bitmap; -import android.os.Parcel; -import android.os.Parcelable; - -import com.mapbox.mapboxsdk.exceptions.InvalidMarkerPositionException; -import com.mapbox.mapboxsdk.geometry.LatLng; - -/** - * builder class for composing MarkerView objects. - *

- * Do not extend this class directly but extend {@link BaseMarkerViewOptions} instead. - *

- * @deprecated Use a {@link com.mapbox.mapboxsdk.style.layers.SymbolLayer} instead. An example of converting Android - * SDK views to be used as a symbol see https://github.com/mapbox/mapbox-gl-native/blob/68f32bc104422207c64da8d90e8411b138d87f04/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java - */ -@Deprecated -public class MarkerViewOptions extends BaseMarkerViewOptions { - - private MarkerView marker; - - /** - * Defines default options for a MarkerView. Extend {@link BaseMarkerViewOptions} if you need - * more customization. - */ - public MarkerViewOptions() { - marker = new MarkerView(); - } - - protected MarkerViewOptions(Parcel in) { - marker = new MarkerView(); - position((LatLng) in.readParcelable(LatLng.class.getClassLoader())); - snippet(in.readString()); - title(in.readString()); - flat(in.readByte() != 0); - anchor(in.readFloat(), in.readFloat()); - infoWindowAnchor(in.readFloat(), in.readFloat()); - rotation(in.readFloat()); - visible(in.readByte() != 0); - alpha(in.readFloat()); - if (in.readByte() != 0) { - // this means we have an icon - String iconId = in.readString(); - Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader()); - Icon icon = new Icon(iconId, iconBitmap); - icon(icon); - } - } - - /** - * Get the instance of the object for which this method was called. - * - * @return the object for which this method was called. - */ - @Override - public MarkerViewOptions getThis() { - return this; - } - - /** - * Describe the kinds of special objects contained in this Parcelable's - * marshalled representation. - * - * @return integer 0. - */ - @Override - public int describeContents() { - return 0; - } - - /** - * Flatten this object in to a Parcel. - * - * @param out The Parcel in which the object should be written. - * @param flags Additional flags about how the object should be written. May be 0 or - * {@link #PARCELABLE_WRITE_RETURN_VALUE}. - */ - @Override - public void writeToParcel(Parcel out, int flags) { - out.writeParcelable(getPosition(), flags); - out.writeString(getSnippet()); - out.writeString(getTitle()); - out.writeByte((byte) (isFlat() ? 1 : 0)); - out.writeFloat(getAnchorU()); - out.writeFloat(getAnchorV()); - out.writeFloat(getInfoWindowAnchorU()); - out.writeFloat(getInfoWindowAnchorV()); - out.writeFloat(getRotation()); - out.writeByte((byte) (isVisible() ? 1 : 0)); - out.writeFloat(alpha); - Icon icon = getIcon(); - out.writeByte((byte) (icon != null ? 1 : 0)); - if (icon != null) { - out.writeString(getIcon().getId()); - out.writeParcelable(getIcon().getBitmap(), flags); - } - } - - /** - * Get the {@link MarkerView}. - * - * @return {@link MarkerView}. - */ - @Override - public MarkerView getMarker() { - if (position == null) { - throw new InvalidMarkerPositionException(); - } - - marker.setPosition(position); - marker.setSnippet(snippet); - marker.setTitle(title); - marker.setIcon(icon); - marker.setFlat(flat); - marker.setAnchor(anchorU, anchorV); - marker.setInfoWindowAnchor(infoWindowAnchorU, infoWindowAnchorV); - marker.setRotation(rotation); - marker.setVisible(visible); - marker.setAlpha(alpha); - return marker; - } - - public static final Parcelable.Creator CREATOR = - new Parcelable.Creator() { - public MarkerViewOptions createFromParcel(Parcel in) { - return new MarkerViewOptions(in); - } - - public MarkerViewOptions[] newArray(int size) { - return new MarkerViewOptions[size]; - } - }; - - /** - * Compares this {@link MarkerViewOptions} object with another {@link MarkerViewOptions} and - * determines if they match. - * - * @param object Another {@link MarkerViewOptions} to compare with this object. - * @return True if the {@link MarkerViewOptions} being passed in matches this - * {@link PolylineOptions} object. Else, false. - */ - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - MarkerViewOptions that = (MarkerViewOptions) object; - return marker != null ? marker.equals(that.marker) : that.marker == null; - } - - /** - * Gives an integer which can be used as the bucket number for storing elements of the set/map. - * This bucket number is the address of the element inside the set/map. There's no guarantee - * that this hash value will be consistent between different Java implementations, or even - * between different execution runs of the same program. - * - * @return integer value you can use for storing element. - */ - @Override - public int hashCode() { - return marker != null ? marker.hashCode() : 0; - } -} diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java deleted file mode 100644 index c042b00577..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.mapbox.mapboxsdk.constants; - -import android.support.annotation.IntDef; - -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * MyBearingTracking exposes different types of bearing tracking modes. - *

- * These modes visualise the user direction by extracting the direction from either sensor or location data. - *

- *

- * Required to enable showing the user location first through {@link MapboxMap#setMyLocationEnabled(boolean)}. - *

- * - * @see com.mapbox.mapboxsdk.maps.TrackingSettings#setMyBearingTrackingMode(int) - * @see MyLocationView#setMyBearingTrackingMode(int) - */ -public class MyBearingTracking { - - @IntDef( {NONE, COMPASS, GPS, GPS_NORTH_FACING}) - @Retention(RetentionPolicy.SOURCE) - public @interface Mode { - } - - /** - * Bearing tracking is disabled - */ - public static final int NONE = 0x00000000; - - /** - * Tracking the bearing of the user based on sensor data - */ - public static final int COMPASS = 0x00000004; - - /** - * Tracking the bearing of the user based on GPS data - */ - public static final int GPS = 0x00000008; - - /** - * Tracking the bearing of the user based on GPS data, but camera always faces north direction - */ - public static final int GPS_NORTH_FACING = 0x0000000B; - -} diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java deleted file mode 100644 index 1283283fa5..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyLocationTracking.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.mapbox.mapboxsdk.constants; - -import android.support.annotation.IntDef; - -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.TrackingSettings; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * MyLocationTracking exposes types of location tracking modes. - * *

- * This allows tracking the user location on screen by updating the camera position when a location update occurs. - *

- *

- * Required to enable showing the user location first through {@link MapboxMap#setMyLocationEnabled(boolean)}. - *

- * - * @see MapboxMap#setMyLocationEnabled(boolean) - * @see TrackingSettings#setMyLocationTrackingMode(int) - */ -public class MyLocationTracking { - - @IntDef( {TRACKING_NONE, TRACKING_FOLLOW}) - @Retention(RetentionPolicy.SOURCE) - public @interface Mode { - } - - /** - * Tracking the location of the user is disabled. - */ - public static final int TRACKING_NONE = 0x00000000; - - /** - * Tracking the location of the user. {@link MapView} will reposition to center of {@link MyLocationView} - */ - public static final int TRACKING_FOLLOW = 0x00000004; - -} 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 64b33ad598..9fa7df0dbd 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 @@ -2,21 +2,16 @@ package com.mapbox.mapboxsdk.maps; import android.graphics.Bitmap; import android.graphics.PointF; -import android.graphics.Rect; import android.graphics.RectF; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.util.LongSparseArray; -import android.view.View; import com.mapbox.mapboxsdk.Mapbox; 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.Marker; -import com.mapbox.mapboxsdk.annotations.MarkerView; -import com.mapbox.mapboxsdk.annotations.MarkerViewManager; import com.mapbox.mapboxsdk.annotations.Polygon; import com.mapbox.mapboxsdk.annotations.PolygonOptions; import com.mapbox.mapboxsdk.annotations.Polyline; @@ -31,7 +26,7 @@ import timber.log.Timber; * Responsible for managing and tracking state of Annotations linked to Map. All events related to * annotations that occur on {@link MapboxMap} are forwarded to this class. *

- * Responsible for referencing {@link InfoWindowManager} and {@link MarkerViewManager}. + * Responsible for referencing {@link InfoWindowManager}. *

*

* Exposes convenience methods to add/remove/update all subtypes of annotations found in @@ -45,7 +40,6 @@ class AnnotationManager { private final MapView mapView; private final IconManager iconManager; private final InfoWindowManager infoWindowManager = new InfoWindowManager(); - private final MarkerViewManager markerViewManager; private final LongSparseArray annotationsArray; private final List selectedMarkers = new ArrayList<>(); @@ -60,34 +54,27 @@ class AnnotationManager { private Polygons polygons; private Polylines polylines; - AnnotationManager(NativeMapView view, MapView mapView, LongSparseArray annotationsArray, - MarkerViewManager markerViewManager, IconManager iconManager, Annotations annotations, - Markers markers, Polygons polygons, Polylines polylines, ShapeAnnotations shapeAnnotations) { + AnnotationManager(MapView mapView, LongSparseArray annotationsArray, IconManager iconManager, + Annotations annotations, Markers markers, Polygons polygons, Polylines polylines, + ShapeAnnotations shapeAnnotations) { this.mapView = mapView; this.annotationsArray = annotationsArray; - this.markerViewManager = markerViewManager; this.iconManager = iconManager; this.annotations = annotations; this.markers = markers; this.polygons = polygons; this.polylines = polylines; this.shapeAnnotations = shapeAnnotations; - if (view != null) { - // null checking needed for unit tests - view.addOnMapChangedListener(markerViewManager); - } } // TODO refactor MapboxMap out for Projection and Transform // Requires removing MapboxMap from Annotations by using Peer model from #6912 AnnotationManager bind(MapboxMap mapboxMap) { this.mapboxMap = mapboxMap; - this.markerViewManager.bind(mapboxMap); return this; } void update() { - markerViewManager.update(); infoWindowManager.update(); } @@ -114,13 +101,8 @@ class AnnotationManager { if (selectedMarkers.contains(marker)) { selectedMarkers.remove(marker); } - - if (marker instanceof MarkerView) { - markerViewManager.removeMarkerView((MarkerView) marker); - } else { - // do icon cleanup - iconManager.iconCleanup(marker.getIcon()); - } + // do icon cleanup + iconManager.iconCleanup(marker.getIcon()); } annotations.removeBy(annotation); } @@ -133,12 +115,7 @@ class AnnotationManager { if (selectedMarkers.contains(marker)) { selectedMarkers.remove(marker); } - - if (marker instanceof MarkerView) { - markerViewManager.removeMarkerView((MarkerView) marker); - } else { - iconManager.iconCleanup(marker.getIcon()); - } + iconManager.iconCleanup(marker.getIcon()); } } annotations.removeBy(annotationList); @@ -155,11 +132,7 @@ class AnnotationManager { if (annotation instanceof Marker) { Marker marker = (Marker) annotation; marker.hideInfoWindow(); - if (marker instanceof MarkerView) { - markerViewManager.removeMarkerView((MarkerView) marker); - } else { - iconManager.iconCleanup(marker.getIcon()); - } + iconManager.iconCleanup(marker.getIcon()); } } annotations.removeAll(); @@ -194,20 +167,6 @@ class AnnotationManager { return markers.obtainAllIn(rectangle); } - MarkerView addMarker(@NonNull BaseMarkerViewOptions markerOptions, @NonNull MapboxMap mapboxMap, - @Nullable MarkerViewManager.OnMarkerViewAddedListener onMarkerViewAddedListener) { - return markers.addViewBy(markerOptions, mapboxMap, onMarkerViewAddedListener); - } - - List addMarkerViews(@NonNull List markerViewOptions, - @NonNull MapboxMap mapboxMap) { - return markers.addViewsBy(markerViewOptions, mapboxMap); - } - - List getMarkerViewsInRect(@NonNull RectF rectangle) { - return markers.obtainViewsIn(rectangle); - } - void reloadMarkers() { markers.reload(); } @@ -283,11 +242,6 @@ class AnnotationManager { deselectMarkers(); } - if (marker instanceof MarkerView) { - markerViewManager.select((MarkerView) marker, false); - markerViewManager.ensureInfoWindowOffset((MarkerView) marker); - } - if (infoWindowManager.isInfoWindowValidForMarker(marker) || infoWindowManager.getInfoWindowAdapter() != null) { infoWindowManager.add(marker.showInfoWindow(mapboxMap, mapView)); } @@ -306,10 +260,6 @@ class AnnotationManager { if (marker.isInfoWindowShown()) { marker.hideInfoWindow(); } - - if (marker instanceof MarkerView) { - markerViewManager.deselect((MarkerView) marker, false); - } } } @@ -326,10 +276,6 @@ class AnnotationManager { marker.hideInfoWindow(); } - if (marker instanceof MarkerView) { - markerViewManager.deselect((MarkerView) marker, false); - } - selectedMarkers.remove(marker); } @@ -341,10 +287,6 @@ class AnnotationManager { return infoWindowManager; } - MarkerViewManager getMarkerViewManager() { - return markerViewManager; - } - void adjustTopOffsetPixels(MapboxMap mapboxMap) { int count = annotationsArray.size(); for (int i = 0; i < count; i++) { @@ -424,13 +366,8 @@ class AnnotationManager { } private boolean isClickHandledForMarker(long markerId) { - boolean handledDefaultClick; Marker marker = (Marker) getAnnotation(markerId); - if (marker instanceof MarkerView) { - handledDefaultClick = markerViewManager.onClickMarkerView((MarkerView) marker); - } else { - handledDefaultClick = onClickMarker(marker); - } + boolean handledDefaultClick = onClickMarker(marker); if (!handledDefaultClick) { toggleMarkerSelectionState(marker); @@ -470,21 +407,17 @@ class AnnotationManager { private static class MarkerHitResolver { - private final MarkerViewManager markerViewManager; private final Projection projection; - private View view; private Bitmap bitmap; private PointF markerLocation; - private Rect hitRectView = new Rect(); private RectF hitRectMarker = new RectF(); private RectF highestSurfaceIntersection = new RectF(); private long closestMarkerId = NO_ANNOTATION_ID; MarkerHitResolver(@NonNull MapboxMap mapboxMap) { - this.markerViewManager = mapboxMap.getMarkerViewManager(); this.projection = mapboxMap.getProjection(); } @@ -495,20 +428,7 @@ class AnnotationManager { private void resolveForMarkers(MarkerHit markerHit) { for (Marker marker : markerHit.markers) { - if (marker instanceof MarkerView) { - resolveForMarkerView(markerHit, (MarkerView) marker); - } else { - resolveForMarker(markerHit, marker); - } - } - } - - private void resolveForMarkerView(MarkerHit markerHit, MarkerView markerView) { - view = markerViewManager.getView(markerView); - if (view != null) { - view.getHitRect(hitRectView); - hitRectMarker = new RectF(hitRectView); - hitTestMarker(markerHit, markerView, hitRectMarker); + resolveForMarker(markerHit, marker); } } 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 80ffa973e7..ffb9b459c0 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 @@ -6,7 +6,6 @@ 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 java.util.HashMap; import java.util.List; @@ -15,8 +14,7 @@ import java.util.Map; /** * Responsible for managing icons added to the Map. *

- * Maintains a {@link List} of {@link Icon} and is responsible for initialising default markers and - * setting up {@link MarkerView} annotation ghosting. + * Maintains a {@link List} of {@link Icon} and is responsible for initialising default markers. *

*

* Keep track of icons added and the resulting average icon size. This is used internally by our @@ -50,13 +48,6 @@ class IconManager { return icon; } - void loadIconForMarkerView(MarkerView marker) { - Icon icon = marker.getIcon(); - Bitmap bitmap = icon.getBitmap(); - updateHighestIconSize(bitmap); - addIcon(icon, false); - } - 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 8047e19809..6675161390 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 @@ -41,7 +41,6 @@ final class MapGestureDetector { private final Transform transform; private final Projection projection; private final UiSettings uiSettings; - private final TrackingSettings trackingSettings; private final AnnotationManager annotationManager; private final CameraChangeDispatcher cameraChangeDispatcher; @@ -89,13 +88,11 @@ final class MapGestureDetector { private boolean rotateGestureOccurred; MapGestureDetector(Context context, Transform transform, Projection projection, UiSettings uiSettings, - TrackingSettings trackingSettings, AnnotationManager annotationManager, - CameraChangeDispatcher cameraChangeDispatcher) { + AnnotationManager annotationManager, CameraChangeDispatcher cameraChangeDispatcher) { this.annotationManager = annotationManager; this.transform = transform; this.projection = projection; this.uiSettings = uiSettings; - this.trackingSettings = trackingSettings; this.cameraChangeDispatcher = cameraChangeDispatcher; // Touch gesture detectors @@ -131,10 +128,6 @@ final class MapGestureDetector { /** * Get the current active gesture focal point. - *

- * 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)}. - *

* * @return the current active gesture focal point. */ @@ -400,7 +393,7 @@ final class MapGestureDetector { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || recentScaleGestureOccurred) { + if (recentScaleGestureOccurred) { // don't allow a fling is scroll is disabled // and ignore when a scale gesture has occurred return false; @@ -415,8 +408,6 @@ final class MapGestureDetector { return false; } - trackingSettings.resetTrackingModesIfRequired(true, false, false); - // cancel any animation transform.cancelTransitions(); @@ -441,10 +432,6 @@ final class MapGestureDetector { // Called for drags @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { - if (!trackingSettings.isScrollGestureCurrentlyEnabled()) { - return false; - } - if (tiltGestureOccurred) { return false; } @@ -467,9 +454,6 @@ final class MapGestureDetector { } } - // reset tracking if needed - trackingSettings.resetTrackingModesIfRequired(true, false, false); - // Scroll the map transform.moveBy(-distanceX, -distanceY, 0 /*no duration*/); @@ -596,10 +580,6 @@ final class MapGestureDetector { } quickZoom = !twoTap; - // make an assumption here; if the zoom center is specified by the gesture, it's NOT going - // to be in the center of the map. Therefore the zoom will translate the map center, so tracking - // should be disabled. - trackingSettings.resetTrackingModesIfRequired(!quickZoom, false, false); // Scale the map if (focalPoint != null) { // arround user provided focal point @@ -711,10 +691,6 @@ final class MapGestureDetector { // Called when two fingers first touch the screen @Override public boolean onRotateBegin(RotateGestureDetector detector) { - if (!trackingSettings.isRotateGestureCurrentlyEnabled()) { - return false; - } - // notify camera change listener cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); @@ -726,7 +702,7 @@ final class MapGestureDetector { // Called for rotation @Override public boolean onRotate(RotateGestureDetector detector) { - if (!trackingSettings.isRotateGestureCurrentlyEnabled() || tiltGestureOccurred) { + if (tiltGestureOccurred) { return false; } @@ -753,10 +729,6 @@ final class MapGestureDetector { rotateGestureOccurred = true; } - // rotation constitutes translation of anything except the center of - // rotation, so cancel both location and bearing tracking if required - trackingSettings.resetTrackingModesIfRequired(true, true, false); - // Calculate map bearing value double bearing = transform.getRawBearing() + angle; 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 d1f01a30f7..1e6c8762a1 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 @@ -13,23 +13,19 @@ import android.view.ViewConfiguration; *

*

    *
  • Uses {@link Transform} to change the map state
  • - *
  • Uses {@link TrackingSettings} to verify validity of the current tracking mode.
  • *
  • Uses {@link UiSettings} to verify validity of user restricted movement.
  • *
*

*/ final class MapKeyListener { - private final TrackingSettings trackingSettings; private final Transform transform; private final UiSettings uiSettings; private TrackballLongPressTimeOut currentTrackballLongPressTimeOut; - MapKeyListener(@NonNull Transform transform, @NonNull TrackingSettings trackingSettings, - @NonNull UiSettings uiSettings) { + MapKeyListener(@NonNull Transform transform, @NonNull UiSettings uiSettings) { this.transform = transform; - this.trackingSettings = trackingSettings; this.uiSettings = uiSettings; } @@ -55,10 +51,6 @@ final class MapKeyListener { return true; case KeyEvent.KEYCODE_DPAD_LEFT: - if (!trackingSettings.isScrollGestureCurrentlyEnabled()) { - return false; - } - // Cancel any animation transform.cancelTransitions(); @@ -67,10 +59,6 @@ final class MapKeyListener { return true; case KeyEvent.KEYCODE_DPAD_RIGHT: - if (!trackingSettings.isScrollGestureCurrentlyEnabled()) { - return false; - } - // Cancel any animation transform.cancelTransitions(); @@ -79,10 +67,6 @@ final class MapKeyListener { return true; case KeyEvent.KEYCODE_DPAD_UP: - if (!trackingSettings.isScrollGestureCurrentlyEnabled()) { - return false; - } - // Cancel any animation transform.cancelTransitions(); @@ -91,10 +75,6 @@ final class MapKeyListener { return true; case KeyEvent.KEYCODE_DPAD_DOWN: - if (!trackingSettings.isScrollGestureCurrentlyEnabled()) { - return false; - } - // Cancel any animation transform.cancelTransitions(); @@ -183,10 +163,6 @@ final class MapKeyListener { switch (event.getActionMasked()) { // The trackball was rotated case MotionEvent.ACTION_MOVE: - if (!trackingSettings.isScrollGestureCurrentlyEnabled()) { - return false; - } - // Cancel any animation transform.cancelTransitions(); 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 a921d14038..a8fb320631 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 @@ -17,7 +17,6 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.TextureView; import android.view.View; -import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.FrameLayout; import android.widget.ImageView; @@ -30,15 +29,12 @@ import com.mapbox.android.telemetry.MapboxTelemetry; import com.mapbox.mapboxsdk.BuildConfig; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.annotations.Annotation; -import com.mapbox.mapboxsdk.annotations.MarkerViewManager; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.maps.renderer.MapRenderer; import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer; import com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewMapRenderer; import com.mapbox.mapboxsdk.maps.widgets.CompassView; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings; import com.mapbox.mapboxsdk.net.ConnectivityReceiver; import com.mapbox.mapboxsdk.storage.FileSource; @@ -82,7 +78,6 @@ public class MapView extends FrameLayout { private boolean destroyed; private boolean hasSurface; - private MyLocationView myLocationView; private CompassView compassView; private PointF focalPoint; private ImageView attrView; @@ -130,7 +125,6 @@ public class MapView extends FrameLayout { // inflate view View view = LayoutInflater.from(context).inflate(R.layout.mapbox_mapview_internal, this); compassView = (CompassView) view.findViewById(R.id.compassView); - myLocationView = (MyLocationView) view.findViewById(R.id.userLocationView); attrView = (ImageView) view.findViewById(R.id.attributionView); logoView = (ImageView) view.findViewById(R.id.logoView); @@ -152,42 +146,33 @@ public class MapView extends FrameLayout { // callback for registering touch listeners RegisterTouchListener registerTouchListener = new RegisterTouchListener(); - // callback for zooming in the camera - CameraZoomInvalidator zoomInvalidator = new CameraZoomInvalidator(); - // callback for camera change events final CameraChangeDispatcher cameraChangeDispatcher = new CameraChangeDispatcher(); // setup components for MapboxMap creation Projection proj = new Projection(nativeMapView); UiSettings uiSettings = new UiSettings(proj, focalPointInvalidator, compassView, attrView, logoView); - TrackingSettings trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointInvalidator, - zoomInvalidator); - MyLocationViewSettings myLocationViewSettings = new MyLocationViewSettings(myLocationView, proj, - focalPointInvalidator); LongSparseArray annotationsArray = new LongSparseArray<>(); - MarkerViewManager markerViewManager = new MarkerViewManager((ViewGroup) findViewById(R.id.markerViewContainer)); IconManager iconManager = new IconManager(nativeMapView); Annotations annotations = new AnnotationContainer(nativeMapView, annotationsArray); - Markers markers = new MarkerContainer(nativeMapView, this, annotationsArray, iconManager, markerViewManager); + Markers markers = new MarkerContainer(nativeMapView, annotationsArray, iconManager); Polygons polygons = new PolygonContainer(nativeMapView, annotationsArray); Polylines polylines = new PolylineContainer(nativeMapView, annotationsArray); ShapeAnnotations shapeAnnotations = new ShapeAnnotationContainer(nativeMapView, annotationsArray); - AnnotationManager annotationManager = new AnnotationManager(nativeMapView, this, annotationsArray, - markerViewManager, iconManager, annotations, markers, polygons, polylines, shapeAnnotations); - Transform transform = new Transform(nativeMapView, annotationManager.getMarkerViewManager(), trackingSettings, - cameraChangeDispatcher); + AnnotationManager annotationManager = new AnnotationManager(this, annotationsArray, iconManager, + annotations, markers, polygons, polylines, shapeAnnotations); + Transform transform = new Transform(nativeMapView, cameraChangeDispatcher); - mapboxMap = new MapboxMap(nativeMapView, transform, uiSettings, trackingSettings, myLocationViewSettings, proj, - registerTouchListener, annotationManager, cameraChangeDispatcher); + mapboxMap = new MapboxMap(nativeMapView, transform, uiSettings, proj, registerTouchListener, + annotationManager, cameraChangeDispatcher); focalPointInvalidator.addListener(mapboxMap.createFocalPointChangeListener()); mapCallback.attachMapboxMap(mapboxMap); // user input - mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings, trackingSettings, - annotationManager, cameraChangeDispatcher); - mapKeyListener = new MapKeyListener(transform, trackingSettings, uiSettings); + mapGestureDetector = new MapGestureDetector(context, transform, proj, + uiSettings, annotationManager, cameraChangeDispatcher); + mapKeyListener = new MapKeyListener(transform, uiSettings); // overlain zoom buttons mapZoomButtonController = new MapZoomButtonController(new ZoomButtonsController(this)); @@ -197,8 +182,6 @@ public class MapView extends FrameLayout { compassView.injectCompassAnimationListener(createCompassAnimationListener(cameraChangeDispatcher)); compassView.setOnClickListener(createCompassClickListener(cameraChangeDispatcher)); - // inject widgets with MapboxMap - myLocationView.setMapboxMap(mapboxMap); attrView.setOnClickListener(new AttributionClickListener(context, mapboxMap)); // Ensure this view is interactable @@ -1031,27 +1014,6 @@ public class MapView extends FrameLayout { } } - private class CameraZoomInvalidator implements TrackingSettings.CameraZoomInvalidator { - - @Override - public void zoomTo(double zoomLevel) { - Transform transform = mapboxMap.getTransform(); - double currentZoomLevel = transform.getCameraPosition().zoom; - if (currentZoomLevel < 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); - } - } - } - private static class MapCallback implements OnMapChangedListener { private MapboxMap mapboxMap; @@ -1068,7 +1030,6 @@ public class MapView extends FrameLayout { initialLoad = false; mapboxMap.onPreMapReady(); onMapReady(); - 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) { 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 4f2c940ea3..5c171fe43f 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 @@ -4,27 +4,21 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.PointF; import android.graphics.RectF; -import android.location.Location; import android.os.Bundle; import android.support.annotation.FloatRange; import android.support.annotation.IntRange; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.UiThread; -import android.support.v4.util.Pools; import android.text.TextUtils; import android.view.View; -import android.view.ViewGroup; import com.mapbox.geojson.Feature; import com.mapbox.geojson.Geometry; import com.mapbox.mapboxsdk.annotations.Annotation; import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions; -import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.MarkerOptions; -import com.mapbox.mapboxsdk.annotations.MarkerView; -import com.mapbox.mapboxsdk.annotations.MarkerViewManager; import com.mapbox.mapboxsdk.annotations.Polygon; import com.mapbox.mapboxsdk.annotations.PolygonOptions; import com.mapbox.mapboxsdk.annotations.Polyline; @@ -33,19 +27,14 @@ import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdate; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.constants.MapboxConstants; -import com.mapbox.mapboxsdk.constants.MyBearingTracking; -import com.mapbox.mapboxsdk.constants.MyLocationTracking; import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings; import com.mapbox.mapboxsdk.style.layers.Filter; import com.mapbox.mapboxsdk.style.layers.Layer; import com.mapbox.mapboxsdk.style.light.Light; import com.mapbox.mapboxsdk.style.sources.Source; -import com.mapbox.android.core.location.LocationEngine; -import java.lang.reflect.ParameterizedType; import java.util.HashMap; import java.util.List; @@ -66,11 +55,9 @@ public final class MapboxMap { private final NativeMapView nativeMapView; private final UiSettings uiSettings; - private final TrackingSettings trackingSettings; private final Projection projection; private final Transform transform; private final AnnotationManager annotationManager; - private final MyLocationViewSettings myLocationViewSettings; private final CameraChangeDispatcher cameraChangeDispatcher; private final OnRegisterTouchListener onRegisterTouchListener; @@ -78,14 +65,11 @@ public final class MapboxMap { private MapboxMap.OnFpsChangedListener onFpsChangedListener; private PointF focalPoint; - MapboxMap(NativeMapView map, Transform transform, UiSettings ui, TrackingSettings tracking, - MyLocationViewSettings myLocationView, Projection projection, OnRegisterTouchListener listener, + MapboxMap(NativeMapView map, Transform transform, UiSettings ui, Projection proj, OnRegisterTouchListener listener, AnnotationManager annotations, CameraChangeDispatcher cameraChangeDispatcher) { this.nativeMapView = map; this.uiSettings = ui; - this.trackingSettings = tracking; - this.projection = projection; - this.myLocationViewSettings = myLocationView; + this.projection = proj; this.annotationManager = annotations.bind(this); this.transform = transform; this.onRegisterTouchListener = listener; @@ -95,8 +79,6 @@ public final class MapboxMap { void initialise(@NonNull Context context, @NonNull MapboxMapOptions options) { transform.initialise(this, options); uiSettings.initialise(context, options); - myLocationViewSettings.initialise(options); - trackingSettings.initialise(options); // Map configuration setDebugActive(options.getDebugActive()); @@ -110,7 +92,6 @@ public final class MapboxMap { */ void onStart() { nativeMapView.update(); - trackingSettings.onStart(); if (TextUtils.isEmpty(nativeMapView.getStyleUrl())) { // if user hasn't loaded a Style yet nativeMapView.setStyleUrl(Style.MAPBOX_STREETS); @@ -121,7 +102,6 @@ public final class MapboxMap { * Called when the hosting Activity/Fragment onStop() method is called. */ void onStop() { - trackingSettings.onStop(); } /** @@ -133,9 +113,7 @@ public final class MapboxMap { outState.putParcelable(MapboxConstants.STATE_CAMERA_POSITION, transform.getCameraPosition()); outState.putBoolean(MapboxConstants.STATE_DEBUG_ACTIVE, nativeMapView.getDebug()); outState.putString(MapboxConstants.STATE_STYLE_URL, nativeMapView.getStyleUrl()); - trackingSettings.onSaveInstanceState(outState); uiSettings.onSaveInstanceState(outState); - myLocationViewSettings.onSaveInstanceState(outState); } /** @@ -145,19 +123,11 @@ public final class MapboxMap { */ void onRestoreInstanceState(Bundle savedInstanceState) { final CameraPosition cameraPosition = savedInstanceState.getParcelable(MapboxConstants.STATE_CAMERA_POSITION); - - myLocationViewSettings.onRestoreInstanceState(savedInstanceState); uiSettings.onRestoreInstanceState(savedInstanceState); - trackingSettings.onRestoreInstanceState(savedInstanceState); - if (cameraPosition != null) { - moveCamera(CameraUpdateFactory.newCameraPosition( - new CameraPosition.Builder(cameraPosition).build()) - ); + moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder(cameraPosition).build())); } - nativeMapView.setDebug(savedInstanceState.getBoolean(MapboxConstants.STATE_DEBUG_ACTIVE)); - final String styleUrl = savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL); if (!TextUtils.isEmpty(styleUrl)) { nativeMapView.setStyleUrl(savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL)); @@ -172,22 +142,10 @@ public final class MapboxMap { annotationManager.adjustTopOffsetPixels(this); } - /** - * Called when the OnMapReadyCallback has finished executing. - *

- * Invalidation of the camera position is required to update the added components in - * OnMapReadyCallback with the correct transformation. - *

- */ - void onPostMapReady() { - invalidateCameraPosition(); - } - /** * Called when the region is changing or has changed. */ void onUpdateRegionChange() { - trackingSettings.update(); annotationManager.update(); } @@ -554,38 +512,6 @@ public final class MapboxMap { return uiSettings; } - // - // TrackingSettings - // - - /** - * 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/plugin-locationlayer instead. - */ - @Deprecated - public TrackingSettings getTrackingSettings() { - return trackingSettings; - } - - // - // MyLocationViewSettings - // - - /** - * 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/plugin-locationlayer instead. - */ - @Deprecated - public MyLocationViewSettings getMyLocationViewSettings() { - return myLocationViewSettings; - } - // // Projection // @@ -804,11 +730,6 @@ public final class MapboxMap { * unless specified within {@link CameraUpdate}. A callback can be used to be notified when * easing the camera stops. If {@link #getCameraPosition()} is called during the animation, it * will return the current location of the camera in flight. - *

- * Note that this will cancel location tracking mode if enabled. You can change this behaviour by calling - * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setDismissLocationTrackingOnGesture(boolean)} with false before - * invoking this method and calling it with true in the {@link CancelableCallback#onFinish()}. - *

* * @param update The change that should be applied to the camera. * @param durationMs The duration of the animation in milliseconds. This must be strictly @@ -830,11 +751,6 @@ public final class MapboxMap { * unless specified within {@link CameraUpdate}. A callback can be used to be notified when * easing the camera stops. If {@link #getCameraPosition()} is called during the animation, it * will return the current location of the camera in flight. - *

- * Note that this will cancel location tracking mode if enabled. You can change this behaviour by calling - * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setDismissLocationTrackingOnGesture(boolean)} with false before - * invoking this method and calling it with true in the {@link CancelableCallback#onFinish()}. - *

* * @param update The change that should be applied to the camera. * @param durationMs The duration of the animation in milliseconds. This must be strictly @@ -927,16 +843,6 @@ public final class MapboxMap { transform.animateCamera(MapboxMap.this, update, durationMs, callback); } - /** - * Invalidates the current camera position by reconstructing it from mbgl - */ - void invalidateCameraPosition() { - CameraPosition cameraPosition = transform.invalidateCameraPosition(); - if (cameraPosition != null) { - transform.updateCameraPosition(cameraPosition); - } - } - // // Reset North // @@ -1221,77 +1127,6 @@ public final class MapboxMap { return annotationManager.addMarker(markerOptions, this); } - /** - *

- * Adds a marker to this map. - *

- * 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 - * @deprecated Use a {@link com.mapbox.mapboxsdk.style.layers.SymbolLayer} instead. An example of converting Android - * SDK views to be used as a symbol see https://github.com/mapbox/mapbox-gl-native/blob/68f32bc104422207c64da8d90e8411b138d87f04/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java - */ - @NonNull - @Deprecated - public MarkerView addMarker(@NonNull BaseMarkerViewOptions markerOptions) { - return annotationManager.addMarker(markerOptions, this, null); - } - - /** - *

- * Adds a marker to this map. - *

- * 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 - * @deprecated Use a {@link com.mapbox.mapboxsdk.style.layers.SymbolLayer} instead. An example of converting Android - * SDK views to be used as a symbol see https://github.com/mapbox/mapbox-gl-native/blob/68f32bc104422207c64da8d90e8411b138d87f04/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java - */ - @Deprecated - @NonNull - public MarkerView addMarker(@NonNull BaseMarkerViewOptions markerOptions, - final MarkerViewManager.OnMarkerViewAddedListener onMarkerViewAddedListener) { - return annotationManager.addMarker(markerOptions, this, onMarkerViewAddedListener); - } - - /** - * Adds multiple markersViews to this map. - *

- * 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 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 - * @deprecated Use a {@link com.mapbox.mapboxsdk.style.layers.SymbolLayer} instead. An example of converting Android - * SDK views to be used as a symbol see https://github.com/mapbox/mapbox-gl-native/blob/68f32bc104422207c64da8d90e8411b138d87f04/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java - */ - @NonNull - @Deprecated - public List addMarkerViews(@NonNull List markerViewOptions) { - return annotationManager.addMarkerViews(markerViewOptions, this); - } - - /** - * 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 - * @deprecated Use a {@link com.mapbox.mapboxsdk.style.layers.SymbolLayer} instead. An example of converting Android - * SDK views to be used as a symbol see https://github.com/mapbox/mapbox-gl-native/blob/68f32bc104422207c64da8d90e8411b138d87f04/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java - */ - @NonNull - @Deprecated - public List getMarkerViewsInRect(@NonNull RectF rect) { - return annotationManager.getMarkerViewsInRect(rect); - } - /** *

* Adds multiple markers to this map. @@ -1586,15 +1421,6 @@ public final class MapboxMap { return annotationManager.getSelectedMarkers(); } - /** - * Get the MarkerViewManager associated to the MapView. - * - * @return the associated MarkerViewManager - */ - public MarkerViewManager getMarkerViewManager() { - return annotationManager.getMarkerViewManager(); - } - // // InfoWindow // @@ -1670,7 +1496,7 @@ public final class MapboxMap { for (int i = 0; i < padding.length; i++) { padding[i] = mapPadding[i] + padding[i]; } - projection.setContentPadding(padding, myLocationViewSettings.getPadding()); + projection.setContentPadding(padding); // get padded camera position from LatLngBounds CameraPosition cameraPosition = nativeMapView.getCameraForLatLngBounds(latLngBounds); @@ -1694,7 +1520,7 @@ public final class MapboxMap { for (int i = 0; i < padding.length; i++) { padding[i] = mapPadding[i] + padding[i]; } - projection.setContentPadding(padding, myLocationViewSettings.getPadding()); + projection.setContentPadding(padding); // get padded camera position from LatLngBounds CameraPosition cameraPosition = nativeMapView.getCameraForGeometry(geometry, bearing); @@ -1731,7 +1557,7 @@ public final class MapboxMap { } private void setPadding(int[] padding) { - projection.setContentPadding(padding, myLocationViewSettings.getPadding()); + projection.setContentPadding(padding); uiSettings.invalidate(); } @@ -2080,107 +1906,6 @@ public final class MapboxMap { return annotationManager.getInfoWindowManager().getOnInfoWindowCloseListener(); } - // - // User location - // - - /** - * 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/plugin-locationlayer instead. - */ - @Deprecated - public boolean isMyLocationEnabled() { - return trackingSettings.isMyLocationEnabled(); - } - - /** - *

- * Enables or disables the my-location layer. - * While enabled, the my-location layer continuously draws an indication of a user's current - * location and bearing. - *

- * In order to use the my-location layer feature you need to request permission for either - * 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/plugin-locationlayer instead. - */ - @Deprecated - public void setMyLocationEnabled(boolean enabled) { - trackingSettings.setMyLocationEnabled(enabled); - } - - /** - * 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/plugin-locationlayer instead. - */ - @Nullable - @Deprecated - public Location getMyLocation() { - return trackingSettings.getMyLocation(); - } - - /** - * Sets a callback that's invoked when the the My Location view - * (which signifies the user's location) changes location. - * - * @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/plugin-locationlayer instead. - */ - @Deprecated - public void setOnMyLocationChangeListener(@Nullable MapboxMap.OnMyLocationChangeListener - listener) { - trackingSettings.setOnMyLocationChangeListener(listener); - } - - /** - * 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/plugin-locationlayer instead. - */ - @Deprecated - public void setLocationSource(@Nullable LocationEngine locationSource) { - trackingSettings.setLocationSource(locationSource); - } - - /** - * Sets a callback that's invoked when the location tracking mode changes. - * - * @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/plugin-locationlayer instead. - */ - @Deprecated - public void setOnMyLocationTrackingModeChangeListener( - @Nullable MapboxMap.OnMyLocationTrackingModeChangeListener listener) { - trackingSettings.setOnMyLocationTrackingModeChangeListener(listener); - } - - /** - * Sets a callback that's invoked when the bearing tracking mode changes. - * - * @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/plugin-locationlayer instead. - */ - @Deprecated - public void setOnMyBearingTrackingModeChangeListener(@Nullable OnMyBearingTrackingModeChangeListener listener) { - trackingSettings.setOnMyBearingTrackingModeChangeListener(listener); - } - // // Invalidate // @@ -2548,187 +2273,6 @@ public final class MapboxMap { View getInfoWindow(@NonNull Marker marker); } - /** - * Interface definition for a callback to be invoked when an MarkerView will be shown. - * - * @param the instance type of MarkerView - * @deprecated Use a {@link com.mapbox.mapboxsdk.style.layers.SymbolLayer} instead. An example of converting Android - * SDK views to be used as a symbol see https://github.com/mapbox/mapbox-gl-native/blob/68f32bc104422207c64da8d90e8411b138d87f04/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java - */ - @Deprecated - public abstract static class MarkerViewAdapter { - - private Context context; - private final Class persistentClass; - private final Pools.SimplePool viewReusePool; - - /** - * Create an instance of MarkerViewAdapter. - * - * @param context the context associated to a MapView - */ - @SuppressWarnings("unchecked") - public MarkerViewAdapter(Context context) { - this.context = context; - persistentClass = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; - viewReusePool = new Pools.SimplePool<>(10000); - } - - /** - * Called when an MarkerView will be added to the MapView. - * - * @param marker the model representing the MarkerView - * @param convertView the reusable view - * @param parent the parent ViewGroup of the convertview - * @return the View that is adapted to the contents of MarkerView - */ - @Nullable - public abstract View getView(@NonNull U marker, @Nullable View convertView, @NonNull ViewGroup parent); - - /** - * Called when an MarkerView is removed from the MapView or the View object is going to be reused. - *

- * This method should be used to reset an animated view back to it's original state for view reuse. - *

- *

- * Returning true indicates you want to the view reuse to be handled automatically. - * Returning false indicates you want to perform an animation and you are required calling - * {@link #releaseView(View)} yourself. - *

- * - * @param marker the model representing the MarkerView - * @param convertView the reusable view - * @return true if you want reuse to occur automatically, false if you want to manage this yourself. - */ - public boolean prepareViewForReuse(@NonNull MarkerView marker, @NonNull View convertView) { - return true; - } - - /** - * Called when a MarkerView is selected from the MapView. - *

- * Returning true from this method indicates you want to move the MarkerView to the selected state. - * Returning false indicates you want to animate the View first an manually select the MarkerView when appropriate. - *

- * - * @param marker the model representing the MarkerView - * @param convertView the reusable view - * @param reselectionFromRecycling indicates if the onSelect callback is the initial selection - * callback or that selection occurs due to recreation of selected marker - * @return true if you want to select the Marker immediately, false if you want to manage this yourself. - */ - public boolean onSelect(@NonNull U marker, @NonNull View convertView, boolean reselectionFromRecycling) { - return true; - } - - /** - * Called when a MarkerView is deselected from the MapView. - * - * @param marker the model representing the MarkerView - * @param convertView the reusable view - */ - public void onDeselect(@NonNull U marker, @NonNull View convertView) { - } - - /** - * Returns the generic type of the used MarkerView. - * - * @return the generic type - */ - public final Class getMarkerClass() { - return persistentClass; - } - - /** - * Returns the pool used to store reusable Views. - * - * @return the pool associated to this adapter - */ - public final Pools.SimplePool getViewReusePool() { - return viewReusePool; - } - - /** - * Returns the context associated to the hosting MapView. - * - * @return the context used - */ - public final Context getContext() { - return context; - } - - /** - * Release a View to the ViewPool. - * - * @param view the view to be released - */ - public final void releaseView(View view) { - view.setVisibility(View.GONE); - viewReusePool.release(view); - } - } - - /** - * Interface definition for a callback to be invoked when the user clicks on a MarkerView. - */ - public interface OnMarkerViewClickListener { - - /** - * Called when the user clicks on a MarkerView. - * - * @param marker the MarkerView associated to the clicked View - * @param view the clicked View - * @param adapter the adapter used to adapt the MarkerView to the View - * @return If true the listener has consumed the event and the info window will not be shown - */ - boolean onMarkerClick(@NonNull Marker marker, @NonNull View view, @NonNull MarkerViewAdapter adapter); - } - - /** - * Interface definition for a callback to be invoked when the the My Location view changes location. - * - * @see MapboxMap#setOnMyLocationChangeListener(OnMyLocationChangeListener) - */ - public interface OnMyLocationChangeListener { - /** - * Called when the location of the My Location view has changed - * (be it latitude/longitude, bearing or accuracy). - * - * @param location The current location of the My Location view The type of map change event. - */ - void onMyLocationChange(@Nullable Location location); - } - - /** - * Interface definition for a callback to be invoked when the the My Location tracking mode changes. - * - * @see TrackingSettings#setMyLocationTrackingMode(int) - */ - public interface OnMyLocationTrackingModeChangeListener { - - /** - * Called when the tracking mode of My Location tracking has changed - * - * @param myLocationTrackingMode the current active location tracking mode - */ - void onMyLocationTrackingModeChange(@MyLocationTracking.Mode int myLocationTrackingMode); - } - - /** - * Interface definition for a callback to be invoked when the the My Location tracking mode changes. - * - * @see TrackingSettings#setMyLocationTrackingMode(int) - */ - public interface OnMyBearingTrackingModeChangeListener { - - /** - * Called when the tracking mode of My Bearing tracking has changed - * - * @param myBearingTrackingMode the current active bearing tracking mode - */ - void onMyBearingTrackingModeChange(@MyBearingTracking.Mode int myBearingTrackingMode); - } - /** * Interface definition for a callback to be invoked when a task is complete or cancelled. */ diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MarkerContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MarkerContainer.java index 2c2f07a112..c00b4ed90d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MarkerContainer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MarkerContainer.java @@ -3,17 +3,12 @@ package com.mapbox.mapboxsdk.maps; import android.graphics.RectF; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.support.v4.util.LongSparseArray; 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; import java.util.ArrayList; import java.util.List; @@ -24,18 +19,13 @@ import java.util.List; class MarkerContainer implements Markers { private final NativeMapView nativeMapView; - private final MapView mapView; private final LongSparseArray annotations; private final IconManager iconManager; - private final MarkerViewManager markerViewManager; - MarkerContainer(NativeMapView nativeMapView, MapView mapView, LongSparseArray annotations, IconManager - iconManager, MarkerViewManager markerViewManager) { + MarkerContainer(NativeMapView nativeMapView, LongSparseArray annotations, IconManager iconManager) { this.nativeMapView = nativeMapView; - this.mapView = mapView; this.annotations = annotations; this.iconManager = iconManager; - this.markerViewManager = markerViewManager; } @Override @@ -77,7 +67,6 @@ class MarkerContainer implements Markers { @Override public void update(@NonNull Marker updatedMarker, @NonNull MapboxMap mapboxMap) { - ensureIconLoaded(updatedMarker, mapboxMap); nativeMapView.updateMarker(updatedMarker); annotations.setValueAt(annotations.indexOfKey(updatedMarker.getId()), updatedMarker); } @@ -118,76 +107,6 @@ class MarkerContainer implements Markers { return new ArrayList<>(annotations); } - @Override - public MarkerView addViewBy(@NonNull BaseMarkerViewOptions markerOptions, @NonNull MapboxMap mapboxMap, @Nullable - MarkerViewManager.OnMarkerViewAddedListener onMarkerViewAddedListener) { - final MarkerView marker = prepareViewMarker(markerOptions); - - // add marker to map - marker.setMapboxMap(mapboxMap); - long id = nativeMapView.addMarker(marker); - marker.setId(id); - annotations.put(id, marker); - - if (onMarkerViewAddedListener != null) { - markerViewManager.addOnMarkerViewAddedListener(marker, onMarkerViewAddedListener); - } - markerViewManager.setEnabled(true); - markerViewManager.setWaitingForRenderInvoke(true); - return marker; - } - - @Override - public List addViewsBy(@NonNull List markerViewOptions, @NonNull - MapboxMap mapboxMap) { - List 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; - } - - @Override - public List obtainViewsIn(@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 idsList = new ArrayList<>(ids.length); - for (long id : ids) { - idsList.add(id); - } - - List annotations = new ArrayList<>(ids.length); - List annotationList = obtainAnnotations(); - 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); - } - @Override public void reload() { iconManager.reloadIcons(); @@ -210,12 +129,6 @@ class MarkerContainer implements Markers { return marker; } - private void ensureIconLoaded(Marker marker, MapboxMap mapboxMap) { - if (!(marker instanceof MarkerView)) { - iconManager.ensureIconLoaded(marker, mapboxMap); - } - } - private List obtainAnnotations() { List annotations = new ArrayList<>(); for (int i = 0; i < this.annotations.size(); i++) { @@ -223,15 +136,4 @@ class MarkerContainer implements Markers { } return annotations; } - - private MarkerView prepareViewMarker(BaseMarkerViewOptions markerViewOptions) { - MarkerView marker = markerViewOptions.getMarker(); - Icon icon = markerViewOptions.getIcon(); - if (icon == null) { - icon = IconFactory.getInstance(mapView.getContext()).defaultMarkerView(); - } - iconManager.loadIconForMarkerView(marker); - marker.setIcon(icon); - return marker; - } } \ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java index d646e0ac49..a58f079e27 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java @@ -3,13 +3,9 @@ package com.mapbox.mapboxsdk.maps; import android.graphics.RectF; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions; -import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions; import com.mapbox.mapboxsdk.annotations.Marker; -import com.mapbox.mapboxsdk.annotations.MarkerView; -import com.mapbox.mapboxsdk.annotations.MarkerViewManager; import java.util.List; @@ -27,13 +23,5 @@ interface Markers { List obtainAllIn(@NonNull RectF rectangle); - MarkerView addViewBy(@NonNull BaseMarkerViewOptions markerOptions, @NonNull MapboxMap mapboxMap, - @Nullable MarkerViewManager.OnMarkerViewAddedListener onMarkerViewAddedListener); - - List addViewsBy(@NonNull List markerViewOptions, - @NonNull MapboxMap mapboxMap); - - List obtainViewsIn(@NonNull RectF rectangle); - void reload(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java index 16c73b1ca5..8e73449a61 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java @@ -24,27 +24,15 @@ public class Projection { this.contentPadding = new int[] {0, 0, 0, 0}; } - void setContentPadding(int[] contentPadding, int[] userLocationViewPadding) { + void setContentPadding(int[] contentPadding) { this.contentPadding = contentPadding; - - int[] padding = new int[] { - contentPadding[0] + userLocationViewPadding[0], - contentPadding[1] + userLocationViewPadding[1], - contentPadding[2] + userLocationViewPadding[2], - contentPadding[3] + userLocationViewPadding[3] - }; - - nativeMapView.setContentPadding(padding); + nativeMapView.setContentPadding(contentPadding); } int[] getContentPadding() { return contentPadding; } - public void invalidateContentPadding(int[] userLocationViewPadding) { - setContentPadding(contentPadding, userLocationViewPadding); - } - /** * Returns the spherical Mercator projected meters for a LatLng. */ 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 deleted file mode 100644 index 3743096824..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java +++ /dev/null @@ -1,419 +0,0 @@ -package com.mapbox.mapboxsdk.maps; - -import android.location.Location; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.UiThread; - -import com.mapbox.mapboxsdk.Mapbox; -import com.mapbox.mapboxsdk.camera.CameraPosition; -import com.mapbox.mapboxsdk.constants.MapboxConstants; -import com.mapbox.mapboxsdk.constants.MyBearingTracking; -import com.mapbox.mapboxsdk.constants.MyLocationTracking; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; -import com.mapbox.android.core.location.LocationEngine; -import com.mapbox.android.core.location.LocationEngineListener; -import com.mapbox.android.core.permissions.PermissionsManager; - -import timber.log.Timber; - -/** - * Settings for the user location and bearing tracking of a MapboxMap. - * - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. - */ -@Deprecated -public final class TrackingSettings { - - private final MyLocationView myLocationView; - private final UiSettings uiSettings; - private final FocalPointChangeListener focalPointChangedListener; - private final CameraZoomInvalidator zoomInvalidator; - private LocationEngine locationSource; - private LocationEngineListener myLocationListener; - private boolean locationChangeAnimationEnabled = true; - private boolean isCustomLocationSource; - - private boolean myLocationEnabled; - private boolean dismissLocationTrackingOnGesture = true; - private boolean dismissBearingTrackingOnGesture = true; - - private MapboxMap.OnMyLocationTrackingModeChangeListener onMyLocationTrackingModeChangeListener; - private MapboxMap.OnMyBearingTrackingModeChangeListener onMyBearingTrackingModeChangeListener; - - TrackingSettings(@NonNull MyLocationView myLocationView, UiSettings uiSettings, - FocalPointChangeListener focalPointChangedListener, CameraZoomInvalidator zoomInvalidator) { - this.myLocationView = myLocationView; - this.focalPointChangedListener = focalPointChangedListener; - this.uiSettings = uiSettings; - this.zoomInvalidator = zoomInvalidator; - } - - void initialise(MapboxMapOptions options) { - locationSource = Mapbox.getLocationEngine(); - setMyLocationEnabled(options.getLocationEnabled()); - } - - void onSaveInstanceState(Bundle outState) { - outState.putInt(MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, getMyLocationTrackingMode()); - outState.putInt(MapboxConstants.STATE_MY_BEARING_TRACKING_MODE, getMyBearingTrackingMode()); - outState.putBoolean(MapboxConstants.STATE_MY_LOCATION_TRACKING_DISMISS, isDismissLocationTrackingOnGesture()); - outState.putBoolean(MapboxConstants.STATE_MY_BEARING_TRACKING_DISMISS, isDismissBearingTrackingOnGesture()); - outState.putBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED, isMyLocationEnabled()); - outState.putBoolean(MapboxConstants.STATE_LOCATION_CHANGE_ANIMATION_ENABLED, isLocationChangeAnimationEnabled()); - outState.putBoolean(MapboxConstants.STATE_USING_CUSTOM_LOCATION_SOURCE, isCustomLocationSource()); - } - - void onRestoreInstanceState(Bundle savedInstanceState) { - try { - setMyLocationEnabled( - savedInstanceState.getBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED), - savedInstanceState.getBoolean(MapboxConstants.STATE_USING_CUSTOM_LOCATION_SOURCE) - ); - } catch (SecurityException ignore) { - // User did not accept location permissions - } - // noinspection ResourceType - setMyLocationTrackingMode(savedInstanceState.getInt( - MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, MyLocationTracking.TRACKING_NONE)); - // noinspection ResourceType - setMyBearingTrackingMode(savedInstanceState.getInt( - MapboxConstants.STATE_MY_BEARING_TRACKING_MODE, MyBearingTracking.NONE)); - setDismissLocationTrackingOnGesture(savedInstanceState.getBoolean( - MapboxConstants.STATE_MY_LOCATION_TRACKING_DISMISS, true)); - setDismissBearingTrackingOnGesture(savedInstanceState.getBoolean( - MapboxConstants.STATE_MY_BEARING_TRACKING_DISMISS, true)); - setLocationChangeAnimationEnabled(savedInstanceState.getBoolean( - MapboxConstants.STATE_LOCATION_CHANGE_ANIMATION_ENABLED, true)); - } - - /** - *

- * Set the current my location tracking mode. - *

- *

- * Will enable my location if not active. - *

- * See {@link MyLocationTracking} for different values. - * - * @param myLocationTrackingMode The location tracking mode to be used. - * @throws SecurityException if no suitable permission is present - * @see MyLocationTracking - */ - @UiThread - public void setMyLocationTrackingMode(@MyLocationTracking.Mode int myLocationTrackingMode) { - myLocationView.setLocationChangeAnimationEnabled(isLocationChangeAnimationEnabled()); - myLocationView.setMyLocationTrackingMode(myLocationTrackingMode); - - if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) { - zoomInvalidator.zoomTo(2.0); - focalPointChangedListener.onFocalPointChanged(myLocationView.getCenter()); - } else { - focalPointChangedListener.onFocalPointChanged(null); - } - - if (onMyLocationTrackingModeChangeListener != null) { - onMyLocationTrackingModeChangeListener.onMyLocationTrackingModeChange(myLocationTrackingMode); - } - } - - /** - * Returns the current user location tracking mode. - * - * @return The current user location tracking mode. - * One of the values from {@link MyLocationTracking.Mode}. - * @see MyLocationTracking.Mode - */ - @UiThread - @MyLocationTracking.Mode - public int getMyLocationTrackingMode() { - return myLocationView.getMyLocationTrackingMode(); - } - - /** - *

- * Set the current my bearing tracking mode. - *

- * Shows the direction the user is heading. - *

- * When location tracking is disabled the direction of {@link MyLocationView} is rotated. When - * location tracking is enabled the {@link MapView} is rotated based on the bearing value. - *

- * See {@link MyBearingTracking} for different values. - * - * @param myBearingTrackingMode The bearing tracking mode to be used. - * @throws SecurityException if no suitable permission is present - * @see MyBearingTracking - */ - @UiThread - public void setMyBearingTrackingMode(@MyBearingTracking.Mode int myBearingTrackingMode) { - myLocationView.setMyBearingTrackingMode(myBearingTrackingMode); - if (onMyBearingTrackingModeChangeListener != null) { - onMyBearingTrackingModeChangeListener.onMyBearingTrackingModeChange(myBearingTrackingMode); - } - } - - /** - * Returns the current user bearing tracking mode. - * See {@link MyBearingTracking} for possible return values. - * - * @return the current user bearing tracking mode. - * @see MyBearingTracking - */ - @UiThread - @MyBearingTracking.Mode - public int getMyBearingTrackingMode() { - return myLocationView.getMyBearingTrackingMode(); - } - - /** - * Returns if all tracking modes will be dismissed when a gesture occurs. - * - * @return True to indicate that location and bearing tracking will be dismissed. - */ - public boolean isAllDismissTrackingOnGesture() { - return dismissLocationTrackingOnGesture && dismissBearingTrackingOnGesture; - } - - /** - * Set the dismissal of the tracking modes if a gesture occurs. - * - * @param dismissTrackingOnGesture True to dismiss all the tracking modes. - */ - public void setDismissAllTrackingOnGesture(boolean dismissTrackingOnGesture) { - dismissLocationTrackingOnGesture = dismissTrackingOnGesture; - dismissBearingTrackingOnGesture = dismissTrackingOnGesture; - } - - /** - * Set the dismissal of the tracking modes if a gesture occurs. - * - * @param dismissLocationTrackingOnGesture True to dismiss the location tracking mode. - */ - public void setDismissLocationTrackingOnGesture(boolean dismissLocationTrackingOnGesture) { - this.dismissLocationTrackingOnGesture = dismissLocationTrackingOnGesture; - } - - /** - * Returns if the location tracking will be disabled when a gesture occurs - * - * @return True if location tracking will be disabled. - */ - public boolean isDismissLocationTrackingOnGesture() { - return dismissLocationTrackingOnGesture; - } - - /** - * Set the dismissal of the bearing tracking modes if a gesture occurs. - * - * @param dismissBearingTrackingOnGesture True to dimsiss the bearinf tracking mode - */ - public void setDismissBearingTrackingOnGesture(boolean dismissBearingTrackingOnGesture) { - this.dismissBearingTrackingOnGesture = dismissBearingTrackingOnGesture; - } - - /** - * Returns if bearing will disabled when a gesture occurs - * - * @return True if bearing tracking will be disabled - */ - public boolean isDismissBearingTrackingOnGesture() { - return dismissBearingTrackingOnGesture; - } - - /** - * Returns if location tracking is disabled - * - * @return True if location tracking is disabled. - */ - public boolean isLocationTrackingDisabled() { - return myLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE; - } - - /** - * Returns if bearing tracking disabled - * - * @return True if bearing tracking is disabled. - */ - public boolean isBearingTrackingDisabled() { - return myLocationView.getMyBearingTrackingMode() == MyBearingTracking.NONE; - } - - /** - * Returns if rotate gesture are currently enabled. - * - * @return True if rotate gestures are currently enabled. - */ - public boolean isRotateGestureCurrentlyEnabled() { - // rotate gestures are recognised if: - // The user settings are enabled AND; - // EITHER bearing tracking is dismissed on gesture OR there is no bearing tracking - return uiSettings.isRotateGesturesEnabled() - && (dismissBearingTrackingOnGesture - || myLocationView.getMyBearingTrackingMode() == MyBearingTracking.NONE - || myLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE); - } - - /** - * Returns if scroll gesture are currently enabled. - * - * @return True if scroll gestures are currently enabled. - */ - public boolean isScrollGestureCurrentlyEnabled() { - return uiSettings.isScrollGesturesEnabled() - && (dismissLocationTrackingOnGesture - || myLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE); - } - - /** - * Returns whether location change animation is applied for {@link MyLocationTracking#TRACKING_FOLLOW}. - * - * @return True if animation is applied, false otherwise. - */ - public boolean isLocationChangeAnimationEnabled() { - return locationChangeAnimationEnabled; - } - - /** - * Set whether location change animation should be applied for {@link MyLocationTracking#TRACKING_FOLLOW}. - * - * @param locationChangeAnimationEnabled True if animation should be applied, false otherwise. - */ - public void setLocationChangeAnimationEnabled(boolean locationChangeAnimationEnabled) { - this.locationChangeAnimationEnabled = locationChangeAnimationEnabled; - - myLocationView.setLocationChangeAnimationEnabled(locationChangeAnimationEnabled); - } - - /** - * Reset the tracking modes as necessary. Location tracking is reset if the map center is changed and not from - * location, bearing tracking if there is a rotation. - * - * @param translate true if translation - * @param rotate true if rotation - * @param isFromLocation true if from location - */ - void resetTrackingModesIfRequired(boolean translate, boolean rotate, boolean isFromLocation) { - // if tracking is on, and we should dismiss tracking with gestures, and this is a scroll action, turn tracking off - if (translate && !isLocationTrackingDisabled() && isDismissLocationTrackingOnGesture() && !isFromLocation) { - setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE); - } - - // reset bearing tracking only on rotate - if (rotate && !isBearingTrackingDisabled() && isDismissBearingTrackingOnGesture()) { - setMyBearingTrackingMode(MyBearingTracking.NONE); - } - } - - /** - * Reset the tracking modes as necessary. Animated camera position changes can reset the underlying tracking modes. - * - * @param currentCameraPosition the current camera position - * @param targetCameraPosition the changed camera position - * @param isFromLocation true if from location - */ - void resetTrackingModesIfRequired(CameraPosition currentCameraPosition, CameraPosition targetCameraPosition, - boolean isFromLocation) { - if (currentCameraPosition.target != null) { - resetTrackingModesIfRequired(!currentCameraPosition.target.equals(targetCameraPosition.target), false, - isFromLocation); - } - } - - Location getMyLocation() { - return myLocationView.getLocation(); - } - - void setOnMyLocationChangeListener(@Nullable final MapboxMap.OnMyLocationChangeListener listener) { - if (listener != null) { - myLocationListener = new LocationEngineListener() { - @Override - public void onConnected() { - // Nothing - } - - @Override - public void onLocationChanged(Location location) { - if (listener != null) { - listener.onMyLocationChange(location); - } - } - }; - locationSource.addLocationEngineListener(myLocationListener); - } else { - locationSource.removeLocationEngineListener(myLocationListener); - myLocationListener = null; - } - } - - public boolean isCustomLocationSource() { - return isCustomLocationSource; - } - - void setOnMyLocationTrackingModeChangeListener(MapboxMap.OnMyLocationTrackingModeChangeListener listener) { - this.onMyLocationTrackingModeChangeListener = listener; - } - - void setOnMyBearingTrackingModeChangeListener(MapboxMap.OnMyBearingTrackingModeChangeListener listener) { - this.onMyBearingTrackingModeChangeListener = listener; - } - - MyLocationView getMyLocationView() { - return myLocationView; - } - - - boolean isMyLocationEnabled() { - return myLocationEnabled; - } - - void setMyLocationEnabled(boolean locationEnabled) { - setMyLocationEnabled(locationEnabled, isCustomLocationSource()); - } - - private void setMyLocationEnabled(boolean locationEnabled, boolean isCustomLocationSource) { - if (locationEnabled && !PermissionsManager.areLocationPermissionsGranted(myLocationView.getContext())) { - Timber.e("Could not activate user location tracking: " - + "user did not accept the permission or permissions were not requested."); - return; - } - myLocationEnabled = locationEnabled; - this.isCustomLocationSource = isCustomLocationSource; - myLocationView.setEnabled(locationEnabled, isCustomLocationSource); - } - - void setLocationSource(LocationEngine locationSource) { - if (this.locationSource != null && this.locationSource.equals(locationSource)) { - // this source is already active - return; - } - - this.isCustomLocationSource = locationSource != null; - if (locationSource == null) { - locationSource = Mapbox.getLocationEngine(); - } - this.locationSource = locationSource; - myLocationView.setLocationSource(locationSource); - } - - void update() { - if (!myLocationView.isEnabled()) { - return; - } - myLocationView.update(); - } - - void onStart() { - myLocationView.onStart(); - } - - void onStop() { - myLocationView.onStop(); - } - - interface CameraZoomInvalidator { - void zoomTo(double zoomLevel); - } -} 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 84a601039f..aa1bcae37f 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 @@ -6,13 +6,11 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.UiThread; -import com.mapbox.mapboxsdk.annotations.MarkerViewManager; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdate; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; import timber.log.Timber; @@ -29,9 +27,6 @@ import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener; final class Transform implements MapView.OnMapChangedListener { private final NativeMapView mapView; - private final MarkerViewManager markerViewManager; - private final TrackingSettings trackingSettings; - private final MyLocationView myLocationView; private final Handler handler = new Handler(); private CameraPosition cameraPosition; @@ -41,12 +36,8 @@ final class Transform implements MapView.OnMapChangedListener { private CameraChangeDispatcher cameraChangeDispatcher; - Transform(NativeMapView mapView, MarkerViewManager markerViewManager, TrackingSettings trackingSettings, - CameraChangeDispatcher cameraChangeDispatcher) { + Transform(NativeMapView mapView, CameraChangeDispatcher cameraChangeDispatcher) { this.mapView = mapView; - this.markerViewManager = markerViewManager; - this.trackingSettings = trackingSettings; - this.myLocationView = trackingSettings.getMyLocationView(); this.cameraChangeDispatcher = cameraChangeDispatcher; } @@ -71,18 +62,9 @@ final class Transform implements MapView.OnMapChangedListener { return cameraPosition; } - @UiThread - void updateCameraPosition(@NonNull CameraPosition position) { - if (myLocationView != null) { - myLocationView.setCameraPosition(position); - } - markerViewManager.setTilt((float) position.tilt); - } - @Override public void onMapChanged(@MapView.MapChange int change) { if (change == REGION_DID_CHANGE_ANIMATED) { - updateCameraPosition(invalidateCameraPosition()); if (cameraCancelableCallback != null) { handler.post(new Runnable() { @Override @@ -103,7 +85,6 @@ final class Transform implements MapView.OnMapChangedListener { final void moveCamera(MapboxMap mapboxMap, CameraUpdate update, final MapboxMap.CancelableCallback callback) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); if (isValidCameraPosition(cameraPosition)) { - trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false); cancelTransitions(); cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION); mapView.jumpTo(cameraPosition.bearing, cameraPosition.target, cameraPosition.tilt, cameraPosition.zoom); @@ -125,7 +106,6 @@ final class Transform implements MapView.OnMapChangedListener { final MapboxMap.CancelableCallback callback, boolean isDismissable) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); if (isValidCameraPosition(cameraPosition)) { - trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, isDismissable); cancelTransitions(); cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION); @@ -143,7 +123,6 @@ final class Transform implements MapView.OnMapChangedListener { final MapboxMap.CancelableCallback callback) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); if (isValidCameraPosition(cameraPosition)) { - trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false); cancelTransitions(); cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION); @@ -169,10 +148,6 @@ final class Transform implements MapView.OnMapChangedListener { cameraChangeDispatcher.onCameraMove(); } - if (isComponentUpdateRequired(cameraPosition)) { - updateCameraPosition(cameraPosition); - } - this.cameraPosition = cameraPosition; if (onCameraChangeListener != null) { onCameraChangeListener.onCameraChange(this.cameraPosition); @@ -181,11 +156,6 @@ final class Transform implements MapView.OnMapChangedListener { return cameraPosition; } - private boolean isComponentUpdateRequired(@NonNull CameraPosition cameraPosition) { - return this.cameraPosition != null && (this.cameraPosition.tilt != cameraPosition.tilt - || this.cameraPosition.bearing != cameraPosition.bearing); - } - void cancelTransitions() { // notify user about cancel cameraChangeDispatcher.onCameraMoveCanceled(); @@ -297,23 +267,14 @@ final class Transform implements MapView.OnMapChangedListener { } void setBearing(double bearing) { - if (myLocationView != null) { - myLocationView.setBearing(bearing); - } mapView.setBearing(bearing); } void setBearing(double bearing, float focalX, float focalY) { - if (myLocationView != null) { - myLocationView.setBearing(bearing); - } mapView.setBearing(bearing, focalX, focalY); } void setBearing(double bearing, float focalX, float focalY, long duration) { - if (myLocationView != null) { - myLocationView.setBearing(bearing); - } mapView.setBearing(bearing, focalX, focalY, duration); } @@ -335,10 +296,6 @@ final class Transform implements MapView.OnMapChangedListener { } void setTilt(Double pitch) { - if (myLocationView != null) { - myLocationView.setTilt(pitch); - } - markerViewManager.setTilt(pitch.floatValue()); mapView.setPitch(pitch, 0); } 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 deleted file mode 100644 index 3f37da99d5..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ /dev/null @@ -1,1104 +0,0 @@ -package com.mapbox.mapboxsdk.maps.widgets; - -import android.animation.ValueAnimator; -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Camera; -import android.graphics.Canvas; -import android.graphics.Matrix; -import android.graphics.Paint; -import android.graphics.PointF; -import android.graphics.PorterDuff; -import android.graphics.Rect; -import android.graphics.drawable.Drawable; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.location.Location; -import android.os.Bundle; -import android.os.Parcelable; -import android.os.SystemClock; -import android.support.annotation.ColorInt; -import android.support.annotation.FloatRange; -import android.support.annotation.IntRange; -import android.support.annotation.NonNull; -import android.util.AttributeSet; -import android.view.View; -import android.view.ViewGroup; - -import com.mapbox.mapboxsdk.Mapbox; -import com.mapbox.mapboxsdk.camera.CameraPosition; -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.constants.MyBearingTracking; -import com.mapbox.mapboxsdk.constants.MyLocationTracking; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.Projection; -import com.mapbox.android.core.location.LocationEngine; -import com.mapbox.android.core.location.LocationEngineListener; -import com.mapbox.android.core.location.LocationEnginePriority; - -import java.lang.ref.WeakReference; - -import timber.log.Timber; - -/** - * UI element overlaid on a map to show the user's location. - *

- * Use {@link MyLocationViewSettings} to manipulate the state of this view. - *

- * - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. - */ -@Deprecated -public class MyLocationView extends View { - - private static final int UNDEFINED_TINT_COLOR = -1; - private MyLocationBehavior myLocationBehavior; - private MapboxMap mapboxMap; - - private Projection projection; - private float[] projectedCoordinate = new float[2]; - private float projectedX; - private float projectedY; - - private float contentPaddingX; - private float contentPaddingY; - - private LatLng latLng; - private Location location; - private LocationEngine locationEngine; - private long locationUpdateTimestamp; - private float previousDirection; - - private float accuracy; - private Paint accuracyPaint; - private float accuracyThreshold; - - private ValueAnimator locationChangeAnimator; - private ValueAnimator accuracyAnimator; - private ValueAnimator directionAnimator; - private boolean locationChangeAnimationEnabled = true; - - private ValueAnimator.AnimatorUpdateListener invalidateSelfOnUpdateListener = - new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator animation) { - invalidate(); - } - }; - - private Drawable foregroundDrawable; - private Drawable foregroundBearingDrawable; - private Drawable backgroundDrawable; - - private Rect foregroundBounds; - private Rect backgroundBounds; - - private int backgroundOffsetLeft; - private int backgroundOffsetTop; - private int backgroundOffsetRight; - private int backgroundOffsetBottom; - - private Matrix matrix; - private Camera camera; - private PointF screenLocation; - - // camera vars - private double tilt; - private double bearing; - private float magneticHeading; - - // Controls the compass update rate in milliseconds - private static final int COMPASS_UPDATE_RATE_MS = 500; - - @MyLocationTracking.Mode - private int myLocationTrackingMode; - - @MyBearingTracking.Mode - private int myBearingTrackingMode; - - private GpsLocationListener userLocationListener; - private CompassListener compassListener; - - public MyLocationView(Context context) { - super(context); - init(context); - } - - public MyLocationView(Context context, AttributeSet attrs) { - super(context, attrs); - init(context); - } - - public MyLocationView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context); - } - - private void init(Context context) { - if (isInEditMode()) { - return; - } - - setEnabled(false); - - // setup LayoutParams - ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - setLayoutParams(lp); - - matrix = new Matrix(); - camera = new Camera(); - camera.setLocation(0, 0, -1000); - accuracyPaint = new Paint(); - - myLocationBehavior = new MyLocationBehaviorFactory().getBehavioralModel(MyLocationTracking.TRACKING_NONE); - compassListener = new CompassListener(context); - } - - @Deprecated - public void init(LocationEngine locationSource) { - this.locationEngine = locationSource; - } - - /** - * Set the foreground drawable, for internal use only. - * - * @param defaultDrawable The drawable shown when showing this view - * @param bearingDrawable The drawable shown when tracking of bearing is enabled - */ - public final void setForegroundDrawables(Drawable defaultDrawable, Drawable bearingDrawable) { - if (defaultDrawable == null) { - return; - } - - if (bearingDrawable == null) { - // if user only provided one resource - // use same for bearing mode - bearingDrawable = defaultDrawable.getConstantState().newDrawable(); - } - - if (backgroundDrawable == null) { - // if the user didn't provide a background resource we will use the foreground resource instead, - // we need to create a new drawable to handle tinting correctly - backgroundDrawable = defaultDrawable.getConstantState().newDrawable(); - } - - if (defaultDrawable.getIntrinsicWidth() != bearingDrawable.getIntrinsicWidth() - || defaultDrawable.getIntrinsicHeight() != bearingDrawable.getIntrinsicHeight()) { - throw new RuntimeException("The dimensions from location and bearing drawables should be match"); - } - - foregroundDrawable = defaultDrawable; - foregroundBearingDrawable = bearingDrawable; - - invalidateBounds(); - } - - /** - * Set the foreground drawable tint, for internal use only. - * - * @param color The color to tint the drawable with - */ - public final void setForegroundDrawableTint(@ColorInt int color) { - applyDrawableTint(foregroundDrawable, color); - applyDrawableTint(foregroundBearingDrawable, color); - invalidate(); - } - - /** - * Set the shadow drawable, for internal use only. - * - * @param drawable The drawable shown as shadow - */ - public final void setShadowDrawable(Drawable drawable) { - setShadowDrawable(drawable, 0, 0, 0, 0); - } - - /** - * Set the shadow drawable with some additional offset. - * - * @param drawable The drawable shown as shadow - * @param left The left offset margin - * @param top The top offset margin - * @param right The right offset margin - * @param bottom The bottom offset margin - */ - public final void setShadowDrawable(Drawable drawable, int left, int top, int right, int bottom) { - if (drawable != null) { - backgroundDrawable = drawable; - } - - backgroundOffsetLeft = left; - backgroundOffsetTop = top; - backgroundOffsetRight = right; - backgroundOffsetBottom = bottom; - - invalidateBounds(); - } - - /** - * Set the shadow drawable tint color, for internal use only. - * - * @param color The tint color to apply - */ - public final void setShadowDrawableTint(@ColorInt int color) { - if (backgroundDrawable == null) { - return; - } - applyDrawableTint(backgroundDrawable, color); - invalidate(); - } - - /** - * Set the accuracy tint color, for internal use only. - * - * @param color The tint color to apply - */ - public final void setAccuracyTint(@ColorInt int color) { - int alpha = accuracyPaint.getAlpha(); - accuracyPaint.setColor(color); - accuracyPaint.setAlpha(alpha); - invalidate(); - } - - /** - * Set the accuracy alpha value, for internal use only. - * - * @param alpha The alpha accuracy value to apply - */ - public final void setAccuracyAlpha(@IntRange(from = 0, to = 255) int alpha) { - accuracyPaint.setAlpha(alpha); - invalidate(); - } - - private void invalidateBounds() { - if (backgroundDrawable == null || foregroundDrawable == null || foregroundBearingDrawable == null) { - return; - } - - int backgroundWidth = backgroundDrawable.getIntrinsicWidth(); - int backgroundHeight = backgroundDrawable.getIntrinsicHeight(); - int horizontalOffset = backgroundOffsetLeft - backgroundOffsetRight; - int verticalOffset = backgroundOffsetTop - backgroundOffsetBottom; - backgroundBounds = new Rect(-backgroundWidth / 2 + horizontalOffset, - -backgroundHeight / 2 + verticalOffset, backgroundWidth / 2 + horizontalOffset, backgroundHeight / 2 - + verticalOffset); - backgroundDrawable.setBounds(backgroundBounds); - - int foregroundWidth = foregroundDrawable.getIntrinsicWidth(); - int foregroundHeight = foregroundDrawable.getIntrinsicHeight(); - foregroundBounds = new Rect(-foregroundWidth / 2, -foregroundHeight / 2, foregroundWidth / 2, foregroundHeight / 2); - foregroundDrawable.setBounds(foregroundBounds); - foregroundBearingDrawable.setBounds(foregroundBounds); - - // invoke a new draw - invalidate(); - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - - if (location == null || foregroundBounds == null || backgroundBounds == null || accuracyAnimator == null - || screenLocation == null) { - // Not ready yet - return; - } - - final PointF pointF = screenLocation; - float metersPerPixel = (float) projection.getMetersPerPixelAtLatitude(location.getLatitude()); - float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel; - - // reset - matrix.reset(); - projectedCoordinate[0] = 0; - projectedCoordinate[1] = 0; - - // put camera in position - camera.save(); - camera.rotate((float) tilt, 0, 0); - camera.getMatrix(matrix); - - if (myBearingTrackingMode != MyBearingTracking.NONE && directionAnimator != null) { - matrix.preRotate((Float) directionAnimator.getAnimatedValue()); - } - - matrix.preTranslate(0, contentPaddingY); - matrix.postTranslate(pointF.x, pointF.y - contentPaddingY); - - // concat our matrix on canvas - canvas.concat(matrix); - - // calculate focal point - matrix.mapPoints(projectedCoordinate); - projectedX = pointF.x - projectedCoordinate[0]; - projectedY = pointF.y - projectedCoordinate[1]; - - // restore orientation from camera - camera.restore(); - - // draw circle - canvas.drawCircle(0, 0, accuracyPixels, accuracyPaint); - - // draw shadow - if (backgroundDrawable != null) { - backgroundDrawable.draw(canvas); - } - - // draw foreground - if (myBearingTrackingMode == MyBearingTracking.NONE) { - if (foregroundDrawable != null) { - foregroundDrawable.draw(canvas); - } - } else if (foregroundBearingDrawable != null && foregroundBounds != null) { - if (myBearingTrackingMode == MyBearingTracking.GPS - || myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING - || compassListener.isSensorAvailable()) { - foregroundBearingDrawable.draw(canvas); - } else { - // We are tracking MyBearingTracking.COMPASS, but sensor is not available. - foregroundDrawable.draw(canvas); - } - } - } - - /** - * Set the tilt value, for internal use only. - * - * @param tilt The tilt to apply - */ - public void setTilt(@FloatRange(from = 0, to = 60.0f) double tilt) { - this.tilt = tilt; - invalidate(); - } - - /** - * Set the bearing value, for internal use only. - * - * @param bearing The bearing to apply - */ - public void setBearing(double bearing) { - this.bearing = bearing; - if (myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) { - if (myBearingTrackingMode == MyBearingTracking.GPS - || myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING) { - if (location != null) { - setCompass(location.getBearing() - bearing); - } - } else if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) { - setCompass(magneticHeading - bearing); - } - } - } - - /** - * Set the bearing and tilt from a camera position, for internal use only. - * - * @param position The camera position to extract bearing and tilt from - */ - public void setCameraPosition(CameraPosition position) { - if (position != null) { - setBearing(position.bearing); - setTilt(position.tilt); - } - } - - /** - * Called when the hosting activity is starting, for internal use only. - */ - public void onStart() { - if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) { - compassListener.onResume(); - } - if (isEnabled()) { - toggleGps(true); - } - } - - /** - * Called when the hosting activity is stopping, for internal use only. - */ - public void onStop() { - compassListener.onPause(); - toggleGps(false); - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - // cleanup to prevent memory leaks - if (locationChangeAnimator != null) { - locationChangeAnimator.cancel(); - locationChangeAnimator = null; - } - - if (accuracyAnimator != null) { - accuracyAnimator.cancel(); - accuracyAnimator = null; - } - - if (directionAnimator != null) { - directionAnimator.cancel(); - directionAnimator = null; - } - - if (userLocationListener != null) { - locationEngine.removeLocationEngineListener(userLocationListener); - locationEngine = null; - userLocationListener = null; - } - } - - /** - * Update current locationstate. - */ - public void update() { - if (isEnabled()) { - myLocationBehavior.invalidate(); - } else { - setVisibility(View.INVISIBLE); - } - } - - // TODO refactor MapboxMap out - public void setMapboxMap(MapboxMap mapboxMap) { - this.mapboxMap = mapboxMap; - this.projection = mapboxMap.getProjection(); - } - - /** - * Set the enabled state, for internal use only. - * - * @param enabled The value to set the state to - */ - @Override - public void setEnabled(boolean enabled) { - setEnabled(enabled, false); - } - - /** - * Set the enabled state, for internal use only. - * - * @param enabled The value to set the state to - * @param isCustomLocationEngine Flag handling for handling user provided custom location engine - */ - public void setEnabled(boolean enabled, boolean isCustomLocationEngine) { - super.setEnabled(enabled); - setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); - toggleGps(enabled, isCustomLocationEngine); - } - - /** - * Save the view instance state, for internal use only. - * - * @return the marshaled representation of the view state - */ - @Override - protected Parcelable onSaveInstanceState() { - Bundle bundle = new Bundle(); - bundle.putParcelable("superState", super.onSaveInstanceState()); - bundle.putDouble("tilt", tilt); - return bundle; - } - - /** - * Restore the view instance state, for internal use only. - * - * @param state the marshalled representation of the state to restore - */ - @Override - public void onRestoreInstanceState(Parcelable state) { - if (state instanceof Bundle) { - Bundle bundle = (Bundle) state; - tilt = bundle.getDouble("tilt"); - state = bundle.getParcelable("superState"); - } - super.onRestoreInstanceState(state); - } - - private void toggleGps(boolean enableGps) { - toggleGps(enableGps, mapboxMap != null - && mapboxMap.getTrackingSettings().isCustomLocationSource()); - } - - /** - * Enabled / Disable GPS location updates along with updating the UI, for internal use only. - * - * @param enableGps true if GPS is to be enabled, false if GPS is to be disabled - */ - private void toggleGps(boolean enableGps, boolean isCustomLocationEngine) { - if (enableGps) { - if (locationEngine == null) { - if (!isCustomLocationEngine) { - locationEngine = Mapbox.getLocationEngine(); - } else { - return; - } - } - - if (userLocationListener == null) { - userLocationListener = new GpsLocationListener(this, locationEngine); - } - - locationEngine.addLocationEngineListener(userLocationListener); - locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY); - locationEngine.activate(); - } else { - if (locationEngine == null) { - return; - } - // Disable location and user dot - location = null; - locationEngine.removeLocationEngineListener(userLocationListener); - locationEngine.removeLocationUpdates(); - locationEngine.deactivate(); - restoreLocationEngine(); - } - } - - /** - * Get the current location. - * - * @return the current location - */ - public Location getLocation() { - return location; - } - - /** - * Set the current location, for internal use only. - * - * @param location The current location - */ - public void setLocation(Location location) { - if (location == null) { - this.location = null; - return; - } - - this.location = location; - myLocationBehavior.updateLatLng(location); - - if (mapboxMap != null && (myBearingTrackingMode == MyBearingTracking.GPS - || myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING) - && myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) { - setBearing(mapboxMap.getCameraPosition().bearing); - } - } - - /** - * Set location change animation enabled, for internal use only. - * - * @param locationChangeAnimationEnabled True if location changes are animated - */ - public void setLocationChangeAnimationEnabled(boolean locationChangeAnimationEnabled) { - this.locationChangeAnimationEnabled = locationChangeAnimationEnabled; - } - - /** - * Set accuracy circle threshold. Circle won't be displayed if accuracy is below set value. - * For internal use only. - * - * @param accuracyThreshold Value below which circle won't be displayed - */ - public void setAccuracyThreshold(float accuracyThreshold) { - this.accuracyThreshold = accuracyThreshold; - } - - /** - * Set the bearing tracking mode, for internal use only. - * - * @param myBearingTrackingMode The bearing tracking mode - */ - public void setMyBearingTrackingMode(@MyBearingTracking.Mode int myBearingTrackingMode) { - this.myBearingTrackingMode = myBearingTrackingMode; - if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) { - compassListener.onResume(); - } else { - compassListener.onPause(); - if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW - && myBearingTrackingMode == MyBearingTracking.GPS) { - // always face north - setCompass(0); - } else { - myLocationBehavior.invalidate(); - } - } - invalidate(); - } - - /** - * Set the location tracking mode, for internla use only. - * - * @param myLocationTrackingMode The location tracking mode - */ - public void setMyLocationTrackingMode(@MyLocationTracking.Mode int myLocationTrackingMode) { - MyLocationBehaviorFactory factory = new MyLocationBehaviorFactory(); - myLocationBehavior = factory.getBehavioralModel(myLocationTrackingMode); - - if (location != null) { - if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) { - // center map directly - mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(location))); - } else { - // do not use interpolated location from tracking mode - latLng = null; - } - myLocationBehavior.updateLatLng(location); - } - - this.myLocationTrackingMode = myLocationTrackingMode; - invalidate(); - } - - /** - * Get the location tracking mode, for internal use only. - * - * @return The location tracking mode - */ - @MyLocationTracking.Mode - public int getMyLocationTrackingMode() { - return myLocationTrackingMode; - } - - - /** - * Get the bearing tracking mode, for internal use only. - * - * @return the bearing tracking mode - */ - @MyBearingTracking.Mode - public int getMyBearingTrackingMode() { - return myBearingTrackingMode; - } - - /** - * Set the compass bearing value, for internal use only. - * - * @param bearing The compas bearing value - */ - private void setCompass(double bearing) { - setCompass(bearing, 0 /* no animation */); - } - - private void setCompass(double bearing, long duration) { - float oldDir = previousDirection; - if (directionAnimator != null) { - oldDir = (Float) directionAnimator.getAnimatedValue(); - directionAnimator.end(); - directionAnimator = null; - } - - float newDir = (float) bearing; - float diff = oldDir - newDir; - if (diff > 180.0f) { - newDir += 360.0f; - } else if (diff < -180.0f) { - newDir -= 360.f; - } - previousDirection = newDir; - - directionAnimator = ValueAnimator.ofFloat(oldDir, newDir); - directionAnimator.setDuration(duration); - directionAnimator.addUpdateListener(invalidateSelfOnUpdateListener); - directionAnimator.start(); - } - - /** - * Get the center of this view in screen coordinates. - * - * @return the center of the view - */ - public PointF getCenter() { - return new PointF(getCenterX(), getCenterY()); - } - - /** - * Get the x value of the center of this view. - * - * @return the x value of the center of the view - */ - private float getCenterX() { - return (getX() + getMeasuredWidth()) / 2 + contentPaddingX - projectedX; - } - - /** - * Get the y value of the center of this view. - * - * @return the y value of the center of the view - */ - private float getCenterY() { - return (getY() + getMeasuredHeight()) / 2 + contentPaddingY - projectedY; - } - - public void setContentPadding(int[] padding) { - contentPaddingX = (padding[0] - padding[2]) / 2; - contentPaddingY = (padding[1] - padding[3]) / 2; - } - - /** - * Set the location source from which location updates are received, for internal use only. - * - * @param locationEngine The location engine to receive updates from - */ - public void setLocationSource(LocationEngine locationEngine) { - toggleGps(false); - this.locationEngine = locationEngine; - this.userLocationListener = null; - setEnabled(isEnabled(), locationEngine != null); - } - - private void applyDrawableTint(Drawable drawable, @ColorInt int color) { - if (color == UNDEFINED_TINT_COLOR) { - removeTintColorFilter(drawable); - } else { - applyTintColorFilter(drawable, color); - } - } - - private void removeTintColorFilter(Drawable drawable) { - if (drawable != null) { - drawable.mutate().setColorFilter(null); - } - } - - private void applyTintColorFilter(Drawable drawable, @ColorInt int color) { - if (drawable != null) { - drawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN); - } - } - - private void restoreLocationEngine() { - locationEngine.setPriority(LocationEnginePriority.LOW_POWER); - locationEngine.activate(); - } - - private static class GpsLocationListener implements LocationEngineListener { - - private WeakReference userLocationView; - private WeakReference locationSource; - - GpsLocationListener(MyLocationView myLocationView, LocationEngine locationEngine) { - userLocationView = new WeakReference<>(myLocationView); - locationSource = new WeakReference<>(locationEngine); - } - - @SuppressLint("MissingPermission") - @Override - public void onConnected() { - MyLocationView locationView = userLocationView.get(); - LocationEngine locationEngine = locationSource.get(); - if (locationView != null && locationEngine != null) { - Location lastKnownLocation = locationEngine.getLastLocation(); - if (lastKnownLocation != null) { - locationView.setLocation(lastKnownLocation); - } - locationEngine.requestLocationUpdates(); - } - } - - /** - * Callback method for receiving location updates from LocationServices. - * - * @param location The new Location data - */ - @Override - public void onLocationChanged(Location location) { - MyLocationView locationView = userLocationView.get(); - if (locationView != null) { - locationView.setLocation(location); - } - } - } - - private class CompassListener implements SensorEventListener { - - private final SensorManager sensorManager; - - private Sensor rotationVectorSensor; - private float[] matrix = new float[9]; - private float[] rotationVectorValue; - private float[] truncatedRotationVectorValue = new float[4]; - - private float[] orientation = new float[3]; - private boolean reportMissingSensor = true; - // Compass data - private long compassUpdateNextTimestamp = 0; - - CompassListener(Context context) { - sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); - rotationVectorSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR); - } - - public void onResume() { - sensorManager.registerListener(this, rotationVectorSensor, SensorManager.SENSOR_DELAY_GAME); - } - - public void onPause() { - sensorManager.unregisterListener(this, rotationVectorSensor); - } - - public boolean isSensorAvailable() { - if (rotationVectorSensor == null && reportMissingSensor) { - reportMissingSensor = false; - Timber.e("Sensor.TYPE_ROTATION_VECTOR is missing from this device. Unable to use MyBearingTracking.COMPASS."); - } - return rotationVectorSensor != null; - } - - @Override - public void onSensorChanged(SensorEvent event) { - - // check when the last time the compass was updated, return if too soon. - long currentTime = SystemClock.elapsedRealtime(); - if (currentTime < compassUpdateNextTimestamp) { - return; - } - - if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) { - rotationVectorValue = getRotationVectorFromSensorEvent(event); - SensorManager.getRotationMatrixFromVector(matrix, rotationVectorValue); - SensorManager.getOrientation(matrix, orientation); - - magneticHeading = (float) Math.toDegrees(SensorManager.getOrientation(matrix, orientation)[0]); - if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) { - // Change the user location view orientation to reflect the device orientation - rotateCamera(magneticHeading); - setCompass(0, COMPASS_UPDATE_RATE_MS); - } else { - // Change compass direction - setCompass(magneticHeading - bearing, COMPASS_UPDATE_RATE_MS); - } - - compassUpdateNextTimestamp = currentTime + COMPASS_UPDATE_RATE_MS; - } - } - - /** - * Pulls out the rotation vector from a SensorEvent, with a maximum length - * vector of four elements to avoid potential compatibility issues. - * - * @param event the sensor event - * @return the events rotation vector, potentially truncated - */ - @NonNull - float[] getRotationVectorFromSensorEvent(@NonNull SensorEvent event) { - if (event.values.length > 4) { - // On some Samsung devices SensorManager.getRotationMatrixFromVector - // appears to throw an exception if rotation vector has length > 4. - // For the purposes of this class the first 4 values of the - // rotation vector are sufficient (see crbug.com/335298 for details). - // Only affects Android 4.3 - System.arraycopy(event.values, 0, truncatedRotationVectorValue, 0, 4); - return truncatedRotationVectorValue; - } else { - return event.values; - } - } - - private void rotateCamera(float rotation) { - CameraPosition.Builder builder = new CameraPosition.Builder(); - builder.bearing(rotation); - mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), COMPASS_UPDATE_RATE_MS, - false /*linear interpolator*/, null); - } - - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - - } - - private class MarkerCoordinateAnimatorListener implements ValueAnimator.AnimatorUpdateListener { - - private MyLocationBehavior behavior; - private double fromLat; - private double fromLng; - private double toLat; - private double toLng; - - private MarkerCoordinateAnimatorListener(MyLocationBehavior myLocationBehavior, LatLng from, LatLng to) { - behavior = myLocationBehavior; - fromLat = from.getLatitude(); - fromLng = from.getLongitude(); - toLat = to.getLatitude(); - toLng = to.getLongitude(); - } - - @Override - public void onAnimationUpdate(ValueAnimator animation) { - float frac = animation.getAnimatedFraction(); - double latitude = fromLat + (toLat - fromLat) * frac; - double longitude = fromLng + (toLng - fromLng) * frac; - behavior.updateLatLng(latitude, longitude); - update(); - } - } - - private class MyLocationBehaviorFactory { - - MyLocationBehavior getBehavioralModel(@MyLocationTracking.Mode int mode) { - if (mode == MyLocationTracking.TRACKING_NONE) { - return new MyLocationShowBehavior(); - } else { - return new MyLocationTrackingBehavior(); - } - } - } - - private abstract class MyLocationBehavior { - - MyLocationBehavior() { - if (latLng != null) { - locationUpdateTimestamp = SystemClock.elapsedRealtime(); - } - } - - void updateLatLng(@NonNull Location newLocation) { - location = newLocation; - } - - void updateLatLng(double lat, double lon) { - if (latLng != null) { - latLng.setLatitude(lat); - latLng.setLongitude(lon); - } - } - - void updateAccuracy(@NonNull Location location) { - if (accuracyAnimator != null && accuracyAnimator.isRunning()) { - // use current accuracy as a starting point - accuracy = (Float) accuracyAnimator.getAnimatedValue(); - accuracyAnimator.end(); - } - - float newAccuracy = location.getAccuracy() >= accuracyThreshold ? location.getAccuracy() : 0f; - accuracyAnimator = ValueAnimator.ofFloat(accuracy, newAccuracy); - accuracyAnimator.setDuration(750); - accuracyAnimator.start(); - accuracy = newAccuracy; - } - - abstract void invalidate(); - } - - private class MyLocationTrackingBehavior extends MyLocationBehavior { - - @Override - void updateLatLng(@NonNull Location location) { - super.updateLatLng(location); - if (latLng == null) { - // first location fix - latLng = new LatLng(location); - locationUpdateTimestamp = SystemClock.elapsedRealtime(); - } - - // updateLatLng timestamp - float previousUpdateTimeStamp = locationUpdateTimestamp; - locationUpdateTimestamp = SystemClock.elapsedRealtime(); - - // calculate animation duration - int animationDuration; - if (previousUpdateTimeStamp == 0) { - animationDuration = 0; - } else { - animationDuration = (int) ((locationUpdateTimestamp - previousUpdateTimeStamp) * 1.1f) - /*make animation slightly longer*/; - } - - // calculate interpolated location - latLng = new LatLng(location); - CameraPosition.Builder builder = new CameraPosition.Builder().target(latLng); - - // add direction - if (myBearingTrackingMode == MyBearingTracking.GPS) { - if (location.hasBearing()) { - builder.bearing(location.getBearing()); - } - setCompass(0, COMPASS_UPDATE_RATE_MS); - } - - if (myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING) { - builder.bearing(0); - if (location.hasBearing()) { - setCompass(location.getBearing(), COMPASS_UPDATE_RATE_MS); - } - } - - // accuracy - updateAccuracy(location); - - if (locationChangeAnimationEnabled && animationDuration > 0) { - // ease to new camera position with a linear interpolator - mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), animationDuration, false, null, - true); - } else { - mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(builder.build())); - } - } - - @Override - void invalidate() { - int[] mapPadding = mapboxMap.getPadding(); - float x = (getWidth() + mapPadding[0] - mapPadding[2]) / 2 + contentPaddingX; - float y = (getHeight() - mapPadding[3] + mapPadding[1]) / 2 + contentPaddingY; - screenLocation = new PointF(x, y); - MyLocationView.this.invalidate(); - } - } - - private class MyLocationShowBehavior extends MyLocationBehavior { - - @Override - void updateLatLng(@NonNull final Location location) { - super.updateLatLng(location); - if (latLng == null) { - // first location update - latLng = new LatLng(location); - locationUpdateTimestamp = SystemClock.elapsedRealtime(); - } - - // update LatLng location - LatLng newLocation = new LatLng(location); - - // update LatLng accuracy - updateAccuracy(location); - - // calculate updateLatLng time + add some extra offset to improve animation - long previousUpdateTimeStamp = locationUpdateTimestamp; - locationUpdateTimestamp = SystemClock.elapsedRealtime(); - long locationUpdateDuration = (long) ((locationUpdateTimestamp - previousUpdateTimeStamp) * 1.2f); - - // animate changes - if (locationChangeAnimator != null) { - locationChangeAnimator.end(); - locationChangeAnimator = null; - } - - locationChangeAnimator = ValueAnimator.ofFloat(0.0f, 1.0f); - if (locationChangeAnimationEnabled) { - locationChangeAnimator.setDuration(locationUpdateDuration); - } else { - locationChangeAnimator.setDuration(0); - } - locationChangeAnimator.addUpdateListener(new MarkerCoordinateAnimatorListener(this, - latLng, newLocation - )); - locationChangeAnimator.start(); - latLng = newLocation; - } - - @Override - void invalidate() { - if (latLng != null) { - screenLocation = projection.toScreenLocation(latLng); - } - MyLocationView.this.invalidate(); - } - } -} diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java deleted file mode 100644 index ec7c53e1d0..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java +++ /dev/null @@ -1,389 +0,0 @@ -package com.mapbox.mapboxsdk.maps.widgets; - -import android.graphics.drawable.Drawable; -import android.os.Bundle; -import android.support.annotation.ColorInt; -import android.support.annotation.IntRange; -import android.support.annotation.NonNull; - -import com.mapbox.mapboxsdk.camera.CameraPosition; -import com.mapbox.mapboxsdk.constants.MapboxConstants; -import com.mapbox.mapboxsdk.constants.MyLocationTracking; -import com.mapbox.mapboxsdk.maps.FocalPointChangeListener; -import com.mapbox.mapboxsdk.maps.MapboxMapOptions; -import com.mapbox.mapboxsdk.maps.Projection; -import com.mapbox.mapboxsdk.utils.BitmapUtils; - -/** - * Settings to configure the visual appearance of the MyLocationView. - * - * @deprecated use location layer plugin from - * https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead. - */ -@Deprecated -public class MyLocationViewSettings { - - private Projection projection; - private MyLocationView myLocationView; - private FocalPointChangeListener focalPointChangeListener; - - // - // State - // - - private boolean enabled; - - // - // Foreground - // - - private Drawable foregroundDrawable; - private Drawable foregroundBearingDrawable; - - @ColorInt - private int foregroundTintColor; - - // - // Background - // - - private Drawable backgroundDrawable; - private int[] backgroundOffset = new int[4]; - - @ColorInt - private int backgroundTintColor; - - // - // Accuracy - // - - private int accuracyAlpha; - private float accuracyThreshold = 0f; - - @ColorInt - private int accuracyTintColor; - - // - // Padding - // - - private int[] padding = new int[4]; - - /** - * Creates an instance of MyLocationViewSettings - *

- * - * @param myLocationView the MyLocationView to apply the settings to - * @param projection the MapView projection - * @param focalPointChangedListener the interface to be invoked when focal points changes - * @see MyLocationView - */ - public MyLocationViewSettings(MyLocationView myLocationView, Projection projection, FocalPointChangeListener - focalPointChangedListener) { - this.myLocationView = myLocationView; - this.projection = projection; - this.focalPointChangeListener = focalPointChangedListener; - } - - /** - * Initialise this with MapboxMapOptions. - * - * @param options the options to initialise this class from - */ - public void initialise(@NonNull MapboxMapOptions options) { - CameraPosition position = options.getCamera(); - if (position != null && !position.equals(CameraPosition.DEFAULT)) { - setTilt(position.tilt); - } - setForegroundDrawable(options.getMyLocationForegroundDrawable(), options.getMyLocationForegroundBearingDrawable()); - setForegroundTintColor(options.getMyLocationForegroundTintColor()); - setBackgroundDrawable(options.getMyLocationBackgroundDrawable(), options.getMyLocationBackgroundPadding()); - setBackgroundTintColor(options.getMyLocationBackgroundTintColor()); - setAccuracyAlpha(options.getMyLocationAccuracyAlpha()); - setAccuracyTintColor(options.getMyLocationAccuracyTintColor()); - setAccuracyThreshold(options.getMyLocationAccuracyThreshold()); - } - - public void onSaveInstanceState(Bundle outState) { - outState.putBoolean(MapboxConstants.STATE_LOCATION_VIEW_ENABLED, isEnabled()); - outState.putByteArray( - MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_DRAWABLE, - BitmapUtils.getByteArrayFromDrawable(getForegroundDrawable()) - ); - outState.putByteArray( - MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_BEARING_DRAWABLE, - BitmapUtils.getByteArrayFromDrawable(getForegroundBearingDrawable()) - ); - outState.putInt(MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_TINT_COLOR, getForegroundTintColor()); - outState.putByteArray( - MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_DRAWABLE, - BitmapUtils.getByteArrayFromDrawable(getBackgroundDrawable()) - ); - outState.putIntArray(MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_OFFSET, getBackgroundOffset()); - outState.putInt(MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_TINT_COLOR, getBackgroundTintColor()); - outState.putInt(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_ALPHA, getAccuracyAlpha()); - outState.putInt(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_TINT_COLOR, getAccuracyTintColor()); - outState.putFloat(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_THRESHOLD, getAccuracyThreshold()); - outState.putIntArray(MapboxConstants.STATE_LOCATION_VIEW_PADDING, getPadding()); - } - - public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { - setEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_LOCATION_VIEW_ENABLED)); - setForegroundDrawable( - BitmapUtils.getDrawableFromByteArray( - myLocationView.getContext(), - savedInstanceState.getByteArray(MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_DRAWABLE) - ), - BitmapUtils.getDrawableFromByteArray( - myLocationView.getContext(), - savedInstanceState.getByteArray(MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_BEARING_DRAWABLE) - ) - ); - setForegroundTintColor(savedInstanceState.getInt(MapboxConstants.STATE_LOCATION_VIEW_FOREGROUND_TINT_COLOR)); - setBackgroundDrawable( - BitmapUtils.getDrawableFromByteArray( - myLocationView.getContext(), - savedInstanceState.getByteArray(MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_DRAWABLE) - ), - savedInstanceState.getIntArray(MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_OFFSET) - ); - setBackgroundTintColor(savedInstanceState.getInt(MapboxConstants.STATE_LOCATION_VIEW_BACKGROUND_TINT_COLOR)); - setAccuracyAlpha(savedInstanceState.getInt(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_ALPHA)); - setAccuracyTintColor(savedInstanceState.getInt(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_TINT_COLOR)); - setAccuracyThreshold(savedInstanceState.getFloat(MapboxConstants.STATE_LOCATION_VIEW_ACCURACY_THRESHOLD)); - setPadding(savedInstanceState.getIntArray(MapboxConstants.STATE_LOCATION_VIEW_PADDING)); - } - - /** - * Returns if the MyLocationView is enabled - * - * @return true if MyLocationView is enabled, - */ - public boolean isEnabled() { - return enabled; - } - - /** - * Set the enabled state of MyLocationView - * - * @param enabled true shows the MyLocationView on the map - */ - public void setEnabled(boolean enabled) { - this.enabled = enabled; - myLocationView.setEnabled(enabled); - } - - /** - * Set the foreground drawable of the MyLocationView - *

- * The foreground drawable is the image visible on screen - *

- * It's linked with the foreground tint color - * - * @param foregroundDrawable the drawable to show as foreground without bearing - * @param foregroundBearingDrawable the drawable to show as foreground when bearing is enabled - */ - public void setForegroundDrawable(Drawable foregroundDrawable, Drawable foregroundBearingDrawable) { - this.foregroundDrawable = foregroundDrawable; - this.foregroundBearingDrawable = foregroundBearingDrawable; - myLocationView.setForegroundDrawables(foregroundDrawable, foregroundBearingDrawable); - myLocationView.setForegroundDrawableTint(foregroundTintColor); - } - - /** - * Get the foreground drawable when bearing is disabled. - * - * @return the drawable used as foreground - */ - public Drawable getForegroundDrawable() { - return foregroundDrawable; - } - - /** - * Get the foreground drawable when bearing is enabled. - * - * @return the bearing drawable used as foreground - */ - public Drawable getForegroundBearingDrawable() { - return foregroundBearingDrawable; - } - - /** - * Set the foreground tint color. - *

- * The color will tint both the foreground and the bearing foreground drawable. - *

- * - * @param foregroundTintColor the color to tint the foreground drawable or -1 (undefined color) to remove the - * existing foreground tint color - */ - public void setForegroundTintColor(@ColorInt int foregroundTintColor) { - this.foregroundTintColor = foregroundTintColor; - myLocationView.setForegroundDrawableTint(foregroundTintColor); - } - - /** - * Get the foreground tint color. - * - * @return the foreground tint color - */ - public int getForegroundTintColor() { - return foregroundTintColor; - } - - /** - * Set the background drawable of MyLocationView - *

- * Padding can be added to provide an offset to the background - *

- * It's linked with the background tint color - * - * @param backgroundDrawable the drawable to show as background - * @param padding the padding added to the background - */ - public void setBackgroundDrawable(Drawable backgroundDrawable, int[] padding) { - this.backgroundDrawable = backgroundDrawable; - this.backgroundOffset = padding; - if (padding != null && padding.length == 4) { - myLocationView.setShadowDrawable(backgroundDrawable, padding[0], padding[1], padding[2], padding[3]); - } else { - myLocationView.setShadowDrawable(backgroundDrawable); - } - myLocationView.setShadowDrawableTint(backgroundTintColor); - } - - /** - * Get the background drawable of MyLocationView. - * - * @return the drawable used as background - */ - public Drawable getBackgroundDrawable() { - return backgroundDrawable; - } - - /** - * Set the background tint color. - * - * @param backgroundTintColor the color to tint the background drawable or -1 (undefined color) to remove the - * existing background tint color - */ - public void setBackgroundTintColor(@ColorInt int backgroundTintColor) { - this.backgroundTintColor = backgroundTintColor; - myLocationView.setShadowDrawableTint(backgroundTintColor); - } - - /** - * Get the background tint color. - * - * @return the background tint color - */ - public int getBackgroundTintColor() { - return backgroundTintColor; - } - - /** - * Get the background offset. - * - * @return the background offset - */ - public int[] getBackgroundOffset() { - return backgroundOffset; - } - - /** - * Set the MyLocationView padding. - * - * @param left the padding left of MyLocationView - * @param top the padding top of MyLocationView - * @param right the padding right of MyLocationView - * @param bottom the padding bottom of MyLocaionView - */ - public void setPadding(int left, int top, int right, int bottom) { - padding = new int[] {left, top, right, bottom}; - setPadding(padding); - } - - private void setPadding(int[] padding) { - myLocationView.setContentPadding(padding); - projection.invalidateContentPadding(padding); - invalidateFocalPointForTracking(myLocationView); - } - - /** - * Get the MyLocationView padding. - * - * @return an array describing the padding in a LTRB manner - */ - public int[] getPadding() { - return padding; - } - - /** - * Get the alpha value of the accuracy circle of MyLocationView - * - * @return the alpha value - */ - public int getAccuracyAlpha() { - return accuracyAlpha; - } - - /** - * Set the alpha value of the accuracy circle of MyLocationView - * - * @param accuracyAlpha the alpha value to set - */ - public void setAccuracyAlpha(@IntRange(from = 0, to = 255) int accuracyAlpha) { - this.accuracyAlpha = accuracyAlpha; - myLocationView.setAccuracyAlpha(accuracyAlpha); - } - - /** - * Get the accuracy tint color of MyLocationView. - * - * @return the tint color used for accuracy - */ - public int getAccuracyTintColor() { - return accuracyTintColor; - } - - /** - * Set the accuracy tint color of MyLocationView. - * - * @param accuracyTintColor the accuracy tint color - */ - public void setAccuracyTintColor(@ColorInt int accuracyTintColor) { - this.accuracyTintColor = accuracyTintColor; - myLocationView.setAccuracyTint(accuracyTintColor); - } - - /** - * Returns current accuracy threshold value (in meters). - * - * @return Value of accuracy threshold (in meters), below which circle won't be displayed - */ - public float getAccuracyThreshold() { - return accuracyThreshold; - } - - /** - * Set accuracy circle threshold. Circle won't be displayed if accuracy is below set value. - * - * @param accuracyThreshold Value of accuracy (in meters), below which circle won't be displayed - */ - public void setAccuracyThreshold(float accuracyThreshold) { - this.accuracyThreshold = accuracyThreshold; - myLocationView.setAccuracyThreshold(accuracyThreshold); - } - - public void setTilt(double tilt) { - myLocationView.setTilt(tilt); - } - - private void invalidateFocalPointForTracking(MyLocationView myLocationView) { - if (!(myLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE)) { - focalPointChangeListener.onFocalPointChanged(myLocationView.getCenter()); - } else { - focalPointChangeListener.onFocalPointChanged(null); - } - } -} 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 29ff49f47e..c6efd0aeaf 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 @@ -1,19 +1,6 @@ - - - - - diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java index d9e3ae427d..6ee5c157b9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java @@ -5,7 +5,6 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException; -import com.mapbox.android.core.location.LocationEngine; import org.junit.Before; import org.junit.Test; @@ -25,13 +24,11 @@ public class MapboxTest { private Context context; private Context appContext; - private LocationEngine locationSource; @Before public void before() { context = mock(Context.class); appContext = mock(Context.class); - locationSource = mock(LocationEngine.class); when(context.getApplicationContext()).thenReturn(appContext); } @@ -83,7 +80,7 @@ public class MapboxTest { } private void injectMapboxSingleton(String accessToken) { - Mapbox mapbox = new Mapbox(appContext, accessToken, locationSource); + Mapbox mapbox = new Mapbox(appContext, accessToken); try { Field field = Mapbox.class.getDeclaredField("INSTANCE"); field.setAccessible(true); diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java deleted file mode 100644 index ebd30f5422..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java +++ /dev/null @@ -1,219 +0,0 @@ -package com.mapbox.mapboxsdk.annotations; - -import android.os.Parcelable; - -import com.mapbox.mapboxsdk.exceptions.InvalidMarkerPositionException; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.utils.MockParcel; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -public class MarkerViewTest { - - @Mock - MapboxMap mapboxMap; - - @Mock - MarkerViewManager markerViewManager; - - @Before - public void beforeTest() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testSanity() { - MarkerViewOptions markerOptions = new MarkerViewOptions(); - assertNotNull("markerOptions should not be null", markerOptions); - } - - @Test - public void testMarker() { - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()); - assertNotNull("marker should not be null", markerOptions.getMarker()); - } - - @Test(expected = InvalidMarkerPositionException.class) - public void testInvalidMarker() { - new MarkerViewOptions().getMarker(); - } - - @Test - public void testPosition() { - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(10, 12)); - MarkerView marker = markerOptions.getMarker(); - assertEquals(marker.getPosition(), new LatLng(10, 12)); - assertEquals(markerOptions.getPosition(), new LatLng(10, 12)); - } - - @Test - public void testSnippet() { - MarkerViewOptions markerOptions = new MarkerViewOptions().snippet("Mapbox").position(new LatLng()); - MarkerView marker = markerOptions.getMarker(); - assertEquals(marker.getSnippet(), "Mapbox"); - } - - @Test - public void testTitle() { - MarkerViewOptions markerOptions = new MarkerViewOptions().title("Mapbox").position(new LatLng()); - MarkerView marker = markerOptions.getMarker(); - assertEquals(marker.getTitle(), "Mapbox"); - assertEquals(markerOptions.getTitle(), "Mapbox"); - } - - @Test - public void testFlat() { - MarkerViewOptions markerOptions = new MarkerViewOptions().flat(true).position(new LatLng()); - MarkerView marker = markerOptions.getMarker(); - assertTrue("flat should be true", marker.isFlat()); - } - - @Test - public void testFlatDefault() { - assertFalse("default value of flat should be false", new MarkerViewOptions().position( - new LatLng()).getMarker().isFlat()); - } - - @Test - public void testAnchor() { - float anchorU = 1; - float anchorV = 1; - MarkerViewOptions markerOptions = new MarkerViewOptions().anchor(anchorU, anchorV).position(new LatLng()); - MarkerView marker = markerOptions.getMarker(); - assertEquals("anchorU should match ", anchorU, marker.getAnchorU(), 0); - assertEquals("anchorU should match ", anchorV, marker.getAnchorV(), 0); - } - - @Test - public void testAnchorDefault() { - MarkerView marker = new MarkerViewOptions().position(new LatLng()).getMarker(); - assertEquals("anchorU should match ", 0.5, marker.getAnchorU(), 0); - assertEquals("anchorU should match ", 1, marker.getAnchorV(), 0); - } - - @Test - public void testInfoWindowAnchor() { - float anchorU = 1; - float anchorV = 1; - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).infoWindowAnchor(anchorU, anchorV); - MarkerView marker = markerOptions.getMarker(); - assertEquals("anchorU should match ", 1, marker.getInfoWindowAnchorU(), 0); - assertEquals("anchorU should match ", 1, marker.getInfoWindowAnchorV(), 0); - } - - @Test - public void testInfoWindowAnchorDefault() { - MarkerView marker = new MarkerViewOptions().position(new LatLng()).getMarker(); - assertEquals("anchorU should match ", 0.5, marker.getInfoWindowAnchorU(), 0); - assertEquals("anchorU should match ", 0, marker.getInfoWindowAnchorV(), 0); - } - - @Test - public void testRotation() { - int rotation = 90; - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(rotation); - MarkerView marker = markerOptions.getMarker(); - assertEquals("rotation should match ", rotation, marker.getRotation(), 0); - } - - @Test - public void testRotationAboveMax() { - MarkerViewOptions markerOptions = new MarkerViewOptions().rotation(390).position(new LatLng()); - MarkerView marker = markerOptions.getMarker(); - assertEquals(marker.getRotation(), 30, 0); - } - - @Test - public void testRotationBelowMin() { - MarkerViewOptions markerOptions = new MarkerViewOptions().rotation(-10).position(new LatLng()); - MarkerView marker = markerOptions.getMarker(); - assertEquals(marker.getRotation(), 350, 0); - } - - @Test - public void testVisible() { - boolean visible = false; - MarkerViewOptions markerOptions = new MarkerViewOptions().visible(visible).position(new LatLng()); - MarkerView marker = markerOptions.getMarker(); - assertEquals("visible should match ", visible, marker.isVisible()); - } - - @Test - public void testVisibleDefault() { - assertTrue(new MarkerViewOptions().position(new LatLng()).getMarker().isVisible()); - } - - @Test - public void testBuilder() { - MarkerView marker = new MarkerViewOptions().title("title").snippet("snippet").position( - new LatLng(10, 12)).getMarker(); - assertEquals(marker.getSnippet(), "snippet"); - assertEquals(marker.getPosition(), new LatLng(10, 12)); - } - - @Test - public void testHashCode() { - MarkerView marker = new MarkerViewOptions().position(new LatLng()).getMarker(); - assertEquals("hash code should match", marker.hashCode(), 0); - } - - @Test - public void testHashCodeBuilder() { - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(10, 12)); - assertEquals("hash code should match", markerOptions.hashCode(), 0); - } - - @Test - public void testEquals() { - MarkerView markerOne = new MarkerViewOptions().position(new LatLng(0, 0)).getMarker(); - MarkerView markerTwo = new MarkerViewOptions().position(new LatLng(0, 0)).getMarker(); - assertEquals(markerOne, markerTwo); - } - - @Test - public void testEqualsItself() { - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(0, 0)); - MarkerView marker = markerOptions.getMarker(); - assertEquals("MarkerView should match", marker, marker); - assertEquals("MarkerViewOptions should match", markerOptions, markerOptions); - } - - @Test - public void testNotEquals() { - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng(0, 0)); - MarkerView marker = markerOptions.getMarker(); - assertNotEquals("MarkerViewOptions should match", markerOptions, new Object()); - assertNotEquals("MarkerView should match", marker, new Object()); - } - - @Test - public void testEqualityBuilder() { - MarkerViewOptions markerOne = new MarkerViewOptions().position(new LatLng(0, 0)); - MarkerViewOptions markerTwo = new MarkerViewOptions().position(new LatLng(0, 0)); - assertEquals(markerOne, markerTwo); - } - - @Test - public void testToString() { - MarkerView marker = new MarkerViewOptions().position(new LatLng(0, 0)).getMarker(); - assertEquals(marker.toString(), "MarkerView [position[" - + "LatLng [latitude=0.0, longitude=0.0, altitude=0.0]" + "]]"); - } - - @Test - public void testParcelable() { - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).title("t").snippet("s"); - Parcelable parcelable = MockParcel.obtain(markerOptions); - assertEquals("Parcel should match original object", parcelable, markerOptions); - } -} diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AnnotationManagerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AnnotationManagerTest.java index 239ad7392b..4a975659ee 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AnnotationManagerTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AnnotationManagerTest.java @@ -6,7 +6,6 @@ import com.mapbox.mapboxsdk.annotations.Annotation; import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.MarkerOptions; -import com.mapbox.mapboxsdk.annotations.MarkerViewManager; import com.mapbox.mapboxsdk.geometry.LatLng; import org.junit.Test; @@ -27,15 +26,14 @@ public class AnnotationManagerTest { NativeMapView aNativeMapView = mock(NativeMapView.class); MapView aMapView = mock(MapView.class); LongSparseArray annotationsArray = new LongSparseArray<>(); - MarkerViewManager aMarkerViewManager = mock(MarkerViewManager.class); IconManager aIconManager = mock(IconManager.class); Annotations annotations = new AnnotationContainer(aNativeMapView, annotationsArray); - Markers markers = new MarkerContainer(aNativeMapView, aMapView, annotationsArray, aIconManager, aMarkerViewManager); + Markers markers = new MarkerContainer(aNativeMapView, annotationsArray, aIconManager); Polygons polygons = new PolygonContainer(aNativeMapView, annotationsArray); Polylines polylines = new PolylineContainer(aNativeMapView, annotationsArray); ShapeAnnotations shapeAnnotations = new ShapeAnnotationContainer(aNativeMapView, annotationsArray); - AnnotationManager annotationManager = new AnnotationManager(aNativeMapView, aMapView, annotationsArray, - aMarkerViewManager, aIconManager, annotations, markers, polygons, polylines, shapeAnnotations); + AnnotationManager annotationManager = new AnnotationManager(aMapView, annotationsArray, + aIconManager, annotations, markers, polygons, polylines, shapeAnnotations); Marker aMarker = mock(Marker.class); long aId = 5L; when(aNativeMapView.addMarker(aMarker)).thenReturn(aId); @@ -54,15 +52,14 @@ public class AnnotationManagerTest { NativeMapView aNativeMapView = mock(NativeMapView.class); MapView aMapView = mock(MapView.class); LongSparseArray annotationsArray = new LongSparseArray<>(); - MarkerViewManager aMarkerViewManager = mock(MarkerViewManager.class); IconManager aIconManager = mock(IconManager.class); Annotations annotations = new AnnotationContainer(aNativeMapView, annotationsArray); - Markers markers = new MarkerContainer(aNativeMapView, aMapView, annotationsArray, aIconManager, aMarkerViewManager); + Markers markers = new MarkerContainer(aNativeMapView, annotationsArray, aIconManager); Polygons polygons = new PolygonContainer(aNativeMapView, annotationsArray); Polylines polylines = new PolylineContainer(aNativeMapView, annotationsArray); ShapeAnnotations shapeAnnotations = new ShapeAnnotationContainer(aNativeMapView, annotationsArray); - AnnotationManager annotationManager = new AnnotationManager(aNativeMapView, aMapView, annotationsArray, - aMarkerViewManager, aIconManager, annotations, markers, polygons, polylines, shapeAnnotations); + AnnotationManager annotationManager = new AnnotationManager(aMapView, annotationsArray, + aIconManager, annotations, markers, polygons, polylines, shapeAnnotations); long firstId = 1L; long secondId = 2L; List markerList = new ArrayList<>(); diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java index eeb00355bd..48ad9f47c9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java @@ -21,7 +21,7 @@ public class MapTouchListenersTest { Projection projection = mock(Projection.class); when(projection.fromScreenLocation(pointF)).thenReturn(latLng); MapGestureDetector mapGestureDetector = new MapGestureDetector(null, - null, projection, null, null, null, null); + null, projection, null, null, null); MapboxMap.OnMapClickListener listener = mock(MapboxMap.OnMapClickListener.class); mapGestureDetector.addOnMapClickListener(listener); @@ -41,7 +41,7 @@ public class MapTouchListenersTest { Projection projection = mock(Projection.class); when(projection.fromScreenLocation(pointF)).thenReturn(latLng); MapGestureDetector mapGestureDetector = new MapGestureDetector(null, - null, projection, null, null, null, null); + null, projection, null, null, null); MapboxMap.OnMapLongClickListener listener = mock(MapboxMap.OnMapLongClickListener.class); mapGestureDetector.addOnMapLongClickListener(listener); @@ -61,7 +61,7 @@ public class MapTouchListenersTest { Projection projection = mock(Projection.class); when(projection.fromScreenLocation(pointF)).thenReturn(latLng); MapGestureDetector mapGestureDetector = new MapGestureDetector(null, - null, projection, null, null, null, null); + null, projection, null, null, null); MapboxMap.OnFlingListener listener = mock(MapboxMap.OnFlingListener.class); mapGestureDetector.addOnFlingListener(listener); @@ -81,7 +81,7 @@ public class MapTouchListenersTest { Projection projection = mock(Projection.class); when(projection.fromScreenLocation(pointF)).thenReturn(latLng); MapGestureDetector mapGestureDetector = new MapGestureDetector(null, - null, projection, null, null, null, null); + null, projection, null, null, null); MapboxMap.OnScrollListener listener = mock(MapboxMap.OnScrollListener.class); mapGestureDetector.addOnScrollListener(listener); diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java index 5e9f94db28..2566ad2f1d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java @@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.maps; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings; import org.junit.After; import org.junit.Before; @@ -16,12 +15,9 @@ public class MapboxMapTest { @Before public void beforeTest() { - mapboxMap = new MapboxMap(mock(NativeMapView.class), mock(Transform.class), mock(UiSettings.class), - mock(TrackingSettings.class), - mock(MyLocationViewSettings.class), mock(Projection.class), mock(MapboxMap.OnRegisterTouchListener.class), mock(AnnotationManager.class), diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java deleted file mode 100644 index de5f364a5b..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.mapbox.mapboxsdk.maps; - -import android.Manifest; -import android.content.Context; -import android.content.pm.PackageManager; -import android.graphics.PointF; - -import com.mapbox.mapboxsdk.constants.MyLocationTracking; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class TrackingSettingsTest { - - @InjectMocks - MyLocationView myLocationView = mock(MyLocationView.class); - - @InjectMocks - UiSettings uiSettings = mock(UiSettings.class); - - @InjectMocks - FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class); - - @InjectMocks - TrackingSettings.CameraZoomInvalidator zoomInvalidator = mock(TrackingSettings.CameraZoomInvalidator.class); - - private TrackingSettings trackingSettings; - - @Before - public void beforeTest() { - trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointChangeListener, zoomInvalidator); - } - - @Test - public void testSanity() { - assertNotNull("trackingsettings should not be null", trackingSettings); - } - - @Test - public void testDismissTrackingModesOnGesture() { - trackingSettings.setDismissAllTrackingOnGesture(false); - assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isAllDismissTrackingOnGesture()); - } - - @Test - public void testValidateGesturesForTrackingModes() { - trackingSettings.setDismissAllTrackingOnGesture(false); - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isAllDismissTrackingOnGesture()); - } - - @Test - public void testMyLocationEnabled() { - // setup mock context to provide accepted location permission - Context context = mock(Context.class); - when(myLocationView.getContext()).thenReturn(context); - when(context.checkPermission(eq(Manifest.permission.ACCESS_COARSE_LOCATION), anyInt(), - anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED); - - assertFalse("Location should be disabled by default.", trackingSettings.isMyLocationEnabled()); - trackingSettings.setMyLocationEnabled(true); - assertTrue("Location should be enabled", trackingSettings.isMyLocationEnabled()); - } - - @Test - public void testCameraZoomTo2forTracking() { - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - verify(zoomInvalidator, atLeast(1)).zoomTo(2.0); - } - - @Test - public void testFocalPointChangeForTracking() { - final float centerX = 32.3f; - final float centerY = 46.3f; - final PointF pointF = new PointF(centerX, centerY); - when(myLocationView.getCenter()).thenReturn(pointF); - - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - verify(focalPointChangeListener, atLeast(1)).onFocalPointChanged(pointF); - } - - @Test - public void testFocalPointChangeForNonTracking() { - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE); - verify(focalPointChangeListener, atLeast(1)).onFocalPointChanged(null); - } -} diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java deleted file mode 100644 index c9ce19dc85..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.mapbox.mapboxsdk.maps.widgets; - -import android.graphics.Color; -import android.graphics.drawable.Drawable; - -import com.mapbox.mapboxsdk.maps.FocalPointChangeListener; -import com.mapbox.mapboxsdk.maps.Projection; -import com.mapbox.mapboxsdk.maps.TrackingSettings; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; - -import java.util.Arrays; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class MyLocationViewSettingsTest { - - @InjectMocks - Projection projection = mock(Projection.class); - - @InjectMocks - MyLocationView myLocationView = mock(MyLocationView.class); - - @InjectMocks - TrackingSettings trackingSettings = mock(TrackingSettings.class); - - @InjectMocks - FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class); - - private MyLocationViewSettings locationViewSettings; - - @Before - public void beforeTest() { - locationViewSettings = new MyLocationViewSettings(myLocationView, projection, focalPointChangeListener); - } - - @Test - public void testSanity() { - assertNotNull("should not be null", locationViewSettings); - } - - @Test - public void testForegroundDrawables() { - Drawable foregroundDrawable = mock(Drawable.class); - Drawable foregroundBearingDrawable = mock(Drawable.class); - Drawable.ConstantState constantState = mock(Drawable.ConstantState.class); - when(foregroundDrawable.getConstantState()).thenReturn(constantState); - when(constantState.newDrawable()).thenReturn(foregroundDrawable); - locationViewSettings.setForegroundDrawable(foregroundDrawable, foregroundBearingDrawable); - assertEquals("foreground should match", foregroundDrawable, locationViewSettings.getForegroundDrawable()); - assertEquals("foreground bearing should match", foregroundBearingDrawable, - locationViewSettings.getForegroundBearingDrawable()); - } - - @Test - public void testBackgroundDrawable() { - Drawable backgroundDrawable = mock(Drawable.class); - int[] offset = new int[] {1, 2, 3, 4}; - locationViewSettings.setBackgroundDrawable(backgroundDrawable, offset); - assertEquals("foreground should match", backgroundDrawable, locationViewSettings.getBackgroundDrawable()); - assertTrue("offsets should match", Arrays.equals(offset, locationViewSettings.getBackgroundOffset())); - } - - @Test - public void testForegroundTint() { - int color = Color.RED; - locationViewSettings.setForegroundTintColor(Color.RED); - assertEquals("color should match", color, locationViewSettings.getForegroundTintColor()); - } - - @Test - public void testForegroundTransparentTint() { - int color = Color.TRANSPARENT; - locationViewSettings.setForegroundTintColor(Color.TRANSPARENT); - assertEquals("color should match", color, locationViewSettings.getForegroundTintColor()); - } - - @Test - public void testBackgroundTint() { - int color = Color.RED; - locationViewSettings.setBackgroundTintColor(Color.RED); - assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor()); - } - - @Test - public void testBackgroundTransparentTint() { - int color = Color.TRANSPARENT; - locationViewSettings.setBackgroundTintColor(Color.TRANSPARENT); - assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor()); - } - - @Test - public void testEnabled() { - assertFalse("initial state should be false", locationViewSettings.isEnabled()); - locationViewSettings.setEnabled(true); - assertTrue("state should be true", locationViewSettings.isEnabled()); - } -} - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java index b4bc118129..38fd8491a8 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java @@ -161,16 +161,6 @@ public class MapboxMapTest extends BaseActivityTest { })); } - // - // TrackingSettings - // - - @Test - public void testTrackingSettings() { - validateTestSetup(); - assertNotNull("TrackingSettings should not be null", mapboxMap.getTrackingSettings()); - } - // // InfoWindow // @@ -203,30 +193,6 @@ public class MapboxMapTest extends BaseActivityTest { })); } - // - // Location - // - - @Test - @Ignore /* disabled due to enabling permissions during test #7177 */ - public void testMyLocationEnabled() { - validateTestSetup(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> { - mapboxMap.setMyLocationEnabled(true); - assertTrue("MyLocationEnabled should be true", mapboxMap.isMyLocationEnabled()); - })); - } - - @Test - @Ignore /* can't create handler inside thread that not called Looper.prepare() */ - public void testMyLocationDisabled() { - validateTestSetup(); - onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> { - mapboxMap.setMyLocationEnabled(false); - assertFalse("MyLocationEnabled should be false", mapboxMap.isMyLocationEnabled()); - })); - } - // // setters/getters interfaces // diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java index 33a946d0a1..bc34d141c6 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/IconTest.java @@ -118,7 +118,7 @@ public class IconTest extends BaseActivityTest { .position(new LatLng(5, 1)) ); mapboxMap.addMarker(new MarkerOptions() - .icon(iconFactory.fromResource(R.drawable.ic_android)) + .icon(iconFactory.fromResource(R.drawable.icon)) .position(new LatLng(6, 1)) ); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java deleted file mode 100644 index ad153336a4..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/annotations/MarkerViewTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.annotations; - -import com.mapbox.mapboxsdk.annotations.Marker; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.annotation.MarkerViewActivity; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; -import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerViewOptions; -import com.mapbox.mapboxsdk.testapp.utils.TestConstants; - -import org.junit.Ignore; -import org.junit.Test; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withText; -import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke; -import static org.junit.Assert.assertEquals; - -public class MarkerViewTest extends BaseActivityTest { - - private Marker marker; - - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } - - @Test - @Ignore - public void addMarkerViewTest() { - validateTestSetup(); - addAdapter(); - invoke(mapboxMap, (uiController, mapboxMap) -> { - assertEquals("Markers should be empty", 0, mapboxMap.getMarkers().size()); - - TextMarkerViewOptions options = new TextMarkerViewOptions(); - options.text(TestConstants.TEXT_MARKER_TEXT); - options.position(new LatLng()); - options.snippet(TestConstants.TEXT_MARKER_SNIPPET); - options.title(TestConstants.TEXT_MARKER_TITLE); - marker = mapboxMap.addMarker(options); - assertEquals("Markers size should be 1, ", 1, mapboxMap.getMarkers().size()); - assertEquals("Marker id should be 0", 0, marker.getId()); - assertEquals("Marker target should match", new LatLng(), marker.getPosition()); - assertEquals("Marker snippet should match", TestConstants.TEXT_MARKER_SNIPPET, marker.getSnippet()); - assertEquals("Marker target should match", TestConstants.TEXT_MARKER_TITLE, marker.getTitle()); - uiController.loopMainThreadForAtLeast(500); - }); - onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed())); - } - - @Test - @Ignore - public void showInfoWindowTest() { - validateTestSetup(); - addAdapter(); - invoke(mapboxMap, (uiController, mapboxMap) -> { - final TextMarkerViewOptions options = new TextMarkerViewOptions(); - options.position(new LatLng()); - options.text(TestConstants.TEXT_MARKER_TEXT); - options.snippet(TestConstants.TEXT_MARKER_SNIPPET); - options.title(TestConstants.TEXT_MARKER_TITLE); - marker = mapboxMap.addMarker(options); - uiController.loopMainThreadForAtLeast(500); - mapboxMap.selectMarker(marker); - }); - onView(withText(TestConstants.TEXT_MARKER_TEXT)).check(matches(isDisplayed())); - onView(withText(TestConstants.TEXT_MARKER_TITLE)).check(matches(isDisplayed())); - onView(withText(TestConstants.TEXT_MARKER_SNIPPET)).check(matches(isDisplayed())); - } - - private void addAdapter() { - invoke(mapboxMap, (uiController, mapboxMap) -> mapboxMap.getMarkerViewManager().addMarkerViewAdapter( - new MarkerViewActivity.TextAdapter(rule.getActivity(), mapboxMap))); - } - -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java deleted file mode 100644 index cf58ba50a6..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java +++ /dev/null @@ -1,229 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.maps.widgets; - -import android.annotation.SuppressLint; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; -import android.view.View; - -import com.mapbox.mapboxsdk.Mapbox; -import com.mapbox.mapboxsdk.camera.CameraPosition; -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.constants.MyBearingTracking; -import com.mapbox.mapboxsdk.constants.MyLocationTracking; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest; -import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.junit.Ignore; -import org.junit.Test; - -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; -import static org.hamcrest.Matchers.not; - -/** - * Experimental MyLocationView tests, - * requires application to be granted with runtime location permissions. - *

- * Tests for enabling and disabling the {@link MyLocationView}. - * Tests for enabling tracking modes and if the correct default images are shown when toggling - * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setMyLocationTrackingMode(int)} & - * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setMyBearingTrackingMode(int)}. - *

- */ -public class MyLocationViewTest extends BaseActivityTest { - - @Override - protected Class getActivityClass() { - return EspressoTestActivity.class; - } - - @Test - @Ignore // requires runtime permissions, disabled for CI - public void testEnabled() { - validateTestSetup(); - onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); - onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true)); - onView(withId(R.id.userLocationView)).check(matches(isDisplayed())); - onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, false)); - onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); - } - - @Test - @Ignore - // requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException: - // Looped for 5049 iterations over 60 SECONDS. - public void testTracking() { - validateTestSetup(); - onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed()))); - onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap)); - onView(withId(R.id.userLocationView)).check(matches(isDisplayed())); - onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, - R.drawable.mapbox_mylocation_icon_default, false))); - onView(withId(R.id.mapView)).perform(new EnableCompassBearingTrackingAction(mapboxMap)); - onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap, - R.drawable.mapbox_mylocation_icon_bearing, true))); - } - - private class ToggleLocationAction implements ViewAction { - - private MapboxMap mapboxMap; - private boolean isEnabled; - - ToggleLocationAction(MapboxMap map, boolean enable) { - mapboxMap = map; - isEnabled = enable; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @SuppressLint("MissingPermission") - @Override - public void perform(UiController uiController, View view) { - if (isEnabled) { - // move camera above user location - mapboxMap.moveCamera( - CameraUpdateFactory.newCameraPosition( - new CameraPosition.Builder() - .target(new LatLng(Mapbox.getLocationEngine().getLastLocation())) - .build() - ) - ); - } - - // show loction on screen - mapboxMap.setMyLocationEnabled(isEnabled); - } - } - - private class EnableLocationTrackingAction implements ViewAction { - - private MapboxMap mapboxMap; - - EnableLocationTrackingAction(MapboxMap map) { - mapboxMap = map; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - } - } - - private class EnableCompassBearingTrackingAction implements ViewAction { - - private MapboxMap mapboxMap; - - EnableCompassBearingTrackingAction(MapboxMap map) { - mapboxMap = map; - } - - @Override - public Matcher getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } - - @Override - public void perform(UiController uiController, View view) { - mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS); - // wait for next compass update cycle - uiController.loopMainThreadForAtLeast(500); - } - } - - private class DrawableMatcher extends TypeSafeMatcher { - - private MapboxMap mapboxMap; - private boolean isBearingDrawable; - private final int expectedId; - - DrawableMatcher(MapboxMap mapboxMap, int expectedId, boolean isBearingDrawable) { - super(MyLocationView.class); - this.mapboxMap = mapboxMap; - this.expectedId = expectedId; - this.isBearingDrawable = isBearingDrawable; - } - - @Override - protected boolean matchesSafely(View target) { - Drawable currentDrawable = isBearingDrawable - ? mapboxMap.getMyLocationViewSettings().getForegroundBearingDrawable() : - mapboxMap.getMyLocationViewSettings().getForegroundDrawable(); - - Resources resources = target.getContext().getResources(); - Drawable expectedDrawable = resources.getDrawable(expectedId); - return areDrawablesIdentical(currentDrawable, expectedDrawable); - } - - @Override - public void describeTo(Description description) { - description.appendText("trying to match MyLocationView drawable to " + expectedId); - } - - boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) { - Drawable.ConstantState stateA = drawableA.getConstantState(); - Drawable.ConstantState stateB = drawableB.getConstantState(); - return (stateA != null && stateB != null && stateA.equals(stateB)) - || getBitmap(drawableA).sameAs(getBitmap(drawableB)); - } - - Bitmap getBitmap(Drawable drawable) { - Bitmap result; - if (drawable instanceof BitmapDrawable) { - result = ((BitmapDrawable) drawable).getBitmap(); - } else { - int width = drawable.getIntrinsicWidth(); - int height = drawable.getIntrinsicHeight(); - // Some drawables have no intrinsic width - e.g. solid colours. - if (width <= 0) { - width = 1; - } - if (height <= 0) { - height = 1; - } - - result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(result); - drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); - drawable.draw(canvas); - } - return result; - } - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 9e64e03e11..785fda173d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -68,17 +68,6 @@ android:name="android.support.PARENT_ACTIVITY" android:value=".activity.FeatureOverviewActivity"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - markerViews = new ArrayList<>(); - private boolean stopped; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_animated_marker); - - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(mapboxMap -> { - AnimatedMarkerActivity.this.mapboxMap = mapboxMap; - setupMap(); - - animationRunnable = () -> { - for (int i = 0; i < 10; i++) { - addRandomCar(); - } - addPassenger(); - addMainCar(); - }; - mapView.post(animationRunnable); - }); - } - - private void setupMap() { - CameraPosition cameraPosition = new CameraPosition.Builder() - .target(dupontCircle) - .zoom(15) - .build(); - mapboxMap.setCameraPosition(cameraPosition); - } - - private void addPassenger() { - if (isActivityStopped()) { - return; - } - - LatLng randomLatLng = getLatLngInBounds(); - - if (passengerMarker == null) { - Icon icon = IconUtils.drawableToIcon(this, R.drawable.ic_directions_run_black, - ResourcesCompat.getColor(getResources(), R.color.blueAccent, getTheme())); - passengerMarker = mapboxMap.addMarker(new MarkerViewOptions() - .position(randomLatLng) - .icon(icon)); - } else { - passengerMarker.setPosition(randomLatLng); - } - } - - private void addMainCar() { - if (isActivityStopped()) { - return; - } - - LatLng randomLatLng = getLatLngInBounds(); - - if (carMarker == null) { - carMarker = createCarMarker(randomLatLng, R.drawable.ic_taxi_top, - markerView -> { - // Make sure the car marker is selected so that it's always brought to the front (#5285) - mapboxMap.selectMarker(carMarker); - animateMoveToPassenger(carMarker); - }); - markerViews.add(carMarker); - } else { - carMarker.setPosition(randomLatLng); - } - } - - private void animateMoveToPassenger(final MarkerView car) { - if (isActivityStopped()) { - return; - } - - ValueAnimator animator = animateMoveMarker(car, passengerMarker.getPosition()); - animator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - addPassenger(); - animateMoveToPassenger(car); - } - }); - } - - protected void addRandomCar() { - markerViews.add(createCarMarker(getLatLngInBounds(), R.drawable.ic_car_top, - markerView -> randomlyMoveMarker(markerView))); - } - - private void randomlyMoveMarker(final MarkerView marker) { - if (isActivityStopped()) { - return; - } - - ValueAnimator animator = animateMoveMarker(marker, getLatLngInBounds()); - - // Add listener to restart animation on end - animator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - randomlyMoveMarker(marker); - } - }); - } - - private ValueAnimator animateMoveMarker(final MarkerView marker, LatLng to) { - marker.setRotation((float) getBearing(marker.getPosition(), to)); - - final ValueAnimator markerAnimator = ObjectAnimator.ofObject( - marker, "position", new LatLngEvaluator(), marker.getPosition(), to); - markerAnimator.setDuration((long) (10 * marker.getPosition().distanceTo(to))); - markerAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); - - // Start - markerAnimator.start(); - - return markerAnimator; - } - - private MarkerView createCarMarker(LatLng start, @DrawableRes int carResource, - MarkerViewManager.OnMarkerViewAddedListener listener) { - Icon icon = IconFactory.getInstance(AnimatedMarkerActivity.this) - .fromResource(carResource); - - // View Markers - return mapboxMap.addMarker(new MarkerViewOptions() - .position(start) - .icon(icon), listener); - - // GL Markers -// return mapboxMap.addMarker(new MarkerOptions() -// .position(start) -// .icon(icon)); - - } - - private LatLng getLatLngInBounds() { - LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds; - Random generator = new Random(); - double randomLat = bounds.getLatSouth() + generator.nextDouble() - * (bounds.getLatNorth() - bounds.getLatSouth()); - double randomLon = bounds.getLonWest() + generator.nextDouble() - * (bounds.getLonEast() - bounds.getLonWest()); - return new LatLng(randomLat, randomLon); - } - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - protected void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - - stopped = true; - - // Stop ongoing animations, prevent memory leaks - if (mapboxMap != null) { - MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager(); - for (MarkerView markerView : markerViews) { - View view = markerViewManager.getView(markerView); - if (view != null) { - view.animate().cancel(); - } - } - } - - // onStop - mapView.onStop(); - mapView.removeCallbacks(animationRunnable); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } - - /** - * Evaluator for LatLng pairs - */ - private static class LatLngEvaluator implements TypeEvaluator { - - private LatLng latLng = new LatLng(); - - @Override - public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) { - latLng.setLatitude(startValue.getLatitude() - + ((endValue.getLatitude() - startValue.getLatitude()) * fraction)); - latLng.setLongitude(startValue.getLongitude() - + ((endValue.getLongitude() - startValue.getLongitude()) * fraction)); - return latLng; - } - } - - private double getBearing(LatLng from, LatLng to) { - return TurfMeasurement.bearing( - Point.fromLngLat(from.getLongitude(), from.getLatitude()), - Point.fromLngLat(to.getLongitude(), to.getLatitude()) - ); - } - - private boolean isActivityStopped() { - return stopped; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java index afeb3b8979..2e62f18a32 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java @@ -1,11 +1,8 @@ package com.mapbox.mapboxsdk.testapp.activity.annotation; -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; import android.app.ProgressDialog; import android.os.AsyncTask; import android.os.Bundle; -import android.support.v4.content.res.ResourcesCompat; import android.support.v4.view.MenuItemCompat; import android.support.v7.app.AppCompatActivity; import android.view.Menu; @@ -14,27 +11,23 @@ import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; -import android.widget.TextView; -import android.widget.Toast; -import com.mapbox.mapboxsdk.annotations.Icon; + import com.mapbox.mapboxsdk.annotations.MarkerOptions; -import com.mapbox.mapboxsdk.annotations.MarkerViewOptions; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil; -import com.mapbox.mapboxsdk.testapp.utils.IconUtils; -import timber.log.Timber; import java.io.IOException; import java.lang.ref.WeakReference; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; -import java.util.Locale; import java.util.Random; +import timber.log.Timber; + /** * Test activity showcasing adding a large amount of Markers or MarkerViews. */ @@ -42,7 +35,6 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView private MapboxMap mapboxMap; private MapView mapView; - private boolean customMarkerView; private List locations; private ProgressDialog progressDialog; @@ -54,11 +46,6 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(mapboxMap -> BulkMarkerActivity.this.mapboxMap = mapboxMap); - - final View fab = findViewById(R.id.fab); - if (fab != null) { - fab.setOnClickListener(new FabClickListener()); - } } @Override @@ -102,36 +89,6 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView amount = locations.size(); } - if (customMarkerView) { - showViewMarkers(amount); - } else { - showGlMarkers(amount); - } - } - - private void showViewMarkers(int amount) { - DecimalFormat formatter = new DecimalFormat("#.#####"); - Random random = new Random(); - int randomIndex; - - int color = ResourcesCompat.getColor(getResources(), R.color.redAccent, getTheme()); - Icon icon = IconUtils.drawableToIcon(this, R.drawable.ic_droppin, color); - - List markerOptionsList = new ArrayList<>(); - for (int i = 0; i < amount; i++) { - randomIndex = random.nextInt(locations.size()); - LatLng latLng = locations.get(randomIndex); - MarkerViewOptions markerOptions = new MarkerViewOptions() - .position(latLng) - .icon(icon) - .title(String.valueOf(i)) - .snippet(formatter.format(latLng.getLatitude()) + ", " + formatter.format(latLng.getLongitude())); - markerOptionsList.add(markerOptions); - } - mapboxMap.addMarkerViews(markerOptionsList); - } - - private void showGlMarkers(int amount) { List markerOptionsList = new ArrayList<>(); DecimalFormat formatter = new DecimalFormat("#.#####"); Random random = new Random(); @@ -196,55 +153,6 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView mapView.onLowMemory(); } - private class FabClickListener implements View.OnClickListener { - - private TextView viewCountView; - - @Override - public void onClick(final View view) { - if (mapboxMap != null) { - customMarkerView = true; - - // remove fab - view.animate().alpha(0).setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - view.setVisibility(View.GONE); - } - }).start(); - - // reload markers - Spinner spinner = (Spinner) findViewById(R.id.spinner); - if (spinner != null) { - int amount = Integer.valueOf( - getResources().getStringArray(R.array.bulk_marker_list)[spinner.getSelectedItemPosition()]); - showMarkers(amount); - } - - viewCountView = (TextView) findViewById(R.id.countView); - - mapView.addOnMapChangedListener(change -> { - if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) { - if (!mapboxMap.getMarkerViewManager().getMarkerViewAdapters().isEmpty()) { - viewCountView.setText(String.format(Locale.getDefault(), "ViewCache size %d", - mapboxMap.getMarkerViewManager().getMarkerViewContainer().getChildCount())); - } - } - }); - - mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener( - (marker, view1, adapter) -> { - Toast.makeText( - BulkMarkerActivity.this, - "Hello " + marker.getId(), - Toast.LENGTH_SHORT).show(); - return false; - }); - } - } - } - private static class LoadLocationTask extends AsyncTask> { private WeakReference activity; 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 deleted file mode 100644 index 8c0dd69a0c..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java +++ /dev/null @@ -1,483 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.annotation; - -import android.animation.Animator; -import android.animation.AnimatorInflater; -import android.animation.AnimatorListenerAdapter; -import android.animation.FloatEvaluator; -import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; -import android.content.Context; -import android.os.Bundle; -import android.os.Handler; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; - -import com.mapbox.mapboxsdk.annotations.Icon; -import com.mapbox.mapboxsdk.annotations.IconFactory; -import com.mapbox.mapboxsdk.annotations.Marker; -import com.mapbox.mapboxsdk.annotations.MarkerOptions; -import com.mapbox.mapboxsdk.annotations.MarkerView; -import com.mapbox.mapboxsdk.annotations.MarkerViewManager; -import com.mapbox.mapboxsdk.annotations.MarkerViewOptions; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.model.annotations.CountryMarkerView; -import com.mapbox.mapboxsdk.testapp.model.annotations.CountryMarkerViewOptions; -import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerView; -import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerViewOptions; - -import java.util.Locale; -import java.util.Random; - -/** - * Test activity showcasing multiple MarkerViews above Washington D.C. - *

- * Shows a couple of open InfoWindows out of current Viewport. - * Updates the rotation and location of a couple of MarkerViews. - *

- */ -public class MarkerViewActivity extends AppCompatActivity { - - private static final LatLng[] LAT_LNGS = new LatLng[] { - new LatLng(38.897424, -77.036508), - new LatLng(38.909698, -77.029642), - new LatLng(38.907227, -77.036530), - new LatLng(38.905607, -77.031916), - new LatLng(38.889441, -77.050134), - new LatLng(38.888000, -77.050000) // Slight overlap to show re-ordering on selection - }; - - private MapboxMap mapboxMap; - private MapView mapView; - - // MarkerView location updates - private MarkerView movingMarkerOne; - private MarkerView movingMarkerTwo; - private Random randomAnimator = new Random(); - private Handler locationUpdateHandler = new Handler(); - private Runnable moveMarkerRunnable = new MoveMarkerRunnable(); - - // MarkerView rotate updates - private MarkerView rotateMarker; - private Handler rotateUpdateHandler = new Handler(); - private Runnable rotateMarkerRunnable = new RotateMarkerRunnable(); - private int rotation = 360; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_marker_view); - - final TextView viewCountView = (TextView) findViewById(R.id.countView); - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(mapboxMap -> { - MarkerViewActivity.this.mapboxMap = mapboxMap; - - final MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager(); - - Icon usFlag = IconFactory.getInstance(MarkerViewActivity.this) - .fromResource(R.drawable.ic_us); - - // add default ViewMarker markers - for (int i = 0; i < LAT_LNGS.length; i++) { - MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions() - .position(LAT_LNGS[i]) - .title(String.valueOf(i)) - .alpha(0.5f) - .icon(usFlag) - ); - } - - // add custom ViewMarker - CountryMarkerViewOptions options = new CountryMarkerViewOptions(); - options.flagRes(R.drawable.icon_burned); - options.abbrevName("Mapbox"); - options.title("Hello"); - options.position(new LatLng(38.899774, -77.023237)); - options.flat(true); - MarkerView markerView = mapboxMap.addMarker(options); - - // Use object animator to rotate MarkerView - ValueAnimator markerAnimator = ObjectAnimator.ofObject(markerView, "rotation", new FloatEvaluator(), -90, 90); - markerAnimator.setDuration(5000); - markerAnimator.start(); - - MarkerViewActivity.this.mapboxMap.addMarker(new MarkerOptions() - .title("United States") - .position(new LatLng(38.902580, -77.050102)) - ); - - rotateMarker = MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions() - .text("A") - .rotation(rotation = 270) - .position(new LatLng(38.889876, -77.008849)) - ); - loopMarkerRotate(); - - - MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions() - .text("B") - .position(new LatLng(38.907327, -77.041293)) - ); - - MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions() - .text("C") - .position(new LatLng(38.897642, -77.041980)) - ); - - // if you want to customise a ViewMarker you need to extend ViewMarker and provide an adapter implementation - // set adapters for child classes of ViewMarker - markerViewManager.addMarkerViewAdapter(new CountryAdapter(MarkerViewActivity.this, mapboxMap)); - markerViewManager.addMarkerViewAdapter(new TextAdapter(MarkerViewActivity.this, mapboxMap)); - - final ViewGroup markerViewContainer = markerViewManager.getMarkerViewContainer(); - - // add a change listener to validate the size of amount of child views - mapView.addOnMapChangedListener(change -> { - if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) { - if (!markerViewManager.getMarkerViewAdapters().isEmpty() && viewCountView != null) { - viewCountView.setText(String.format( - Locale.getDefault(), - getString(R.string.viewcache_size), - markerViewContainer.getChildCount()) - ); - } - } - }); - - // add a OnMarkerView click listener - MarkerViewActivity.this.mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener( - (marker, view, adapter) -> { - Toast.makeText(MarkerViewActivity.this, "Hello " + marker.getId(), Toast.LENGTH_SHORT).show(); - return false; - }); - - movingMarkerOne = MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions() - .position(CarLocation.CAR_0_LNGS[0]) - .icon(IconFactory.getInstance(mapView.getContext()) - .fromResource(R.drawable.ic_android)) - ); - - movingMarkerTwo = mapboxMap.addMarker(new MarkerViewOptions() - .position(CarLocation.CAR_1_LNGS[0]) - .icon(IconFactory.getInstance(mapView.getContext()) - .fromResource(R.drawable.ic_android_2)) - ); - - // allow more open infowindows at the same time - mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true); - - // add offscreen markers - Marker markerRightOffScreen = mapboxMap.addMarker(new MarkerOptions() - .setPosition(new LatLng(38.892846, -76.909399)) - .title("InfoWindow") - .snippet("Offscreen, to the right of the Map.")); - - Marker markerRightBottomOffScreen = mapboxMap.addMarker(new MarkerOptions() - .setPosition(new LatLng(38.791645, -77.039006)) - .title("InfoWindow") - .snippet("Offscreen, to the bottom of the Map")); - - // open infowindow offscreen markers - mapboxMap.selectMarker(markerRightOffScreen); - mapboxMap.selectMarker(markerRightBottomOffScreen); - }); - } - - private void loopMarkerRotate() { - rotateUpdateHandler.postDelayed(rotateMarkerRunnable, 800); - } - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - loopMarkerMove(); - } - - private void loopMarkerMove() { - locationUpdateHandler.postDelayed(moveMarkerRunnable, randomAnimator.nextInt(3000) + 1000); - } - - @Override - protected void onStop() { - super.onStop(); - mapView.onStop(); - locationUpdateHandler.removeCallbacks(moveMarkerRunnable); - rotateUpdateHandler.removeCallbacks(rotateMarkerRunnable); - } - - /** - * Updates the position of a Marker - */ - private class MoveMarkerRunnable implements Runnable { - @Override - public void run() { - int randomInteger = randomAnimator.nextInt(9); - if (randomAnimator.nextInt() % 2 == 0) { - movingMarkerOne.setPosition(CarLocation.CAR_0_LNGS[randomInteger]); - } else { - movingMarkerTwo.setPosition(CarLocation.CAR_1_LNGS[randomInteger]); - } - loopMarkerMove(); - } - } - - /** - * Updates the rotation of a Marker - */ - private class RotateMarkerRunnable implements Runnable { - - private static final int ROTATION_INCREASE_VALUE = 9; - - @Override - public void run() { - rotation -= ROTATION_INCREASE_VALUE; - if (rotation >= 0) { - rotation += 360; - } - rotateMarker.setRotation(rotation); - loopMarkerRotate(); - } - } - - /** - * Adapts a MarkerView to display an abbreviated name in a TextView and a flag in an ImageView. - */ - private static class CountryAdapter extends MapboxMap.MarkerViewAdapter { - - private LayoutInflater inflater; - private MapboxMap mapboxMap; - - CountryAdapter(@NonNull Context context, @NonNull MapboxMap mapboxMap) { - super(context); - this.inflater = LayoutInflater.from(context); - this.mapboxMap = mapboxMap; - } - - @Nullable - @Override - public View getView(@NonNull CountryMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) { - ViewHolder viewHolder; - if (convertView == null) { - viewHolder = new ViewHolder(); - convertView = inflater.inflate(R.layout.view_custom_marker, parent, false); - viewHolder.flag = (ImageView) convertView.findViewById(R.id.imageView); - viewHolder.abbrev = (TextView) convertView.findViewById(R.id.textView); - convertView.setTag(viewHolder); - } else { - viewHolder = (ViewHolder) convertView.getTag(); - } - viewHolder.flag.setImageResource(marker.getFlagRes()); - viewHolder.abbrev.setText(marker.getAbbrevName()); - return convertView; - } - - @Override - public boolean onSelect( - @NonNull final CountryMarkerView marker, @NonNull final View convertView, boolean reselectionForViewReuse) { - convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null); - ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(convertView, View.ROTATION, 0, 360); - rotateAnimator.setDuration(reselectionForViewReuse ? 0 : 350); - rotateAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - convertView.setLayerType(View.LAYER_TYPE_NONE, null); - mapboxMap.selectMarker(marker); - } - }); - rotateAnimator.start(); - - // false indicates that we are calling selectMarker after our animation ourselves - // true will let the system call it for you, which will result in showing an InfoWindow instantly - return false; - } - - @Override - public void onDeselect(@NonNull CountryMarkerView marker, @NonNull final View convertView) { - convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null); - ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(convertView, View.ROTATION, 360, 0); - rotateAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - convertView.setLayerType(View.LAYER_TYPE_NONE, null); - } - }); - rotateAnimator.start(); - } - - private static class ViewHolder { - ImageView flag; - TextView abbrev; - } - } - - /** - * Adapts a MarkerView to display text in a TextView. - */ - public static class TextAdapter extends MapboxMap.MarkerViewAdapter { - - private LayoutInflater inflater; - private MapboxMap mapboxMap; - - public TextAdapter(@NonNull Context context, @NonNull MapboxMap mapboxMap) { - super(context); - this.inflater = LayoutInflater.from(context); - this.mapboxMap = mapboxMap; - } - - @Nullable - @Override - public View getView(@NonNull TextMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) { - ViewHolder viewHolder; - if (convertView == null) { - viewHolder = new ViewHolder(); - convertView = inflater.inflate(R.layout.view_text_marker, parent, false); - viewHolder.textView = (TextView) convertView.findViewById(R.id.textView); - convertView.setTag(viewHolder); - } else { - viewHolder = (ViewHolder) convertView.getTag(); - } - viewHolder.textView.setText(marker.getText()); - return convertView; - } - - @Override - public boolean onSelect( - @NonNull final TextMarkerView marker, @NonNull final View convertView, boolean reselectionForViewReuse) { - animateGrow(marker, convertView, 0); - - // false indicates that we are calling selectMarker after our animation ourselves - // true will let the system call it for you, which will result in showing an InfoWindow instantly - return false; - } - - @Override - public void onDeselect(@NonNull TextMarkerView marker, @NonNull final View convertView) { - animateShrink(convertView, 350); - } - - @Override - public boolean prepareViewForReuse(@NonNull MarkerView marker, @NonNull View convertView) { - // this method is called before a view will be reused, we need to restore view state - // as we have scaled the view in onSelect. If not correctly applied other MarkerView will - // become large since these have been recycled - - // cancel ongoing animation - convertView.animate().cancel(); - - if (marker.isSelected()) { - // shrink view to be able to be reused - animateShrink(convertView, 0); - } - - // true if you want reuse to occur automatically, false if you want to manage this yourself - return true; - } - - private void animateGrow(@NonNull final MarkerView marker, @NonNull final View convertView, int duration) { - convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null); - Animator animator = AnimatorInflater.loadAnimator(convertView.getContext(), R.animator.scale_up); - animator.setDuration(duration); - animator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - convertView.setLayerType(View.LAYER_TYPE_NONE, null); - mapboxMap.selectMarker(marker); - } - }); - animator.setTarget(convertView); - animator.start(); - } - - private void animateShrink(@NonNull final View convertView, int duration) { - convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null); - Animator animator = AnimatorInflater.loadAnimator(convertView.getContext(), R.animator.scale_down); - animator.setDuration(duration); - animator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - convertView.setLayerType(View.LAYER_TYPE_NONE, null); - } - }); - animator.setTarget(convertView); - animator.start(); - } - - private static class ViewHolder { - TextView textView; - } - } - - - @Override - public void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - public void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } - - private static class CarLocation { - - static LatLng[] CAR_0_LNGS = new LatLng[] { - new LatLng(38.92334425495122, -77.0533673443786), - new LatLng(38.9234737236897, -77.05389484528261), - new LatLng(38.9257094658146, -76.98819752280579), - new LatLng(38.8324328369647, -77.00690648325929), - new LatLng(38.87540698725855, -77.0093148713099), - new LatLng(38.96499498141065, -77.07707916040054), - new LatLng(38.90794910679896, -76.99695304153806), - new LatLng(38.86234025281626, -76.9950528034839), - new LatLng(38.862930274733635, -76.99647808241964) - }; - - static LatLng[] CAR_1_LNGS = new LatLng[] { - new LatLng(38.94237975070426, -76.98324549005675), - new LatLng(38.941520236084486, -76.98234257804742), - new LatLng(38.85972219720714, -76.98955808483929), - new LatLng(38.944289166113776, -76.98584257252891), - new LatLng(38.94375860578053, -76.98470344318412), - new LatLng(38.943167431929645, -76.98373163938666), - new LatLng(38.882834728904605, -77.02862535635137), - new LatLng(38.882869724926245, -77.02992539231113), - new LatLng(38.9371988177896, -76.97786740676564) - }; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java deleted file mode 100644 index 848eab9a3c..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.annotation; - -import android.graphics.RectF; -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.view.View; -import android.widget.Toast; - -import com.mapbox.mapboxsdk.annotations.MarkerView; -import com.mapbox.mapboxsdk.annotations.MarkerViewOptions; -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -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 java.util.List; - -import timber.log.Timber; - -/** - * Test activity showcasing counting MarkerViews in a rectangle. - */ -public class MarkerViewsInRectangleActivity extends AppCompatActivity implements OnMapReadyCallback, - View.OnClickListener { - - public MapView mapView; - private MapboxMap mapboxMap; - private View selectionBox; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_marker_view_in_rect); - - selectionBox = findViewById(R.id.selection_box); - - // Initialize map as normal - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(this); - } - - @Override - public void onMapReady(MapboxMap mapboxMap) { - MarkerViewsInRectangleActivity.this.mapboxMap = mapboxMap; - selectionBox.setOnClickListener(this); - mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.0907, 5.1214), 16)); - mapboxMap.addMarker(new MarkerViewOptions().position(new LatLng(52.0907, 5.1214))); - } - - @Override - public void onClick(View view) { - // Query - int top = selectionBox.getTop() - mapView.getTop(); - int left = selectionBox.getLeft() - mapView.getLeft(); - RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight()); - Timber.i("Querying box %s", box); - List markers = mapboxMap.getMarkerViewsInRect(box); - - // Show count - Toast.makeText( - MarkerViewsInRectangleActivity.this, - String.format("%s markers inside box", markers.size()), - Toast.LENGTH_SHORT).show(); - } - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - protected void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java index 9dea4f77de..55e55ce1e2 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java @@ -7,8 +7,8 @@ import android.support.v7.app.AppCompatActivity; import android.widget.TextView; import com.mapbox.mapboxsdk.annotations.InfoWindow; -import com.mapbox.mapboxsdk.annotations.MarkerView; -import com.mapbox.mapboxsdk.annotations.MarkerViewOptions; +import com.mapbox.mapboxsdk.annotations.Marker; +import com.mapbox.mapboxsdk.annotations.MarkerOptions; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapView; @@ -50,7 +50,7 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen mapboxMap.getUiSettings().setDeselectMarkersOnTap(false); // Add a marker - final MarkerView marker = addMarker(mapboxMap); + final Marker marker = addMarker(mapboxMap); mapboxMap.selectMarker(marker); // On map click, change the info window contents @@ -77,9 +77,9 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(PARIS)); } - private MarkerView addMarker(MapboxMap mapboxMap) { + private Marker addMarker(MapboxMap mapboxMap) { return mapboxMap.addMarker( - new MarkerViewOptions() + new MarkerOptions() .position(PARIS) .icon(IconUtils.drawableToIcon(this, R.drawable.ic_location_city, ResourcesCompat.getColor(getResources(), R.color.mapbox_blue, getTheme())) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java index 3b58843e13..33aae320c7 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/BottomSheetActivity.java @@ -1,7 +1,6 @@ package com.mapbox.mapboxsdk.testapp.activity.maplayout; import android.content.Context; -import android.location.Location; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -151,10 +150,9 @@ public class BottomSheetActivity extends AppCompatActivity { @Override public void onMapReady(MapboxMap mapboxMap) { - Location location = mapboxMap.getMyLocation(); - if (location != null) { - mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15)); - } + mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom( + new LatLng(51.510790, -0.078966), 15) + ); } @Override @@ -230,10 +228,9 @@ public class BottomSheetActivity extends AppCompatActivity { @Override public void onMapReady(MapboxMap mapboxMap) { - Location location = mapboxMap.getMyLocation(); - if (location != null) { - mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15)); - } + mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom( + new LatLng(52.529910, 13.402729), 15) + ); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java index 75b2378ef7..b4dde8d2cd 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java @@ -11,11 +11,9 @@ import android.view.View; import android.view.ViewGroup; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.constants.MyLocationTracking; import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.TrackingSettings; import com.mapbox.mapboxsdk.maps.UiSettings; import com.mapbox.mapboxsdk.testapp.R; @@ -50,14 +48,6 @@ public class DoubleMapActivity extends AppCompatActivity { mapboxMap = map; mapboxMap.setStyleUrl(Style.DARK); mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(18)); - try { - mapboxMap.setMyLocationEnabled(true); - TrackingSettings settings = mapboxMap.getTrackingSettings(); - settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - } catch (SecurityException securityException) { - // permission is handled in MainActivity - finish(); - } } /** @@ -106,15 +96,6 @@ public class DoubleMapActivity extends AppCompatActivity { uiSettings.setAttributionEnabled(false); uiSettings.setLogoEnabled(false); - try { - mapboxMap.setMyLocationEnabled(true); - TrackingSettings settings = mapboxMap.getTrackingSettings(); - settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - } catch (SecurityException securityException) { - // permission is handled in MainActivity - getActivity().finish(); - } - mapboxMap.setOnMapClickListener(point -> { // test if we can open 2 activities after each other startActivity(new Intent(mapViewMini.getContext(), DoubleMapActivity.class)); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java index 9a6079b157..49444cc7bb 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java @@ -8,11 +8,9 @@ import android.view.MenuItem; import com.mapbox.mapboxsdk.annotations.MarkerOptions; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.constants.MyLocationTracking; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.TrackingSettings; import com.mapbox.mapboxsdk.testapp.R; /** @@ -96,24 +94,7 @@ public class MapPaddingActivity extends AppCompatActivity { return true; } - private void toggleGps(boolean enable) { - try { - // Enable user location - mapboxMap.setMyLocationEnabled(enable); - - TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); - trackingSettings.setDismissLocationTrackingOnGesture(false); - trackingSettings.setMyLocationTrackingMode( - enable ? MyLocationTracking.TRACKING_FOLLOW : MyLocationTracking.TRACKING_NONE); - } catch (SecurityException securityException) { - // permission not granted is handled in FeatureOverviewActivity - finish(); - } - } - private void moveToBangalore() { - toggleGps(false); - LatLng bangalore = new LatLng(12.9810816, 77.6368034); CameraPosition cameraPosition = new CameraPosition.Builder() .zoom(16) @@ -126,12 +107,26 @@ public class MapPaddingActivity extends AppCompatActivity { mapboxMap.addMarker(new MarkerOptions().title("Center map").position(bangalore)); } + + private void moveToBerlin() { + LatLng berlin = new LatLng(52.529910, 13.402729); + CameraPosition cameraPosition = new CameraPosition.Builder() + .zoom(14) + .target(berlin) + .bearing(160) + .tilt(20) + .build(); + + mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); + mapboxMap.addMarker(new MarkerOptions().title("Center map").position(berlin)); + } + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_user_tracking: if (mapboxMap != null) { - toggleGps(true); + moveToBerlin(); } return true; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HillshadeLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HillshadeLayerActivity.java index 066446652b..7e9b3fb7e4 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HillshadeLayerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HillshadeLayerActivity.java @@ -25,7 +25,7 @@ public class HillshadeLayerActivity extends AppCompatActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_fill_extrusion_layer); + setContentView(R.layout.activity_hillshade_layer); mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java deleted file mode 100644 index eec26cc9a7..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/BaseLocationActivity.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.userlocation; - -import android.os.Build; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.UiThread; -import android.support.design.widget.Snackbar; -import android.support.v7.app.AppCompatActivity; -import android.text.TextUtils; - -import com.mapbox.android.core.permissions.PermissionsListener; -import com.mapbox.android.core.permissions.PermissionsManager; - -import java.util.List; - -/** - * Base class for location aware activities. - */ -public abstract class BaseLocationActivity extends AppCompatActivity implements PermissionsListener { - - private PermissionsManager permissionsManager; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - permissionsManager = new PermissionsManager(this); - } - - @UiThread - protected final void toggleGps(boolean enableGps) { - if (enableGps) { - if (!isRuntimePermissionsRequired()) { - permissionsManager.requestLocationPermissions(this); - } else { - enableLocation(true); - } - } else { - enableLocation(false); - } - } - - @Override - public void onExplanationNeeded(List list) { - Snackbar.make( - findViewById(android.R.id.content), - TextUtils.join("", list.toArray()), - Snackbar.LENGTH_SHORT).show(); - } - - @Override - public void onPermissionResult(boolean isPermissionAccepted) { - enableLocation(isPermissionAccepted); - } - - @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults); - } - - private boolean isRuntimePermissionsRequired() { - return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; - } - - protected abstract void enableLocation(boolean enabled); -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java deleted file mode 100644 index ff2559089c..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/CustomLocationEngineActivity.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.userlocation; - -import android.os.Bundle; -import android.support.design.widget.FloatingActionButton; -import android.view.Menu; -import android.view.MenuItem; - -import com.mapbox.mapboxsdk.Mapbox; -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.testapp.R; - -/** - * Test activity showcasing using a custom location engine. - */ -public class CustomLocationEngineActivity extends BaseLocationActivity { - - private MapView mapView; - private MapboxMap mapboxMap; - private FloatingActionButton locationToggleFab; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_custom_location_engine); - - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(map -> { - mapboxMap = map; - mapboxMap.setLocationSource(MockLocationEngine.getInstance()); - }); - - locationToggleFab = (FloatingActionButton) findViewById(R.id.fabLocationToggle); - locationToggleFab.setOnClickListener(view -> { - if (mapboxMap != null) { - enableLocation(!mapboxMap.isMyLocationEnabled()); - } - }); - } - - @Override - protected void enableLocation(boolean enabled) { - mapboxMap.setMyLocationEnabled(enabled); - if (enabled) { - locationToggleFab.setImageResource(R.drawable.ic_location_disabled); - } else { - locationToggleFab.setImageResource(R.drawable.ic_my_location); - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.menu_location_engine, menu); - return super.onCreateOptionsMenu(menu); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (mapboxMap != null) { - int itemId = item.getItemId(); - if (itemId == R.id.action_id_location_source_lost) { - mapboxMap.setLocationSource(Mapbox.getLocationEngine()); - return true; - } else if (itemId == R.id.action_id_location_source_mock) { - mapboxMap.setLocationSource(MockLocationEngine.getInstance()); - return true; - } else if (itemId == R.id.action_id_location_source_null) { - mapboxMap.setLocationSource(null); - return true; - } - } - return super.onOptionsItemSelected(item); - } - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - protected void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java deleted file mode 100644 index f4fe710de1..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MockLocationEngine.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.userlocation; - -import android.animation.AnimatorListenerAdapter; -import android.animation.TypeEvaluator; -import android.animation.ValueAnimator; -import android.location.Location; - -import com.mapbox.android.core.location.LocationEngine; -import com.mapbox.android.core.location.LocationEngineListener; - -import timber.log.Timber; - -/** - * Sample LocationEngine that provides mocked LOCATIONS simulating GPS updates - */ -public class MockLocationEngine extends LocationEngine { - private static MockLocationEngine INSTANCE; - - private final LocationAnimator locationAnimator; - private boolean running; - private static int counter; - - MockLocationEngine(Location start, Location end) { - locationAnimator = new LocationAnimator(start, end, animation -> { - for (LocationEngineListener listener : locationListeners) { - listener.onLocationChanged((Location) animation.getAnimatedValue()); - } - }); - } - - public static synchronized MockLocationEngine getInstance() { - if (INSTANCE == null) { - INSTANCE = new MockLocationEngine( - MockLocationEngine.createLocation(40.416913, -3.703861), - MockLocationEngine.createLocation(39.461643, -0.368041) - ); - } - return INSTANCE; - } - - public static Location createLocation(double latitude, double longitude) { - Location location = new Location(MockLocationEngine.class.getSimpleName()); - location.setLatitude(latitude); - location.setLongitude(longitude); - return location; - } - - @Override - public void activate() { - // "Connection" is immediate here - for (LocationEngineListener listener : locationListeners) { - listener.onConnected(); - } - } - - @Override - public void deactivate() { - } - - @Override - public boolean isConnected() { - return true; // Always connected - } - - @Override - public Location getLastLocation() { - return null; - } - - @Override - public void requestLocationUpdates() { - if (!running) { - locationAnimator.start(); - running = true; - } - } - - @Override - public void removeLocationUpdates() { - if (running) { - locationAnimator.stop(); - running = false; - Timber.e("LOC %s", counter); - } - } - - @Override - public Type obtainType() { - return Type.MOCK; - } - - private static class LocationAnimator extends AnimatorListenerAdapter { - - private static final long DURATION_ANIMATION = 10000; - private final ValueAnimator locationAnimator; - private long animationTime; - - LocationAnimator(Location start, Location end, ValueAnimator.AnimatorUpdateListener listener) { - locationAnimator = ValueAnimator.ofObject(new LocationEvaluator(), start, end); - locationAnimator.setDuration(DURATION_ANIMATION); - locationAnimator.addUpdateListener(listener); - locationAnimator.addListener(this); - } - - void start() { - locationAnimator.start(); - locationAnimator.setCurrentPlayTime(animationTime); - } - - void stop() { - animationTime = locationAnimator.getCurrentPlayTime(); - locationAnimator.cancel(); - } - - private static class LocationEvaluator implements TypeEvaluator { - - private Location location = new Location(MockLocationEngine.class.getSimpleName()); - - @Override - public Location evaluate(float fraction, Location startValue, Location endValue) { - counter++; - location.setLatitude(startValue.getLatitude() - + ((endValue.getLatitude() - startValue.getLatitude()) * fraction)); - location.setLongitude(startValue.getLongitude() - + ((endValue.getLongitude() - startValue.getLongitude()) * fraction)); - return location; - } - } - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java deleted file mode 100644 index f603050030..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.userlocation; - -import android.graphics.Color; -import android.location.Location; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.content.ContextCompat; -import android.view.View; -import android.view.ViewGroup; - -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -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.MapboxMapOptions; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.android.core.location.LocationEngineListener; - -/** - * Test activity showcasing how to change the MyLocationView drawable. - */ -public class MyLocationDrawableActivity extends BaseLocationActivity implements LocationEngineListener { - - private MapView mapView; - private MapboxMap mapboxMap; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_my_location_customization); - findViewById(R.id.progress).setVisibility(View.GONE); - - MapboxMapOptions mapboxMapOptions = new MapboxMapOptions(); - mapboxMapOptions.styleUrl(Style.MAPBOX_STREETS); - mapboxMapOptions.myLocationForegroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_android)); - mapboxMapOptions.myLocationBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_android)); - mapboxMapOptions.myLocationForegroundTintColor(Color.GREEN); - mapboxMapOptions.myLocationBackgroundTintColor(Color.YELLOW); - mapboxMapOptions.myLocationBackgroundPadding(new int[] {0, 0, - (int) getResources().getDimension(R.dimen.locationview_background_drawable_padding), - (int) getResources().getDimension(R.dimen.locationview_background_drawable_padding)}); - mapboxMapOptions.myLocationAccuracyTint(Color.RED); - mapboxMapOptions.myLocationAccuracyAlpha(155); - - mapView = new MapView(this, mapboxMapOptions); - mapView.setId(R.id.mapView); - ViewGroup parent = (ViewGroup) findViewById(android.R.id.content); - parent.addView(mapView); - - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(map -> { - mapboxMap = map; - toggleGps(true); - }); - } - - @Override - protected void enableLocation(boolean enabled) { - mapboxMap.setMyLocationEnabled(enabled); - } - - @Override - public void onConnected() { - // Nothing - } - - @Override - public void onLocationChanged(Location location) { - mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 14)); - } - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - protected void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java deleted file mode 100644 index ff3c4dfbc0..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.userlocation; - -import android.app.Activity; -import android.graphics.Color; -import android.location.Location; -import android.os.Bundle; -import android.support.annotation.IdRes; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.content.ContextCompat; -import android.view.View; - -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.constants.MyLocationTracking; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.TrackingSettings; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.android.core.location.LocationEngineListener; - -/** - * Test activity showcasing how to tint the MyLocationView. - */ -public class MyLocationTintActivity extends BaseLocationActivity implements LocationEngineListener { - - private MapView mapView; - private MapboxMap mapboxMap; - private boolean firstRun; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_my_location_dot_color); - - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(map -> { - mapboxMap = map; - - // enable location updates - toggleGps(true); - - // add some padding - final MyLocationViewSettings myLocationViewSettings = mapboxMap.getMyLocationViewSettings(); - myLocationViewSettings.setPadding(0, 500, 0, 0); - - // enable tracking - TrackingSettings settings = mapboxMap.getTrackingSettings(); - settings.setDismissLocationTrackingOnGesture(false); - settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - - // handle default button clicks - ViewUtils.attachClickListener( - MyLocationTintActivity.this, - R.id.default_user_dot_coloring_button, - view -> { - myLocationViewSettings.setAccuracyTintColor(ContextCompat.getColor( - MyLocationTintActivity.this, R.color.mapbox_blue)); - myLocationViewSettings.setForegroundTintColor(ContextCompat.getColor( - MyLocationTintActivity.this, R.color.mapbox_blue)); - myLocationViewSettings.setBackgroundTintColor(Color.WHITE); - }); - - // handle tint user dot button clicks - ViewUtils.attachClickListener( - MyLocationTintActivity.this, - R.id.tint_user_dot_button, - view -> { - myLocationViewSettings.setAccuracyTintColor( - ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen)); - myLocationViewSettings.setForegroundTintColor( - ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen)); - myLocationViewSettings.setBackgroundTintColor(Color.WHITE); - }); - - // handle tint accuracy ring button clicks - ViewUtils.attachClickListener( - MyLocationTintActivity.this, - R.id.user_accuracy_ring_tint_button, - view -> { - myLocationViewSettings.setAccuracyTintColor( - ContextCompat.getColor(MyLocationTintActivity.this, R.color.accent)); - myLocationViewSettings.setForegroundTintColor( - ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_blue)); - myLocationViewSettings.setBackgroundTintColor(Color.WHITE); - }); - - ViewUtils.attachClickListener( - MyLocationTintActivity.this, - R.id.user_dot_transparent_button, - view -> { - myLocationViewSettings.setForegroundTintColor(Color.TRANSPARENT); - myLocationViewSettings.setBackgroundTintColor(Color.TRANSPARENT); - } - ); - }); - - } - - @Override - public void onConnected() { - // Nothing - } - - @Override - public void onLocationChanged(Location location) { - if (mapboxMap != null && firstRun) { - mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15)); - firstRun = false; - } - } - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - public void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - public void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - @Override - protected void enableLocation(boolean enabled) { - if (enabled) { - mapboxMap.setMyLocationEnabled(true); - if (mapboxMap.getMyLocation() != null) { - mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom( - new LatLng(mapboxMap.getMyLocation().getLatitude(), - mapboxMap.getMyLocation().getLongitude()), 15)); - } - } else { - mapboxMap.setMyLocationEnabled(false); - } - } - - private static class ViewUtils { - - public static void attachClickListener( - @NonNull Activity activity, @IdRes int buttonId, @Nullable View.OnClickListener clickListener) { - View view = activity.findViewById(buttonId); - if (view != null) { - view.setOnClickListener(clickListener); - } - } - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java deleted file mode 100644 index ea3a6f14bc..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.userlocation; - -import android.os.Bundle; -import android.support.design.widget.FloatingActionButton; - -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.testapp.R; - -import timber.log.Timber; - -/** - * Test activity showcasing toggling the user location on the map. - */ -public class MyLocationToggleActivity extends BaseLocationActivity { - - private MapView mapView; - private MapboxMap mapboxMap; - private FloatingActionButton locationToggleFab; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_my_location_toggle); - - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(map -> mapboxMap = map); - - locationToggleFab = (FloatingActionButton) findViewById(R.id.fabLocationToggle); - locationToggleFab.setOnClickListener(view -> { - if (mapboxMap != null) { - toggleGps(!mapboxMap.isMyLocationEnabled()); - } - }); - } - - @Override - protected void enableLocation(boolean enabled) { - Timber.e("Enabling location: %s", enabled); - mapboxMap.setMyLocationEnabled(enabled); - if (enabled) { - locationToggleFab.setImageResource(R.drawable.ic_location_disabled); - } else { - locationToggleFab.setImageResource(R.drawable.ic_my_location); - } - } - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - protected void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } - -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java deleted file mode 100644 index ffbb2c1a90..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java +++ /dev/null @@ -1,296 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.userlocation; - -import android.location.Location; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.Spinner; -import android.widget.Toast; - -import com.mapbox.mapboxsdk.Mapbox; -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.constants.MyBearingTracking; -import com.mapbox.mapboxsdk.constants.MyLocationTracking; -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.maps.TrackingSettings; -import com.mapbox.mapboxsdk.maps.UiSettings; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.android.core.location.LocationEngineListener; - -import timber.log.Timber; - -/** - * Test activity showcasing the different tracking modes the SDK exposes. - *

- * This includes MyLocationTracking/MyLocationBearingTracking and how the components can be configured to be dismissed - * using gesture configurations. - *

- */ -public class MyLocationTrackingModeActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener, - OnMapReadyCallback, LocationEngineListener { - - public static final int TRACKING_NONE_INDEX = 0; - public static final int TRACKING_FOLLOW_INDEX = 1; - public static final int BEARING_NONE_INDEX = 0; - public static final int BEARING_GPS_INDEX = 1; - public static final int BEARING_COMPASS_INDEX = 2; - - private MapView mapView; - private MapboxMap mapboxMap; - private Spinner locationSpinner; - private Spinner bearingSpinner; - private boolean firstRun = true; - - private MenuItem dismissLocationTrackingOnGestureItem; - private MenuItem dismissBearingTrackingOnGestureItem; - private MenuItem enableRotateGesturesItem; - private MenuItem enableScrollGesturesItem; - - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_my_location_tracking); - setupToolbar(); - - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(this); - } - - @Override - public void onMapReady(MapboxMap mapboxMap) { - MyLocationTrackingModeActivity.this.mapboxMap = mapboxMap; - - mapboxMap.setMyLocationEnabled(true); - Mapbox.getLocationEngine().addLocationEngineListener(this); - Mapbox.getLocationEngine().requestLocationUpdates(); - } - - @Override - public void onConnected() { - // Nothing - } - - @Override - public void onLocationChanged(Location location) { - Timber.e("Location changed %s", location); - if (firstRun) { - setInitialLocation(location, 16); - } - } - - private void setInitialLocation(Location location, double zoom) { - mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), zoom)); - mapboxMap.setMyLocationEnabled(true); - setupSpinners(mapboxMap); - firstRun = false; - } - - private void setupToolbar() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayShowTitleEnabled(false); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - - locationSpinner = (Spinner) findViewById(R.id.spinner_location); - ArrayAdapter locationTrackingAdapter = ArrayAdapter.createFromResource( - actionBar.getThemedContext(), R.array.user_tracking_mode, android.R.layout.simple_spinner_item); - locationTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - locationSpinner.setAdapter(locationTrackingAdapter); - - bearingSpinner = (Spinner) findViewById(R.id.spinner_bearing); - ArrayAdapter bearingTrackingAdapter = ArrayAdapter.createFromResource( - actionBar.getThemedContext(), R.array.user_bearing_mode, android.R.layout.simple_spinner_item); - bearingTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - bearingSpinner.setAdapter(bearingTrackingAdapter); - } - } - - private void setupSpinners(@NonNull MapboxMap mapboxMap) { - locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); - bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); - setCheckBoxes(); - - mapboxMap.setOnMyLocationTrackingModeChangeListener(myLocationTrackingMode -> { - locationSpinner.setOnItemSelectedListener(null); - switch (myLocationTrackingMode) { - case MyLocationTracking.TRACKING_NONE: - locationSpinner.setSelection(TRACKING_NONE_INDEX); - break; - case MyLocationTracking.TRACKING_FOLLOW: - locationSpinner.setSelection(TRACKING_FOLLOW_INDEX); - break; - } - locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); - }); - - mapboxMap.setOnMyBearingTrackingModeChangeListener(myBearingTrackingMode -> { - bearingSpinner.setOnItemSelectedListener(null); - switch (myBearingTrackingMode) { - case MyBearingTracking.NONE: - bearingSpinner.setSelection(BEARING_NONE_INDEX); - break; - - case MyBearingTracking.GPS: - bearingSpinner.setSelection(BEARING_GPS_INDEX); - break; - - case MyBearingTracking.COMPASS: - bearingSpinner.setSelection(BEARING_COMPASS_INDEX); - break; - } - bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); - }); - } - - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) throws SecurityException { - TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); - if (parent.getId() == R.id.spinner_location) { - switch (position) { - case TRACKING_NONE_INDEX: - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE); - break; - - case TRACKING_FOLLOW_INDEX: - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - break; - } - } else if (parent.getId() == R.id.spinner_bearing) { - switch (position) { - case BEARING_NONE_INDEX: - trackingSettings.setMyBearingTrackingMode(MyBearingTracking.NONE); - break; - - case BEARING_GPS_INDEX: - trackingSettings.setMyBearingTrackingMode(MyBearingTracking.GPS); - break; - - case BEARING_COMPASS_INDEX: - trackingSettings.setMyBearingTrackingMode(MyBearingTracking.COMPASS); - break; - } - } - } - - @Override - public void onNothingSelected(AdapterView parent) { - - } - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - } - - @Override - protected void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - mapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - Mapbox.getLocationEngine().removeLocationEngineListener(this); - Mapbox.getLocationEngine().removeLocationUpdates(); - mapView.onStop(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - public void onLowMemory() { - super.onLowMemory(); - mapView.onLowMemory(); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.menu_tracking, menu); - dismissLocationTrackingOnGestureItem = menu.findItem(R.id.action_toggle_dismissible_location); - dismissBearingTrackingOnGestureItem = menu.findItem(R.id.action_toggle_dismissible_bearing); - enableRotateGesturesItem = menu.findItem(R.id.action_toggle_rotate_gesture_enabled); - enableScrollGesturesItem = menu.findItem(R.id.action_toggle_scroll_gesture_enabled); - setCheckBoxes(); - return true; - } - - private void setCheckBoxes() { - if (mapboxMap != null && dismissBearingTrackingOnGestureItem != null) { - TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); - UiSettings uiSettings = mapboxMap.getUiSettings(); - dismissBearingTrackingOnGestureItem.setChecked(trackingSettings.isDismissBearingTrackingOnGesture()); - dismissLocationTrackingOnGestureItem.setChecked(trackingSettings.isDismissLocationTrackingOnGesture()); - enableRotateGesturesItem.setChecked(uiSettings.isRotateGesturesEnabled()); - enableScrollGesturesItem.setChecked(uiSettings.isScrollGesturesEnabled()); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - boolean state; - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - case R.id.action_toggle_dismissible_location: - state = !item.isChecked(); - mapboxMap.getTrackingSettings().setDismissLocationTrackingOnGesture(state); - Toast.makeText(this, "Dismiss tracking mode on gesture = " + state, Toast.LENGTH_SHORT).show(); - item.setChecked(state); - return true; - case R.id.action_toggle_dismissible_bearing: - state = !item.isChecked(); - mapboxMap.getTrackingSettings().setDismissBearingTrackingOnGesture(state); - Toast.makeText(this, "Dismiss bearing mode on gesture = " + state, Toast.LENGTH_SHORT).show(); - item.setChecked(state); - return true; - case R.id.action_toggle_rotate_gesture_enabled: - state = !item.isChecked(); - mapboxMap.getUiSettings().setRotateGesturesEnabled(state); - Toast.makeText(this, "Rotate gesture enabled = " + state, Toast.LENGTH_SHORT).show(); - item.setChecked(state); - return true; - case R.id.action_toggle_scroll_gesture_enabled: - state = !item.isChecked(); - mapboxMap.getUiSettings().setScrollGesturesEnabled(state); - Toast.makeText(this, "Scroll gesture enabled = " + state, Toast.LENGTH_SHORT).show(); - item.setChecked(state); - return true; - default: - return super.onOptionsItemSelected(item); - } - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerView.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerView.java deleted file mode 100644 index cab03e4f7a..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerView.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.model.annotations; - -import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions; -import com.mapbox.mapboxsdk.annotations.MarkerView; - -public class CountryMarkerView extends MarkerView { - - private String abbrevName; - private int flagRes; - - public CountryMarkerView(BaseMarkerViewOptions baseMarkerViewOptions, String abbrevName, int flagRes) { - super(baseMarkerViewOptions); - this.abbrevName = abbrevName; - this.flagRes = flagRes; - } - - public String getAbbrevName() { - return abbrevName; - } - - public int getFlagRes() { - return flagRes; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java deleted file mode 100644 index 6602054f47..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.model.annotations; - -import android.graphics.Bitmap; -import android.os.Parcel; -import android.os.Parcelable; - -import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions; -import com.mapbox.mapboxsdk.annotations.Icon; -import com.mapbox.mapboxsdk.annotations.IconFactory; -import com.mapbox.mapboxsdk.geometry.LatLng; - -public class CountryMarkerViewOptions extends BaseMarkerViewOptions { - - private String abbrevName; - private int flagRes; - - public CountryMarkerViewOptions() { - } - - protected CountryMarkerViewOptions(Parcel in) { - position((LatLng) in.readParcelable(LatLng.class.getClassLoader())); - snippet(in.readString()); - title(in.readString()); - flat(in.readByte() != 0); - anchor(in.readFloat(), in.readFloat()); - infoWindowAnchor(in.readFloat(), in.readFloat()); - rotation(in.readFloat()); - visible(in.readByte() != 0); - alpha(in.readFloat()); - if (in.readByte() != 0) { - // this means we have an icon - String iconId = in.readString(); - Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader()); - Icon icon = IconFactory.recreate(iconId, iconBitmap); - icon(icon); - } - abbrevName(in.readString()); - flagRes(in.readInt()); - } - - @Override - public CountryMarkerViewOptions getThis() { - return this; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel out, int flags) { - out.writeParcelable(getPosition(), flags); - out.writeString(getSnippet()); - out.writeString(getTitle()); - out.writeByte((byte) (isFlat() ? 1 : 0)); - out.writeFloat(getAnchorU()); - out.writeFloat(getAnchorV()); - out.writeFloat(getInfoWindowAnchorU()); - out.writeFloat(getInfoWindowAnchorV()); - out.writeFloat(getRotation()); - out.writeByte((byte) (isVisible() ? 1 : 0)); - out.writeFloat(getAlpha()); - Icon icon = getIcon(); - out.writeByte((byte) (icon != null ? 1 : 0)); - if (icon != null) { - out.writeString(getIcon().getId()); - out.writeParcelable(getIcon().getBitmap(), flags); - } - out.writeString(abbrevName); - out.writeInt(flagRes); - } - - @Override - public CountryMarkerView getMarker() { - return new CountryMarkerView(this, abbrevName, flagRes); - } - - public CountryMarkerViewOptions abbrevName(String abbrevName) { - this.abbrevName = abbrevName; - return getThis(); - } - - public CountryMarkerViewOptions flagRes(int flagRes) { - this.flagRes = flagRes; - return getThis(); - } - - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public CountryMarkerViewOptions createFromParcel(Parcel in) { - return new CountryMarkerViewOptions(in); - } - - public CountryMarkerViewOptions[] newArray(int size) { - return new CountryMarkerViewOptions[size]; - } - }; -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java deleted file mode 100644 index b01c9907e0..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.model.annotations; - -import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions; -import com.mapbox.mapboxsdk.annotations.MarkerView; - -public class PulseMarkerView extends MarkerView { - - public PulseMarkerView(BaseMarkerViewOptions baseMarkerViewOptions) { - super(baseMarkerViewOptions); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java deleted file mode 100644 index d752e5d0ef..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.model.annotations; - -import android.graphics.Bitmap; -import android.os.Parcel; -import android.os.Parcelable; - -import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions; -import com.mapbox.mapboxsdk.annotations.Icon; -import com.mapbox.mapboxsdk.annotations.IconFactory; -import com.mapbox.mapboxsdk.geometry.LatLng; - -public class PulseMarkerViewOptions extends BaseMarkerViewOptions { - - public PulseMarkerViewOptions() { - } - - protected PulseMarkerViewOptions(Parcel in) { - position((LatLng) in.readParcelable(LatLng.class.getClassLoader())); - snippet(in.readString()); - title(in.readString()); - flat(in.readByte() != 0); - anchor(in.readFloat(), in.readFloat()); - selected = in.readByte() != 0; - rotation(in.readFloat()); - if (in.readByte() != 0) { - // this means we have an icon - String iconId = in.readString(); - Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader()); - Icon icon = IconFactory.recreate(iconId, iconBitmap); - icon(icon); - } - } - - @Override - public PulseMarkerViewOptions getThis() { - return this; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel out, int flags) { - out.writeParcelable(getPosition(), flags); - out.writeString(getSnippet()); - out.writeString(getTitle()); - out.writeByte((byte) (isFlat() ? 1 : 0)); - out.writeFloat(getAnchorU()); - out.writeFloat(getAnchorV()); - out.writeFloat(getInfoWindowAnchorU()); - out.writeFloat(getInfoWindowAnchorV()); - out.writeByte((byte) (selected ? 1 : 0)); - out.writeFloat(getRotation()); - Icon icon = getIcon(); - out.writeByte((byte) (icon != null ? 1 : 0)); - if (icon != null) { - out.writeString(getIcon().getId()); - out.writeParcelable(getIcon().getBitmap(), flags); - } - } - - @Override - public PulseMarkerView getMarker() { - return new PulseMarkerView(this); - } - - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public PulseMarkerViewOptions createFromParcel(Parcel in) { - return new PulseMarkerViewOptions(in); - } - - public PulseMarkerViewOptions[] newArray(int size) { - return new PulseMarkerViewOptions[size]; - } - }; -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java deleted file mode 100644 index dcee5c2409..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.model.annotations; - -import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions; -import com.mapbox.mapboxsdk.annotations.MarkerView; - -public class TextMarkerView extends MarkerView { - - private String text; - - public TextMarkerView(BaseMarkerViewOptions baseMarkerViewOptions, String text) { - super(baseMarkerViewOptions); - this.text = text; - } - - public String getText() { - return text; - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerViewOptions.java deleted file mode 100644 index df7c575f74..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerViewOptions.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.model.annotations; - -import android.graphics.Bitmap; -import android.os.Parcel; -import android.os.Parcelable; - -import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions; -import com.mapbox.mapboxsdk.annotations.Icon; -import com.mapbox.mapboxsdk.annotations.IconFactory; -import com.mapbox.mapboxsdk.geometry.LatLng; - -public class TextMarkerViewOptions extends BaseMarkerViewOptions { - - private String text; - - public TextMarkerViewOptions() { - } - - protected TextMarkerViewOptions(Parcel in) { - position((LatLng) in.readParcelable(LatLng.class.getClassLoader())); - snippet(in.readString()); - title(in.readString()); - flat(in.readByte() != 0); - anchor(in.readFloat(), in.readFloat()); - infoWindowAnchor(in.readFloat(), in.readFloat()); - rotation(in.readFloat()); - visible(in.readByte() != 0); - alpha(in.readFloat()); - if (in.readByte() != 0) { - // this means we have an icon - String iconId = in.readString(); - Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader()); - Icon icon = IconFactory.recreate(iconId, iconBitmap); - icon(icon); - } - text(in.readString()); - } - - @Override - public TextMarkerViewOptions getThis() { - return this; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel out, int flags) { - out.writeParcelable(getPosition(), flags); - out.writeString(getSnippet()); - out.writeString(getTitle()); - out.writeByte((byte) (isFlat() ? 1 : 0)); - out.writeFloat(getAnchorU()); - out.writeFloat(getAnchorV()); - out.writeFloat(getInfoWindowAnchorU()); - out.writeFloat(getInfoWindowAnchorV()); - out.writeFloat(getRotation()); - out.writeByte((byte) (isVisible() ? 1 : 0)); - out.writeFloat(alpha); - Icon icon = getIcon(); - out.writeByte((byte) (icon != null ? 1 : 0)); - if (icon != null) { - out.writeString(getIcon().getId()); - out.writeParcelable(getIcon().getBitmap(), flags); - } - out.writeString(text); - } - - @Override - public TextMarkerView getMarker() { - return new TextMarkerView(this, text); - } - - public TextMarkerViewOptions text(String text) { - this.text = text; - return getThis(); - } - - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public CountryMarkerViewOptions createFromParcel(Parcel in) { - return new CountryMarkerViewOptions(in); - } - - public CountryMarkerViewOptions[] newArray(int size) { - return new CountryMarkerViewOptions[size]; - } - }; -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_down.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_down.xml deleted file mode 100644 index f450edb1fb..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_down.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_up.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_up.xml deleted file mode 100644 index f8da05f35e..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_up.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android.png deleted file mode 100644 index a20277dc1b..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android_2.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android_2.png deleted file mode 100644 index d1c802c265..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android_2.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/icon_burned.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/icon_burned.png deleted file mode 100644 index c9d3f3d2d0..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/icon_burned.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android.png deleted file mode 100644 index 114bb25199..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android_2.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android_2.png deleted file mode 100644 index 62867cdca4..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android_2.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/icon_burned.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/icon_burned.png deleted file mode 100644 index 235a854d71..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/icon_burned.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android.png deleted file mode 100644 index e80400c4dd..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android_2.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android_2.png deleted file mode 100644 index 1b34d09842..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android_2.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/icon_burned.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/icon_burned.png deleted file mode 100644 index c9d3f3d2d0..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/icon_burned.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android.png deleted file mode 100644 index 19be40bf88..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android_2.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android_2.png deleted file mode 100644 index b44cec791f..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android_2.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_us.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_us.png deleted file mode 100644 index d09e068fe9..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_us.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/icon_burned.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/icon_burned.png deleted file mode 100644 index 8667ce6c44..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/icon_burned.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android.png deleted file mode 100644 index c2c4373973..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android_2.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android_2.png deleted file mode 100644 index b735fda69f..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android_2.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_taxi_top.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_taxi_top.png deleted file mode 100644 index 09f84fd9cb..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_taxi_top.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/icon_burned.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/icon_burned.png deleted file mode 100644 index df0ca2e83d..0000000000 Binary files a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/icon_burned.png and /dev/null differ diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_check_box.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_check_box.xml deleted file mode 100644 index cf8bfa24b5..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_check_box.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_run_black.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_run_black.xml deleted file mode 100644 index dfa43f020e..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_run_black.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_droppin.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_droppin.xml deleted file mode 100644 index a25e7884cd..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_droppin.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled.xml deleted file mode 100644 index 4fedff778b..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml deleted file mode 100644 index 0566757d58..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_location_engine.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_location_engine.xml deleted file mode 100644 index e9f461c7ee..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_location_engine.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_bulk.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_bulk.xml index 52691a26fe..0f60b34324 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_bulk.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_bulk.xml @@ -24,15 +24,4 @@ android:padding="16dp" android:textSize="20sp"/> - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view.xml deleted file mode 100644 index dae3a1d9b7..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view_in_rect.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view_in_rect.xml deleted file mode 100644 index ecda2873ce..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view_in_rect.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml deleted file mode 100644 index addfe8427b..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml deleted file mode 100644 index de18e265de..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - -