summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location
diff options
context:
space:
mode:
authorTim Watson <tewatson89@gmail.com>2019-04-03 14:51:13 -0700
committerGitHub <noreply@github.com>2019-04-03 14:51:13 -0700
commit0ff25060dae4858a1b60e2277dbd8921de7a6785 (patch)
treed29d578b9b9d6cfb0999b7a30819d379b85172b7 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location
parentba2b7a74c420856401d344ff15b27771175c9819 (diff)
parent0f416fbbde9b146eb28a4bf88586738d12505007 (diff)
downloadqtlocation-mapboxgl-upstream/friedbunny-external-pr-14135.tar.gz
Merge pull request #1 from mapbox/masterupstream/friedbunny-external-pr-14135
Merge Master
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java6
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java16
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentConstants.java32
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java17
4 files changed, 41 insertions, 30 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java
index 4e56c6e9c0..b9aa371a47 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java
@@ -77,9 +77,11 @@ final class LocationCameraController {
void initializeOptions(LocationComponentOptions options) {
this.options = options;
if (options.trackingGesturesManagement()) {
- mapboxMap.setGesturesManager(internalGesturesManager, true, true);
+ if (mapboxMap.getGesturesManager() != internalGesturesManager) {
+ mapboxMap.setGesturesManager(internalGesturesManager, true, true);
+ }
adjustGesturesThresholds();
- } else {
+ } else if (mapboxMap.getGesturesManager() != initialGesturesManager) {
mapboxMap.setGesturesManager(initialGesturesManager, true, true);
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java
index b97ab75b5e..327ab3c8ed 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java
@@ -220,7 +220,6 @@ public final class LocationComponent {
* @param style the proxy object for current map style. More info at {@link Style}
* @deprecated use {@link LocationComponentActivationOptions.Builder} instead
*/
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style) {
activateLocationComponent(context, style,
@@ -237,7 +236,6 @@ public final class LocationComponent {
* there should be no location engine initialized
* @deprecated use {@link LocationComponentActivationOptions.Builder} instead
*/
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
boolean useDefaultLocationEngine) {
@@ -259,7 +257,6 @@ public final class LocationComponent {
* @param locationEngineRequest the location request
* @deprecated use {@link LocationComponentActivationOptions.Builder} instead
*/
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
boolean useDefaultLocationEngine,
@@ -284,7 +281,6 @@ public final class LocationComponent {
* @param options the options
* @deprecated use {@link LocationComponentActivationOptions.Builder} instead
*/
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
boolean useDefaultLocationEngine,
@@ -309,7 +305,6 @@ public final class LocationComponent {
* @param styleRes the LocationComponent style res
* @deprecated use {@link LocationComponentActivationOptions.Builder} instead
*/
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style, @StyleRes int styleRes) {
activateLocationComponent(context, style, LocationComponentOptions.createFromAttributes(context, styleRes));
@@ -327,7 +322,6 @@ public final class LocationComponent {
* @param options the options
* @deprecated use {@link LocationComponentActivationOptions.Builder} instead
*/
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
@NonNull LocationComponentOptions options) {
@@ -346,7 +340,6 @@ public final class LocationComponent {
* @param styleRes the LocationComponent style res
* @deprecated use {@link LocationComponentActivationOptions.Builder} instead
*/
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
@Nullable LocationEngine locationEngine, @StyleRes int styleRes) {
@@ -365,7 +358,6 @@ public final class LocationComponent {
* @param styleRes the LocationComponent style res
* @deprecated use {@link LocationComponentActivationOptions.Builder} instead
*/
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
@Nullable LocationEngine locationEngine,
@@ -382,7 +374,6 @@ public final class LocationComponent {
* @param locationEngine the engine
* @deprecated use {@link LocationComponentActivationOptions.Builder} instead
*/
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
@Nullable LocationEngine locationEngine) {
@@ -398,7 +389,6 @@ public final class LocationComponent {
* @param locationEngineRequest the location request
* @deprecated use {@link LocationComponentActivationOptions.Builder} instead
*/
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
@Nullable LocationEngine locationEngine,
@@ -415,7 +405,6 @@ public final class LocationComponent {
* @param options the options
* @deprecated use {@link LocationComponentActivationOptions.Builder} instead
*/
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
@Nullable LocationEngine locationEngine,
@@ -453,8 +442,7 @@ public final class LocationComponent {
*
* @param activationOptions a fully built {@link LocationComponentActivationOptions} object
*/
- public void activateLocationComponent(@NonNull LocationComponentActivationOptions
- activationOptions) {
+ public void activateLocationComponent(@NonNull LocationComponentActivationOptions activationOptions) {
LocationComponentOptions options = activationOptions.locationComponentOptions();
if (options == null) {
int styleRes = activationOptions.styleRes();
@@ -496,6 +484,7 @@ public final class LocationComponent {
*
* @param isEnabled true if the plugin should be visible and listen for location updates, false otherwise.
*/
+ @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
public void setLocationComponentEnabled(boolean isEnabled) {
checkActivationState();
if (isEnabled) {
@@ -954,7 +943,6 @@ public final class LocationComponent {
* @return the last known location
*/
@Nullable
- @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
public Location getLastKnownLocation() {
checkActivationState();
return lastLocation;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentConstants.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentConstants.java
index 093c91e799..c0173cb8e8 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentConstants.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponentConstants.java
@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.location;
/**
- * Contains all the constants being used for the Location layer.
+ * Contains all the constants being used for the {@link LocationComponent}.
*/
final class LocationComponentConstants {
@@ -49,11 +49,31 @@ final class LocationComponentConstants {
static final String PROPERTY_BEARING_ICON = "mapbox-property-shadow-icon";
// Layers
- static final String SHADOW_LAYER = "mapbox-location-shadow";
- static final String FOREGROUND_LAYER = "mapbox-location-layer";
- static final String BACKGROUND_LAYER = "mapbox-location-stroke-layer";
- static final String ACCURACY_LAYER = "mapbox-location-accuracy-layer";
- static final String BEARING_LAYER = "mapbox-location-bearing-layer";
+
+ /**
+ * Layer ID of the location shadow.
+ */
+ public static final String SHADOW_LAYER = "mapbox-location-shadow-layer";
+
+ /**
+ * Layer ID of the location foreground icon.
+ */
+ public static final String FOREGROUND_LAYER = "mapbox-location-foreground-layer";
+
+ /**
+ * Layer ID of the location background icon.
+ */
+ public static final String BACKGROUND_LAYER = "mapbox-location-background-layer";
+
+ /**
+ * Layer ID of the location accuracy.
+ */
+ public static final String ACCURACY_LAYER = "mapbox-location-accuracy-layer";
+
+ /**
+ * Layer ID of the location bearing icon.
+ */
+ public static final String BEARING_LAYER = "mapbox-location-bearing-layer";
// Icons
static final String FOREGROUND_ICON = "mapbox-location-icon";
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java
index f11acacf31..aa8a82bf6d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java
@@ -5,6 +5,7 @@ import android.graphics.PointF;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
@@ -18,7 +19,6 @@ import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -70,7 +70,8 @@ final class LocationLayerController {
private LocationComponentOptions options;
private final OnRenderModeChangedListener internalRenderModeChangedListener;
- private final List<String> layerMap = new ArrayList<>();
+ @VisibleForTesting
+ final Set<String> layerSet = new HashSet<>();
private Feature locationFeature;
private GeoJsonSource locationSource;
@@ -112,7 +113,7 @@ final class LocationLayerController {
removeLayers();
addLayers(newLayerBelowOption);
if (isHidden) {
- for (String layerId : layerMap) {
+ for (String layerId : layerSet) {
setLayerVisibility(layerId, false);
}
}
@@ -193,7 +194,7 @@ final class LocationLayerController {
void hide() {
isHidden = true;
- for (String layerId : layerMap) {
+ for (String layerId : layerSet) {
setLayerVisibility(layerId, false);
}
}
@@ -257,14 +258,14 @@ final class LocationLayerController {
private void addLayerToMap(Layer layer, @NonNull String idBelowLayer) {
style.addLayerBelow(layer, idBelowLayer);
- layerMap.add(layer.getId());
+ layerSet.add(layer.getId());
}
private void removeLayers() {
- for (String layerId : layerMap) {
+ for (String layerId : layerSet) {
style.removeLayer(layerId);
}
- layerMap.clear();
+ layerSet.clear();
}
private void setBearingProperty(@NonNull String propertyId, float bearing) {
@@ -351,7 +352,7 @@ final class LocationLayerController {
}
private void styleScaling(@NonNull LocationComponentOptions options) {
- for (String layerId : layerMap) {
+ for (String layerId : layerSet) {
Layer layer = style.getLayer(layerId);
if (layer instanceof SymbolLayer) {
layer.setProperties(