From ad46d67aeb84b258668126dddc00c581f4808f3e Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Thu, 11 May 2017 21:00:41 +0200
Subject: [android] - keep observer when timeout occurs, make observer param
nullable, fixup log messages (#8919)
---
.../com/mapbox/mapboxsdk/offline/OfflineRegion.java | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
index a55e8dd848..2110e12b36 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
@@ -4,6 +4,7 @@ import android.os.Handler;
import android.os.Looper;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import com.mapbox.mapboxsdk.storage.FileSource;
@@ -205,7 +206,7 @@ public class OfflineRegion {
/**
* Constructor
- *
+ *
* For JNI use only, to create a new offline region, use
* {@link OfflineManager#createOfflineRegion} instead.
*/
@@ -247,7 +248,7 @@ public class OfflineRegion {
*
* @param observer the observer to be notified
*/
- public void setObserver(@NonNull final OfflineRegionObserver observer) {
+ public void setObserver(@Nullable final OfflineRegionObserver observer) {
setOfflineRegionObserver(new OfflineRegionObserver() {
@Override
public void onStatusChanged(final OfflineRegionStatus status) {
@@ -255,7 +256,9 @@ public class OfflineRegion {
getHandler().post(new Runnable() {
@Override
public void run() {
- observer.onStatusChanged(status);
+ if (observer != null) {
+ observer.onStatusChanged(status);
+ }
}
});
}
@@ -267,7 +270,9 @@ public class OfflineRegion {
getHandler().post(new Runnable() {
@Override
public void run() {
- observer.onError(error);
+ if (observer != null) {
+ observer.onError(error);
+ }
}
});
}
@@ -279,7 +284,9 @@ public class OfflineRegion {
getHandler().post(new Runnable() {
@Override
public void run() {
- observer.mapboxTileCountLimitExceeded(limit);
+ if (observer != null) {
+ observer.mapboxTileCountLimitExceeded(limit);
+ }
}
});
}
--
cgit v1.2.1
From 850b008a2fd872c6158502b821da17864711bb12 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Thu, 11 May 2017 21:39:17 +0200
Subject: [android] - avoid crashing when deleting already deleted region
(#8920)
---
.../mapbox/mapboxsdk/offline/OfflineRegion.java | 48 ++++++++++++----------
1 file changed, 27 insertions(+), 21 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
index 2110e12b36..44bb2a05ee 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
@@ -37,6 +37,9 @@ public class OfflineRegion {
//Region id
private long id;
+ // delete status
+ private boolean isDeleted;
+
private OfflineRegionDefinition definition;
/**
@@ -353,28 +356,31 @@ public class OfflineRegion {
* @param callback the callback to be invoked
*/
public void delete(@NonNull final OfflineRegionDeleteCallback callback) {
- deleteOfflineRegion(new OfflineRegionDeleteCallback() {
- @Override
- public void onDelete() {
- getHandler().post(new Runnable() {
- @Override
- public void run() {
- callback.onDelete();
- OfflineRegion.this.finalize();
- }
- });
- }
+ if (!isDeleted) {
+ deleteOfflineRegion(new OfflineRegionDeleteCallback() {
+ @Override
+ public void onDelete() {
+ isDeleted = true;
+ getHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ callback.onDelete();
+ OfflineRegion.this.finalize();
+ }
+ });
+ }
- @Override
- public void onError(final String error) {
- getHandler().post(new Runnable() {
- @Override
- public void run() {
- callback.onError(error);
- }
- });
- }
- });
+ @Override
+ public void onError(final String error) {
+ getHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ callback.onError(error);
+ }
+ });
+ }
+ });
+ }
}
/**
--
cgit v1.2.1
From e681f69993ea9b28e745e8933744960eb5a608f8 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 12 May 2017 15:16:13 +0200
Subject: [android] - update LOST to 2.3.0 (#8872)
---
platform/android/MapboxGLAndroidSDK/build.gradle | 4 +++-
.../java/com/mapbox/mapboxsdk/location/LocationSource.java | 10 ----------
2 files changed, 3 insertions(+), 11 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle
index 1156a6ef43..c4668f598c 100644
--- a/platform/android/MapboxGLAndroidSDK/build.gradle
+++ b/platform/android/MapboxGLAndroidSDK/build.gradle
@@ -6,7 +6,9 @@ dependencies {
compile rootProject.ext.dep.supportDesign
compile rootProject.ext.dep.timber
compile rootProject.ext.dep.okhttp3
- compile rootProject.ext.dep.lost
+ compile(rootProject.ext.dep.lost) {
+ exclude module: 'support-compat'
+ }
// Mapbox Android Services (GeoJSON support)
compile(rootProject.ext.dep.mapboxJavaGeoJSON) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
index b795cf1d5b..c4bdb4a17d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
@@ -135,14 +135,4 @@ public class LocationSource extends LocationEngine implements
listener.onLocationChanged(location);
}
}
-
- @Override
- public void onProviderDisabled(String provider) {
- Log.d(LOG_TAG, "Provider disabled: " + provider);
- }
-
- @Override
- public void onProviderEnabled(String provider) {
- Log.d(LOG_TAG, "Provider enabled: " + provider);
- }
}
--
cgit v1.2.1
From cb737362b631284e1516561caf30c2027f9bdc03 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 12 May 2017 15:27:27 +0200
Subject: [android] - update proguard config, allow debug mimification, update
OkHttp to latest version (#8944)
---
platform/android/MapboxGLAndroidSDK/build.gradle | 4 +-
.../android/MapboxGLAndroidSDK/proguard-rules.pro | 89 +---------------------
2 files changed, 7 insertions(+), 86 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle
index c4668f598c..fca36237c3 100644
--- a/platform/android/MapboxGLAndroidSDK/build.gradle
+++ b/platform/android/MapboxGLAndroidSDK/build.gradle
@@ -95,6 +95,9 @@ android {
}
}
}
+
+ // proguard config for .aar
+ consumerProguardFiles 'proguard-rules.pro'
}
// avoid naming conflicts, force usage of prefix
@@ -122,7 +125,6 @@ android {
release {
// aar proguard configuration
- consumerProguardFiles 'proguard-rules.pro'
jniDebuggable false
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/proguard-rules.pro b/platform/android/MapboxGLAndroidSDK/proguard-rules.pro
index baecd80e50..8e47815451 100644
--- a/platform/android/MapboxGLAndroidSDK/proguard-rules.pro
+++ b/platform/android/MapboxGLAndroidSDK/proguard-rules.pro
@@ -2,89 +2,8 @@
# in ../sdk/tools/proguard/proguard-android.txt,
# contents of this file will be appended into proguard-android.txt
-keepattributes Signature, *Annotation*, EnclosingMethod
-
-# Square okio, ignoring warnings,
-# see https://github.com/square/okio/issues/60
--dontwarn okhttp3.**
--dontwarn okio.**
-
-# Gesture package
-keep class almeros.android.multitouch.gesturedetectors.** { *; }
-
-# Package annotations
--keep class com.mapbox.mapboxsdk.annotations.** { *; }
-
-# Package camera
--keep class com.mapbox.mapboxsdk.camera.** { *; }
-
-# Package geometry
--keep class com.mapbox.mapboxsdk.geometry.** { *; }
-
-# Package http
--keep class com.mapbox.mapboxsdk.http.** { *; }
-
-# Package maps
--keep class com.mapbox.mapboxsdk.maps.** { *; }
-
-# Package net
--keep class com.mapbox.mapboxsdk.net.** { *; }
-
-# Package offline
--keep class com.mapbox.mapboxsdk.offline.** { *; }
-
-# Package storage
--keep class com.mapbox.mapboxsdk.storage.** { *; }
-
-# Package style
--keep class com.mapbox.mapboxsdk.style.layers.** { *; }
--keep class com.mapbox.mapboxsdk.style.sources.** { *; }
--keep class com.mapbox.mapboxsdk.style.functions.** { *; }
-
-# Package telemetry
--keep class com.mapbox.mapboxsdk.telemetry.** { *; }
-
-#
-# Mapbox-java Proguard rules
-# We include these rules since libjava is a Jar file not AAR
-#
-
-# Retrofit 2
-# Platform calls Class.forName on types which do not exist on Android to determine platform.
--dontnote retrofit2.Platform
-# Platform used when running on RoboVM on iOS. Will not be used at runtime.
--dontnote retrofit2.Platform$IOS$MainThreadExecutor
-# Platform used when running on Java 8 VMs. Will not be used at runtime.
--dontwarn retrofit2.Platform$Java8
-# Retain generic type information for use by reflection by converters and adapters.
--keepattributes Signature
-# Retain declared checked exceptions for use by a Proxy instance.
--keepattributes Exceptions
-
-# For using GSON @Expose annotation
--keepattributes *Annotation*
-# Gson specific classes
--dontwarn sun.misc.**
-
-# Prevent proguard from stripping interface information from TypeAdapterFactory,
-# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
--keep class * implements com.google.gson.TypeAdapterFactory
--keep class * implements com.google.gson.JsonSerializer
--keep class * implements com.google.gson.JsonDeserializer
-
-# MAS Data Models
--keep class com.mapbox.services.commons.geojson.** { *; }
--keep class com.mapbox.services.mapmatching.v4.models.** { *; }
--keep class com.mapbox.services.distance.v1.models.** { *; }
--keep class com.mapbox.services.directions.v4.models.** { *; }
--keep class com.mapbox.services.directions.v5.models.** { *; }
--keep class com.mapbox.services.geocoding.v5.models.** { *; }
-
--dontwarn javax.annotation.**
-
--keepclassmembers class rx.internal.util.unsafe.** {
- long producerIndex;
- long consumerIndex;
-}
-
--keep class com.google.** { *; }
--dontwarn com.google.**
\ No newline at end of file
+-keep class com.mapbox.mapboxsdk.** { *; }
+-keep interface com.mapbox.mapboxsdk.** { *; }
+-keep class com.mapbox.services.android.telemetry.** { *; }
+-keep class com.mapbox.services.commons.** { *;}
\ No newline at end of file
--
cgit v1.2.1
From 0ef1293dada1490c808ae821228d5a2f3324afdb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?=
Date: Fri, 9 Sep 2016 10:17:42 -0700
Subject: [core, android, ios, macos, qt] v10 default styles
Upgraded from v9 default styles to v10 wherever the developer expects to get the latest and greatest, as well as in a couple tests where it may be beneficial to ensure that we can handle a two-digit version number in the style URL.
Cherry-picked from ed54849e9909e7f7cd8724b39b2bc94f16cf9a11.
---
.../src/main/java/com/mapbox/mapboxsdk/constants/Style.java | 6 +++---
platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
index d55fd4c023..fae3bdde2c 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
@@ -35,13 +35,13 @@ public class Style {
* constant means your map style will always use the latest version and may change as we
* improve the style.
*/
- public static final String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v9";
+ public static final String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v10";
/**
* Outdoors: A general-purpose style tailored to outdoor activities. Using this constant means
* your map style will always use the latest version and may change as we improve the style.
*/
- public static final String OUTDOORS = "mapbox://styles/mapbox/outdoors-v9";
+ public static final String OUTDOORS = "mapbox://styles/mapbox/outdoors-v10";
/**
* Light: Subtle light backdrop for data visualizations. Using this constant means your map
@@ -66,5 +66,5 @@ public class Style {
* constant means your map style will always use the latest version and may change as we
* improve the style.
*/
- public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-streets-v9";
+ public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-streets-v10";
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml
index 0862305cfb..7adc29e2de 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml
@@ -18,10 +18,10 @@
- mapbox://styles/mapbox/streets-v9
- mapbox://styles/mapbox/outdoors-v9
+ mapbox://styles/mapbox/streets-v10
+ mapbox://styles/mapbox/outdoors-v10
mapbox://styles/mapbox/light-v9
mapbox://styles/mapbox/dark-v9
mapbox://styles/mapbox/satellite-v9
- mapbox://styles/mapbox/satellite-streets-v9
+ mapbox://styles/mapbox/satellite-streets-v10
--
cgit v1.2.1
From 886bf2528ff1615a50521e75fc6ea211cef3b8d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?=
Date: Mon, 8 May 2017 17:45:22 -0700
Subject: [core, android, ios, macos] Added Traffic Day/Night to default styles
The Styles API section of the Mapbox API Documentation site now lists Traffic Day v2 and Traffic Night v2, so this change adds those styles to all the places where styles are listed.
Also switched iosapp and macosapp to unversioned style factory methods since MGLStyleDefaultVersion is no longer applicable for all styles.
Cherry-picked from 4d6f54553d277c0af24a0b8ff03d2dd7e9284ca2.
---
.../java/com/mapbox/mapboxsdk/constants/Style.java | 20 +++++++++++++++++++-
.../src/main/res/values/strings.xml | 2 ++
2 files changed, 21 insertions(+), 1 deletion(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
index fae3bdde2c..77d0929df3 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
@@ -23,7 +23,7 @@ public class Style {
* constants means your map style will always use the latest version and may change as we
* improve the style
*/
- @StringDef( {MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS})
+ @StringDef( {MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS, TRAFFIC_DAY, TRAFFIC_NIGHT})
@Retention(RetentionPolicy.SOURCE)
public @interface StyleUrl {
}
@@ -67,4 +67,22 @@ public class Style {
* improve the style.
*/
public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-streets-v10";
+
+ /**
+ * Traffic Day: Color-coded roads based on live traffic congestion data. Traffic data is currently
+ * available in
+ * these select
+ * countries. Using this constant means your map style will always use the latest version and
+ * may change as we improve the style.
+ */
+ public static final String TRAFFIC_DAY = "mapbox://styles/mapbox/traffic-day-v2";
+
+ /**
+ * Traffic Night: Color-coded roads based on live traffic congestion data, designed to maximize
+ * legibility in low-light situations. Traffic data is currently available in
+ * these select
+ * countries. Using this constant means your map style will always use the latest version and
+ * may change as we improve the style.
+ */
+ public static final String TRAFFIC_NIGHT = "mapbox://styles/mapbox/traffic-night-v2";
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml
index 7adc29e2de..65fb3e14a3 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml
@@ -24,4 +24,6 @@
mapbox://styles/mapbox/dark-v9
mapbox://styles/mapbox/satellite-v9
mapbox://styles/mapbox/satellite-streets-v10
+ mapbox://styles/mapbox/traffic-day-v2
+ mapbox://styles/mapbox/traffic-night-v2
--
cgit v1.2.1
From a68788a2cfb85efe69b0d81672bff7272368494e Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 12 May 2017 20:07:06 +0200
Subject: [android] Release android-v5.1.0-beta.2 (#8976)
* [android] url getter on sources
* [android] fix ui test filter in makefile
* [android] - build SNAPSHOT from release branch (#8958)
* [android] - update changelog for 5.1.0-beta.2
* [android] - bump version number
* [android] - Camera change listener v2.0
* [core] allow filesource url transform reset
* [android] Update attribution wordmark (#8774)
* Update wordmark on android
* Moved attribution i icon to the right of mapbox word (in mapview preview image)
* update padding and margin
* [android] update hardcoded branch name
* revert version to 5.1.0-SNAPSHOT
---
.../mapboxsdk/maps/CameraChangeDispatcher.java | 67 ++++++++++++++
.../mapbox/mapboxsdk/maps/MapGestureDetector.java | 39 ++++----
.../java/com/mapbox/mapboxsdk/maps/MapView.java | 11 ++-
.../java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 100 ++++++++++++++++++++-
.../mapbox/mapboxsdk/maps/MapboxMapOptions.java | 30 +++----
.../java/com/mapbox/mapboxsdk/maps/Transform.java | 57 ++++++++++--
.../java/com/mapbox/mapboxsdk/maps/UiSettings.java | 23 ++---
.../mapboxsdk/style/sources/GeoJsonSource.java | 10 +++
.../mapboxsdk/style/sources/RasterSource.java | 13 +++
.../mapboxsdk/style/sources/VectorSource.java | 10 +++
.../main/res/drawable-hdpi/mapbox_logo_icon.png | Bin 3408 -> 4778 bytes
.../main/res/drawable-mdpi/mapbox_logo_icon.png | Bin 1958 -> 2622 bytes
.../main/res/drawable-xhdpi/mapbox_logo_icon.png | Bin 4492 -> 6579 bytes
.../main/res/drawable-xxhdpi/mapbox_logo_icon.png | Bin 7059 -> 10802 bytes
.../main/res/drawable-xxxhdpi/mapbox_logo_icon.png | Bin 9402 -> 14441 bytes
.../main/res/drawable/mapbox_info_icon_default.xml | 8 +-
.../res/drawable/mapbox_info_icon_selected.xml | 10 +--
.../main/res/layout/mapbox_mapview_internal.xml | 3 +-
.../src/main/res/layout/mapbox_mapview_preview.xml | 35 +++++---
.../src/main/res/values/dimens.xml | 9 +-
20 files changed, 342 insertions(+), 83 deletions(-)
create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
new file mode 100644
index 0000000000..bd028aecb6
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
@@ -0,0 +1,67 @@
+package com.mapbox.mapboxsdk.maps;
+
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener;
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveCanceledListener;
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener;
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveListener;
+
+class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, MapboxMap.OnCameraMoveListener,
+ MapboxMap.OnCameraMoveCanceledListener, OnCameraIdleListener {
+
+ private boolean idle = true;
+
+ private OnCameraMoveStartedListener onCameraMoveStartedListener;
+ private OnCameraMoveCanceledListener onCameraMoveCanceledListener;
+ private OnCameraMoveListener onCameraMoveListener;
+ private OnCameraIdleListener onCameraIdleListener;
+
+ void setOnCameraMoveStartedListener(OnCameraMoveStartedListener onCameraMoveStartedListener) {
+ this.onCameraMoveStartedListener = onCameraMoveStartedListener;
+ }
+
+ void setOnCameraMoveCanceledListener(OnCameraMoveCanceledListener onCameraMoveCanceledListener) {
+ this.onCameraMoveCanceledListener = onCameraMoveCanceledListener;
+ }
+
+ void setOnCameraMoveListener(OnCameraMoveListener onCameraMoveListener) {
+ this.onCameraMoveListener = onCameraMoveListener;
+ }
+
+ void setOnCameraIdleListener(OnCameraIdleListener onCameraIdleListener) {
+ this.onCameraIdleListener = onCameraIdleListener;
+ }
+
+ @Override
+ public void onCameraMoveStarted(int reason) {
+ if (!idle) {
+ return;
+ }
+
+ idle = false;
+ if (onCameraMoveStartedListener != null) {
+ onCameraMoveStartedListener.onCameraMoveStarted(reason);
+ }
+ }
+
+ @Override
+ public void onCameraMove() {
+ if (onCameraMoveListener != null && !idle) {
+ onCameraMoveListener.onCameraMove();
+ }
+ }
+
+ @Override
+ public void onCameraMoveCanceled() {
+ if (onCameraMoveCanceledListener != null && !idle) {
+ onCameraMoveCanceledListener.onCameraMoveCanceled();
+ }
+ }
+
+ @Override
+ public void onCameraIdle() {
+ if (onCameraIdleListener != null && !idle) {
+ idle = true;
+ onCameraIdleListener.onCameraIdle();
+ }
+ }
+}
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 dca833bbf4..39433d8b93 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
@@ -22,6 +22,8 @@ import com.mapbox.services.android.telemetry.MapboxTelemetry;
import com.mapbox.services.android.telemetry.utils.MathUtils;
import com.mapbox.services.android.telemetry.utils.TelemetryUtils;
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener.REASON_API_GESTURE;
+
/**
* Manages gestures events on a MapView.
*
@@ -35,6 +37,7 @@ final class MapGestureDetector {
private final UiSettings uiSettings;
private final TrackingSettings trackingSettings;
private final AnnotationManager annotationManager;
+ private final CameraChangeDispatcher cameraChangeDispatcher;
private final GestureDetectorCompat gestureDetector;
private final ScaleGestureDetector scaleGestureDetector;
@@ -56,12 +59,14 @@ final class MapGestureDetector {
private boolean scaleGestureOccurred = false;
MapGestureDetector(Context context, Transform transform, Projection projection, UiSettings uiSettings,
- TrackingSettings trackingSettings, AnnotationManager annotationManager) {
+ TrackingSettings trackingSettings, 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
gestureDetector = new GestureDetectorCompat(context, new GestureListener());
@@ -187,6 +192,7 @@ final class MapGestureDetector {
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapDragEndEvent(
getLocationFromGesture(event.getX(), event.getY()), transform));
scrollInProgress = false;
+ cameraChangeDispatcher.onCameraIdle();
}
twoTap = false;
@@ -273,6 +279,9 @@ final class MapGestureDetector {
break;
}
+ // notify camera change listener
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
+
// Single finger double tap
if (focalPoint != null) {
// User provided focal point
@@ -337,6 +346,7 @@ final class MapGestureDetector {
// and ignore when a scale gesture has occurred
return false;
}
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
float screenDensity = uiSettings.getPixelRatio();
@@ -362,9 +372,7 @@ final class MapGestureDetector {
long animationTime = (long) (velocityXY / 7 / tiltFactor + MapboxConstants.ANIMATION_DURATION_FLING_BASE);
// update transformation
- transform.setGestureInProgress(true);
transform.moveBy(offsetX, offsetY, animationTime);
- transform.setGestureInProgress(false);
if (onFlingListener != null) {
onFlingListener.onFling();
@@ -377,6 +385,10 @@ final class MapGestureDetector {
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (!scrollInProgress) {
scrollInProgress = true;
+
+ // Cancel any animation
+ transform.cancelTransitions();
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent(
getLocationFromGesture(e1.getX(), e1.getY()),
MapboxEvent.GESTURE_PAN_START, transform));
@@ -391,8 +403,6 @@ final class MapGestureDetector {
// reset tracking if needed
trackingSettings.resetTrackingModesIfRequired(true, false);
- // Cancel any animation
- transform.cancelTransitions();
// Scroll the map
transform.moveBy(-distanceX, -distanceY, 0 /*no duration*/);
@@ -446,6 +456,8 @@ final class MapGestureDetector {
// If scale is large enough ignore a tap
scaleFactor *= detector.getScaleFactor();
if ((scaleFactor > 1.05f) || (scaleFactor < 0.95f)) {
+ // notify camera change listener
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
zoomStarted = true;
}
@@ -465,9 +477,6 @@ final class MapGestureDetector {
return false;
}
- // Cancel any animation
- transform.cancelTransitions();
-
// Gesture is a quickzoom if there aren't two fingers
quickZoom = !twoTap;
@@ -512,6 +521,9 @@ final class MapGestureDetector {
return false;
}
+ // notify camera change listener
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
+
beginTime = detector.getEventTime();
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent(
getLocationFromGesture(detector.getFocusX(), detector.getFocusY()),
@@ -522,6 +534,7 @@ final class MapGestureDetector {
// Called when the fingers leave the screen
@Override
public void onRotateEnd(RotateGestureDetector detector) {
+ // notify camera change listener
beginTime = 0;
totalAngle = 0.0f;
started = false;
@@ -553,13 +566,8 @@ final class MapGestureDetector {
if (!started) {
return false;
}
-
- // Cancel any animation
- transform.cancelTransitions();
-
// rotation constitutes translation of anything except the center of
// rotation, so cancel both location and bearing tracking if required
-
trackingSettings.resetTrackingModesIfRequired(true, true);
// Get rotate value
@@ -593,6 +601,8 @@ final class MapGestureDetector {
return false;
}
+ // notify camera change listener
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
beginTime = detector.getEventTime();
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent(
getLocationFromGesture(detector.getFocusX(), detector.getFocusY()),
@@ -633,9 +643,6 @@ final class MapGestureDetector {
return false;
}
- // Cancel any animation
- transform.cancelTransitions();
-
// Get tilt value (scale and clamp)
double pitch = transform.getTilt();
pitch -= 0.1 * detector.getShovePixelsDelta();
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 872802292c..d00da4c155 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
@@ -129,6 +129,9 @@ public class MapView extends FrameLayout {
// callback for zooming in the camera
CameraZoomInvalidator zoomInvalidator = new CameraZoomInvalidator();
+ // callback for camera change events
+ CameraChangeDispatcher cameraChangeDispatcher = new CameraChangeDispatcher();
+
// setup components for MapboxMap creation
Projection proj = new Projection(nativeMapView);
UiSettings uiSettings = new UiSettings(proj, focalPoint, compassView, attrView, view.findViewById(R.id.logoView));
@@ -136,12 +139,14 @@ public class MapView extends FrameLayout {
MyLocationViewSettings myLocationViewSettings = new MyLocationViewSettings(myLocationView, proj, focalPoint);
MarkerViewManager markerViewManager = new MarkerViewManager((ViewGroup) findViewById(R.id.markerViewContainer));
AnnotationManager annotations = new AnnotationManager(nativeMapView, this, markerViewManager);
- Transform transform = new Transform(nativeMapView, annotations.getMarkerViewManager(), trackingSettings);
+ Transform transform = new Transform(nativeMapView, annotations.getMarkerViewManager(), trackingSettings,
+ cameraChangeDispatcher);
mapboxMap = new MapboxMap(nativeMapView, transform, uiSettings, trackingSettings, myLocationViewSettings, proj,
- registerTouchListener, annotations);
+ registerTouchListener, annotations, cameraChangeDispatcher);
// user input
- mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings, trackingSettings, annotations);
+ mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings, trackingSettings, annotations,
+ cameraChangeDispatcher);
mapKeyListener = new MapKeyListener(transform, trackingSettings, uiSettings);
MapZoomControllerListener zoomListener = new MapZoomControllerListener(mapGestureDetector, uiSettings, transform);
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 1751dcf042..96603355f1 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
@@ -69,6 +69,7 @@ public final class MapboxMap {
private final Transform transform;
private final AnnotationManager annotationManager;
private final MyLocationViewSettings myLocationViewSettings;
+ private final CameraChangeDispatcher cameraChangeDispatcher;
private final OnRegisterTouchListener onRegisterTouchListener;
@@ -76,7 +77,7 @@ public final class MapboxMap {
MapboxMap(NativeMapView map, Transform transform, UiSettings ui, TrackingSettings tracking,
MyLocationViewSettings myLocationView, Projection projection, OnRegisterTouchListener listener,
- AnnotationManager annotations) {
+ AnnotationManager annotations, CameraChangeDispatcher cameraChangeDispatcher) {
this.nativeMapView = map;
this.uiSettings = ui;
this.trackingSettings = tracking;
@@ -85,6 +86,7 @@ public final class MapboxMap {
this.annotationManager = annotations.bind(this);
this.transform = transform;
this.onRegisterTouchListener = listener;
+ this.cameraChangeDispatcher = cameraChangeDispatcher;
}
void initialise(@NonNull Context context, @NonNull MapboxMapOptions options) {
@@ -1595,10 +1597,51 @@ public final class MapboxMap {
* To unset the callback, use null.
*/
@UiThread
+ @Deprecated
public void setOnCameraChangeListener(@Nullable OnCameraChangeListener listener) {
transform.setOnCameraChangeListener(listener);
}
+ /**
+ * Sets a callback that is invoked when camera movement has ended.
+ *
+ * @param listener the listener to notify
+ */
+ @UiThread
+ public void setOnCameraIdleListener(@Nullable OnCameraIdleListener listener) {
+ cameraChangeDispatcher.setOnCameraIdleListener(listener);
+ }
+
+ /**
+ * Sets a callback that is invoked when camera movement was cancelled.
+ *
+ * @param listener the listener to notify
+ */
+ @UiThread
+ public void setOnCameraMoveCancelListener(@Nullable OnCameraMoveCanceledListener listener) {
+ cameraChangeDispatcher.setOnCameraMoveCanceledListener(listener);
+ }
+
+ /**
+ * Sets a callback that is invoked when camera movement has started.
+ *
+ * @param listener the listener to notify
+ */
+ @UiThread
+ public void setOnCameraMoveStartedistener(@Nullable OnCameraMoveStartedListener listener) {
+ cameraChangeDispatcher.setOnCameraMoveStartedListener(listener);
+ }
+
+ /**
+ * Sets a callback that is invoked when camera position changes.
+ *
+ * @param listener the listener to notify
+ */
+ @UiThread
+ public void setOnCameraMoveListener(@Nullable OnCameraMoveListener listener) {
+ cameraChangeDispatcher.setOnCameraMoveListener(listener);
+ }
+
/**
* Sets a callback that's invoked on every frame rendered to the map view.
*
@@ -1913,7 +1956,12 @@ public final class MapboxMap {
/**
* Interface definition for a callback to be invoked when the camera changes position.
+ *
+ * @deprecated Replaced by MapboxMap.OnCameraMoveStartedListener, MapboxMap.OnCameraMoveListener and
+ * MapboxMap.OnCameraIdleListener. The order in which the deprecated onCameraChange method will be called in relation
+ * to the methods in the new camera change listeners is undefined.
*/
+ @Deprecated
public interface OnCameraChangeListener {
/**
* Called after the camera position has changed. During an animation,
@@ -1925,6 +1973,56 @@ public final class MapboxMap {
void onCameraChange(CameraPosition position);
}
+ /**
+ * Interface definition for a callback to be invoked for when the camera motion starts.
+ */
+ public interface OnCameraMoveStartedListener {
+ int REASON_API_GESTURE = 1;
+ int REASON_DEVELOPER_ANIMATION = 2;
+ int REASON_API_ANIMATION = 3;
+
+ /**
+ * Called when the camera starts moving after it has been idle or when the reason for camera motion has changed.
+ *
+ * @param reason the reason for the camera change
+ */
+ void onCameraMoveStarted(int reason);
+ }
+
+ /**
+ * Interface definition for a callback to be invoked for when the camera changes position.
+ */
+ public interface OnCameraMoveListener {
+ /**
+ * Called repeatedly as the camera continues to move after an onCameraMoveStarted call.
+ * This may be called as often as once every frame and should not perform expensive operations.
+ */
+ void onCameraMove();
+ }
+
+ /**
+ * Interface definition for a callback to be invoked for when the camera's motion has been stopped or when the camera
+ * starts moving for a new reason.
+ */
+ public interface OnCameraMoveCanceledListener {
+ /**
+ * Called when the developer explicitly calls the cancelTransitions() method or if the reason for camera motion has
+ * changed before the onCameraIdle had a chance to fire after the previous animation.
+ * Do not update or animate the camera from within this method.
+ */
+ void onCameraMoveCanceled();
+ }
+
+ /**
+ * Interface definition for a callback to be invoked for when camera movement has ended.
+ */
+ public interface OnCameraIdleListener {
+ /**
+ * Called when camera movement has ended.
+ */
+ void onCameraIdle();
+ }
+
/**
* Interface definition for a callback to be invoked when a frame is rendered to the map view.
*
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
index 8fcfdd6db0..68603ab1a3 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
@@ -35,10 +35,8 @@ import java.util.Arrays;
*/
public class MapboxMapOptions implements Parcelable {
- private static final float DIMENSION_SEVEN_DP = 7f;
- private static final float DIMENSION_TEN_DP = 10f;
- private static final float DIMENSION_SIXTEEN_DP = 16f;
- private static final float DIMENSION_SEVENTY_SIX_DP = 76f;
+ private static final float FOUR_DP = 4f;
+ private static final float EIGHTY_NINE_DP = 92f;
private CameraPosition cameraPosition;
@@ -206,13 +204,13 @@ public class MapboxMapOptions implements Parcelable {
Gravity.TOP | Gravity.END));
mapboxMapOptions.compassMargins(new int[] {
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginLeft,
- DIMENSION_TEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
((int) typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginTop,
- DIMENSION_TEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
((int) typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginRight,
- DIMENSION_TEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
((int) typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginBottom,
- DIMENSION_TEN_DP * pxlRatio))});
+ FOUR_DP * pxlRatio))});
mapboxMapOptions.compassFadesWhenFacingNorth(typedArray.getBoolean(
R.styleable.mapbox_MapView_mapbox_uiCompassFadeFacingNorth, true));
Drawable compassDrawable = typedArray.getDrawable(
@@ -227,13 +225,13 @@ public class MapboxMapOptions implements Parcelable {
Gravity.BOTTOM | Gravity.START));
mapboxMapOptions.logoMargins(new int[] {
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginLeft,
- DIMENSION_SIXTEEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginTop,
- DIMENSION_SIXTEEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginRight,
- DIMENSION_SIXTEEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginBottom,
- DIMENSION_SIXTEEN_DP * pxlRatio))});
+ FOUR_DP * pxlRatio))});
mapboxMapOptions.attributionTintColor(typedArray.getColor(
R.styleable.mapbox_MapView_mapbox_uiAttributionTintColor, -1));
@@ -243,13 +241,13 @@ public class MapboxMapOptions implements Parcelable {
R.styleable.mapbox_MapView_mapbox_uiAttributionGravity, Gravity.BOTTOM));
mapboxMapOptions.attributionMargins(new int[] {
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginLeft,
- DIMENSION_SEVENTY_SIX_DP) * pxlRatio),
+ EIGHTY_NINE_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginTop,
- DIMENSION_SEVEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginRight,
- DIMENSION_SEVEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginBottom,
- DIMENSION_SEVEN_DP * pxlRatio))});
+ FOUR_DP * pxlRatio))});
mapboxMapOptions.locationEnabled(typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_myLocation, false));
mapboxMapOptions.myLocationForegroundTintColor(
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 e101340111..af44a08a81 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
@@ -16,6 +16,7 @@ import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.maps.MapView.REGION_DID_CHANGE_ANIMATED;
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener;
/**
* Resembles the current Map transformation.
@@ -33,13 +34,18 @@ final class Transform implements MapView.OnMapChangedListener {
private CameraPosition cameraPosition;
private MapboxMap.CancelableCallback cameraCancelableCallback;
+
private MapboxMap.OnCameraChangeListener onCameraChangeListener;
- Transform(NativeMapView mapView, MarkerViewManager markerViewManager, TrackingSettings trackingSettings) {
+ private CameraChangeDispatcher cameraChangeDispatcher;
+
+ Transform(NativeMapView mapView, MarkerViewManager markerViewManager, TrackingSettings trackingSettings,
+ CameraChangeDispatcher cameraChangeDispatcher) {
this.mapView = mapView;
this.markerViewManager = markerViewManager;
this.trackingSettings = trackingSettings;
this.myLocationView = trackingSettings.getMyLocationView();
+ this.cameraChangeDispatcher = cameraChangeDispatcher;
}
void initialise(@NonNull MapboxMap mapboxMap, @NonNull MapboxMapOptions options) {
@@ -79,6 +85,7 @@ final class Transform implements MapView.OnMapChangedListener {
cameraCancelableCallback.onFinish();
cameraCancelableCallback = null;
}
+ cameraChangeDispatcher.onCameraIdle();
mapView.removeOnMapChangedListener(this);
}
}
@@ -89,10 +96,12 @@ final class Transform implements MapView.OnMapChangedListener {
if (!cameraPosition.equals(this.cameraPosition)) {
trackingSettings.resetTrackingModesIfRequired(cameraPosition);
cancelTransitions();
+ cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
mapView.jumpTo(cameraPosition.bearing, cameraPosition.target, cameraPosition.tilt, cameraPosition.zoom);
if (callback != null) {
callback.onFinish();
}
+ cameraChangeDispatcher.onCameraIdle();
}
}
@@ -103,6 +112,8 @@ final class Transform implements MapView.OnMapChangedListener {
if (!cameraPosition.equals(this.cameraPosition)) {
trackingSettings.resetTrackingModesIfRequired(cameraPosition);
cancelTransitions();
+ cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
+
if (callback != null) {
cameraCancelableCallback = callback;
mapView.addOnMapChangedListener(this);
@@ -119,8 +130,9 @@ final class Transform implements MapView.OnMapChangedListener {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (!cameraPosition.equals(this.cameraPosition)) {
trackingSettings.resetTrackingModesIfRequired(cameraPosition);
-
cancelTransitions();
+ cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
+
if (callback != null) {
cameraCancelableCallback = callback;
mapView.addOnMapChangedListener(this);
@@ -135,7 +147,12 @@ final class Transform implements MapView.OnMapChangedListener {
@Nullable
CameraPosition invalidateCameraPosition() {
if (mapView != null) {
- cameraPosition = mapView.getCameraPosition();
+ CameraPosition cameraPosition = mapView.getCameraPosition();
+ if (this.cameraPosition != null && !this.cameraPosition.equals(cameraPosition)) {
+ cameraChangeDispatcher.onCameraMove();
+ }
+
+ this.cameraPosition = cameraPosition;
if (onCameraChangeListener != null) {
onCameraChangeListener.onCameraChange(this.cameraPosition);
}
@@ -144,10 +161,17 @@ final class Transform implements MapView.OnMapChangedListener {
}
void cancelTransitions() {
+ // notify user about cancel
+ cameraChangeDispatcher.onCameraMoveCanceled();
+
+ // notify animateCamera and easeCamera about cancelling
if (cameraCancelableCallback != null) {
+ cameraChangeDispatcher.onCameraIdle();
cameraCancelableCallback.onCancel();
cameraCancelableCallback = null;
}
+
+ // cancel ongoing transitions
mapView.cancelTransitions();
}
@@ -157,6 +181,10 @@ final class Transform implements MapView.OnMapChangedListener {
mapView.resetNorth();
}
+ //
+ // Camera change listener API
+ //
+
void setOnCameraChangeListener(@Nullable MapboxMap.OnCameraChangeListener listener) {
this.onCameraChangeListener = listener;
}
@@ -172,9 +200,6 @@ final class Transform implements MapView.OnMapChangedListener {
}
void zoom(boolean zoomIn, @NonNull PointF focalPoint) {
- // Cancel any animation
- cancelTransitions();
-
CameraPosition cameraPosition = invalidateCameraPosition();
if (cameraPosition != null) {
int newZoom = (int) Math.round(cameraPosition.zoom + (zoomIn ? 1 : -1));
@@ -187,6 +212,15 @@ final class Transform implements MapView.OnMapChangedListener {
}
void setZoom(double zoom, @NonNull PointF focalPoint, long duration) {
+ mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
+ @Override
+ public void onMapChanged(int change) {
+ if (change == MapView.REGION_DID_CHANGE_ANIMATED) {
+ mapView.removeOnMapChangedListener(this);
+ cameraChangeDispatcher.onCameraIdle();
+ }
+ }
+ });
mapView.setZoom(zoom, focalPoint, duration);
}
@@ -278,6 +312,17 @@ final class Transform implements MapView.OnMapChangedListener {
}
void moveBy(double offsetX, double offsetY, long duration) {
+ if (duration > 0) {
+ mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
+ @Override
+ public void onMapChanged(int change) {
+ if (change == MapView.DID_FINISH_RENDERING_MAP_FULLY_RENDERED) {
+ mapView.removeOnMapChangedListener(this);
+ cameraChangeDispatcher.onCameraIdle();
+ }
+ }
+ });
+ }
mapView.moveBy(offsetX, offsetY, duration);
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
index 354a42536a..1bcf8a70b9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
@@ -146,7 +146,7 @@ public final class UiSettings {
if (compassMargins != null) {
setCompassMargins(compassMargins[0], compassMargins[1], compassMargins[2], compassMargins[3]);
} else {
- int tenDp = (int) resources.getDimension(R.dimen.mapbox_ten_dp);
+ int tenDp = (int) resources.getDimension(R.dimen.mapbox_four_dp);
setCompassMargins(tenDp, tenDp, tenDp, tenDp);
}
setCompassFadeFacingNorth(options.getCompassFadeFacingNorth());
@@ -171,9 +171,7 @@ public final class UiSettings {
private byte[] convert(Bitmap resource) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
resource.compress(Bitmap.CompressFormat.PNG, 100, stream);
- byte[] byteArray = stream.toByteArray();
-
- return byteArray;
+ return stream.toByteArray();
}
private void restoreCompass(Bundle savedInstanceState) {
@@ -189,10 +187,7 @@ public final class UiSettings {
private Drawable decode(byte[] bitmap) {
Bitmap compass = BitmapFactory.decodeByteArray(bitmap, 0, bitmap.length);
-
- Drawable compassImage = new BitmapDrawable(compassView.getResources(), compass);
-
- return compassImage;
+ return new BitmapDrawable(compassView.getResources(), compass);
}
private void initialiseLogo(MapboxMapOptions options, Resources resources) {
@@ -202,8 +197,8 @@ public final class UiSettings {
if (logoMargins != null) {
setLogoMargins(logoMargins[0], logoMargins[1], logoMargins[2], logoMargins[3]);
} else {
- int sixteenDp = (int) resources.getDimension(R.dimen.mapbox_sixteen_dp);
- setLogoMargins(sixteenDp, sixteenDp, sixteenDp, sixteenDp);
+ int twoDp = (int) resources.getDimension(R.dimen.mapbox_two_dp);
+ setLogoMargins(twoDp, twoDp, twoDp, twoDp);
}
}
@@ -226,16 +221,12 @@ public final class UiSettings {
}
private void initialiseAttribution(Context context, MapboxMapOptions options) {
- Resources resources = context.getResources();
setAttributionEnabled(options.getAttributionEnabled());
setAttributionGravity(options.getAttributionGravity());
int[] attributionMargins = options.getAttributionMargins();
if (attributionMargins != null) {
- setAttributionMargins(attributionMargins[0], attributionMargins[1], attributionMargins[2], attributionMargins[3]);
- } else {
- int sevenDp = (int) resources.getDimension(R.dimen.mapbox_seven_dp);
- int seventySixDp = (int) resources.getDimension(R.dimen.mapbox_seventy_six_dp);
- setAttributionMargins(seventySixDp, sevenDp, sevenDp, sevenDp);
+ setAttributionMargins(attributionMargins[0], attributionMargins[1],
+ attributionMargins[2], attributionMargins[3]);
}
int attributionTintColor = options.getAttributionTintColor();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
index ec80186761..10ecb945ad 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
@@ -227,6 +227,14 @@ public class GeoJsonSource extends Source {
nativeSetUrl(url);
}
+ /**
+ * @return The url or null
+ */
+ @Nullable
+ public String getUrl() {
+ return nativeGetUrl();
+ }
+
/**
* Queries the source for features.
*
@@ -243,6 +251,8 @@ public class GeoJsonSource extends Source {
protected native void nativeSetUrl(String url);
+ protected native String nativeGetUrl();
+
private native void nativeSetGeoJsonString(String geoJson);
private native void nativeSetFeatureCollection(FeatureCollection geoJson);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java
index 98b74afcff..38ed208618 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java
@@ -1,5 +1,7 @@
package com.mapbox.mapboxsdk.style.sources;
+import android.support.annotation.Nullable;
+
import java.net.URL;
/**
@@ -72,8 +74,19 @@ public class RasterSource extends Source {
initialize(id, tileSet.toValueObject(), tileSize);
}
+ /**
+ * @return The url or null
+ */
+ @Nullable
+ public String getUrl() {
+ return nativeGetUrl();
+ }
+
protected native void initialize(String layerId, Object payload, int tileSize);
@Override
protected native void finalize() throws Throwable;
+
+ protected native String nativeGetUrl();
+
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java
index 7230492d0e..9b59cf8967 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java
@@ -76,11 +76,21 @@ public class VectorSource extends Source {
return features != null ? Arrays.asList(features) : new ArrayList();
}
+ /**
+ * @return The url or null
+ */
+ @Nullable
+ public String getUrl() {
+ return nativeGetUrl();
+ }
+
protected native void initialize(String layerId, Object payload);
@Override
protected native void finalize() throws Throwable;
+ protected native String nativeGetUrl();
+
private native Feature[] querySourceFeatures(String[] sourceLayerId,
Object[] filter);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/mapbox_logo_icon.png b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/mapbox_logo_icon.png
index c0f4ed2c4c..7568387a8d 100644
Binary files a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/mapbox_logo_icon.png and b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/mapbox_logo_icon.png differ
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/mapbox_logo_icon.png b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/mapbox_logo_icon.png
index 5a9da3fe39..9cdec5151c 100644
Binary files a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/mapbox_logo_icon.png and b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/mapbox_logo_icon.png differ
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/mapbox_logo_icon.png b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/mapbox_logo_icon.png
index 194aa64da2..7eec45f4b1 100644
Binary files a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/mapbox_logo_icon.png and b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/mapbox_logo_icon.png differ
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapbox_logo_icon.png b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapbox_logo_icon.png
index d1260a16f3..5876056f1c 100644
Binary files a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapbox_logo_icon.png and b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapbox_logo_icon.png differ
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/mapbox_logo_icon.png b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/mapbox_logo_icon.png
index 5f9647610a..e5780ccc07 100644
Binary files a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/mapbox_logo_icon.png and b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/mapbox_logo_icon.png differ
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_default.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_default.xml
index fa82bb8d9b..65837d65d0 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_default.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_default.xml
@@ -1,8 +1,8 @@
+ android:width="21dp"
+ android:height="21dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_selected.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_selected.xml
index 074928d05a..ccbd1d8d39 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_selected.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_selected.xml
@@ -1,9 +1,9 @@
+ android:width="21dp"
+ android:height="21dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
+ android:pathData="M11,17h2v-6h-2v6zm1,-15C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm0,18c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2V7h-2v2z"/>
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml
index e6a2677785..6d07de7baa 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
@@ -39,10 +39,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
- android:background="@drawable/mapbox_default_bg_selector"
android:clickable="true"
+ android:focusable="true"
android:contentDescription="@string/mapbox_attributionsIconContentDescription"
- android:padding="7dp"
android:src="@drawable/mapbox_info_bg_selector"/>
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_preview.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_preview.xml
index d015bc5785..1c1ab0e71b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_preview.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_preview.xml
@@ -1,22 +1,29 @@
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+ android:contentDescription="@null"
+ android:src="@drawable/mapbox_mapview_preview"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"/>
@@ -24,18 +31,22 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:layout_marginBottom="@dimen/mapbox_seven_dp"
- android:layout_marginLeft="@dimen/mapbox_seventy_six_dp"
+ android:layout_toEndOf="@+id/logoView"
+ android:contentDescription="@null"
+ android:layout_marginBottom="@dimen/mapbox_four_dp"
android:background="@drawable/mapbox_default_bg_selector"
- android:clickable="true"
- android:contentDescription="@string/mapbox_attributionsIconContentDescription"
- android:src="@drawable/mapbox_info_bg_selector" />
+ android:src="@drawable/mapbox_info_bg_selector"
+ android:layout_marginLeft="@dimen/mapbox_four_dp"
+ android:layout_marginStart="@dimen/mapbox_four_dp"
+ android:layout_toRightOf="@+id/logoView"/>
+ android:contentDescription="@null"
+ android:src="@drawable/mapbox_compass_icon"/>
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml
index df6983e11d..ce20cb9a8b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml
@@ -4,10 +4,15 @@
8dp
-2dp
1.5dp
- 7dp
+ @dimen/mapbox_two_dp
+ @dimen/mapbox_two_dp
+ @dimen/mapbox_two_dp
+ @dimen/mapbox_two_dp
+ 2dp
+ 4dp
8dp
10dp
16dp
- 76dp
+ 95dp
18dp
--
cgit v1.2.1
From 59442167b16ec5b92c29aad4670340b740a0a9e4 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Mon, 15 May 2017 13:39:34 +0200
Subject: [android] - MarkerView deselect events with OnMarkerViewClickListener
integration (#8996)
---
.../java/com/mapbox/mapboxsdk/maps/AnnotationManager.java | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 6553b64592..e811470d64 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
@@ -670,12 +670,15 @@ class AnnotationManager {
for (Marker nearbyMarker : nearbyMarkers) {
for (Marker selectedMarker : selectedMarkers) {
if (nearbyMarker.equals(selectedMarker)) {
- if (onMarkerClickListener != null) {
- // end developer has provided a custom click listener
+ if (nearbyMarker instanceof MarkerView) {
+ handledDefaultClick = markerViewManager.onClickMarkerView((MarkerView) nearbyMarker);
+ } else if (onMarkerClickListener != null) {
handledDefaultClick = onMarkerClickListener.onMarkerClick(nearbyMarker);
- if (!handledDefaultClick) {
- deselectMarker(nearbyMarker);
- }
+ }
+
+ if (!handledDefaultClick) {
+ // only deselect marker if user didn't handle the click event themselves
+ deselectMarker(nearbyMarker);
}
return true;
}
--
cgit v1.2.1
From eb83c7250933b7d3705a3508976c69571a9b9d4c Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 19 May 2017 09:14:54 +0200
Subject: [android] - bump tools and support lib version due to SNAPSHOT
dependencies (#9046)
* [android] - bump tools and support lib version for SNAPSHOT dependencies
* revert unsupported Circle CI build tools version
---
platform/android/MapboxGLAndroidSDK/build.gradle | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle
index fca36237c3..5e19e94f5d 100644
--- a/platform/android/MapboxGLAndroidSDK/build.gradle
+++ b/platform/android/MapboxGLAndroidSDK/build.gradle
@@ -6,9 +6,7 @@ dependencies {
compile rootProject.ext.dep.supportDesign
compile rootProject.ext.dep.timber
compile rootProject.ext.dep.okhttp3
- compile(rootProject.ext.dep.lost) {
- exclude module: 'support-compat'
- }
+ compile rootProject.ext.dep.lost
// Mapbox Android Services (GeoJSON support)
compile(rootProject.ext.dep.mapboxJavaGeoJSON) {
--
cgit v1.2.1
From f4f587f46dbde355bebd70e57cacf2ad788d0fd9 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 19 May 2017 12:23:47 +0200
Subject: [android] - remove marker from selected markers when removing marker
from annotation manager. (#9047)
---
.../main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java | 9 +++++++++
1 file changed, 9 insertions(+)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 e811470d64..3694668a7e 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
@@ -92,6 +92,10 @@ class AnnotationManager {
if (annotation instanceof Marker) {
Marker marker = (Marker) annotation;
marker.hideInfoWindow();
+ if (selectedMarkers.contains(marker)) {
+ selectedMarkers.remove(marker);
+ }
+
if (marker instanceof MarkerView) {
markerViewManager.removeMarkerView((MarkerView) marker);
}
@@ -118,6 +122,10 @@ class AnnotationManager {
if (annotation instanceof Marker) {
Marker marker = (Marker) annotation;
marker.hideInfoWindow();
+ if (selectedMarkers.contains(marker)) {
+ selectedMarkers.remove(marker);
+ }
+
if (marker instanceof MarkerView) {
markerViewManager.removeMarkerView((MarkerView) marker);
}
@@ -138,6 +146,7 @@ class AnnotationManager {
Annotation annotation;
int count = annotations.size();
long[] ids = new long[count];
+ selectedMarkers.clear();
for (int i = 0; i < count; i++) {
ids[i] = annotations.keyAt(i);
annotation = annotations.get(ids[i]);
--
cgit v1.2.1
From 3c35bf1d170d1b331d871f75ad031834d99d2e78 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Wed, 24 May 2017 14:47:31 +0200
Subject: [android] - stop location updates when toggle MyLocationView state
(#9099)
---
.../src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java | 1 +
1 file changed, 1 insertion(+)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
index aecf3cc655..338d29c87c 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
@@ -440,6 +440,7 @@ public class MyLocationView extends View {
} else {
// Disable location and user dot
location = null;
+ locationSource.removeLocationUpdates();
locationSource.removeLocationEngineListener(userLocationListener);
locationSource.deactivate();
}
--
cgit v1.2.1
From c392c678ab4ea560cefca59d14b215e2d4c79ecb Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 26 May 2017 10:32:11 +0200
Subject: [android] - logo placement for creating a Mapview programatically
(#9094)
* [android] - Correct logo placement for creating a Mapview programatically, fixup non default placements
* Fixed NIGHTY_TWO_DP typo to NINETY_TWO_DP
---
.../mapbox/mapboxsdk/maps/MapboxMapOptions.java | 4 ++--
.../java/com/mapbox/mapboxsdk/maps/UiSettings.java | 28 +++++++++++++++-------
.../src/main/res/values/dimens.xml | 2 +-
3 files changed, 23 insertions(+), 11 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
index 68603ab1a3..98f94ddb39 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
@@ -36,7 +36,7 @@ import java.util.Arrays;
public class MapboxMapOptions implements Parcelable {
private static final float FOUR_DP = 4f;
- private static final float EIGHTY_NINE_DP = 92f;
+ private static final float NINETY_TWO_DP = 92f;
private CameraPosition cameraPosition;
@@ -241,7 +241,7 @@ public class MapboxMapOptions implements Parcelable {
R.styleable.mapbox_MapView_mapbox_uiAttributionGravity, Gravity.BOTTOM));
mapboxMapOptions.attributionMargins(new int[] {
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginLeft,
- EIGHTY_NINE_DP * pxlRatio)),
+ NINETY_TWO_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginTop,
FOUR_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginRight,
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
index 1bcf8a70b9..accecf232b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
@@ -193,12 +193,16 @@ public final class UiSettings {
private void initialiseLogo(MapboxMapOptions options, Resources resources) {
setLogoEnabled(options.getLogoEnabled());
setLogoGravity(options.getLogoGravity());
- int[] logoMargins = options.getLogoMargins();
+ setLogoMargins(resources, options.getLogoMargins());
+ }
+
+ private void setLogoMargins(Resources resources, int[]logoMargins) {
if (logoMargins != null) {
setLogoMargins(logoMargins[0], logoMargins[1], logoMargins[2], logoMargins[3]);
} else {
- int twoDp = (int) resources.getDimension(R.dimen.mapbox_two_dp);
- setLogoMargins(twoDp, twoDp, twoDp, twoDp);
+ // user did not specify margins when programmatically creating a map
+ int fourDp = (int) resources.getDimension(R.dimen.mapbox_four_dp);
+ setLogoMargins(fourDp, fourDp, fourDp, fourDp);
}
}
@@ -223,15 +227,23 @@ public final class UiSettings {
private void initialiseAttribution(Context context, MapboxMapOptions options) {
setAttributionEnabled(options.getAttributionEnabled());
setAttributionGravity(options.getAttributionGravity());
- int[] attributionMargins = options.getAttributionMargins();
+ setAttributionMargins(context, options.getAttributionMargins());
+ int attributionTintColor = options.getAttributionTintColor();
+ setAttributionTintColor(attributionTintColor != -1
+ ? attributionTintColor : ColorUtils.getPrimaryColor(context));
+ }
+
+ private void setAttributionMargins(Context context, int[] attributionMargins) {
if (attributionMargins != null) {
setAttributionMargins(attributionMargins[0], attributionMargins[1],
attributionMargins[2], attributionMargins[3]);
+ } else {
+ // user did not specify margins when programmatically creating a map
+ Resources resources = context.getResources();
+ int margin = (int) resources.getDimension(R.dimen.mapbox_four_dp);
+ int leftMargin = (int) resources.getDimension(R.dimen.mapbox_ninety_two_dp);
+ setAttributionMargins(leftMargin, margin, margin, margin);
}
-
- int attributionTintColor = options.getAttributionTintColor();
- setAttributionTintColor(attributionTintColor != -1
- ? attributionTintColor : ColorUtils.getPrimaryColor(context));
}
private void saveAttribution(Bundle outState) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml
index ce20cb9a8b..8edbd47c29 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml
@@ -13,6 +13,6 @@
8dp
10dp
16dp
- 95dp
+ 92dp
18dp
--
cgit v1.2.1
From 5716bd3aecc777813161292e104ac9ceba3f230a Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 26 May 2017 16:04:09 +0200
Subject: [android] - add binding support for Light (#9013)
---
.../MapboxGLAndroidSDK/gradle-checkstyle.gradle | 1 +
.../java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 15 ++
.../com/mapbox/mapboxsdk/maps/NativeMapView.java | 10 ++
.../mapbox/mapboxsdk/style/layers/Property.java | 21 +++
.../com/mapbox/mapboxsdk/style/light/Light.java | 181 +++++++++++++++++++++
.../com/mapbox/mapboxsdk/style/light/Position.java | 81 +++++++++
.../mapbox/mapboxsdk/style/light/light.java.ejs | 121 ++++++++++++++
7 files changed, 430 insertions(+)
create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java
create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java
create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/gradle-checkstyle.gradle b/platform/android/MapboxGLAndroidSDK/gradle-checkstyle.gradle
index 05037c6be7..e0bc076d3d 100644
--- a/platform/android/MapboxGLAndroidSDK/gradle-checkstyle.gradle
+++ b/platform/android/MapboxGLAndroidSDK/gradle-checkstyle.gradle
@@ -15,6 +15,7 @@ task checkstyle(type: Checkstyle) {
exclude '**/style/layers/Property.java'
exclude '**/style/layers/PropertyFactory.java'
exclude '**/style/layers/*Layer.java'
+ exclude '**/style/light/Light.java'
classpath = files()
ignoreFailures = false
}
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 96603355f1..0bfa74d1c0 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
@@ -41,6 +41,7 @@ import com.mapbox.mapboxsdk.location.LocationSource;
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.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.commons.geojson.Feature;
@@ -567,6 +568,20 @@ public final class MapboxMap {
return projection;
}
+ //
+ //
+ //
+
+ /**
+ * Get the global light source used to change lighting conditions on extruded fill layers.
+ *
+ * @return the global light source
+ */
+ @Nullable
+ public Light getLight() {
+ return nativeMapView.getLight();
+ }
+
//
// Camera API
//
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
index cf8faa9012..008a1971cc 100755
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
@@ -26,6 +26,7 @@ import com.mapbox.mapboxsdk.storage.FileSource;
import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException;
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.CannotAddSourceException;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.services.commons.geojson.Feature;
@@ -885,6 +886,13 @@ final class NativeMapView {
fileSource.setApiBaseUrl(baseUrl);
}
+ public Light getLight() {
+ if (isDestroyedOn("getLight")) {
+ return null;
+ }
+ return nativeGetLight();
+ }
+
public float getPixelRatio() {
return pixelRatio;
}
@@ -1120,6 +1128,8 @@ final class NativeMapView {
String[] layerIds,
Object[] filter);
+ private native Light nativeGetLight();
+
int getWidth() {
if (isDestroyedOn("")) {
return 0;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
index 48e0ec5de3..5e345268f9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Property.java
@@ -467,6 +467,27 @@ public final class Property {
@Retention(RetentionPolicy.SOURCE)
public @interface FILL_EXTRUSION_TRANSLATE_ANCHOR {}
+ // ANCHOR: Whether extruded geometries are lit relative to the map or viewport.
+
+ /**
+ * The position of the light source is aligned to the rotation of the map.
+ */
+ public static final String ANCHOR_MAP = "map";
+ /**
+ * The position of the light source is aligned to the rotation of the viewport.
+ */
+ public static final String ANCHOR_VIEWPORT = "viewport";
+
+ /**
+ * Whether extruded geometries are lit relative to the map or viewport.
+ */
+ @StringDef({
+ ANCHOR_MAP,
+ ANCHOR_VIEWPORT,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface ANCHOR {}
+
private Property() {
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java
new file mode 100644
index 0000000000..b66a50b8a4
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java
@@ -0,0 +1,181 @@
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
+
+package com.mapbox.mapboxsdk.style.light;
+
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+import android.support.annotation.UiThread;
+
+import com.mapbox.mapboxsdk.style.layers.Property;
+import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
+import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
+
+/**
+ * The global light source.
+ *
+ * @see The online documentation
+ */
+@UiThread
+public class Light {
+
+ private long nativePtr;
+
+ /**
+ * Creates a Light.
+ *
+ * @param nativePtr pointer used by core
+ */
+ public Light(long nativePtr) {
+ this.nativePtr = nativePtr;
+ }
+
+ /**
+ * Set the Anchor property. Whether extruded geometries are lit relative to the map or viewport.
+ *
+ * @param anchor as String
+ */
+ public void setAnchor(@Property.ANCHOR String anchor) {
+ nativeSetAnchor(anchor);
+ }
+
+ /**
+ * Get the Anchor property. Whether extruded geometries are lit relative to the map or viewport.
+ *
+ * @return anchor as String
+ */
+ @Property.ANCHOR public String getAnchor() {
+ return nativeGetAnchor();
+ }
+
+ /**
+ * Set the Position property. Position of the light source relative to lit (extruded) geometries, in [r radial coordinate, a azimuthal angle, p polar angle] where r indicates the distance from the center of the base of an object to its light, a indicates the position of the light relative to 0° (0° when `light.anchor` is set to `viewport` corresponds to the top of the viewport, or 0° when `light.anchor` is set to `map` corresponds to due north, and degrees proceed clockwise), and p indicates the height of the light (from 0°, directly above, to 180°, directly below).
+ *
+ * @param position of the light
+ */
+ public void setPosition(@NonNull Position position) {
+ nativeSetPosition(position);
+ }
+
+ /**
+ * Get the Position property. Position of the light source relative to lit (extruded) geometries, in [r radial coordinate, a azimuthal angle, p polar angle] where r indicates the distance from the center of the base of an object to its light, a indicates the position of the light relative to 0° (0° when `light.anchor` is set to `viewport` corresponds to the top of the viewport, or 0° when `light.anchor` is set to `map` corresponds to due north, and degrees proceed clockwise), and p indicates the height of the light (from 0°, directly above, to 180°, directly below).
+ *
+ * @return position as Position
+ */
+ public Position getPosition() {
+ return nativeGetPosition();
+ }
+
+ /**
+ * Get the Position property transition options.
+ *
+ * @return transition options for position
+ */
+ public TransitionOptions getPositionTransition() {
+ return nativeGetPositionTransition();
+ }
+
+ /**
+ * Set the Position property transition options.
+ *
+ * @param options transition options for position
+ */
+ public void setPositionTransition(TransitionOptions options) {
+ nativeSetPositionTransition(options.getDuration(), options.getDelay());
+ }
+
+ /**
+ * Set the Color property. Color tint for lighting extruded geometries.
+ *
+ * @param color as int
+ */
+ public void setColor(@ColorInt int color) {
+ nativeSetColor(PropertyFactory.colorToRgbaString(color));
+ }
+
+ /**
+ * Set the Color property. Color tint for lighting extruded geometries.
+ *
+ * @param color as String
+ */
+ public void setColor(String color) {
+ nativeSetColor(color);
+ }
+
+ /**
+ * Get the Color property. Color tint for lighting extruded geometries.
+ *
+ * @return color as String
+ */
+ public String getColor() {
+ return nativeGetColor();
+ }
+
+ /**
+ * Get the Color property transition options.
+ *
+ * @return transition options for color
+ */
+ public TransitionOptions getColorTransition() {
+ return nativeGetColorTransition();
+ }
+
+ /**
+ * Set the Color property transition options.
+ *
+ * @param options transition options for color
+ */
+ public void setColorTransition(TransitionOptions options) {
+ nativeSetColorTransition(options.getDuration(), options.getDelay());
+ }
+
+ /**
+ * Set the Intensity property. Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as more extreme contrast.
+ *
+ * @param intensity as Float
+ */
+ public void setIntensity(float intensity) {
+ nativeSetIntensity(intensity);
+ }
+
+ /**
+ * Get the Intensity property. Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as more extreme contrast.
+ *
+ * @return intensity as Float
+ */
+ public float getIntensity() {
+ return nativeGetIntensity();
+ }
+
+ /**
+ * Get the Intensity property transition options.
+ *
+ * @return transition options for intensity
+ */
+ public TransitionOptions getIntensityTransition() {
+ return nativeGetIntensityTransition();
+ }
+
+ /**
+ * Set the Intensity property transition options.
+ *
+ * @param options transition options for intensity
+ */
+ public void setIntensityTransition(TransitionOptions options) {
+ nativeSetIntensityTransition(options.getDuration(), options.getDelay());
+ }
+
+ private native void nativeSetAnchor(String anchor);
+ private native String nativeGetAnchor();
+ private native void nativeSetPosition(Position position);
+ private native Position nativeGetPosition();
+ private native TransitionOptions nativeGetPositionTransition();
+ private native void nativeSetPositionTransition(long duration, long delay);
+ private native void nativeSetColor(String color);
+ private native String nativeGetColor();
+ private native TransitionOptions nativeGetColorTransition();
+ private native void nativeSetColorTransition(long duration, long delay);
+ private native void nativeSetIntensity(float intensity);
+ private native float nativeGetIntensity();
+ private native TransitionOptions nativeGetIntensityTransition();
+ private native void nativeSetIntensityTransition(long duration, long delay);
+}
\ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java
new file mode 100644
index 0000000000..215db03ad2
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java
@@ -0,0 +1,81 @@
+package com.mapbox.mapboxsdk.style.light;
+
+/**
+ * Position of the light source relative to lit (extruded) geometries.
+ *
+ * The position is constructed out of a radial coordinate, an azimuthal angle and a polar angle.
+ * where the radial coordinate indicates the distance from the center of the base of an object to its light, the
+ * azimuthal angle indicates the position of the light relative to 0° (0° when
+ * {@link com.mapbox.mapboxsdk.style.layers.Property.ANCHOR} is set to viewport corresponds to the top of the
+ * viewport, or 0° when {@link com.mapbox.mapboxsdk.style.layers.Property.ANCHOR} is set to map corresponds to due
+ * north, and degrees proceed clockwise), and polar indicates the height of the light
+ * (from 0°, directly above, to 180°, directly below).
+ */
+public class Position {
+
+ private float radialCoordinate;
+ private float azimuthalAngle;
+ private float polarAngle;
+
+ /**
+ * Creates a Position from a radial coordinate, an azimuthal angle & a polar angle.
+ *
+ * @param radialCoordinate the distance from the center of the base of an object to its light
+ * @param azimuthalAngle the position of the light relative to 0°
+ * @param polarAngle the height of the light
+ */
+ public Position(float radialCoordinate, float azimuthalAngle, float polarAngle) {
+ this.radialCoordinate = radialCoordinate;
+ this.azimuthalAngle = azimuthalAngle;
+ this.polarAngle = polarAngle;
+ }
+
+ /**
+ * Returns a Position from a radial coordinate, an azimuthal angle & a polar angle
+ *
+ * @param radialCoordinate the radial coordinate
+ * @param azimuthalAngle the azimuthal angle
+ * @param polarAngle the polar angle
+ * @return the created Position object
+ */
+ public static Position fromPosition(float radialCoordinate, float azimuthalAngle, float polarAngle) {
+ return new Position(radialCoordinate, azimuthalAngle, polarAngle);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ Position position = (Position) o;
+
+ if (Float.compare(position.radialCoordinate, radialCoordinate) != 0) {
+ return false;
+ }
+ if (Float.compare(position.azimuthalAngle, azimuthalAngle) != 0) {
+ return false;
+ }
+ return Float.compare(position.polarAngle, polarAngle) == 0;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (radialCoordinate != +0.0f ? Float.floatToIntBits(radialCoordinate) : 0);
+ result = 31 * result + (azimuthalAngle != +0.0f ? Float.floatToIntBits(azimuthalAngle) : 0);
+ result = 31 * result + (polarAngle != +0.0f ? Float.floatToIntBits(polarAngle) : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "Position{"
+ + "radialCoordinate=" + radialCoordinate
+ + ", azimuthalAngle=" + azimuthalAngle
+ + ", polarAngle=" + polarAngle
+ + '}';
+ }
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs
new file mode 100644
index 0000000000..067efe1092
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs
@@ -0,0 +1,121 @@
+<%
+ const properties = locals.properties;
+ const doc = locals.doc;
+-%>
+// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
+
+package com.mapbox.mapboxsdk.style.light;
+
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+import android.support.annotation.UiThread;
+
+import com.mapbox.mapboxsdk.style.layers.Property;
+import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
+import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
+
+/**
+ * The global light source.
+ *
+ * @see The online documentation
+ */
+@UiThread
+public class Light {
+
+ private long nativePtr;
+
+ /**
+ * Creates a Light.
+ *
+ * @param nativePtr pointer used by core
+ */
+ public Light(long nativePtr) {
+ this.nativePtr = nativePtr;
+ }
+<% for (const property of properties) { -%>
+<% if (property.name == "position") {-%>
+
+ /**
+ * Set the <%- camelize(property.name) %> property. <%- property.doc %>
+ *
+ * @param position of the light
+ */
+ public void set<%- camelize(property.name) %>(@NonNull Position position) {
+ nativeSet<%- camelize(property.name) %>(position);
+ }
+
+ /**
+ * Get the <%- camelize(property.name) %> property. <%- property.doc %>
+ *
+ * @return <%- property.name %> as Position
+ */
+ public Position get<%- camelize(property.name) %>() {
+ return nativeGet<%- camelize(property.name) %>();
+ }
+<% } else { -%>
+<% if (property.name == "color") {-%>
+
+ /**
+ * Set the <%- camelize(property.name) %> property. <%- property.doc %>
+ *
+ * @param <%- property.name %> as int
+ */
+ public void set<%- camelize(property.name) %>(@ColorInt int <%- property.name %>) {
+ nativeSet<%- camelize(property.name) %>(PropertyFactory.colorToRgbaString(<%- property.name %>));
+ }
+<% } -%>
+
+ /**
+ * Set the <%- camelize(property.name) %> property. <%- property.doc %>
+ *
+ * @param <%- property.name %> as <%- propertyType(property) %>
+ */
+ public void set<%- camelize(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyJavaType(property) %> <%- property.name %>) {
+ nativeSet<%- camelize(property.name) %>(<%- property.name %>);
+ }
+
+ /**
+ * Get the <%- camelize(property.name) %> property. <%- property.doc %>
+ *
+ * @return <%- property.name %> as <%- propertyType(property) %>
+ */
+ <%- propertyTypeAnnotation(property) %> public <%- propertyJavaType(property) %> get<%- camelize(property.name) %>() {
+ return nativeGet<%- camelize(property.name) %>();
+ }
+<% } -%>
+<% if (property.transition) { -%>
+
+ /**
+ * Get the <%- camelize(property.name) %> property transition options.
+ *
+ * @return transition options for <%- property.name %>
+ */
+ public TransitionOptions get<%- camelize(property.name) %>Transition() {
+ return nativeGet<%- camelize(property.name) %>Transition();
+ }
+
+ /**
+ * Set the <%- camelize(property.name) %> property transition options.
+ *
+ * @param options transition options for <%- property.name %>
+ */
+ public void set<%- camelize(property.name) %>Transition(TransitionOptions options) {
+ nativeSet<%- camelize(property.name) %>Transition(options.getDuration(), options.getDelay());
+ }
+<% } -%>
+<% } -%>
+
+<% for (const property of properties) { -%>
+<% if (property.name == "position") {-%>
+ private native void nativeSet<%- camelize(property.name) %>(Position position);
+ private native Position nativeGet<%- camelize(property.name) %>();
+<% } else { -%>
+ private native void nativeSet<%- camelize(property.name) %>(<%- propertyJavaType(property) -%> <%- property.name %>);
+ private native <%- propertyJavaType(property) -%> nativeGet<%- camelize(property.name) %>();
+<% } -%>
+<% if (property.transition) { -%>
+ private native TransitionOptions nativeGet<%- camelize(property.name) %>Transition();
+ private native void nativeSet<%- camelize(property.name) %>Transition(long duration, long delay);
+<% } -%>
+<% } -%>
+}
\ No newline at end of file
--
cgit v1.2.1
From bc5b147df79425ec03f2fbe6f3a2566ee45b4800 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 26 May 2017 20:01:57 +0200
Subject: [android] - convert dp to pixels when getting meters per pixel at.
(#9048)
---
.../src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
index 008a1971cc..02eeb25f83 100755
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
@@ -621,7 +621,7 @@ final class NativeMapView {
if (isDestroyedOn("getMetersPerPixelAtLatitude")) {
return 0;
}
- return nativeGetMetersPerPixelAtLatitude(lat, getZoom());
+ return nativeGetMetersPerPixelAtLatitude(lat, getZoom()) / pixelRatio;
}
public ProjectedMeters projectedMetersForLatLng(LatLng latLng) {
--
cgit v1.2.1
From fc495dec12a5136f7476aa9d5cb8d76c95024919 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Tue, 30 May 2017 16:56:19 +0200
Subject: [android] - harden orientation changes (#9128)
---
.../com/mapbox/mapboxsdk/annotations/Icon.java | 67 +++++++---
.../mapbox/mapboxsdk/annotations/MarkerView.java | 4 +
.../com/mapbox/mapboxsdk/maps/IconManager.java | 148 ++++++++++-----------
.../com/mapbox/mapboxsdk/maps/NativeMapView.java | 4 -
4 files changed, 125 insertions(+), 98 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java
index b1a05ec436..2ee17c227d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java
@@ -1,15 +1,18 @@
package com.mapbox.mapboxsdk.annotations;
import android.graphics.Bitmap;
+import android.util.DisplayMetrics;
-import com.mapbox.mapboxsdk.maps.MapView;
+import java.nio.ByteBuffer;
/**
- * Icon is the visual representation of a {@link Marker} on a {@link MapView}.
+ * Icon is the visual representation of a Marker on a MapView.
*
* @see Marker
+ * @see IconFactory
*/
public class Icon {
+
private Bitmap mBitmap;
private String mId;
@@ -19,29 +22,67 @@ public class Icon {
}
/**
- * {@link String} identifier for this {@link Icon}.
+ * String identifier for this icon.
*
- * @return {@link String} identifier for this {@link Icon}.
+ * @return String identifier for this icon.
*/
public String getId() {
return mId;
}
/**
- * Get the {@link Bitmap} being used for this {@link Icon}.
+ * Get the bitmap being used for this icon.
*
- * @return The {@link Bitmap} being used for the {@link Icon}.
+ * @return The bitmap being used for the icon.
*/
public Bitmap getBitmap() {
+ if (mBitmap.getConfig() != Bitmap.Config.ARGB_8888) {
+ mBitmap = mBitmap.copy(Bitmap.Config.ARGB_8888, false);
+ }
return mBitmap;
}
/**
- * Compares this {@link Icon} object with another {@link Icon} and determines if they match.
+ * Get the icon bitmap scale.
+ *
+ * Requires the bitmap to be set before calling this method.
+ *
+ *
+ * @return the scale of the bitmap
+ */
+ public float getScale() {
+ if (mBitmap == null) {
+ throw new IllegalStateException("Required to set a Icon before calling getScale");
+ }
+ float density = mBitmap.getDensity();
+ if (density == Bitmap.DENSITY_NONE) {
+ density = DisplayMetrics.DENSITY_DEFAULT;
+ }
+ return density / DisplayMetrics.DENSITY_DEFAULT;
+ }
+
+ /**
+ * Get the icon bitmap bytes.
+ *
+ * Requires the bitmap to be set before calling this method.
+ *
*
- * @param object Another {@link Icon} to compare with this object.
- * @return True if the {@link Icon} being passed in matches this {@link Icon} object. Else,
- * false.
+ * @return the bytes of the bitmap
+ */
+ public byte[] toBytes() {
+ if (mBitmap == null) {
+ throw new IllegalStateException("Required to set a Icon before calling toBytes");
+ }
+ ByteBuffer buffer = ByteBuffer.allocate(mBitmap.getRowBytes() * mBitmap.getHeight());
+ mBitmap.copyPixelsToBuffer(buffer);
+ return buffer.array();
+ }
+
+ /**
+ * Compares this icon object with another icon and determines if they match.
+ *
+ * @param object Another iconi to compare with this object.
+ * @return True if the icon being passed in matches this icon object. Else, false.
*/
@Override
public boolean equals(Object object) {
@@ -53,11 +94,7 @@ public class Icon {
}
Icon icon = (Icon) object;
-
- if (!mBitmap.equals(icon.mBitmap)) {
- return false;
- }
- return mId.equals(icon.mId);
+ return mBitmap.equals(icon.mBitmap) && mId.equals(icon.mId);
}
/**
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
index 30336d4ebd..56e8cc4ce2 100644
--- 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
@@ -3,6 +3,7 @@ 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;
@@ -361,6 +362,9 @@ public class MarkerView extends Marker {
*/
@Override
public Icon getIcon() {
+ if (markerViewIcon == null) {
+ setIcon(IconFactory.getInstance(Mapbox.getApplicationContext()).defaultMarkerView());
+ }
return markerViewIcon;
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java
index c9d81a88bc..9f4171aee8 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java
@@ -1,15 +1,14 @@
package com.mapbox.mapboxsdk.maps;
import android.graphics.Bitmap;
-import android.util.DisplayMetrics;
+import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerView;
import com.mapbox.mapboxsdk.exceptions.IconBitmapChangedException;
-import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -41,118 +40,109 @@ class IconManager {
Icon loadIconForMarker(Marker marker) {
Icon icon = marker.getIcon();
-
- // calculating average before adding
- int iconSize = icons.size() + 1;
-
- // TODO replace former if case with anchor implementation,
- // current workaround for having extra pixels is diving height by 2
if (icon == null) {
- icon = IconFactory.getInstance(nativeMapView.getContext()).defaultMarker();
- Bitmap bitmap = icon.getBitmap();
- averageIconHeight = averageIconHeight + (bitmap.getHeight() / 2 - averageIconHeight) / iconSize;
- averageIconWidth = averageIconWidth + (bitmap.getWidth() - averageIconWidth) / iconSize;
- marker.setIcon(icon);
- } else {
- Bitmap bitmap = icon.getBitmap();
- averageIconHeight = averageIconHeight + (bitmap.getHeight() - averageIconHeight) / iconSize;
- averageIconWidth = averageIconWidth + (bitmap.getWidth() - averageIconWidth) / iconSize;
- }
-
- if (!icons.contains(icon)) {
- icons.add(icon);
- loadIcon(icon);
+ // TODO replace with anchor implementation, we are faking an anchor by adding extra pixels and diving height by 2
+ // TODO we can move this code afterwards to getIcon as with MarkerView.getIcon
+ icon = loadDefaultIconForMarker(marker);
} else {
- Icon oldIcon = icons.get(icons.indexOf(icon));
- if (!oldIcon.getBitmap().sameAs(icon.getBitmap())) {
- throw new IconBitmapChangedException();
- }
+ updateAverageIconSize(icon);
}
+ addIcon(icon);
return icon;
}
- Icon loadIconForMarkerView(MarkerView marker) {
+ void loadIconForMarkerView(MarkerView marker) {
Icon icon = marker.getIcon();
- int iconSize = icons.size() + 1;
- if (icon == null) {
- icon = IconFactory.getInstance(nativeMapView.getContext()).defaultMarkerView();
- marker.setIcon(icon);
- }
Bitmap bitmap = icon.getBitmap();
- averageIconHeight = averageIconHeight + (bitmap.getHeight() - averageIconHeight) / iconSize;
- averageIconWidth = averageIconWidth + (bitmap.getWidth() - averageIconWidth) / iconSize;
- if (!icons.contains(icon)) {
- icons.add(icon);
- } else {
- Icon oldIcon = icons.get(icons.indexOf(icon));
- if (!oldIcon.getBitmap().sameAs(icon.getBitmap())) {
- throw new IconBitmapChangedException();
- }
- }
- return icon;
+ updateAverageIconSize(bitmap);
+ addIcon(icon, false);
}
int getTopOffsetPixelsForIcon(Icon icon) {
return (int) (nativeMapView.getTopOffsetPixelsForAnnotationSymbol(icon.getId()) * nativeMapView.getPixelRatio());
}
- void loadIcon(Icon icon) {
+ int getAverageIconHeight() {
+ return averageIconHeight;
+ }
+
+ int getAverageIconWidth() {
+ return averageIconWidth;
+ }
+
+ private Icon loadDefaultIconForMarker(Marker marker) {
+ Icon icon = IconFactory.getInstance(Mapbox.getApplicationContext()).defaultMarker();
Bitmap bitmap = icon.getBitmap();
- String id = icon.getId();
- if (bitmap.getConfig() != Bitmap.Config.ARGB_8888) {
- bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, false);
- }
- ByteBuffer buffer = ByteBuffer.allocate(bitmap.getRowBytes() * bitmap.getHeight());
- bitmap.copyPixelsToBuffer(buffer);
+ updateAverageIconSize(bitmap.getWidth(), bitmap.getHeight() / 2);
+ marker.setIcon(icon);
+ return icon;
+ }
+
+ private void addIcon(Icon icon) {
+ addIcon(icon, true);
+ }
- float density = bitmap.getDensity();
- if (density == Bitmap.DENSITY_NONE) {
- density = DisplayMetrics.DENSITY_DEFAULT;
+ private void addIcon(Icon icon, boolean addIconToMap) {
+ if (!icons.contains(icon)) {
+ icons.add(icon);
+ if (addIconToMap) {
+ loadIcon(icon);
+ }
+ } else {
+ validateIconChanged(icon);
}
- float scale = density / DisplayMetrics.DENSITY_DEFAULT;
- nativeMapView.addAnnotationIcon(
- id,
+ }
+
+ private void updateAverageIconSize(Icon icon) {
+ updateAverageIconSize(icon.getBitmap());
+ }
+
+ private void updateAverageIconSize(Bitmap bitmap) {
+ updateAverageIconSize(bitmap.getWidth(), bitmap.getHeight());
+ }
+
+ private void updateAverageIconSize(int width, int height) {
+ int iconSize = icons.size() + 1;
+ averageIconHeight = averageIconHeight + (height - averageIconHeight) / iconSize;
+ averageIconWidth = averageIconWidth + (width - averageIconWidth) / iconSize;
+ }
+
+ private void loadIcon(Icon icon) {
+ Bitmap bitmap = icon.getBitmap();
+ nativeMapView.addAnnotationIcon(icon.getId(),
bitmap.getWidth(),
bitmap.getHeight(),
- scale, buffer.array());
+ icon.getScale(),
+ icon.toBytes());
}
void reloadIcons() {
- int count = icons.size();
- for (int i = 0; i < count; i++) {
- Icon icon = icons.get(i);
+ for (Icon icon : icons) {
loadIcon(icon);
}
}
+ private void validateIconChanged(Icon icon) {
+ Icon oldIcon = icons.get(icons.indexOf(icon));
+ if (!oldIcon.getBitmap().sameAs(icon.getBitmap())) {
+ throw new IconBitmapChangedException();
+ }
+ }
+
void ensureIconLoaded(Marker marker, MapboxMap mapboxMap) {
Icon icon = marker.getIcon();
if (icon == null) {
- icon = IconFactory.getInstance(nativeMapView.getContext()).defaultMarker();
- marker.setIcon(icon);
- }
- if (!icons.contains(icon)) {
- icons.add(icon);
- loadIcon(icon);
- } else {
- Icon oldIcon = icons.get(icons.indexOf(icon));
- if (!oldIcon.getBitmap().sameAs(icon.getBitmap())) {
- throw new IconBitmapChangedException();
- }
+ icon = loadDefaultIconForMarker(marker);
}
+ addIcon(icon);
+ setTopOffsetPixels(marker, mapboxMap, icon);
+ }
+ private void setTopOffsetPixels(Marker marker, MapboxMap mapboxMap, Icon icon) {
// this seems to be a costly operation according to the profiler so I'm trying to save some calls
Marker previousMarker = marker.getId() != -1 ? (Marker) mapboxMap.getAnnotation(marker.getId()) : null;
if (previousMarker == null || previousMarker.getIcon() == null || previousMarker.getIcon() != marker.getIcon()) {
marker.setTopOffsetPixels(getTopOffsetPixelsForIcon(icon));
}
}
-
- int getAverageIconHeight() {
- return averageIconHeight;
- }
-
- int getAverageIconWidth() {
- return averageIconWidth;
- }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
index 02eeb25f83..63f2e653cc 100755
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
@@ -897,10 +897,6 @@ final class NativeMapView {
return pixelRatio;
}
- public Context getContext() {
- return mapView.getContext();
- }
-
//
// Callbacks
//
--
cgit v1.2.1
From 83df8a8621287e548ee771599c9c98b61b9971a3 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Wed, 31 May 2017 09:46:12 +0200
Subject: [android] - javadoc update for 5.1.0 release (#9138)
* [android] - javadoc update for 5.1.0 release
* oxford comma
* Grammar/spelling tweaks
* grammar tweak
* grammar tweak
* Grammar tweaks
* Grammar tweaks
---
.../src/main/java/com/mapbox/mapboxsdk/Mapbox.java | 33 ++++++++----
.../mapbox/mapboxsdk/camera/CameraPosition.java | 4 +-
.../mapboxsdk/camera/CameraUpdateFactory.java | 2 +-
.../mapboxsdk/constants/MyBearingTracking.java | 4 +-
.../mapboxsdk/constants/MyLocationTracking.java | 4 +-
.../java/com/mapbox/mapboxsdk/constants/Style.java | 2 +-
.../mapbox/mapboxsdk/location/LocationSource.java | 53 +++++++++++++++++--
.../mapboxsdk/maps/FocalPointChangeListener.java | 3 ++
.../java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 6 +--
.../mapbox/mapboxsdk/offline/OfflineManager.java | 4 +-
.../mapbox/mapboxsdk/offline/OfflineRegion.java | 2 +-
.../com/mapbox/mapboxsdk/storage/Resource.java | 6 +++
.../style/functions/CompositeFunction.java | 2 +-
.../com/mapbox/mapboxsdk/style/layers/Filter.java | 2 +-
.../mapboxsdk/style/layers/TransitionOptions.java | 28 ++++++++++
.../mapbox/mapboxsdk/style/light/package-info.java | 4 ++
.../com/mapbox/mapboxsdk/utils/AnimatorUtils.java | 59 ++++++++++++++++++++++
.../com/mapbox/mapboxsdk/utils/ColorUtils.java | 3 ++
18 files changed, 188 insertions(+), 33 deletions(-)
create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/package-info.java
(limited to 'platform/android/MapboxGLAndroidSDK')
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 8098ee4d86..f75d7ed90d 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
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk;
+import android.app.Application;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
@@ -15,6 +16,14 @@ import com.mapbox.services.android.telemetry.MapboxTelemetry;
import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.location.LocationEnginePriority;
+/**
+ * The entry point of the Mapbox Android SDK.
+ *
+ * Obtain a reference by calling {@link #getInstance(Context, String)}. Usually this class is configured in
+ * {@link Application#onCreate()} and is responsible for the active access token, application context, and
+ * connectivity state.
+ *
+ */
public final class Mapbox {
private static Mapbox INSTANCE;
@@ -25,7 +34,7 @@ public final class Mapbox {
/**
* Get an instance of Mapbox.
*
- * This class manages the active access token, application context and connectivity state.
+ * This class manages the active access token, application context, and connectivity state.
*
*
* @param context Android context which holds or is an application context
@@ -52,9 +61,9 @@ public final class Mapbox {
}
/**
- * Access Token for this application.
+ * Access token for this application.
*
- * @return Mapbox Access Token
+ * @return Mapbox access token
*/
public static String getAccessToken() {
validateMapbox();
@@ -72,12 +81,14 @@ public final class Mapbox {
}
/**
- * Runtime validation of Access Token.
+ * Runtime validation of access token.
*
* @throws MapboxConfigurationException exception thrown when not using a valid accessToken
*/
private static void validateAccessToken() throws MapboxConfigurationException {
- String accessToken = INSTANCE.accessToken;
+ String
+
+ = INSTANCE.accessToken;
if (TextUtils.isEmpty(accessToken) || (!accessToken.toLowerCase(MapboxConstants.MAPBOX_LOCALE).startsWith("pk.")
&& !accessToken.toLowerCase(MapboxConstants.MAPBOX_LOCALE).startsWith("sk."))) {
throw new MapboxConfigurationException();
@@ -92,11 +103,11 @@ public final class Mapbox {
}
/**
- * Manually sets the connectivity state of the app. This is useful for apps that control their
+ * Manually sets the connectivity state of the app. This is useful for apps which control their
* own connectivity state and want to bypass any checks to the ConnectivityManager.
*
* @param connected flag to determine the connectivity state, true for connected, false for
- * disconnected, null for ConnectivityManager to determine.
+ * disconnected, and null for ConnectivityManager to determine.
*/
public static synchronized void setConnected(Boolean connected) {
// Connectivity state overridden by app
@@ -104,10 +115,10 @@ public final class Mapbox {
}
/**
- * Determines whether we have an Internet connection available. Please do not rely on this
- * method in your apps, this method is used internally by the SDK.
+ * Determines whether we have an internet connection available. Please do not rely on this
+ * method in your apps. This method is used internally by the SDK.
*
- * @return true if there is an Internet connection, false otherwise
+ * @return true if there is an internet connection, false otherwise
*/
public static synchronized Boolean isConnected() {
if (INSTANCE.connected != null) {
@@ -119,4 +130,4 @@ public final class Mapbox {
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
return (activeNetwork != null && activeNetwork.isConnected());
}
-}
\ No newline at end of file
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java
index 5e958ff565..66c261f1d0 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java
@@ -156,7 +156,7 @@ public final class CameraPosition implements Parcelable {
}
/**
- * Builder for composing {@link CameraPosition} objects.
+ * Builder for composing CameraPosition objects.
*/
public static final class Builder {
@@ -190,7 +190,7 @@ public final class CameraPosition implements Parcelable {
/**
* Create Builder with an existing CameraPosition data.
*
- * @param typedArray TypedArray containgin attribute values
+ * @param typedArray TypedArray containing attribute values
*/
public Builder(TypedArray typedArray) {
super();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java
index 64b86054a0..8e1411e273 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java
@@ -15,7 +15,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
- * Factory for creating {@link CameraUpdate} objects.
+ * Factory for creating CameraUpdate objects.
*/
public final class CameraUpdateFactory {
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
index f53c65d055..88c3bef673 100644
--- 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
@@ -16,7 +16,7 @@ import java.lang.annotation.RetentionPolicy;
public class MyBearingTracking {
/**
- * Indicates the parameter accepts one of the values from {@link MyBearingTracking}.
+ * Indicates that the parameter accepts one of the values from MyBearingTracking.
*/
@IntDef( {NONE, COMPASS, GPS, /**COMBINED**/})
@Retention(RetentionPolicy.SOURCE)
@@ -38,6 +38,4 @@ public class MyBearingTracking {
*/
public static final int GPS = 0x00000008;
- // public static final int COMBINED = 0x00000012;
-
}
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
index 39f653596f..a1744d701f 100644
--- 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
@@ -17,7 +17,7 @@ import java.lang.annotation.RetentionPolicy;
public class MyLocationTracking {
/**
- * Indicates the parameter accepts one of the values from {@link MyLocationTracking}.
+ * Indicates the parameter accepts one of the values from MyLocationTracking.
*/
@IntDef( {TRACKING_NONE, TRACKING_FOLLOW})
@Retention(RetentionPolicy.SOURCE)
@@ -30,7 +30,7 @@ public class MyLocationTracking {
public static final int TRACKING_NONE = 0x00000000;
/**
- * Tracking the location of the user, {@link MapView} will reposition to center of {@link MyLocationView}
+ * 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/constants/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
index 77d0929df3..31e6313509 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
@@ -19,7 +19,7 @@ public class Style {
/**
- * Indicates the parameter accepts one of the values from {@link Style}. Using one of these
+ * Indicates the parameter accepts one of the values from Style. Using one of these
* constants means your map style will always use the latest version and may change as we
* improve the style
*/
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
index c4bdb4a17d..4e934fa3cc 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
@@ -2,7 +2,7 @@ package com.mapbox.mapboxsdk.location;
import android.content.Context;
import android.location.Location;
-import android.util.Log;
+import android.support.annotation.NonNull;
import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.location.LocationEngineListener;
@@ -15,6 +15,8 @@ import com.mapzen.android.lost.api.LostApiClient;
import java.lang.ref.WeakReference;
+import timber.log.Timber;
+
/**
* Manages locational updates. Contains methods to register and unregister location listeners.
*
@@ -33,8 +35,6 @@ import java.lang.ref.WeakReference;
public class LocationSource extends LocationEngine implements
LostApiClient.ConnectionCallbacks, LocationListener {
- private static final String LOG_TAG = LocationSource.class.getSimpleName();
-
private static LocationEngine instance;
private WeakReference context;
@@ -48,7 +48,13 @@ public class LocationSource extends LocationEngine implements
.build();
}
- public static synchronized LocationEngine getLocationEngine(Context context) {
+ /**
+ * Get the LocationEngine instance.
+ *
+ * @param context a Context from which the application context is derived
+ * @return the LocationEngine instance
+ */
+ public static synchronized LocationEngine getLocationEngine(@NonNull Context context) {
if (instance == null) {
instance = new LocationSource(context.getApplicationContext());
}
@@ -56,6 +62,10 @@ public class LocationSource extends LocationEngine implements
return instance;
}
+ /**
+ * Activate the location engine which will connect whichever location provider you are using. You'll need to call
+ * this before requesting user location updates using {@link LocationEngine#requestLocationUpdates()}.
+ */
@Override
public void activate() {
if (lostApiClient != null && !lostApiClient.isConnected()) {
@@ -63,6 +73,11 @@ public class LocationSource extends LocationEngine implements
}
}
+ /**
+ * Disconnect the location engine which is useful when you no longer need location updates or requesting the users
+ * {@link LocationEngine#getLastLocation()}. Before deactivating, you'll need to stop request user location updates
+ * using {@link LocationEngine#removeLocationUpdates()}.
+ */
@Override
public void deactivate() {
if (lostApiClient != null && lostApiClient.isConnected()) {
@@ -70,11 +85,20 @@ public class LocationSource extends LocationEngine implements
}
}
+ /**
+ * Check if your location provider has been activated/connected. This is mainly used internally but is also useful in
+ * the rare case when you'd like to know if your location engine is connected or not.
+ *
+ * @return boolean true if the location engine has been activated/connected, else false.
+ */
@Override
public boolean isConnected() {
return lostApiClient.isConnected();
}
+ /**
+ * Invoked when the location provider has connected.
+ */
@Override
public void onConnected() {
for (LocationEngineListener listener : locationListeners) {
@@ -82,11 +106,19 @@ public class LocationSource extends LocationEngine implements
}
}
+ /**
+ * Invoked when the location provider connection has been suspended.
+ */
@Override
public void onConnectionSuspended() {
- Log.d(LOG_TAG, "Connection suspended.");
+ Timber.d("Connection suspended.");
}
+ /**
+ * Returns the Last known location is the location provider is connected and location permissions are granted.
+ *
+ * @return the last known location
+ */
@Override
public Location getLastLocation() {
if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context.get())) {
@@ -97,6 +129,9 @@ public class LocationSource extends LocationEngine implements
return null;
}
+ /**
+ * Request location updates to the location provider.
+ */
@Override
public void requestLocationUpdates() {
// Common params
@@ -122,6 +157,9 @@ public class LocationSource extends LocationEngine implements
}
}
+ /**
+ * Dismiss ongoing location update to the location provider.
+ */
@Override
public void removeLocationUpdates() {
if (lostApiClient.isConnected()) {
@@ -129,6 +167,11 @@ public class LocationSource extends LocationEngine implements
}
}
+ /**
+ * Invoked when the Location has changed.
+ *
+ * @param location the new location
+ */
@Override
public void onLocationChanged(Location location) {
for (LocationEngineListener listener : locationListeners) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java
index 006122a4e2..aec9a848b7 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java
@@ -2,6 +2,9 @@ package com.mapbox.mapboxsdk.maps;
import android.graphics.PointF;
+/**
+ * Interface definition of a callback that is invoked when the focal point will change.
+ */
public interface FocalPointChangeListener {
void onFocalPointChanged(PointF pointF);
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 0bfa74d1c0..0ba6c10831 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
@@ -1972,9 +1972,9 @@ public final class MapboxMap {
/**
* Interface definition for a callback to be invoked when the camera changes position.
*
- * @deprecated Replaced by MapboxMap.OnCameraMoveStartedListener, MapboxMap.OnCameraMoveListener and
- * MapboxMap.OnCameraIdleListener. The order in which the deprecated onCameraChange method will be called in relation
- * to the methods in the new camera change listeners is undefined.
+ * @deprecated Replaced by {@link MapboxMap.OnCameraMoveStartedListener}, {@link MapboxMap.OnCameraMoveListener} and
+ * {@link MapboxMap.OnCameraIdleListener}. The order in which the deprecated onCameraChange method will be called in
+ * relation to the methods in the new camera change listeners is undefined.
*/
@Deprecated
public interface OnCameraChangeListener {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java
index 225278b17d..95cb7d66c4 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java
@@ -46,7 +46,7 @@ public class OfflineManager {
/**
* This callback receives an asynchronous response containing a list of all
- * {@link OfflineRegion} in the database, or an error message otherwise.
+ * OfflineRegion in the database or an error message otherwise.
*/
public interface ListOfflineRegionsCallback {
/**
@@ -66,7 +66,7 @@ public class OfflineManager {
/**
* This callback receives an asynchronous response containing the newly created
- * {@link OfflineRegion} in the database, or an error message otherwise.
+ * OfflineRegion in the database or an error message otherwise.
*/
public interface CreateOfflineRegionCallback {
/**
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
index 44bb2a05ee..baa815491f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
@@ -98,7 +98,7 @@ public class OfflineRegion {
}
/**
- * This callback receives an asynchronous response containing the {@link OfflineRegionStatus}
+ * This callback receives an asynchronous response containing the OfflineRegionStatus
* of the offline region, or a {@link String} error message otherwise.
*/
public interface OfflineRegionStatusCallback {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/Resource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/Resource.java
index af98a46a9b..eae83e8c1f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/Resource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/Resource.java
@@ -5,9 +5,15 @@ import android.support.annotation.IntDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+/**
+ * Resource provides access to resource types.
+ */
public final class Resource {
// Note: Keep this in sync with include/mbgl/storage/resource.hpp
+ /**
+ * Resource type variants.
+ */
@IntDef( {UNKNOWN, STYLE, SOURCE, TILE, GLYPHS, SPRITE_IMAGE, SPRITE_JSON})
@Retention(RetentionPolicy.SOURCE)
public @interface Kind {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/CompositeFunction.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/CompositeFunction.java
index 8ded7ecd34..15e4474105 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/CompositeFunction.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/CompositeFunction.java
@@ -13,7 +13,7 @@ import com.mapbox.mapboxsdk.style.layers.PropertyValue;
import java.util.Map;
/**
- * Composite functions combine {@link android.graphics.Camera} and {@link SourceFunction}s.
+ * Composite functions combine Camera and SourceFunctions.
*
* Composite functions allow the appearance of a map feature to change with both its
* properties and zoom. Each stop is an array with two elements, the first is an object
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java
index 643a126388..4dbb461e4c 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Filter.java
@@ -11,7 +11,7 @@ import java.util.Collections;
public class Filter {
/**
- * Base {@link Filter} statement. Subclassed to provide concrete statements.
+ * Base Filter statement. Subclassed to provide concrete statements.
*/
public abstract static class Statement {
protected final String operator;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/TransitionOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/TransitionOptions.java
index a46c11b35c..6e6e4ca613 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/TransitionOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/TransitionOptions.java
@@ -1,23 +1,51 @@
package com.mapbox.mapboxsdk.style.layers;
+/**
+ * Resembles transition property from the style specification.
+ *
+ * @see Transition documentation
+ */
public class TransitionOptions {
private long duration;
private long delay;
+ /**
+ * Create a transition property based on duration and a delay.
+ *
+ * @param duration the duration of the transition
+ * @param delay the delay to start the transition
+ */
public TransitionOptions(long duration, long delay) {
this.duration = duration;
this.delay = delay;
}
+ /**
+ * Create a transition property based on duration and a delay.
+ *
+ * @param duration the duration of the transition
+ * @param delay the delay to start the transition
+ * @return a new transition property object
+ */
public static TransitionOptions fromTransitionOptions(long duration, long delay) {
return new TransitionOptions(duration, delay);
}
+ /**
+ * Get the transition duration.
+ *
+ * @return the transition duration
+ */
public long getDuration() {
return duration;
}
+ /**
+ * Get the transition delay.
+ *
+ * @return the transition delay
+ */
public long getDelay() {
return delay;
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/package-info.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/package-info.java
new file mode 100644
index 0000000000..a613bf9587
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Contains the Mapbox Maps Android Style Light API classes.
+ */
+package com.mapbox.mapboxsdk.style.light;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/AnimatorUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/AnimatorUtils.java
index 7694604d9f..34c52c829b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/AnimatorUtils.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/AnimatorUtils.java
@@ -10,13 +10,31 @@ import android.support.annotation.Nullable;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.view.View;
+/**
+ * Animator utility class.
+ */
public class AnimatorUtils {
+ /**
+ * Animate a view from an animator resource.
+ *
+ * @param view the view to be animated
+ * @param animatorRes the animator resource to be loaded
+ * @param listener the animator end listener
+ */
public static void animate(@NonNull final View view, @AnimatorRes int animatorRes,
@Nullable OnAnimationEndListener listener) {
animate(view, animatorRes, -1, listener);
}
+ /**
+ * Animate a view from an animator resource.
+ *
+ * @param view the view to be animated
+ * @param animatorRes the animator resource to be loaded
+ * @param duration the duration of the animator
+ * @param listener the animator end listener
+ */
public static void animate(final View view, @AnimatorRes int animatorRes, int duration,
@Nullable final OnAnimationEndListener listener) {
if (view == null) {
@@ -43,14 +61,33 @@ public class AnimatorUtils {
animator.start();
}
+ /**
+ * Animate a view from an animator resource.
+ *
+ * @param view the view to be animated
+ * @param animatorRes the animator resource to be loaded
+ */
public static void animate(@NonNull final View view, @AnimatorRes int animatorRes) {
animate(view, animatorRes, -1);
}
+ /**
+ * Animate a view from an animator resource.
+ *
+ * @param view the view to be animated
+ * @param animatorRes the animator resource to be loaded
+ * @param duration the duration of the animator
+ */
public static void animate(@NonNull final View view, @AnimatorRes int animatorRes, int duration) {
animate(view, animatorRes, duration, null);
}
+ /**
+ * Animate a view rotation property to a value.
+ *
+ * @param view the view to be rotated
+ * @param rotation the value to animate to
+ */
public static void rotate(@NonNull final View view, float rotation) {
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(view, View.ROTATION, view.getRotation(), rotation);
@@ -64,6 +101,12 @@ public class AnimatorUtils {
rotateAnimator.start();
}
+ /**
+ * Animate a view rotation property by a value.
+ *
+ * @param view the view to be rotated
+ * @param rotationBy the value to animate by
+ */
public static void rotateBy(@NonNull final View view, float rotationBy) {
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
view.animate().rotationBy(rotationBy).setInterpolator(new FastOutSlowInInterpolator()).setListener(
@@ -76,6 +119,13 @@ public class AnimatorUtils {
});
}
+ /**
+ * Animate a view alpha property to a value.
+ *
+ * @param convertView the view to be animated
+ * @param alpha the value to animate to
+ * @param listener the animator end listener
+ */
public static void alpha(@NonNull final View convertView, float alpha,
@Nullable final OnAnimationEndListener listener) {
convertView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
@@ -99,10 +149,19 @@ public class AnimatorUtils {
rotateAnimator.start();
}
+ /**
+ * Animate a view alpha property to a value.
+ *
+ * @param convertView the view to be animated
+ * @param alpha the value to animate to
+ */
public static void alpha(@NonNull final View convertView, float alpha) {
alpha(convertView, alpha, null);
}
+ /**
+ * An interface definition that is invoked when an animation ends.
+ */
public interface OnAnimationEndListener {
void onAnimationEnd();
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
index 2da2472d69..24c76243d9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
@@ -17,6 +17,9 @@ import com.mapbox.mapboxsdk.exceptions.ConversionException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/**
+ * Color utility class.
+ */
public class ColorUtils {
/**
--
cgit v1.2.1
From b6a4f1212cbf7454134a1e3f367d2e47db305a15 Mon Sep 17 00:00:00 2001
From: Pablo Guardiola
Date: Wed, 31 May 2017 12:59:01 +0200
Subject: [android] fix missing access token variable issue (#9151)
---
.../MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 f75d7ed90d..81134e9497 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
@@ -86,9 +86,7 @@ public final class Mapbox {
* @throws MapboxConfigurationException exception thrown when not using a valid accessToken
*/
private static void validateAccessToken() throws MapboxConfigurationException {
- String
-
- = INSTANCE.accessToken;
+ String accessToken = INSTANCE.accessToken;
if (TextUtils.isEmpty(accessToken) || (!accessToken.toLowerCase(MapboxConstants.MAPBOX_LOCALE).startsWith("pk.")
&& !accessToken.toLowerCase(MapboxConstants.MAPBOX_LOCALE).startsWith("sk."))) {
throw new MapboxConfigurationException();
--
cgit v1.2.1
From 52eba423aecca51dd65c15d2d3dbffe2f06856ba Mon Sep 17 00:00:00 2001
From: Pablo Guardiola
Date: Thu, 1 Jun 2017 10:05:31 +0200
Subject: [android] Cherry picking 9133 (#9145)
* [android] Fix tracking mode + camera race condition (#9133)
* [android] fix tracking mode + camera race condition
* fix resetTrackingModesIfRequired bug (comparing current camera position with target camera position
* cherry pick #9133 and update CHANGELOG
* add null check to prevent null pointer exception
---
.../mapboxsdk/constants/MapboxConstants.java | 1 -
.../mapbox/mapboxsdk/maps/MapGestureDetector.java | 8 ++--
.../java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 30 +++++++++++-
.../mapbox/mapboxsdk/maps/TrackingSettings.java | 54 ++++++----------------
.../java/com/mapbox/mapboxsdk/maps/Transform.java | 9 ++--
.../mapboxsdk/maps/widgets/MyLocationView.java | 49 ++------------------
6 files changed, 57 insertions(+), 94 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
index 9adefa3221..ecb6ffe24e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
@@ -113,7 +113,6 @@ public class MapboxConstants {
public static final String STATE_MY_BEARING_TRACKING_MODE = "mapbox_myBearingTracking";
public static final String STATE_MY_LOCATION_TRACKING_DISMISS = "mapbox_myLocationTrackingDismiss";
public static final String STATE_MY_BEARING_TRACKING_DISMISS = "mapbox_myBearingTrackingDismiss";
- public static final String STATE_MY_TRACKING_MODE_DISMISS_FOR_CAMERA = "mapbox_myBearingTrackingDismiss";
public static final String STATE_COMPASS_ENABLED = "mapbox_compassEnabled";
public static final String STATE_COMPASS_GRAVITY = "mapbox_compassGravity";
public static final String STATE_COMPASS_MARGIN_LEFT = "mapbox_compassMarginLeft";
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 39433d8b93..e60f9b1d1e 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
@@ -357,7 +357,7 @@ final class MapGestureDetector {
return false;
}
- trackingSettings.resetTrackingModesIfRequired(true, false);
+ trackingSettings.resetTrackingModesIfRequired(true, false, false);
// cancel any animation
transform.cancelTransitions();
@@ -402,7 +402,7 @@ final class MapGestureDetector {
}
// reset tracking if needed
- trackingSettings.resetTrackingModesIfRequired(true, false);
+ trackingSettings.resetTrackingModesIfRequired(true, false, false);
// Scroll the map
transform.moveBy(-distanceX, -distanceY, 0 /*no duration*/);
@@ -484,7 +484,7 @@ final class MapGestureDetector {
// 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);
+ trackingSettings.resetTrackingModesIfRequired(!quickZoom, false, false);
// Scale the map
if (focalPoint != null) {
// arround user provided focal point
@@ -568,7 +568,7 @@ final class MapGestureDetector {
}
// rotation constitutes translation of anything except the center of
// rotation, so cancel both location and bearing tracking if required
- trackingSettings.resetTrackingModesIfRequired(true, true);
+ trackingSettings.resetTrackingModesIfRequired(true, true, false);
// Get rotate value
double bearing = transform.getRawBearing();
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 0ba6c10831..7a62f06ad2 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
@@ -746,10 +746,38 @@ public final class MapboxMap {
@UiThread
public final void easeCamera(final CameraUpdate update, final int durationMs, final boolean easingInterpolator,
final MapboxMap.CancelableCallback callback) {
+ easeCamera(update, durationMs, easingInterpolator, callback, false);
+ }
+
+ /**
+ * Gradually move the camera by a specified duration in milliseconds, zoom will not be affected
+ * 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 TrackingSettings#setDismissTrackingModeForCameraPositionChange(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
+ * positive, otherwise an IllegalArgumentException will be thrown.
+ * @param easingInterpolator True for easing interpolator, false for linear.
+ * @param callback An optional callback to be notified from the main thread when the animation
+ * stops. If the animation stops due to its natural completion, the callback
+ * will be notified with onFinish(). If the animation stops due to interruption
+ * by a later camera movement or a user gesture, onCancel() will be called.
+ * Do not update or ease the camera from within onCancel().
+ * @param isDismissable true will allow animated camera changes dismiss a tracking mode.
+ */
+ @UiThread
+ public final void easeCamera(final CameraUpdate update, final int durationMs, final boolean easingInterpolator,
+ final MapboxMap.CancelableCallback callback, final boolean isDismissable) {
new Handler().post(new Runnable() {
@Override
public void run() {
- transform.easeCamera(MapboxMap.this, update, durationMs, easingInterpolator, callback);
+ transform.easeCamera(MapboxMap.this, update, durationMs, easingInterpolator, callback, isDismissable);
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java
index 25b60aa72d..7dcd84de75 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java
@@ -33,7 +33,6 @@ public final class TrackingSettings {
private boolean myLocationEnabled;
private boolean dismissLocationTrackingOnGesture = true;
private boolean dismissBearingTrackingOnGesture = true;
- private boolean isResetTrackingWithCameraPositionChange = true;
private MapboxMap.OnMyLocationTrackingModeChangeListener onMyLocationTrackingModeChangeListener;
private MapboxMap.OnMyBearingTrackingModeChangeListener onMyBearingTrackingModeChangeListener;
@@ -57,8 +56,6 @@ public final class TrackingSettings {
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_MY_TRACKING_MODE_DISMISS_FOR_CAMERA,
- isDismissTrackingModesForCameraPositionChange());
}
void onRestoreInstanceState(Bundle savedInstanceState) {
@@ -77,8 +74,6 @@ public final class TrackingSettings {
MapboxConstants.STATE_MY_LOCATION_TRACKING_DISMISS, true));
setDismissBearingTrackingOnGesture(savedInstanceState.getBoolean(
MapboxConstants.STATE_MY_BEARING_TRACKING_DISMISS, true));
- setDismissTrackingModeForCameraPositionChange(savedInstanceState.getBoolean(
- MapboxConstants.STATE_MY_TRACKING_MODE_DISMISS_FOR_CAMERA, true));
}
/**
@@ -259,15 +254,16 @@ public final class TrackingSettings {
}
/**
- * Reset the tracking modes as necessary. Location tracking is reset if the map center is changed,
- * bearing tracking if there is a rotation.
+ * 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 translate true if translation
+ * @param rotate true if rotation
+ * @param isFromLocation true if from location
*/
- void resetTrackingModesIfRequired(boolean translate, boolean rotate) {
+ 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()) {
+ if (translate && !isLocationTrackingDisabled() && isDismissLocationTrackingOnGesture() && !isFromLocation) {
setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
}
@@ -280,38 +276,18 @@ public final class TrackingSettings {
/**
* Reset the tracking modes as necessary. Animated camera position changes can reset the underlying tracking modes.
*
- * @param cameraPosition the changed camera position
+ * @param currentCameraPosition the current camera position
+ * @param targetCameraPosition the changed camera position
+ * @param isFromLocation true if from location
*/
- void resetTrackingModesIfRequired(CameraPosition cameraPosition) {
- if (isDismissTrackingModesForCameraPositionChange()) {
- resetTrackingModesIfRequired(cameraPosition.target != null, false);
+ void resetTrackingModesIfRequired(CameraPosition currentCameraPosition, CameraPosition targetCameraPosition,
+ boolean isFromLocation) {
+ if (currentCameraPosition.target != null) {
+ resetTrackingModesIfRequired(!currentCameraPosition.target.equals(targetCameraPosition.target), false,
+ isFromLocation);
}
}
- /**
- * Returns if a animation allows to dismiss a tracking mode.
- *
- * By default this is set to true.
- *
- *
- * @return True if camera animations will allow to dismiss a tracking mode
- */
- public boolean isDismissTrackingModesForCameraPositionChange() {
- return isResetTrackingWithCameraPositionChange;
- }
-
- /**
- * Sets a flag to allow animated camera position changes to dismiss a tracking mode.
- *
- *
- *
- *
- * @param willAllowToDismiss True will allow animated camera changes dismiss a trackig mode
- */
- public void setDismissTrackingModeForCameraPositionChange(boolean willAllowToDismiss) {
- isResetTrackingWithCameraPositionChange = willAllowToDismiss;
- }
-
Location getMyLocation() {
return myLocationView.getLocation();
}
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 af44a08a81..7f44e0de07 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
@@ -94,7 +94,7 @@ final class Transform implements MapView.OnMapChangedListener {
final void moveCamera(MapboxMap mapboxMap, CameraUpdate update, MapboxMap.CancelableCallback callback) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (!cameraPosition.equals(this.cameraPosition)) {
- trackingSettings.resetTrackingModesIfRequired(cameraPosition);
+ trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false);
cancelTransitions();
cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
mapView.jumpTo(cameraPosition.bearing, cameraPosition.target, cameraPosition.tilt, cameraPosition.zoom);
@@ -107,10 +107,10 @@ final class Transform implements MapView.OnMapChangedListener {
@UiThread
final void easeCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, boolean easingInterpolator,
- final MapboxMap.CancelableCallback callback) {
+ final MapboxMap.CancelableCallback callback, boolean isDismissable) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (!cameraPosition.equals(this.cameraPosition)) {
- trackingSettings.resetTrackingModesIfRequired(cameraPosition);
+ trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, isDismissable);
cancelTransitions();
cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
@@ -118,7 +118,6 @@ final class Transform implements MapView.OnMapChangedListener {
cameraCancelableCallback = callback;
mapView.addOnMapChangedListener(this);
}
-
mapView.easeTo(cameraPosition.bearing, cameraPosition.target, durationMs, cameraPosition.tilt,
cameraPosition.zoom, easingInterpolator);
}
@@ -129,7 +128,7 @@ final class Transform implements MapView.OnMapChangedListener {
final MapboxMap.CancelableCallback callback) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (!cameraPosition.equals(this.cameraPosition)) {
- trackingSettings.resetTrackingModesIfRequired(cameraPosition);
+ trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false);
cancelTransitions();
cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
index 338d29c87c..f5ef46a5d3 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
@@ -485,19 +485,8 @@ public class MyLocationView extends View {
if (location != null) {
if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
// center map directly
- mapboxMap.getTrackingSettings().setDismissTrackingModeForCameraPositionChange(false);
mapboxMap.easeCamera(CameraUpdateFactory.newLatLng(new LatLng(location)), 0, false /*linear interpolator*/,
- new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
-
- }
-
- @Override
- public void onFinish() {
- mapboxMap.getTrackingSettings().setDismissTrackingModeForCameraPositionChange(true);
- }
- });
+ null, true);
} else {
// do not use interpolated location from tracking mode
latLng = null;
@@ -663,19 +652,8 @@ public class MyLocationView extends View {
private void rotateCamera(float rotation) {
CameraPosition.Builder builder = new CameraPosition.Builder();
builder.bearing(rotation);
- mapboxMap.getTrackingSettings().setDismissTrackingModeForCameraPositionChange(false);
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), COMPASS_UPDATE_RATE_MS,
- false /*linear interpolator*/, new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
-
- }
-
- @Override
- public void onFinish() {
- mapboxMap.getTrackingSettings().setDismissTrackingModeForCameraPositionChange(true);
- }
- });
+ false /*linear interpolator*/, null);
}
@Override
@@ -750,7 +728,7 @@ public class MyLocationView extends View {
abstract void invalidate();
}
- private class MyLocationTrackingBehavior extends MyLocationBehavior implements MapboxMap.CancelableCallback {
+ private class MyLocationTrackingBehavior extends MyLocationBehavior {
@Override
void updateLatLng(@NonNull Location location) {
@@ -789,10 +767,9 @@ public class MyLocationView extends View {
// accuracy
updateAccuracy(location);
- // disable dismiss of tracking settings, enabled in #onFinish
- mapboxMap.getTrackingSettings().setDismissTrackingModeForCameraPositionChange(false);
// ease to new camera position with a linear interpolator
- mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), animationDuration, false, this);
+ mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), animationDuration, false, null,
+ true);
}
@Override
@@ -803,22 +780,6 @@ public class MyLocationView extends View {
screenLocation = new PointF(x, y);
MyLocationView.this.invalidate();
}
-
- @Override
- public void onCancel() {
- //no op
- }
-
- @Override
- public void onFinish() {
- // Posting to end message queue to avoid race condition #8560
- post(new Runnable() {
- @Override
- public void run() {
- mapboxMap.getTrackingSettings().setDismissTrackingModeForCameraPositionChange(true);
- }
- });
- }
}
private class MyLocationShowBehavior extends MyLocationBehavior {
--
cgit v1.2.1
From da532007043b1827e83686faca0de2a45c4ef730 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 2 Jun 2017 12:39:35 +0200
Subject: [android] - validate if gestures should execute (#9173)
---
.../com/mapbox/mapboxsdk/maps/MapGestureDetector.java | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 e60f9b1d1e..33e13c5ecc 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
@@ -383,6 +383,14 @@ final class MapGestureDetector {
// Called for drags
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
+ if (!trackingSettings.isScrollGestureCurrentlyEnabled()) {
+ return false;
+ }
+
+ if (dragStarted) {
+ return false;
+ }
+
if (!scrollInProgress) {
scrollInProgress = true;
@@ -393,13 +401,6 @@ final class MapGestureDetector {
getLocationFromGesture(e1.getX(), e1.getY()),
MapboxEvent.GESTURE_PAN_START, transform));
}
- if (!trackingSettings.isScrollGestureCurrentlyEnabled()) {
- return false;
- }
-
- if (dragStarted) {
- return false;
- }
// reset tracking if needed
trackingSettings.resetTrackingModesIfRequired(true, false, false);
--
cgit v1.2.1
From ef7b3552b52002c153a0b93a87d27f8b5d378f4f Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Tue, 6 Jun 2017 12:13:56 +0200
Subject: [android] - only invoke callback if fling scrolling animation isn't
going to be ignored. (#9192)
---
.../main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java | 3 ++-
.../src/main/java/com/mapbox/mapboxsdk/maps/Transform.java | 7 +++----
2 files changed, 5 insertions(+), 5 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 33e13c5ecc..5346baa4e2 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
@@ -346,7 +346,6 @@ final class MapGestureDetector {
// and ignore when a scale gesture has occurred
return false;
}
- cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
float screenDensity = uiSettings.getPixelRatio();
@@ -362,6 +361,8 @@ final class MapGestureDetector {
// cancel any animation
transform.cancelTransitions();
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
+
// tilt results in a bigger translation, limiting input for #5281
double tilt = transform.getTilt();
double tiltFactor = 1 + ((tilt != 0) ? (tilt / 10) : 0); /* 1 -> 7 */
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 7f44e0de07..9a8997014a 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
@@ -79,7 +79,7 @@ final class Transform implements MapView.OnMapChangedListener {
@Override
public void onMapChanged(@MapView.MapChange int change) {
- if (change == REGION_DID_CHANGE_ANIMATED && cameraCancelableCallback != null) {
+ if (change == REGION_DID_CHANGE_ANIMATED) {
updateCameraPosition(invalidateCameraPosition());
if (cameraCancelableCallback != null) {
cameraCancelableCallback.onFinish();
@@ -116,8 +116,8 @@ final class Transform implements MapView.OnMapChangedListener {
if (callback != null) {
cameraCancelableCallback = callback;
- mapView.addOnMapChangedListener(this);
}
+ mapView.addOnMapChangedListener(this);
mapView.easeTo(cameraPosition.bearing, cameraPosition.target, durationMs, cameraPosition.tilt,
cameraPosition.zoom, easingInterpolator);
}
@@ -134,9 +134,8 @@ final class Transform implements MapView.OnMapChangedListener {
if (callback != null) {
cameraCancelableCallback = callback;
- mapView.addOnMapChangedListener(this);
}
-
+ mapView.addOnMapChangedListener(this);
mapView.flyTo(cameraPosition.bearing, cameraPosition.target, durationMs, cameraPosition.tilt,
cameraPosition.zoom);
}
--
cgit v1.2.1
From a1f8de66794f665b69c35ed163b3e554dc5db348 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Paczos?=
Date: Tue, 6 Jun 2017 12:15:21 +0200
Subject: [android] - dealing with infinite camera move callbacks (#9177)
(#9194)
---
.../main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
index f5ef46a5d3..098f006f6c 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
@@ -701,6 +701,12 @@ public class MyLocationView extends View {
private abstract class MyLocationBehavior {
+ MyLocationBehavior() {
+ if (latLng != null) {
+ locationUpdateTimestamp = SystemClock.elapsedRealtime();
+ }
+ }
+
void updateLatLng(@NonNull Location newLocation) {
location = newLocation;
}
--
cgit v1.2.1
From 45327b6ac46f8b574a767e20ee6a18ab23936db6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Paczos?=
Date: Tue, 6 Jun 2017 21:09:20 +0200
Subject: [android] - keep location tracking mode after screen rotation (#9187)
* [android] - keep location tracking mode after screen rotation (#9186)
* [android] - using easeCamera to keep location tracking instead of overloaded moveCamera (#9187)
* [android] - checkstyle fix up
---
.../src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 7a62f06ad2..8e50adb777 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
@@ -141,12 +141,20 @@ public final class MapboxMap {
*/
void onRestoreInstanceState(Bundle savedInstanceState) {
final CameraPosition cameraPosition = savedInstanceState.getParcelable(MapboxConstants.STATE_CAMERA_POSITION);
- if (cameraPosition != null) {
- moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder(cameraPosition).build()));
- }
uiSettings.onRestoreInstanceState(savedInstanceState);
trackingSettings.onRestoreInstanceState(savedInstanceState);
+
+ if (cameraPosition != null) {
+ easeCamera(CameraUpdateFactory.newCameraPosition(
+ new CameraPosition.Builder(cameraPosition).build()),
+ 0,
+ false,
+ null,
+ !trackingSettings.isLocationTrackingDisabled()
+ );
+ }
+
nativeMapView.setDebug(savedInstanceState.getBoolean(MapboxConstants.STATE_DEBUG_ACTIVE));
final String styleUrl = savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL);
--
cgit v1.2.1
From ae837f4db242c074206aeb2c214b4418fcfed0c0 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Wed, 7 Jun 2017 12:41:30 +0200
Subject: [android] - remove conversion from pixels to dp (#9205)
---
.../src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
index 63f2e653cc..a31babc1c5 100755
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
@@ -621,7 +621,7 @@ final class NativeMapView {
if (isDestroyedOn("getMetersPerPixelAtLatitude")) {
return 0;
}
- return nativeGetMetersPerPixelAtLatitude(lat, getZoom()) / pixelRatio;
+ return nativeGetMetersPerPixelAtLatitude(lat, getZoom());
}
public ProjectedMeters projectedMetersForLatLng(LatLng latLng) {
--
cgit v1.2.1
From 78eca869ae239b9686a885be6492196f6b0ae48a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Paczos?=
Date: Wed, 7 Jun 2017 18:02:28 +0200
Subject: [android] - option to disable camera animation while following
position (#9210)
---
.../mapboxsdk/constants/MapboxConstants.java | 1 +
.../mapbox/mapboxsdk/maps/TrackingSettings.java | 25 ++++++++++++++++++++++
.../mapboxsdk/maps/widgets/MyLocationView.java | 22 +++++++++++++++----
3 files changed, 44 insertions(+), 4 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
index ecb6ffe24e..0396defe74 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
@@ -133,5 +133,6 @@ public class MapboxConstants {
public static final String STATE_ATTRIBUTION_MARGIN_RIGHT = "mapbox_attrMarginRight";
public static final String STATE_ATTRIBUTION_MARGIN_BOTTOM = "mapbox_atrrMarginBottom";
public static final String STATE_ATTRIBUTION_ENABLED = "mapbox_atrrEnabled";
+ public static final String STATE_LOCATION_CHANGE_ANIMATION_ENABLED = "mapbox_locationChangeAnimationEnabled";
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java
index 7dcd84de75..2e12de8dec 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java
@@ -29,6 +29,7 @@ public final class TrackingSettings {
private final CameraZoomInvalidator zoomInvalidator;
private LocationEngine locationSource;
private LocationEngineListener myLocationListener;
+ private boolean locationChangeAnimationEnabled = true;
private boolean myLocationEnabled;
private boolean dismissLocationTrackingOnGesture = true;
@@ -56,6 +57,7 @@ public final class TrackingSettings {
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());
}
void onRestoreInstanceState(Bundle savedInstanceState) {
@@ -74,6 +76,8 @@ public final class TrackingSettings {
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));
}
/**
@@ -91,6 +95,7 @@ public final class TrackingSettings {
*/
@UiThread
public void setMyLocationTrackingMode(@MyLocationTracking.Mode int myLocationTrackingMode) {
+ myLocationView.setLocationChangeAnimationEnabled(isLocationChangeAnimationEnabled());
myLocationView.setMyLocationTrackingMode(myLocationTrackingMode);
if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
@@ -253,6 +258,26 @@ public final class TrackingSettings {
|| 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.
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
index 098f006f6c..afed8635a9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
@@ -68,6 +68,7 @@ public class MyLocationView extends View {
private ValueAnimator locationChangeAnimator;
private ValueAnimator accuracyAnimator;
private ValueAnimator directionAnimator;
+ private boolean locationChangeAnimationEnabled;
private ValueAnimator.AnimatorUpdateListener invalidateSelfOnUpdateListener =
new ValueAnimator.AnimatorUpdateListener() {
@@ -462,6 +463,10 @@ public class MyLocationView extends View {
myLocationBehavior.updateLatLng(location);
}
+ public void setLocationChangeAnimationEnabled(boolean locationChangeAnimationEnabled) {
+ this.locationChangeAnimationEnabled = locationChangeAnimationEnabled;
+ }
+
public void setMyBearingTrackingMode(@MyBearingTracking.Mode int myBearingTrackingMode) {
this.myBearingTrackingMode = myBearingTrackingMode;
if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) {
@@ -773,9 +778,14 @@ public class MyLocationView extends View {
// accuracy
updateAccuracy(location);
- // ease to new camera position with a linear interpolator
- mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), animationDuration, false, null,
- true);
+ if (locationChangeAnimationEnabled) {
+ // ease to new camera position with a linear interpolator
+ mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), animationDuration, false, null,
+ true);
+ } else {
+ mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), 0, false, null,
+ true);
+ }
}
@Override
@@ -817,7 +827,11 @@ public class MyLocationView extends View {
}
locationChangeAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
- locationChangeAnimator.setDuration(locationUpdateDuration);
+ if (locationChangeAnimationEnabled) {
+ locationChangeAnimator.setDuration(locationUpdateDuration);
+ } else {
+ locationChangeAnimator.setDuration(0);
+ }
locationChangeAnimator.addUpdateListener(new MarkerCoordinateAnimatorListener(this,
latLng, newLocation
));
--
cgit v1.2.1
From 233117fe5797f7f0dabddbee780b31a624053b68 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Thu, 8 Jun 2017 08:44:29 +0200
Subject: [android] - invalidating MyLocationView bearing when not following
position (#9212)
---
.../main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java | 5 +++++
1 file changed, 5 insertions(+)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
index afed8635a9..f648db413d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
@@ -461,6 +461,11 @@ public class MyLocationView extends View {
this.location = location;
myLocationBehavior.updateLatLng(location);
+
+ if (mapboxMap != null && myBearingTrackingMode == MyBearingTracking.GPS
+ && myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) {
+ setBearing(mapboxMap.getCameraPosition().bearing);
+ }
}
public void setLocationChangeAnimationEnabled(boolean locationChangeAnimationEnabled) {
--
cgit v1.2.1
From 9f88e373665124464351424e1efc95fe3a1fc05d Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 9 Jun 2017 10:00:00 +0200
Subject: Custom location source fix (#9142)
* [android] - custom location engine fixes (#9139)
* Update to latest LOST dependency, fixup internal location source integration
---
.../src/main/java/com/mapbox/mapboxsdk/Mapbox.java | 12 +++--
.../mapboxsdk/constants/MapboxConstants.java | 2 +-
.../mapbox/mapboxsdk/location/LocationSource.java | 40 ++++-----------
.../java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 3 --
.../mapbox/mapboxsdk/maps/TrackingSettings.java | 31 ++++++++++--
.../mapboxsdk/maps/widgets/MyLocationView.java | 58 +++++++++++++++-------
6 files changed, 87 insertions(+), 59 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 81134e9497..17cd4e0dce 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
@@ -30,6 +30,7 @@ public final class Mapbox {
private Context context;
private String accessToken;
private Boolean connected;
+ private LocationSource locationSource;
/**
* Get an instance of Mapbox.
@@ -45,8 +46,8 @@ public final class Mapbox {
public static synchronized Mapbox getInstance(@NonNull Context context, @NonNull String accessToken) {
if (INSTANCE == null) {
Context appContext = context.getApplicationContext();
- INSTANCE = new Mapbox(appContext, accessToken);
- LocationEngine locationEngine = LocationSource.getLocationEngine(appContext);
+ INSTANCE = new Mapbox(appContext, accessToken, new LocationSource(appContext));
+ LocationEngine locationEngine = new LocationSource(appContext);
locationEngine.setPriority(LocationEnginePriority.NO_POWER);
MapboxTelemetry.getInstance().initialize(
appContext, accessToken, BuildConfig.MAPBOX_EVENTS_USER_AGENT, locationEngine);
@@ -55,9 +56,10 @@ public final class Mapbox {
return INSTANCE;
}
- Mapbox(@NonNull Context context, @NonNull String accessToken) {
+ Mapbox(@NonNull Context context, @NonNull String accessToken, LocationSource locationSource) {
this.context = context;
this.accessToken = accessToken;
+ this.locationSource = locationSource;
}
/**
@@ -128,4 +130,8 @@ public final class Mapbox {
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
return (activeNetwork != null && activeNetwork.isConnected());
}
+
+ public static LocationSource getLocationSource() {
+ return INSTANCE.locationSource;
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
index 0396defe74..1ee59057d2 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
@@ -134,5 +134,5 @@ public class MapboxConstants {
public static final String STATE_ATTRIBUTION_MARGIN_BOTTOM = "mapbox_atrrMarginBottom";
public static final String STATE_ATTRIBUTION_ENABLED = "mapbox_atrrEnabled";
public static final String STATE_LOCATION_CHANGE_ANIMATION_ENABLED = "mapbox_locationChangeAnimationEnabled";
-
+ public static final String STATE_USING_CUSTOM_LOCATION_SOURCE = "mapbox_usingCustomLocationSource";
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
index 4e934fa3cc..8416bd5b6c 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
@@ -2,7 +2,7 @@ package com.mapbox.mapboxsdk.location;
import android.content.Context;
import android.location.Location;
-import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.location.LocationEngineListener;
@@ -13,10 +13,6 @@ import com.mapzen.android.lost.api.LocationRequest;
import com.mapzen.android.lost.api.LocationServices;
import com.mapzen.android.lost.api.LostApiClient;
-import java.lang.ref.WeakReference;
-
-import timber.log.Timber;
-
/**
* Manages locational updates. Contains methods to register and unregister location listeners.
*
@@ -35,40 +31,24 @@ import timber.log.Timber;
public class LocationSource extends LocationEngine implements
LostApiClient.ConnectionCallbacks, LocationListener {
- private static LocationEngine instance;
-
- private WeakReference context;
+ private Context context;
private LostApiClient lostApiClient;
- private LocationSource(Context context) {
+ public LocationSource(Context context) {
super();
- this.context = new WeakReference<>(context);
- lostApiClient = new LostApiClient.Builder(this.context.get())
+ this.context = context.getApplicationContext();
+ lostApiClient = new LostApiClient.Builder(this.context)
.addConnectionCallbacks(this)
.build();
}
- /**
- * Get the LocationEngine instance.
- *
- * @param context a Context from which the application context is derived
- * @return the LocationEngine instance
- */
- public static synchronized LocationEngine getLocationEngine(@NonNull Context context) {
- if (instance == null) {
- instance = new LocationSource(context.getApplicationContext());
- }
-
- return instance;
- }
-
/**
* Activate the location engine which will connect whichever location provider you are using. You'll need to call
* this before requesting user location updates using {@link LocationEngine#requestLocationUpdates()}.
*/
@Override
public void activate() {
- if (lostApiClient != null && !lostApiClient.isConnected()) {
+ if (!lostApiClient.isConnected()) {
lostApiClient.connect();
}
}
@@ -80,7 +60,7 @@ public class LocationSource extends LocationEngine implements
*/
@Override
public void deactivate() {
- if (lostApiClient != null && lostApiClient.isConnected()) {
+ if (lostApiClient.isConnected()) {
lostApiClient.disconnect();
}
}
@@ -111,7 +91,6 @@ public class LocationSource extends LocationEngine implements
*/
@Override
public void onConnectionSuspended() {
- Timber.d("Connection suspended.");
}
/**
@@ -120,8 +99,9 @@ public class LocationSource extends LocationEngine implements
* @return the last known location
*/
@Override
+ @Nullable
public Location getLastLocation() {
- if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context.get())) {
+ if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context)) {
//noinspection MissingPermission
return LocationServices.FusedLocationApi.getLastLocation(lostApiClient);
}
@@ -151,7 +131,7 @@ public class LocationSource extends LocationEngine implements
request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
- if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context.get())) {
+ if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context)) {
//noinspection MissingPermission
LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
}
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 8e50adb777..8a708cb186 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
@@ -37,7 +37,6 @@ 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.location.LocationSource;
import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
import com.mapbox.mapboxsdk.style.layers.Filter;
import com.mapbox.mapboxsdk.style.layers.Layer;
@@ -1872,8 +1871,6 @@ public final class MapboxMap {
* Replaces the location source of the my-location layer.
*
* @param locationSource A {@link LocationEngine} location source to use in the my-location layer.
- * Set to null to use the default {@link LocationSource}
- * location source.
*/
@UiThread
public void setLocationSource(@Nullable LocationEngine locationSource) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java
index 2e12de8dec..bd0bf7c83b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java
@@ -6,11 +6,11 @@ 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.location.LocationSource;
import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.location.LocationEngineListener;
@@ -30,6 +30,7 @@ public final class TrackingSettings {
private LocationEngine locationSource;
private LocationEngineListener myLocationListener;
private boolean locationChangeAnimationEnabled = true;
+ private boolean isCustomLocationSource;
private boolean myLocationEnabled;
private boolean dismissLocationTrackingOnGesture = true;
@@ -47,7 +48,7 @@ public final class TrackingSettings {
}
void initialise(MapboxMapOptions options) {
- locationSource = LocationSource.getLocationEngine(myLocationView.getContext());
+ locationSource = Mapbox.getLocationSource();
setMyLocationEnabled(options.getLocationEnabled());
}
@@ -58,11 +59,15 @@ public final class TrackingSettings {
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));
+ 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
}
@@ -339,6 +344,10 @@ public final class TrackingSettings {
}
}
+ public boolean isCustomLocationSource() {
+ return isCustomLocationSource;
+ }
+
void setOnMyLocationTrackingModeChangeListener(MapboxMap.OnMyLocationTrackingModeChangeListener listener) {
this.onMyLocationTrackingModeChangeListener = listener;
}
@@ -357,16 +366,30 @@ public final class TrackingSettings {
}
void setMyLocationEnabled(boolean locationEnabled) {
+ setMyLocationEnabled(locationEnabled, isCustomLocationSource());
+ }
+
+ private void setMyLocationEnabled(boolean locationEnabled, boolean isCustomLocationSource) {
if (!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;
- myLocationView.setEnabled(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.getLocationSource();
+ }
this.locationSource = locationSource;
myLocationView.setLocationSource(locationSource);
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
index f648db413d..9740679cf5 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
@@ -26,6 +26,7 @@ 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;
@@ -40,6 +41,8 @@ import com.mapbox.services.android.telemetry.location.LocationEnginePriority;
import java.lang.ref.WeakReference;
+import timber.log.Timber;
+
/**
* UI element overlaid on a map to show the user's location.
*/
@@ -148,6 +151,10 @@ public class MyLocationView extends View {
compassListener = new CompassListener(context);
}
+ public void init(LocationSource locationSource) {
+ this.locationSource = locationSource;
+ }
+
public final void setForegroundDrawables(Drawable defaultDrawable, Drawable bearingDrawable) {
if (defaultDrawable == null) {
return;
@@ -391,9 +398,13 @@ public class MyLocationView extends View {
@Override
public void setEnabled(boolean enabled) {
+ setEnabled(enabled, false);
+ }
+
+ public void setEnabled(boolean enabled, boolean isCustomLocationSource) {
super.setEnabled(enabled);
setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
- toggleGps(enabled);
+ toggleGps(enabled, isCustomLocationSource);
}
@Override
@@ -414,22 +425,23 @@ public class MyLocationView extends View {
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
*
* @param enableGps true if GPS is to be enabled, false if GPS is to be disabled
*/
- private void toggleGps(boolean enableGps) {
- if (locationSource == null) {
- locationSource = LocationSource.getLocationEngine(this.getContext());
- }
-
+ private void toggleGps(boolean enableGps, boolean isCustomLocationSource) {
if (enableGps) {
- // Set an initial location if one available
- Location lastLocation = locationSource.getLastLocation();
-
- if (lastLocation != null) {
- setLocation(lastLocation);
+ if (locationSource == null) {
+ if (!isCustomLocationSource) {
+ locationSource = Mapbox.getLocationSource();
+ } else {
+ return;
+ }
}
if (userLocationListener == null) {
@@ -437,16 +449,18 @@ public class MyLocationView extends View {
}
locationSource.addLocationEngineListener(userLocationListener);
+ locationSource.setPriority(LocationEnginePriority.HIGH_ACCURACY);
locationSource.activate();
} else {
+ if (locationSource == null) {
+ return;
+ }
// Disable location and user dot
location = null;
- locationSource.removeLocationUpdates();
locationSource.removeLocationEngineListener(userLocationListener);
+ locationSource.removeLocationUpdates();
locationSource.deactivate();
}
-
- locationSource.setPriority(LocationEnginePriority.HIGH_ACCURACY);
}
public Location getLocation() {
@@ -564,7 +578,10 @@ public class MyLocationView extends View {
}
public void setLocationSource(LocationEngine locationSource) {
+ toggleGps(false);
this.locationSource = locationSource;
+ this.userLocationListener = null;
+ setEnabled(isEnabled(), locationSource != null);
}
private static class GpsLocationListener implements LocationEngineListener {
@@ -580,10 +597,12 @@ public class MyLocationView extends View {
@Override
public void onConnected() {
MyLocationView locationView = userLocationView.get();
- if (locationView != null) {
- LocationEngine locationEngine = locationSource.get();
- Location location = locationEngine.getLastLocation();
- locationView.setLocation(location);
+ LocationEngine locationEngine = locationSource.get();
+ if (locationView != null && locationEngine != null) {
+ Location lastKnownLocation = locationEngine.getLastLocation();
+ if (lastKnownLocation != null) {
+ locationView.setLocation(lastKnownLocation);
+ }
locationEngine.requestLocationUpdates();
}
}
@@ -627,6 +646,9 @@ public class MyLocationView extends View {
}
public boolean isSensorAvailable() {
+ if (rotationVectorSensor == null) {
+ Timber.e("Sensor.TYPE_ROTATION_VECTOR is missing from this device. Unable to use MyBearingTracking.COMPASS.");
+ }
return rotationVectorSensor != null;
}
--
cgit v1.2.1
From fa972fad60e58e5b8f9f9622f508e9732c8c9ffd Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 9 Jun 2017 11:11:33 +0200
Subject: [android] - update components with camera values when animating
(#9174)
---
.../src/main/java/com/mapbox/mapboxsdk/maps/Transform.java | 9 +++++++++
1 file changed, 9 insertions(+)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 9a8997014a..505e440dcb 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
@@ -150,6 +150,10 @@ final class Transform implements MapView.OnMapChangedListener {
cameraChangeDispatcher.onCameraMove();
}
+ if (isComponentUpdateRequired(cameraPosition)) {
+ updateCameraPosition(cameraPosition);
+ }
+
this.cameraPosition = cameraPosition;
if (onCameraChangeListener != null) {
onCameraChangeListener.onCameraChange(this.cameraPosition);
@@ -158,6 +162,11 @@ 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();
--
cgit v1.2.1
From 6ec5e4f8cdb98227db11e5989376c31832ca2048 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 9 Jun 2017 12:05:54 +0200
Subject: Cherry picks to release branch (#9230)
* [ios][macos] test remove source in use
* [android] test remove source in use
* [core] check source usage before remove
* [core] ensure layer::accept works with non-void return values on gcc
* [android] - remove upgrade runtime exceptions (#9191)
---
.../main/java/com/mapbox/mapboxsdk/maps/MapView.java | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 d00da4c155..9a1f2fc515 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
@@ -67,8 +67,6 @@ public class MapView extends FrameLayout {
private MapboxMap mapboxMap;
private MapCallback mapCallback;
- private boolean onStartCalled;
- private boolean onStopCalled;
private MapGestureDetector mapGestureDetector;
private MapKeyListener mapKeyListener;
@@ -233,7 +231,6 @@ public class MapView extends FrameLayout {
*/
@UiThread
public void onStart() {
- onStartCalled = true;
mapboxMap.onStart();
ConnectivityReceiver.instance(getContext()).activate();
}
@@ -243,11 +240,7 @@ public class MapView extends FrameLayout {
*/
@UiThread
public void onResume() {
- if (!onStartCalled) {
- // TODO: 26/10/16, can be removed after 5.0.0 release
- throw new IllegalStateException("MapView#onStart() was not called. "
- + "You must call this method from the parent's {@link Activity#onStart()} or {@link Fragment#onStart()}.");
- }
+ // replaced by onStart in v5.0.0
}
/**
@@ -255,7 +248,7 @@ public class MapView extends FrameLayout {
*/
@UiThread
public void onPause() {
- // replaced by onStop in v5.0.0, keep around for future development
+ // replaced by onStop in v5.0.0
}
/**
@@ -263,7 +256,6 @@ public class MapView extends FrameLayout {
*/
@UiThread
public void onStop() {
- onStopCalled = true;
mapboxMap.onStop();
ConnectivityReceiver.instance(getContext()).deactivate();
}
@@ -273,12 +265,6 @@ public class MapView extends FrameLayout {
*/
@UiThread
public void onDestroy() {
- if (!onStopCalled) {
- // TODO: 26/10/16, can be removed after 5.0.0 release
- throw new IllegalStateException("MapView#onStop() was not called. "
- + "You must call this method from the parent's {@link Activity#onStop()} or {@link Fragment#onStop()}.");
- }
-
destroyed = true;
nativeMapView.terminateContext();
nativeMapView.terminateDisplay();
--
cgit v1.2.1
From 0c275ad6fa8d2c1e2523b6df7696d6fb09587411 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Tue, 13 Jun 2017 12:43:48 +0200
Subject: [android] - correct source changed map event javadoc (#9243)
---
.../src/main/java/com/mapbox/mapboxsdk/maps/MapView.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 9a1f2fc515..098c701e03 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
@@ -774,7 +774,7 @@ public class MapView extends FrameLayout {
public static final int DID_FINISH_LOADING_STYLE = 14;
/**
- * This {@link MapChange} is triggered when a source attribution changes.
+ * This {@link MapChange} is triggered when a source changes.
*
* Register to {@link MapChange} events with {@link MapView#addOnMapChangedListener(OnMapChangedListener)}.
*
--
cgit v1.2.1
From 7bfcce02662a9c429c3ac715728de63e2850231e Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Wed, 14 Jun 2017 14:34:03 +0200
Subject: Cherry pick release (#9263)
* [core] - bump earcut version dependency to handle unused lamba warning (#9242)
* [android] - snapshot bitmap contains view based content (#9252)
---
.../com/mapbox/mapboxsdk/maps/NativeMapView.java | 16 ++++++++---
.../com/mapbox/mapboxsdk/utils/BitmapUtils.java | 33 ++++++++++++++++++++++
2 files changed, 45 insertions(+), 4 deletions(-)
create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
index a31babc1c5..af3b57151d 100755
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
@@ -29,6 +29,7 @@ import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.light.Light;
import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException;
import com.mapbox.mapboxsdk.style.sources.Source;
+import com.mapbox.mapboxsdk.utils.BitmapUtils;
import com.mapbox.services.commons.geojson.Feature;
import java.nio.ByteBuffer;
@@ -39,7 +40,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import timber.log.Timber;
-
// Class that wraps the native methods for convenience
final class NativeMapView {
@@ -920,12 +920,20 @@ final class NativeMapView {
}
protected void onFpsChanged(double fps) {
+ if (isDestroyedOn("OnFpsChanged")) {
+ return;
+ }
mapView.onFpsChanged(fps);
}
- protected void onSnapshotReady(Bitmap bitmap) {
- if (snapshotReadyCallback != null && bitmap != null) {
- snapshotReadyCallback.onSnapshotReady(bitmap);
+ protected void onSnapshotReady(Bitmap mapContent) {
+ if (isDestroyedOn("OnSnapshotReady")) {
+ return;
+ }
+
+ Bitmap viewContent = BitmapUtils.createBitmapFromView(mapView);
+ if (snapshotReadyCallback != null && mapContent != null && viewContent != null) {
+ snapshotReadyCallback.onSnapshotReady(BitmapUtils.mergeBitmap(mapContent, viewContent));
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java
new file mode 100644
index 0000000000..e3fc765734
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java
@@ -0,0 +1,33 @@
+package com.mapbox.mapboxsdk.utils;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.support.annotation.NonNull;
+import android.view.View;
+
+public class BitmapUtils {
+
+ public static Bitmap createBitmapFromView(@NonNull View view) {
+ view.setDrawingCacheEnabled(true);
+ view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
+ view.buildDrawingCache();
+
+ if (view.getDrawingCache() == null) {
+ return null;
+ }
+
+ Bitmap snapshot = Bitmap.createBitmap(view.getDrawingCache());
+ view.setDrawingCacheEnabled(false);
+ view.destroyDrawingCache();
+ return snapshot;
+ }
+
+ public static Bitmap mergeBitmap(@NonNull Bitmap background, @NonNull Bitmap foreground) {
+ Bitmap result = Bitmap.createBitmap(background.getWidth(), background.getHeight(), background.getConfig());
+ Canvas canvas = new Canvas(result);
+ canvas.drawBitmap(background, 0f, 0f, null);
+ canvas.drawBitmap(foreground, 10, 10, null);
+ return result;
+ }
+
+}
--
cgit v1.2.1
From 399c0071f856ad162905f32aa6516516ee59c7b1 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Tue, 20 Jun 2017 09:17:09 +0200
Subject: Validate camera position before transforming (#9275)
* [android] - add camera position validation before transforming
* annotate CameraUpdate with nullability
---
.../main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java | 2 ++
.../src/main/java/com/mapbox/mapboxsdk/maps/Transform.java | 10 +++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java
index 7e0dbf08fb..498aa8343b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java
@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.camera;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -9,6 +10,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
*/
public interface CameraUpdate {
+ @Nullable
CameraPosition getCameraPosition(@NonNull MapboxMap mapboxMap);
}
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 505e440dcb..89fbb79504 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
@@ -93,7 +93,7 @@ final class Transform implements MapView.OnMapChangedListener {
@UiThread
final void moveCamera(MapboxMap mapboxMap, CameraUpdate update, MapboxMap.CancelableCallback callback) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
- if (!cameraPosition.equals(this.cameraPosition)) {
+ if (isValidCameraPosition(cameraPosition)) {
trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false);
cancelTransitions();
cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
@@ -109,7 +109,7 @@ final class Transform implements MapView.OnMapChangedListener {
final void easeCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, boolean easingInterpolator,
final MapboxMap.CancelableCallback callback, boolean isDismissable) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
- if (!cameraPosition.equals(this.cameraPosition)) {
+ if (isValidCameraPosition(cameraPosition)) {
trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, isDismissable);
cancelTransitions();
cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
@@ -127,7 +127,7 @@ final class Transform implements MapView.OnMapChangedListener {
final void animateCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs,
final MapboxMap.CancelableCallback callback) {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
- if (!cameraPosition.equals(this.cameraPosition)) {
+ if (isValidCameraPosition(cameraPosition)) {
trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false);
cancelTransitions();
cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
@@ -141,6 +141,10 @@ final class Transform implements MapView.OnMapChangedListener {
}
}
+ private boolean isValidCameraPosition(@Nullable CameraPosition cameraPosition) {
+ return cameraPosition != null && !cameraPosition.equals(this.cameraPosition);
+ }
+
@UiThread
@Nullable
CameraPosition invalidateCameraPosition() {
--
cgit v1.2.1
From 20cb791b4ca1b449157d8ea02f256807dd7bc9f3 Mon Sep 17 00:00:00 2001
From: Pablo Guardiola
Date: Tue, 20 Jun 2017 09:24:07 +0200
Subject: [android] fix custom marker views anchor issue (#9282)
---
.../mapboxsdk/annotations/MarkerViewManager.java | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java
index bb51f3bfc2..b9e9bea4ed 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java
@@ -10,6 +10,7 @@ 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;
@@ -33,6 +34,15 @@ import java.util.Map;
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<>();
@@ -180,14 +190,16 @@ public class MarkerViewManager implements MapView.OnMapChangedListener {
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) {
- convertView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
- if (convertView.getMeasuredWidth() != 0) {
- marker.setWidth(convertView.getMeasuredWidth());
- marker.setHeight(convertView.getMeasuredHeight());
- }
+ 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());
--
cgit v1.2.1
From 78426f1423ad3b739d7f7fa1fd7f248146281fa2 Mon Sep 17 00:00:00 2001
From: Pablo Guardiola
Date: Tue, 20 Jun 2017 10:01:02 +0200
Subject: fix trackball long press timeout calling the main thread method on a
background thread (#9305)
---
.../src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 7175242282..d1f01a30f7 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
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.maps;
import android.graphics.PointF;
import android.os.Handler;
+import android.os.Looper;
import android.support.annotation.NonNull;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -204,7 +205,7 @@ final class MapKeyListener {
currentTrackballLongPressTimeOut = null;
}
currentTrackballLongPressTimeOut = new TrackballLongPressTimeOut();
- new Handler().postDelayed(currentTrackballLongPressTimeOut,
+ new Handler(Looper.getMainLooper()).postDelayed(currentTrackballLongPressTimeOut,
ViewConfiguration.getLongPressTimeout());
return true;
--
cgit v1.2.1
From a9f52e24e63af6d322b3f4744a38aab395344b1d Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Tue, 20 Jun 2017 15:48:24 +0200
Subject: Revisit Javadoc for 5.1.0 (#9266)
* [android] - revisit public API javadoc
* [android] fix javadoc minor mistakes and typos
* grammar tweak
* add missing public javadoc
---
.../src/main/java/com/mapbox/mapboxsdk/Mapbox.java | 7 +-
.../mapbox/mapboxsdk/annotations/BubbleLayout.java | 106 +++++++++++++++
.../mapbox/mapboxsdk/annotations/IconFactory.java | 46 ++++---
.../mapboxsdk/annotations/MarkerViewManager.java | 19 ++-
.../mapbox/mapboxsdk/camera/CameraPosition.java | 60 +++++----
.../com/mapbox/mapboxsdk/camera/CameraUpdate.java | 8 +-
.../mapboxsdk/camera/CameraUpdateFactory.java | 4 +-
.../mapboxsdk/constants/MyBearingTracking.java | 14 +-
.../mapboxsdk/constants/MyLocationTracking.java | 19 ++-
.../java/com/mapbox/mapboxsdk/constants/Style.java | 1 -
.../exceptions/IconBitmapChangedException.java | 6 +-
.../exceptions/InvalidLatLngBoundsException.java | 4 +-
.../exceptions/InvalidMarkerPositionException.java | 3 +
.../exceptions/MapboxConfigurationException.java | 4 +
.../exceptions/TooManyIconsException.java | 5 +-
.../com/mapbox/mapboxsdk/geometry/ILatLng.java | 18 ++-
.../mapboxsdk/geometry/IProjectedMeters.java | 12 ++
.../java/com/mapbox/mapboxsdk/geometry/LatLng.java | 116 ++++++++++++++--
.../mapbox/mapboxsdk/geometry/LatLngBounds.java | 148 +++++++++++++-------
.../com/mapbox/mapboxsdk/geometry/LatLngSpan.java | 46 ++++++-
.../mapbox/mapboxsdk/geometry/ProjectedMeters.java | 45 ++++++-
.../mapbox/mapboxsdk/geometry/VisibleRegion.java | 31 ++++-
.../mapbox/mapboxsdk/location/LocationSource.java | 8 +-
.../java/com/mapbox/mapboxsdk/maps/MapView.java | 30 ++---
.../java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 30 +++--
.../mapbox/mapboxsdk/maps/MapboxMapOptions.java | 6 +-
.../java/com/mapbox/mapboxsdk/maps/UiSettings.java | 12 +-
.../mapboxsdk/maps/widgets/MyLocationView.java | 150 ++++++++++++++++++++-
.../maps/widgets/MyLocationViewSettings.java | 7 +-
.../mapbox/mapboxsdk/net/ConnectivityReceiver.java | 7 +-
.../mapbox/mapboxsdk/offline/OfflineManager.java | 6 +
.../mapbox/mapboxsdk/offline/OfflineRegion.java | 1 +
.../mapboxsdk/offline/OfflineRegionStatus.java | 60 ++++++++-
.../com/mapbox/mapboxsdk/storage/FileSource.java | 19 ++-
.../mapboxsdk/style/layers/PropertyValue.java | 30 +++++
.../com/mapbox/mapboxsdk/style/light/Light.java | 22 ++-
.../com/mapbox/mapboxsdk/style/light/Position.java | 4 +-
.../mapbox/mapboxsdk/style/light/light.java.ejs | 2 +-
.../com/mapbox/mapboxsdk/utils/BitmapUtils.java | 16 +++
.../com/mapbox/mapboxsdk/utils/ColorUtils.java | 10 +-
.../mapbox/mapboxsdk/utils/MapFragmentUtils.java | 13 ++
41 files changed, 940 insertions(+), 215 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
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 17cd4e0dce..6722000be7 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
@@ -1,6 +1,5 @@
package com.mapbox.mapboxsdk;
-import android.app.Application;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
@@ -17,10 +16,10 @@ import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.location.LocationEnginePriority;
/**
- * The entry point of the Mapbox Android SDK.
+ * The entry point to initialize the Mapbox Android SDK.
*
* Obtain a reference by calling {@link #getInstance(Context, String)}. Usually this class is configured in
- * {@link Application#onCreate()} and is responsible for the active access token, application context, and
+ * Application#onCreate() and is responsible for the active access token, application context, and
* connectivity state.
*
*/
@@ -97,6 +96,8 @@ public final class Mapbox {
/**
* Application context
+ *
+ * @return the application context
*/
public static Context getApplicationContext() {
return INSTANCE.context;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java
index 07e038c08c..c58cc310a8 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BubbleLayout.java
@@ -27,14 +27,32 @@ public class BubbleLayout extends LinearLayout {
private float strokeWidth;
private int strokeColor;
+ /**
+ * Creates an instance of bubble layout.
+ *
+ * @param context The context used to inflate this bubble layout
+ */
public BubbleLayout(Context context) {
this(context, null, 0);
}
+ /**
+ * Creates an instance of bubble layout.
+ *
+ * @param context The context used to inflate this bubble layout
+ * @param attrs The attribute set to initialise this bubble layout from
+ */
public BubbleLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
+ /**
+ * Creates an instance of bubble layout.
+ *
+ * @param context The context used to inflate this bubble layout
+ * @param attrs The attribute set to initialise this bubble layout from
+ * @param defStyleAttr The default style to apply this bubble layout with
+ */
public BubbleLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
@@ -78,10 +96,21 @@ public class BubbleLayout extends LinearLayout {
return dp * (metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}
+ /**
+ * Get the arrow direction.
+ *
+ * @return the arrow direction
+ */
public ArrowDirection getArrowDirection() {
return arrowDirection;
}
+ /**
+ * Set the arrow direction.
+ *
+ * @param arrowDirection The direction of the arrow
+ * @return this
+ */
public BubbleLayout setArrowDirection(ArrowDirection arrowDirection) {
resetPadding();
this.arrowDirection = arrowDirection;
@@ -89,10 +118,21 @@ public class BubbleLayout extends LinearLayout {
return this;
}
+ /**
+ * Get the arrow width.
+ *
+ * @return the width of the arrow
+ */
public float getArrowWidth() {
return arrowWidth;
}
+ /**
+ * Set the arrow width.
+ *
+ * @param arrowWidth The width of the arrow
+ * @return this
+ */
public BubbleLayout setArrowWidth(float arrowWidth) {
resetPadding();
this.arrowWidth = arrowWidth;
@@ -100,10 +140,21 @@ public class BubbleLayout extends LinearLayout {
return this;
}
+ /**
+ * Get the arrow height
+ *
+ * @return the height of the arrow
+ */
public float getArrowHeight() {
return arrowHeight;
}
+ /**
+ * Set the arrow height.
+ *
+ * @param arrowHeight The height of the arrow
+ * @return this
+ */
public BubbleLayout setArrowHeight(float arrowHeight) {
resetPadding();
this.arrowHeight = arrowHeight;
@@ -111,10 +162,21 @@ public class BubbleLayout extends LinearLayout {
return this;
}
+ /**
+ * Get the arrow position.
+ *
+ * @return the arrow position
+ */
public float getArrowPosition() {
return arrowPosition;
}
+ /**
+ * Get the arrow position.
+ *
+ * @param arrowPosition The arrow position
+ * @return this
+ */
public BubbleLayout setArrowPosition(float arrowPosition) {
resetPadding();
this.arrowPosition = arrowPosition;
@@ -122,30 +184,63 @@ public class BubbleLayout extends LinearLayout {
return this;
}
+ /**
+ * Get the corner radius
+ *
+ * @return the corner radius
+ */
public float getCornersRadius() {
return cornersRadius;
}
+ /**
+ * Set the corner radius
+ *
+ * @param cornersRadius The corner radius
+ * @return this
+ */
public BubbleLayout setCornersRadius(float cornersRadius) {
this.cornersRadius = cornersRadius;
requestLayout();
return this;
}
+ /**
+ * Get the bubble color.
+ *
+ * @return the bubble color
+ */
public int getBubbleColor() {
return bubbleColor;
}
+ /**
+ * Set the bubble color.
+ *
+ * @param bubbleColor The buble color
+ * @return this
+ */
public BubbleLayout setBubbleColor(int bubbleColor) {
this.bubbleColor = bubbleColor;
requestLayout();
return this;
}
+ /**
+ * Get stroke width.
+ *
+ * @return the stroke width
+ */
public float getStrokeWidth() {
return strokeWidth;
}
+ /**
+ * Set the stroke width.
+ *
+ * @param strokeWidth The stroke width
+ * @return this
+ */
public BubbleLayout setStrokeWidth(float strokeWidth) {
resetPadding();
this.strokeWidth = strokeWidth;
@@ -153,10 +248,21 @@ public class BubbleLayout extends LinearLayout {
return this;
}
+ /**
+ * Get the stroke color.
+ *
+ * @return the stroke color
+ */
public int getStrokeColor() {
return strokeColor;
}
+ /**
+ * Set the stroke color.
+ *
+ * @param strokeColor The stroke color
+ * @return this
+ */
public BubbleLayout setStrokeColor(int strokeColor) {
this.strokeColor = strokeColor;
requestLayout();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java
index 57aa512401..f9ca9bf4cc 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java
@@ -23,7 +23,7 @@ import java.io.InputStream;
/**
* Factory for creating Icons from bitmap images.
*
- * {@link Icon} is used to display bitmaps on top of the map using {@link Marker} and {@link MarkerView}.
+ * icon is used to display bitmaps on top of the map using {@link Marker} and {@link MarkerView}.
*
*
* @see Icon
@@ -42,6 +42,12 @@ public final class IconFactory {
private int nextId = 0;
+ /**
+ * Get a single instance of IconFactory.
+ *
+ * @param context the context to derive the application context from
+ * @return the single instance of IconFactory
+ */
public static synchronized IconFactory getInstance(@NonNull Context context) {
if (instance == null) {
instance = new IconFactory(context.getApplicationContext());
@@ -71,10 +77,10 @@ public final class IconFactory {
}
/**
- * Creates an {@link Icon} from a given Bitmap image.
+ * Creates an icon from a given Bitmap image.
*
* @param bitmap image used for creating the Icon.
- * @return The {@link Icon} using the given Bitmap image.
+ * @return The icon using the given Bitmap image.
*/
public Icon fromBitmap(@NonNull Bitmap bitmap) {
if (nextId < 0) {
@@ -85,10 +91,10 @@ public final class IconFactory {
}
/**
- * Create an {@link Icon} using the resource ID of a Bitmap image.
+ * Creates an icon using the resource ID of a Bitmap image.
*
* @param resourceId The resource ID of a Bitmap image.
- * @return The {@link Icon} that was loaded from the asset or {@code null} if failed to load.
+ * @return The icon that was loaded from the asset or {@code null} if failed to load.
*/
public Icon fromResource(@DrawableRes int resourceId) {
Drawable drawable = ContextCompat.getDrawable(context, resourceId);
@@ -101,9 +107,9 @@ public final class IconFactory {
}
/**
- * Provides an {@link Icon} using the default marker icon used for {@link Marker}.
+ * Provides an icon using the default marker icon used for {@link Marker}.
*
- * @return An {@link Icon} with the default {@link Marker} icon.
+ * @return An icon with the default {@link Marker} icon.
*/
public Icon defaultMarker() {
if (defaultMarker == null) {
@@ -113,9 +119,9 @@ public final class IconFactory {
}
/**
- * Provides an {@link Icon} using the default marker icon used for {@link MarkerView}.
+ * Provides an icon using the default marker icon used for {@link MarkerView}.
*
- * @return An {@link Icon} with the default {@link MarkerView} icon.
+ * @return An icon with the default {@link MarkerView} icon.
*/
public Icon defaultMarkerView() {
if (defaultMarkerView == null) {
@@ -130,10 +136,10 @@ public final class IconFactory {
}
/**
- * Creates an {@link Icon} using the name of a Bitmap image in the assets directory.
+ * Creates an Icon using the name of a Bitmap image in the assets directory.
*
* @param assetName The name of a Bitmap image in the assets directory.
- * @return The {@link Icon} that was loaded from the asset or {@code null} if failed to load.
+ * @return The Icon that was loaded from the asset or null if failed to load.
*/
public Icon fromAsset(@NonNull String assetName) {
InputStream is;
@@ -146,11 +152,10 @@ public final class IconFactory {
}
/**
- * Creates an {@link Icon} using the absolute file path of a Bitmap image.
+ * Creates an Icon using the absolute file path of a Bitmap image.
*
* @param absolutePath The absolute path of the Bitmap image.
- * @return The {@link Icon} that was loaded from the absolute path or {@code null} if failed to
- * load.
+ * @return The Icon that was loaded from the absolute path or null if failed to load.
*/
public Icon fromPath(@NonNull String absolutePath) {
Bitmap bitmap = BitmapFactory.decodeFile(absolutePath, options);
@@ -158,11 +163,11 @@ public final class IconFactory {
}
/**
- * Create an {@link Icon} using the name of a Bitmap image file located in the internal storage.
- * In particular, this calls {@link Context#openFileInput(String)}.
+ * Create an Icon using the name of a Bitmap image file located in the internal storage.
+ * In particular, this calls Context#openFileInput(String).
*
* @param fileName The name of the Bitmap image file.
- * @return The {@link Icon} that was loaded from the asset or {@code null} if failed to load.
+ * @return The Icon that was loaded from the asset or null if failed to load.
* @see
* Using the Internal Storage
*/
@@ -177,12 +182,11 @@ public final class IconFactory {
}
/**
- * Create an {@link Icon} using a previously created icon identifier along with a provided
- * Bitmap.
+ * Create an Icon using a previously created icon identifier along with a provided Bitmap.
*
- * @param iconId The {@link Icon} identifier you'd like to recreate.
+ * @param iconId The Icon identifier you'd like to recreate.
* @param bitmap a Bitmap used to replace the current one.
- * @return The {@link Icon} using the new Bitmap.
+ * @return The Icon using the new Bitmap.
*/
public static Icon recreate(@NonNull String iconId, @NonNull Bitmap bitmap) {
return new Icon(iconId, bitmap);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java
index b9e9bea4ed..6d42842b7d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java
@@ -135,6 +135,12 @@ public class MarkerViewManager implements MapView.OnMapChangedListener {
}
}
+ /**
+ * 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) {
@@ -544,10 +550,11 @@ public class MarkerViewManager implements MapView.OnMapChangedListener {
}
/**
- * When the provided {@link MarkerView} is clicked on by a user, we check if a custom click
- * event has been created and if not, display a {@link InfoWindow}.
+ * 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.
+ * @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;
@@ -572,9 +579,9 @@ public class MarkerViewManager implements MapView.OnMapChangedListener {
}
/**
- * Handles the {@link MarkerView}'s info window offset.
+ * Handles the MarkerView info window offset.
*
- * @param marker that we are ensuring info window offset.
+ * @param marker that we are ensuring info window offset
*/
public void ensureInfoWindowOffset(MarkerView marker) {
View view = null;
@@ -624,7 +631,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener {
}
/**
- * Default MarkerViewAdapter used for base class of {@link MarkerView} to adapt a MarkerView to
+ * Default MarkerViewAdapter used for base class of MarkerView to adapt a MarkerView to
* an ImageView.
*/
private static class ImageMarkerViewAdapter extends MapboxMap.MarkerViewAdapter {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java
index 66c261f1d0..c2f19072db 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.camera;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
+import android.support.annotation.FloatRange;
import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
@@ -166,14 +167,14 @@ public final class CameraPosition implements Parcelable {
private double zoom = -1;
/**
- * Creates an empty builder.
+ * Create an empty builder.
*/
public Builder() {
super();
}
/**
- * Create Builder with an existing CameraPosition data.
+ * Create a builder with an existing CameraPosition data.
*
* @param previous Existing CameraPosition values to use
*/
@@ -188,7 +189,7 @@ public final class CameraPosition implements Parcelable {
}
/**
- * Create Builder with an existing CameraPosition data.
+ * Create a builder with an existing CameraPosition data.
*
* @param typedArray TypedArray containing attribute values
*/
@@ -205,7 +206,7 @@ public final class CameraPosition implements Parcelable {
}
/**
- * Create Builder from an existing CameraPositionUpdate update.
+ * Create a builder from an existing CameraPositionUpdate update.
*
* @param update Update containing camera options
*/
@@ -220,7 +221,7 @@ public final class CameraPosition implements Parcelable {
}
/**
- * Create Builder from an existing CameraPositionUpdate update.
+ * Create builder from an existing CameraPositionUpdate update.
*
* @param update Update containing camera options
*/
@@ -235,7 +236,7 @@ public final class CameraPosition implements Parcelable {
* Sets the direction that the camera is pointing in, in degrees clockwise from north.
*
* @param bearing Bearing
- * @return Builder
+ * @return this
*/
public Builder bearing(double bearing) {
double direction = bearing;
@@ -252,19 +253,10 @@ public final class CameraPosition implements Parcelable {
}
/**
- * Builds a CameraPosition.
+ * Sets the location where the camera is pointing at.
*
- * @return CameraPosition
- */
- public CameraPosition build() {
- return new CameraPosition(target, zoom, tilt, bearing);
- }
-
- /**
- * Sets the location that the camera is pointing at.
- *
- * @param location Location
- * @return Builder
+ * @param location target of the camera
+ * @return this
*/
public Builder target(LatLng location) {
this.target = location;
@@ -272,28 +264,42 @@ public final class CameraPosition implements Parcelable {
}
/**
- * Set the tilt in degrees
+ * Set the tilt of the camera in degrees
*
- * value is clamped to 0 and 60.
+ * value is clamped to {@link MapboxConstants#MINIMUM_TILT} and {@link MapboxConstants#MAXIMUM_TILT}.
*
*
- * @param tilt Tilt value
- * @return Builder
+ * @param tilt Tilt value of the camera
+ * @return this
*/
- public Builder tilt(double tilt) {
+ public Builder tilt(@FloatRange(from = MapboxConstants.MINIMUM_TILT,
+ to = MapboxConstants.MAXIMUM_TILT) double tilt) {
this.tilt = MathUtils.clamp(tilt, MapboxConstants.MINIMUM_TILT, MapboxConstants.MAXIMUM_TILT);
return this;
}
/**
- * Set the zoom
+ * Set the zoom of the camera
+ *
+ * Zoom ranges from {@link MapboxConstants#MINIMUM_ZOOM} to {@link MapboxConstants#MAXIMUM_ZOOM}
+ *
*
- * @param zoom Zoom value
- * @return Builder
+ * @param zoom Zoom value of the camera
+ * @return this
*/
- public Builder zoom(double zoom) {
+ public Builder zoom(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
+ to = MapboxConstants.MAXIMUM_ZOOM) double zoom) {
this.zoom = zoom;
return this;
}
+
+ /**
+ * Builds the CameraPosition.
+ *
+ * @return CameraPosition
+ */
+ public CameraPosition build() {
+ return new CameraPosition(target, zoom, tilt, bearing);
+ }
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java
index 498aa8343b..31f13cbcff 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java
@@ -6,10 +6,16 @@ import android.support.annotation.Nullable;
import com.mapbox.mapboxsdk.maps.MapboxMap;
/**
- * Interface definition for camera position changes.
+ * Interface definition for camera updates.
*/
public interface CameraUpdate {
+ /**
+ * Get the camera position from the camera update.
+ *
+ * @param mapboxMap Map object to build the position from
+ * @return the camera position from the implementing camera update
+ */
@Nullable
CameraPosition getCameraPosition(@NonNull MapboxMap mapboxMap);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java
index 8e1411e273..50e33f4f9f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdateFactory.java
@@ -42,7 +42,7 @@ public final class CameraUpdateFactory {
}
/**
- * Returns a {@link CameraUpdate} that transforms the camera such that the specified
+ * Returns a CameraUpdate that transforms the camera such that the specified
* latitude/longitude bounds are centered on screen at the greatest possible zoom level.
* You can specify padding, in order to inset the bounding box from the map view's edges.
* The returned CameraUpdate has a bearing of 0 and a tilt of 0.
@@ -56,7 +56,7 @@ public final class CameraUpdateFactory {
}
/**
- * Returns a {@link CameraUpdate} that transforms the camera such that the specified
+ * Returns a CameraUpdate that transforms the camera such that the specified
* latitude/longitude bounds are centered on screen at the greatest possible zoom level.
* You can specify padding, in order to inset the bounding box from the map view's edges.
* The returned CameraUpdate has a bearing of 0 and a tilt of 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
index 88c3bef673..ceac862f39 100644
--- 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
@@ -2,23 +2,27 @@ 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 bearing tracking modes.
+ * 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 {
- /**
- * Indicates that the parameter accepts one of the values from MyBearingTracking.
- */
- @IntDef( {NONE, COMPASS, GPS, /**COMBINED**/})
+ @IntDef( {NONE, COMPASS, GPS})
@Retention(RetentionPolicy.SOURCE)
public @interface Mode {
}
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
index a1744d701f..1283283fa5 100644
--- 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
@@ -3,29 +3,34 @@ 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 different types of locational tracking modes.
+ * 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 com.mapbox.mapboxsdk.maps.TrackingSettings#setMyLocationTrackingMode(int)
- * @see MyLocationView#setMyLocationTrackingMode(int)
+ * @see MapboxMap#setMyLocationEnabled(boolean)
+ * @see TrackingSettings#setMyLocationTrackingMode(int)
*/
public class MyLocationTracking {
- /**
- * Indicates the parameter accepts one of the values from MyLocationTracking.
- */
@IntDef( {TRACKING_NONE, TRACKING_FOLLOW})
@Retention(RetentionPolicy.SOURCE)
public @interface Mode {
}
/**
- * Location tracking is disabled.
+ * Tracking the location of the user is disabled.
*/
public static final int TRACKING_NONE = 0x00000000;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
index 31e6313509..9943a72e06 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java
@@ -17,7 +17,6 @@ import java.lang.annotation.RetentionPolicy;
*/
public class Style {
-
/**
* Indicates the parameter accepts one of the values from Style. Using one of these
* constants means your map style will always use the latest version and may change as we
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/IconBitmapChangedException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/IconBitmapChangedException.java
index 7154049bd7..1f6b0efc4d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/IconBitmapChangedException.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/IconBitmapChangedException.java
@@ -1,15 +1,13 @@
package com.mapbox.mapboxsdk.exceptions;
-import android.graphics.Bitmap;
-
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.maps.MapView;
/**
*
- * A {@code IconBitmapChangedException} is thrown by {@link MapView} when a {@link Marker} is added
- * that has a {@link Icon} with a {@link Bitmap} that has been modified since the creation of the Icon.
+ * An IconBitmapChangedException is thrown by MapView when a Marker is added
+ * that has an Icon with a Bitmap that has been modified since the creation of the Icon.
*
* You cannot modify a {@code Icon} after it has been added to the map in a {@code Marker}
*
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidLatLngBoundsException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidLatLngBoundsException.java
index 08a23a7373..c1d0385815 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidLatLngBoundsException.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidLatLngBoundsException.java
@@ -1,8 +1,8 @@
package com.mapbox.mapboxsdk.exceptions;
/**
- * A InvalidLatLngBoundsException is thrown by {@link com.mapbox.mapboxsdk.geometry.LatLngBounds}
- * when there aren't enough {@link com.mapbox.mapboxsdk.geometry.LatLng} to create a bounds.
+ * An InvalidLatLngBoundsException is thrown by LatLngBounds
+ * when there aren't enough LatLng to create a bounds.
*/
public class InvalidLatLngBoundsException extends RuntimeException {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java
index f0f9b9236b..44ee83265d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/InvalidMarkerPositionException.java
@@ -5,6 +5,9 @@ package com.mapbox.mapboxsdk.exceptions;
*/
public class InvalidMarkerPositionException extends RuntimeException {
+ /**
+ * Creates a invalid marker position exception thrown when a Marker object is created with an invalid LatLng position.
+ */
public InvalidMarkerPositionException() {
super("Adding an invalid Marker to a Map. "
+ "Missing the required position field. "
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/MapboxConfigurationException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/MapboxConfigurationException.java
index 74bceb196c..e9a0261d85 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/MapboxConfigurationException.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/MapboxConfigurationException.java
@@ -8,10 +8,14 @@ import android.content.Context;
* This occurs either when {@link com.mapbox.mapboxsdk.Mapbox} is not correctly initialised or the provided access token
* through {@link com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String)} isn't valid.
*
+ *
* @see com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String)
*/
public class MapboxConfigurationException extends RuntimeException {
+ /**
+ * Creates a Mapbox configuration exception thrown by MapboxMap when the SDK hasn't been properly initialised.
+ */
public MapboxConfigurationException() {
super("\nUsing MapView requires setting a valid access token. Use Mapbox.getInstance(Context context, "
+ "String accessToken) to provide one. "
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/TooManyIconsException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/TooManyIconsException.java
index 8923d822f2..bffc10dc04 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/TooManyIconsException.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/exceptions/TooManyIconsException.java
@@ -1,12 +1,11 @@
package com.mapbox.mapboxsdk.exceptions;
-import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
/**
*
- * A {@code TooManyIconsException} is thrown by {@link IconFactory} when it
- * cannot create a {@link Icon} because there are already too many icons created.
+ * A TooManyIconsException is thrown by IconFactory when it
+ * cannot create a Icon because there are already too many icons created.
*
* You should try to reuse Icon objects whenever possible.
*
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java
index 1af8e7cfc7..07df87af3a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java
@@ -1,12 +1,28 @@
package com.mapbox.mapboxsdk.geometry;
/**
- * Describes a latitude, longitude point.
+ * Describes a latitude, longitude, and altitude tuple.
*/
public interface ILatLng {
+
+ /**
+ * Get the latitude, in degrees.
+ *
+ * @return the latitude value in degrees
+ */
double getLatitude();
+ /**
+ * Get the longitude, in degrees.
+ *
+ * @return the longitude value in degrees
+ */
double getLongitude();
+ /**
+ * Get the altitude, in meters.
+ *
+ * @return the altitude value in meters
+ */
double getAltitude();
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java
index 694c935143..db459d7cbb 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java
@@ -4,7 +4,19 @@ package com.mapbox.mapboxsdk.geometry;
* Describes a projection in Mercator meters.
*/
public interface IProjectedMeters {
+
+ /**
+ * Get the north projection, in meters.
+ *
+ * @return the projected meters in north direction
+ */
double getNorthing();
+ /**
+ * Get the east projection, in meters.
+ *
+ * @return the projected meters in east direction
+ */
double getEasting();
+
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java
index ca2d3673b2..eb57241196 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.geometry;
import android.location.Location;
import android.os.Parcel;
import android.os.Parcelable;
+import android.support.annotation.FloatRange;
import com.mapbox.services.android.telemetry.constants.GeoConstants;
import com.mapbox.services.android.telemetry.utils.MathUtils;
@@ -21,6 +22,9 @@ import com.mapbox.services.android.telemetry.utils.MathUtils;
*/
public class LatLng implements ILatLng, Parcelable {
+ /**
+ * Inner class responsible for recreating Parcels into objects.
+ */
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public LatLng createFromParcel(Parcel in) {
return new LatLng(in);
@@ -44,7 +48,7 @@ public class LatLng implements ILatLng, Parcelable {
}
/**
- * Construct a new latitude, longitude point given float arguments
+ * Construct a new latitude, longitude point given double arguments
*
* @param latitude Latitude in degrees
* @param longitude Longitude in degrees
@@ -55,7 +59,7 @@ public class LatLng implements ILatLng, Parcelable {
}
/**
- * Construct a new latitude, longitude, altitude point given float arguments
+ * Construct a new latitude, longitude, altitude point given double arguments
*
* @param latitude Latitude in degrees
* @param longitude Longitude in degress
@@ -68,7 +72,7 @@ public class LatLng implements ILatLng, Parcelable {
}
/**
- * Transform a Location into a LatLng point
+ * Construct a new latitude, longitude, altitude point given location argument
*
* @param location Android Location
*/
@@ -77,23 +81,40 @@ public class LatLng implements ILatLng, Parcelable {
}
/**
- * Clone an existing latitude longitude point
+ * Construct a new latitude, longitude, altitude point given another latitude, longitude, altitude point.
*
- * @param aLatLng LatLng
+ * @param latLng LatLng to be cloned.
*/
- public LatLng(LatLng aLatLng) {
- this.latitude = aLatLng.latitude;
- this.longitude = aLatLng.longitude;
- this.altitude = aLatLng.altitude;
+ public LatLng(LatLng latLng) {
+ this.latitude = latLng.latitude;
+ this.longitude = latLng.longitude;
+ this.altitude = latLng.altitude;
}
+ /**
+ * Constructs a new latitude, longitude, altitude tuple given a parcel.
+ *
+ * @param in the parcel containing the latitude, longitude, altitude values
+ */
protected LatLng(Parcel in) {
setLatitude(in.readDouble());
setLongitude(in.readDouble());
setAltitude(in.readDouble());
}
- public void setLatitude(double latitude) {
+ /**
+ * Set the latitude, in degrees.
+ *
+ * This value is in the range of [-85.05112878, 85.05112878], see {@link GeoConstants#MIN_LATITUDE} and
+ * {@link GeoConstants#MAX_LATITUDE}
+ *
+ *
+ * @param latitude the latitude value in degrees
+ * @see GeoConstants#MIN_LATITUDE
+ * @see GeoConstants#MAX_LATITUDE
+ */
+ public void setLatitude(
+ @FloatRange(from = GeoConstants.MIN_LATITUDE, to = GeoConstants.MAX_LATITUDE) double latitude) {
if (Double.isNaN(latitude)) {
throw new IllegalArgumentException("latitude must not be NaN");
}
@@ -103,12 +124,35 @@ public class LatLng implements ILatLng, Parcelable {
this.latitude = latitude;
}
+ /**
+ * Get the latitude, in degrees.
+ *
+ * This value is in the range of [-85.05112878, 85.05112878], see {@link GeoConstants#MIN_LATITUDE} and
+ * {@link GeoConstants#MAX_LATITUDE}
+ *
+ *
+ * @return the latitude value in degrees
+ * @see GeoConstants#MIN_LATITUDE
+ * @see GeoConstants#MAX_LATITUDE
+ */
@Override
public double getLatitude() {
return latitude;
}
- public void setLongitude(double longitude) {
+ /**
+ * Set the longitude, in degrees.
+ *
+ * This value is in the range of [-180, 180], see {@link GeoConstants#MIN_LONGITUDE} and
+ * {@link GeoConstants#MAX_LONGITUDE}
+ *
+ *
+ * @param longitude the longitude value in degrees
+ * @see GeoConstants#MIN_LONGITUDE
+ * @see GeoConstants#MAX_LONGITUDE
+ */
+ public void setLongitude(@FloatRange(from = GeoConstants.MIN_LONGITUDE, to = GeoConstants.MAX_LONGITUDE)
+ double longitude) {
if (Double.isNaN(longitude)) {
throw new IllegalArgumentException("longitude must not be NaN");
}
@@ -118,15 +162,36 @@ public class LatLng implements ILatLng, Parcelable {
this.longitude = longitude;
}
+ /**
+ * Get the longitude, in degrees.
+ *
+ * This value is in the range of [-180, 180], see {@link GeoConstants#MIN_LONGITUDE} and
+ * {@link GeoConstants#MAX_LONGITUDE}
+ *
+ *
+ * @return the longitude value in degrees
+ * @see GeoConstants#MIN_LONGITUDE
+ * @see GeoConstants#MAX_LONGITUDE
+ */
@Override
public double getLongitude() {
return longitude;
}
+ /**
+ * Set the altitude, in meters.
+ *
+ * @param altitude the altitude in meters
+ */
public void setAltitude(double altitude) {
this.altitude = altitude;
}
+ /**
+ * Get the altitude, in meters.
+ *
+ * @return the altitude value in meters
+ */
@Override
public double getAltitude() {
return altitude;
@@ -136,13 +201,19 @@ public class LatLng implements ILatLng, Parcelable {
* Return a new LatLng object with a wrapped Longitude. This allows original data object
* to remain unchanged.
*
- * @return New LatLng object with wrapped Longitude
+ * @return new LatLng object with wrapped Longitude
*/
public LatLng wrap() {
longitude = MathUtils.wrap(longitude, GeoConstants.MIN_LONGITUDE, GeoConstants.MAX_LONGITUDE);
return this;
}
+ /**
+ * Indicates whether some other object is "equal to" this one.
+ *
+ * @param object The object to compare
+ * @return True if equal, false if not
+ */
@Override
public boolean equals(Object object) {
if (this == object) {
@@ -158,6 +229,11 @@ public class LatLng implements ILatLng, Parcelable {
&& Double.compare(latLng.longitude, longitude) == 0;
}
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return the hash code value
+ */
@Override
public int hashCode() {
int result;
@@ -171,16 +247,32 @@ public class LatLng implements ILatLng, Parcelable {
return result;
}
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return the string representation
+ */
@Override
public String toString() {
return "LatLng [latitude=" + latitude + ", longitude=" + longitude + ", altitude=" + altitude + "]";
}
+ /**
+ * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
+ *
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
@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
+ */
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeDouble(latitude);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java
index 4a4e2a30aa..505b2db192 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.geometry;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException;
import com.mapbox.services.android.telemetry.constants.GeoConstants;
@@ -18,10 +19,10 @@ import java.util.List;
*/
public class LatLngBounds implements Parcelable {
- private final double mLatNorth;
- private final double mLatSouth;
- private final double mLonEast;
- private final double mLonWest;
+ private final double latitudeNorth;
+ private final double latitudeSouth;
+ private final double longitudeEast;
+ private final double longitudeWest;
/**
* Construct a new LatLngBounds based on its corners, given in NESW
@@ -34,10 +35,10 @@ public class LatLngBounds implements Parcelable {
*/
LatLngBounds(final double northLatitude, final double eastLongitude, final double southLatitude,
final double westLongitude) {
- this.mLatNorth = northLatitude;
- this.mLonEast = eastLongitude;
- this.mLatSouth = southLatitude;
- this.mLonWest = westLongitude;
+ this.latitudeNorth = northLatitude;
+ this.longitudeEast = eastLongitude;
+ this.latitudeSouth = southLatitude;
+ this.longitudeWest = westLongitude;
}
/**
@@ -59,8 +60,8 @@ public class LatLngBounds implements Parcelable {
* @return LatLng center of this LatLngBounds
*/
public LatLng getCenter() {
- return new LatLng((this.mLatNorth + this.mLatSouth) / 2,
- (this.mLonEast + this.mLonWest) / 2);
+ return new LatLng((this.latitudeNorth + this.latitudeSouth) / 2,
+ (this.longitudeEast + this.longitudeWest) / 2);
}
/**
@@ -69,7 +70,7 @@ public class LatLngBounds implements Parcelable {
* @return double latitude value for north
*/
public double getLatNorth() {
- return this.mLatNorth;
+ return this.latitudeNorth;
}
/**
@@ -78,7 +79,7 @@ public class LatLngBounds implements Parcelable {
* @return double latitude value for south
*/
public double getLatSouth() {
- return this.mLatSouth;
+ return this.latitudeSouth;
}
/**
@@ -87,7 +88,7 @@ public class LatLngBounds implements Parcelable {
* @return double longitude value for east
*/
public double getLonEast() {
- return this.mLonEast;
+ return this.longitudeEast;
}
/**
@@ -96,7 +97,7 @@ public class LatLngBounds implements Parcelable {
* @return double longitude value for west
*/
public double getLonWest() {
- return this.mLonWest;
+ return this.longitudeWest;
}
/**
@@ -105,7 +106,7 @@ public class LatLngBounds implements Parcelable {
* @return LatLng of the south west corner
*/
public LatLng getSouthWest() {
- return new LatLng(mLatSouth, mLonWest);
+ return new LatLng(latitudeSouth, longitudeWest);
}
/**
@@ -114,7 +115,7 @@ public class LatLngBounds implements Parcelable {
* @return LatLng of the north east corner
*/
public LatLng getNorthEast() {
- return new LatLng(mLatNorth, mLonEast);
+ return new LatLng(latitudeNorth, longitudeEast);
}
/**
@@ -123,7 +124,7 @@ public class LatLngBounds implements Parcelable {
* @return LatLng of the south east corner
*/
public LatLng getSouthEast() {
- return new LatLng(mLatSouth, mLonEast);
+ return new LatLng(latitudeSouth, longitudeEast);
}
/**
@@ -132,7 +133,7 @@ public class LatLngBounds implements Parcelable {
* @return LatLng of the north west corner
*/
public LatLng getNorthWest() {
- return new LatLng(mLatNorth, mLonWest);
+ return new LatLng(latitudeNorth, longitudeWest);
}
/**
@@ -151,7 +152,7 @@ public class LatLngBounds implements Parcelable {
* @return Span distance
*/
public double getLatitudeSpan() {
- return Math.abs(this.mLatNorth - this.mLatSouth);
+ return Math.abs(this.latitudeNorth - this.latitudeSouth);
}
/**
@@ -161,7 +162,7 @@ public class LatLngBounds implements Parcelable {
* @return Span distance
*/
public double getLongitudeSpan() {
- return Math.abs(this.mLonEast - this.mLonWest);
+ return Math.abs(this.longitudeEast - this.longitudeWest);
}
@@ -174,9 +175,15 @@ public class LatLngBounds implements Parcelable {
return getLongitudeSpan() == 0.0 || getLatitudeSpan() == 0.0;
}
+ /**
+ * Returns a string representaton of the object.
+ *
+ * @return the string representation
+ */
@Override
public String toString() {
- return "N:" + this.mLatNorth + "; E:" + this.mLonEast + "; S:" + this.mLatSouth + "; W:" + this.mLonWest;
+ return "N:" + this.latitudeNorth + "; E:" + this.longitudeEast + "; S:" + this.latitudeSouth
+ + "; W:" + this.longitudeWest;
}
/**
@@ -241,10 +248,10 @@ public class LatLngBounds implements Parcelable {
}
if (o instanceof LatLngBounds) {
LatLngBounds other = (LatLngBounds) o;
- return mLatNorth == other.getLatNorth()
- && mLatSouth == other.getLatSouth()
- && mLonEast == other.getLonEast()
- && mLonWest == other.getLonWest();
+ return latitudeNorth == other.getLatNorth()
+ && latitudeSouth == other.getLatSouth()
+ && longitudeEast == other.getLonEast()
+ && longitudeWest == other.getLonWest();
}
return false;
}
@@ -258,10 +265,10 @@ public class LatLngBounds implements Parcelable {
public boolean contains(final ILatLng latLng) {
final double latitude = latLng.getLatitude();
final double longitude = latLng.getLongitude();
- return ((latitude <= this.mLatNorth)
- && (latitude >= this.mLatSouth))
- && ((longitude <= this.mLonEast)
- && (longitude >= this.mLonWest));
+ return ((latitude <= this.latitudeNorth)
+ && (latitude >= this.latitudeSouth))
+ && ((longitude <= this.longitudeEast)
+ && (longitude >= this.longitudeWest));
}
/**
@@ -295,10 +302,10 @@ public class LatLngBounds implements Parcelable {
* @return BoundingBox
*/
public LatLngBounds union(final double lonNorth, final double latEast, final double lonSouth, final double latWest) {
- return new LatLngBounds((this.mLatNorth < lonNorth) ? lonNorth : this.mLatNorth,
- (this.mLonEast < latEast) ? latEast : this.mLonEast,
- (this.mLatSouth > lonSouth) ? lonSouth : this.mLatSouth,
- (this.mLonWest > latWest) ? latWest : this.mLonWest);
+ return new LatLngBounds((this.latitudeNorth < lonNorth) ? lonNorth : this.latitudeNorth,
+ (this.longitudeEast < latEast) ? latEast : this.longitudeEast,
+ (this.latitudeSouth > lonSouth) ? lonSouth : this.latitudeSouth,
+ (this.longitudeWest > latWest) ? latWest : this.longitudeWest);
}
/**
@@ -307,6 +314,7 @@ public class LatLngBounds implements Parcelable {
* @param box LatLngBounds to intersect with
* @return LatLngBounds
*/
+ @Nullable
public LatLngBounds intersect(LatLngBounds box) {
double minLatWest = Math.max(getLonWest(), box.getLonWest());
double maxLatEast = Math.min(getLonEast(), box.getLonEast());
@@ -334,6 +342,9 @@ public class LatLngBounds implements Parcelable {
return intersect(new LatLngBounds(northLatitude, eastLongitude, southLatitude, westLongitude));
}
+ /**
+ * Inner class responsible for recreating Parcels into objects.
+ */
public static final Parcelable.Creator CREATOR =
new Parcelable.Creator() {
@Override
@@ -347,25 +358,41 @@ public class LatLngBounds implements Parcelable {
}
};
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return the hash code
+ */
@Override
public int hashCode() {
- return (int) ((mLatNorth + 90)
- + ((mLatSouth + 90) * 1000)
- + ((mLonEast + 180) * 1000000)
- + ((mLonEast + 180) * 1000000000));
+ return (int) ((latitudeNorth + 90)
+ + ((latitudeSouth + 90) * 1000)
+ + ((longitudeEast + 180) * 1000000)
+ + ((longitudeEast + 180) * 1000000000));
}
+ /**
+ * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
+ *
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
@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
+ */
@Override
- public void writeToParcel(final Parcel out, final int arg1) {
- out.writeDouble(this.mLatNorth);
- out.writeDouble(this.mLonEast);
- out.writeDouble(this.mLatSouth);
- out.writeDouble(this.mLonWest);
+ public void writeToParcel(final Parcel out, final int flags) {
+ out.writeDouble(this.latitudeNorth);
+ out.writeDouble(this.longitudeEast);
+ out.writeDouble(this.latitudeSouth);
+ out.writeDouble(this.longitudeWest);
}
private static LatLngBounds readFromParcel(final Parcel in) {
@@ -381,28 +408,51 @@ public class LatLngBounds implements Parcelable {
*/
public static final class Builder {
- private List mLatLngList;
+ private List latLngList;
+ /**
+ * Constructs a builder to compose LatLng objects to a LatLngBounds.
+ */
public Builder() {
- mLatLngList = new ArrayList<>();
+ latLngList = new ArrayList<>();
}
+ /**
+ * Builds a new LatLngBounds.
+ *
+ * Throws an {@link InvalidLatLngBoundsException} when no LatLngBounds can be created.
+ *
+ *
+ * @return the build LatLngBounds
+ */
public LatLngBounds build() {
- if (mLatLngList.size() < 2) {
- throw new InvalidLatLngBoundsException(mLatLngList.size());
+ if (latLngList.size() < 2) {
+ throw new InvalidLatLngBoundsException(latLngList.size());
}
- return LatLngBounds.fromLatLngs(mLatLngList);
+ return LatLngBounds.fromLatLngs(latLngList);
}
+ /**
+ * Adds a LatLng object to the LatLngBounds.Builder.
+ *
+ * @param latLngs the List of LatLng objects to be added
+ * @return this
+ */
public Builder includes(List latLngs) {
for (LatLng point : latLngs) {
- mLatLngList.add(point);
+ latLngList.add(point);
}
return this;
}
+ /**
+ * Adds a LatLng object to the LatLngBounds.Builder.
+ *
+ * @param latLng the LatLng to be added
+ * @return this
+ */
public Builder include(@NonNull LatLng latLng) {
- mLatLngList.add(latLng);
+ latLngList.add(latLng);
return this;
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java
index d00ccdb9b8..322c7dfb74 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java
@@ -64,19 +64,28 @@ public class LatLngSpan implements Parcelable {
mLongitudeSpan = longitudeSpan;
}
+ /**
+ * Indicates whether some other object is "equal to" this one.
+ *
+ * @param object The object to compare
+ * @return True if equal, false if not
+ */
@Override
- public boolean equals(Object o) {
- if (this == o) {
+ public boolean equals(Object object) {
+ if (this == object) {
return true;
}
- if (o instanceof LatLngSpan) {
- LatLngSpan other = (LatLngSpan) o;
+ if (object instanceof LatLngSpan) {
+ LatLngSpan other = (LatLngSpan) object;
return mLongitudeSpan == other.getLongitudeSpan()
&& mLatitudeSpan == other.getLatitudeSpan();
}
return false;
}
+ /**
+ * Inner class responsible for recreating Parcels into objects.
+ */
public static final Parcelable.Creator CREATOR =
new Parcelable.Creator() {
@Override
@@ -90,14 +99,41 @@ public class LatLngSpan implements Parcelable {
}
};
+ /**
+ * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
+ *
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
@Override
public int describeContents() {
return 0;
}
+ /**
+ * Flatten this object in to a Parcel.
+ *
+ * @param out Parcel in which the object should be written
+ * @param flags Additional flags about how the object should be written
+ */
@Override
- public void writeToParcel(Parcel out, int arg1) {
+ public void writeToParcel(Parcel out, int flags) {
out.writeDouble(mLatitudeSpan);
out.writeDouble(mLongitudeSpan);
}
+
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return hash code value of this
+ */
+ @Override
+ public int hashCode() {
+ int result;
+ long temp;
+ temp = Double.doubleToLongBits(mLatitudeSpan);
+ result = (int) (temp ^ (temp >>> 32));
+ temp = Double.doubleToLongBits(mLongitudeSpan);
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
+ return result;
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java
index 761d8f2a8b..fa84c33b2b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java
@@ -13,6 +13,9 @@ import android.os.Parcelable;
*/
public class ProjectedMeters implements IProjectedMeters, Parcelable {
+ /**
+ * Inner class responsible for recreating Parcels into objects.
+ */
public static final Creator CREATOR = new Creator() {
public ProjectedMeters createFromParcel(Parcel in) {
return new ProjectedMeters(in);
@@ -47,6 +50,12 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable {
this.easting = projectedMeters.easting;
}
+ /**
+ * Creates a ProjectedMeters from a Parcel.
+ *
+ * @param in The parcel to create from
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
private ProjectedMeters(Parcel in) {
northing = in.readDouble();
easting = in.readDouble();
@@ -72,22 +81,32 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable {
return easting;
}
+ /**
+ * Indicates whether some other object is "equal to" this one.
+ *
+ * @param other The object to compare this to
+ * @return true if equal, false if not
+ */
@Override
- public boolean equals(Object o) {
- if (this == o) {
+ public boolean equals(Object other) {
+ if (this == other) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if (other == null || getClass() != other.getClass()) {
return false;
}
- ProjectedMeters projectedMeters = (ProjectedMeters) o;
+ ProjectedMeters projectedMeters = (ProjectedMeters) other;
return Double.compare(projectedMeters.easting, easting) == 0
&& Double.compare(projectedMeters.northing, northing) == 0;
-
}
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return the hash code of this
+ */
@Override
public int hashCode() {
int result;
@@ -99,16 +118,32 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable {
return result;
}
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return the string representation of this
+ */
@Override
public String toString() {
return "ProjectedMeters [northing=" + northing + ", easting=" + easting + "]";
}
+ /**
+ * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
+ *
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
@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
+ */
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeDouble(northing);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java
index c5b8ad3077..c09c00fced 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java
@@ -37,6 +37,11 @@ public class VisibleRegion implements Parcelable {
*/
public final LatLngBounds latLngBounds;
+ /**
+ * Creates a VisibleRegion from a Parcel.
+ *
+ * @param in The Parcel to create this from
+ */
private VisibleRegion(Parcel in) {
this.farLeft = in.readParcelable(LatLng.class.getClassLoader());
this.farRight = in.readParcelable(LatLng.class.getClassLoader());
@@ -46,7 +51,7 @@ public class VisibleRegion implements Parcelable {
}
/**
- * Creates a new VisibleRegion given the four corners of the camera.
+ * Creates a VisibleRegion given the four corners of the camera.
*
* @param farLeft A LatLng object containing the latitude and longitude of the near left corner of the region.
* @param farRight A LatLng object containing the latitude and longitude of the near left corner of the region.
@@ -88,12 +93,22 @@ public class VisibleRegion implements Parcelable {
&& latLngBounds.equals(visibleRegion.latLngBounds);
}
+ /**
+ * The string representation of the object.
+ *
+ * @return the string representation of this
+ */
@Override
public String toString() {
return "[farLeft [" + farLeft + "], farRight [" + farRight + "], nearLeft [" + nearLeft + "], nearRight ["
+ nearRight + "], latLngBounds [" + latLngBounds + "]]";
}
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return the hash code
+ */
@Override
public int hashCode() {
return ((farLeft.hashCode() + 90)
@@ -102,11 +117,22 @@ public class VisibleRegion implements Parcelable {
+ ((nearRight.hashCode() + 180) * 1000000000));
}
+ /**
+ * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
+ *
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
@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
+ */
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeParcelable(farLeft, flags);
@@ -116,6 +142,9 @@ public class VisibleRegion implements Parcelable {
out.writeParcelable(latLngBounds, flags);
}
+ /**
+ * Inner class responsible for recreating Parcels into objects.
+ */
public static final Parcelable.Creator CREATOR =
new Parcelable.Creator() {
public VisibleRegion createFromParcel(Parcel in) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
index 8416bd5b6c..12e3300429 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
@@ -28,12 +28,16 @@ import com.mapzen.android.lost.api.LostApiClient;
* in the history stack.
*
*/
-public class LocationSource extends LocationEngine implements
- LostApiClient.ConnectionCallbacks, LocationListener {
+public class LocationSource extends LocationEngine implements LostApiClient.ConnectionCallbacks, LocationListener {
private Context context;
private LostApiClient lostApiClient;
+ /**
+ * Constructs a location source instance.
+ *
+ * @param context the context from which the Application context will be derived.
+ */
public LocationSource(Context context) {
super();
this.context = context.getApplicationContext();
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 098c701e03..c51d9327d2 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
@@ -1,7 +1,5 @@
package com.mapbox.mapboxsdk.maps;
-import android.app.Activity;
-import android.app.Fragment;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.PointF;
@@ -27,7 +25,6 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ZoomButtonsController;
-import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.annotations.MarkerViewManager;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
@@ -178,14 +175,14 @@ public class MapView extends FrameLayout {
/**
*
- * You must call this method from the parent's {@link android.app.Activity#onCreate(Bundle)} or
- * {@link android.app.Fragment#onCreate(Bundle)}.
+ * You must call this method from the parent's Activity#onCreate(Bundle)} or
+ * Fragment#onCreate(Bundle).
*
- * You must set a valid access token with {@link Mapbox#getInstance(Context, String)}) before you call this method
- * or an exception will be thrown.
+ * You must set a valid access token with {@link com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String)}
+ * before you call this method or an exception will be thrown.
*
* @param savedInstanceState Pass in the parent's savedInstanceState.
- * @see Mapbox#getInstance(Context, String)
+ * @see com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String)
*/
@UiThread
public void onCreate(@Nullable Bundle savedInstanceState) {
@@ -214,12 +211,11 @@ public class MapView extends FrameLayout {
}
/**
- * You must call this method from the parent's {@link android.app.Activity#onSaveInstanceState(Bundle)}
- * or {@link android.app.Fragment#onSaveInstanceState(Bundle)}.
+ * You must call this method from the parent's Activity#onSaveInstanceState(Bundle)
+ * or Fragment#onSaveInstanceState(Bundle).
*
* @param outState Pass in the parent's outState.
*/
-
@UiThread
public void onSaveInstanceState(@NonNull Bundle outState) {
outState.putBoolean(MapboxConstants.STATE_HAS_SAVED_STATE, true);
@@ -227,7 +223,7 @@ public class MapView extends FrameLayout {
}
/**
- * You must call this method from the parent's {@link Activity#onStart()} or {@link Fragment#onStart()}
+ * You must call this method from the parent's Activity#onStart() or Fragment#onStart()
*/
@UiThread
public void onStart() {
@@ -236,7 +232,7 @@ public class MapView extends FrameLayout {
}
/**
- * You must call this method from the parent's {@link Activity#onResume()} or {@link Fragment#onResume()}.
+ * You must call this method from the parent's Activity#onResume() or Fragment#onResume().
*/
@UiThread
public void onResume() {
@@ -244,7 +240,7 @@ public class MapView extends FrameLayout {
}
/**
- * You must call this method from the parent's {@link Activity#onPause()} or {@link Fragment#onPause()}.
+ * You must call this method from the parent's Activity#onPause() or Fragment#onPause().
*/
@UiThread
public void onPause() {
@@ -252,7 +248,7 @@ public class MapView extends FrameLayout {
}
/**
- * You must call this method from the parent's {@link Activity#onStop()} or {@link Fragment#onStop()}.
+ * You must call this method from the parent's Activity#onStop() or Fragment#onStop().
*/
@UiThread
public void onStop() {
@@ -261,7 +257,7 @@ public class MapView extends FrameLayout {
}
/**
- * You must call this method from the parent's {@link Activity#onDestroy()} or {@link Fragment#onDestroy()}.
+ * You must call this method from the parent's Activity#onDestroy() or Fragment#onDestroy().
*/
@UiThread
public void onDestroy() {
@@ -325,7 +321,7 @@ public class MapView extends FrameLayout {
}
/**
- * You must call this method from the parent's {@link Activity#onLowMemory()} or {@link Fragment#onLowMemory()}.
+ * You must call this method from the parent's Activity#onLowMemory() or Fragment#onLowMemory().
*/
@UiThread
public void onLowMemory() {
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 8a708cb186..d672ab37c3 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
@@ -736,8 +736,8 @@ public final class MapboxMap {
* 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 TrackingSettings#setDismissTrackingModeForCameraPositionChange(boolean)} with false before invoking this
- * method and calling it with true in the {@link CancelableCallback#onFinish()}.
+ * {@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.
@@ -763,8 +763,8 @@ public final class MapboxMap {
* 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 TrackingSettings#setDismissTrackingModeForCameraPositionChange(boolean)} with false before invoking this
- * method and calling it with true in the {@link CancelableCallback#onFinish()}.
+ * {@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.
@@ -887,7 +887,12 @@ public final class MapboxMap {
}
/**
- * Set focal bearing.
+ * Transform the map bearing given a bearing, focal point coordinates, and a duration.
+ *
+ * @param bearing The bearing of the Map to be transformed to
+ * @param focalX The x coordinate of the focal point
+ * @param focalY The y coordinate of the focal point
+ * @param duration The duration of the transformation
*/
public void setFocalBearing(double bearing, float focalX, float focalY, long duration) {
transform.setBearing(bearing, focalX, focalY, duration);
@@ -1059,7 +1064,7 @@ public final class MapboxMap {
* An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be
* sent.
*
- * @param style The bundled style. Accepts one of the values from {@link Style}.
+ * @param style The bundled style.
* @see Style
*/
@UiThread
@@ -1075,7 +1080,8 @@ public final class MapboxMap {
* An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be
* sent.
*
- * @param style The bundled style. Accepts one of the values from {@link Style}.
+ * @param style The bundled style.
+ * @param callback The callback to be invoked when the style has finished loading
* @see Style
*/
@UiThread
@@ -1576,9 +1582,11 @@ public final class MapboxMap {
}
/**
- * Gets a camera position that would fit a bounds.
+ * Get a camera position that fits a provided bounds and padding.
*
* @param latLngBounds the bounds to constrain the map with
+ * @param padding the padding to apply to the bounds
+ * @return the camera position that fits the bounds and padding
*/
public CameraPosition getCameraForLatLngBounds(@Nullable LatLngBounds latLngBounds, int[] padding) {
// calculate and set additional bounds padding
@@ -2410,11 +2418,13 @@ public final class MapboxMap {
}
/**
- * Interface definintion for a callback to be invoked when the style has finished loading.
+ * Interface definition for a callback to be invoked when the style has finished loading.
*/
public interface OnStyleLoadedListener {
/**
- * Invoked when the style has finished loading.
+ * Invoked when the style has finished loading
+ *
+ * @param style the style that has been loaded
*/
void onStyleLoaded(String style);
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
index 98f94ddb39..2efed1b322 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
@@ -378,7 +378,7 @@ public class MapboxMapOptions implements Parcelable {
/**
* Specifies the gravity state of mapbox_compass_icon for a map view.
*
- * @param gravity see {@link android.view.Gravity}
+ * @param gravity Android SDK Gravity.
* @return This
*/
public MapboxMapOptions compassGravity(int gravity) {
@@ -439,7 +439,7 @@ public class MapboxMapOptions implements Parcelable {
/**
* Specifies the gravity state of logo for a map view.
*
- * @param gravity see {@link android.view.Gravity}
+ * @param gravity Android SDK Gravity.
* @return This
*/
public MapboxMapOptions logoGravity(int gravity) {
@@ -472,7 +472,7 @@ public class MapboxMapOptions implements Parcelable {
/**
* Specifies the gravity state of attribution for a map view.
*
- * @param gravity see {@link android.view.Gravity}
+ * @param gravity Android SDK Gravity.
* @return This
*/
public MapboxMapOptions attributionGravity(int gravity) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
index accecf232b..7f8ba21e3e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
@@ -16,7 +16,6 @@ import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
-import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -196,7 +195,7 @@ public final class UiSettings {
setLogoMargins(resources, options.getLogoMargins());
}
- private void setLogoMargins(Resources resources, int[]logoMargins) {
+ private void setLogoMargins(Resources resources, int[] logoMargins) {
if (logoMargins != null) {
setLogoMargins(logoMargins[0], logoMargins[1], logoMargins[2], logoMargins[3]);
} else {
@@ -309,8 +308,7 @@ public final class UiSettings {
*
* By default, the compass is in the top right corner.
*
- * @param gravity One of the values from {@link Gravity}.
- * @see Gravity
+ * @param gravity Android SDK Gravity.
*/
@UiThread
public void setCompassGravity(int gravity) {
@@ -454,8 +452,7 @@ public final class UiSettings {
*
* By default, the logo is in the bottom left corner.
*
- * @param gravity One of the values from {@link Gravity}.
- * @see Gravity
+ * @param gravity Android SDK Gravity.
*/
public void setLogoGravity(int gravity) {
setWidgetGravity(logoView, gravity);
@@ -546,8 +543,7 @@ public final class UiSettings {
*
* By default, the attribution is in the bottom left corner next to the Mapbox logo.
*
- * @param gravity One of the values from {@link Gravity}.
- * @see Gravity
+ * @param gravity Android SDK Gravity.
*/
public void setAttributionGravity(int gravity) {
setWidgetGravity(attributionsView, gravity);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
index 9740679cf5..72868a91d8 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
@@ -45,6 +45,9 @@ 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.
+ *
*/
public class MyLocationView extends View {
@@ -155,6 +158,12 @@ public class MyLocationView extends View {
this.locationSource = 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;
@@ -183,6 +192,11 @@ public class MyLocationView extends View {
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) {
if (foregroundDrawable != null) {
foregroundDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
@@ -193,10 +207,24 @@ public class MyLocationView extends View {
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;
@@ -210,6 +238,11 @@ public class MyLocationView extends View {
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;
@@ -218,6 +251,11 @@ public class MyLocationView extends View {
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);
@@ -225,6 +263,11 @@ public class MyLocationView extends View {
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();
@@ -314,6 +357,11 @@ public class MyLocationView extends View {
}
}
+ /**
+ * 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;
if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
@@ -322,6 +370,11 @@ public class MyLocationView extends View {
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) {
@@ -335,6 +388,11 @@ public class MyLocationView extends View {
}
}
+ /**
+ * 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);
@@ -342,6 +400,9 @@ public class MyLocationView extends View {
}
}
+ /**
+ * Called when the hosting activity is starting, for internal use only.
+ */
public void onStart() {
if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) {
compassListener.onResume();
@@ -351,6 +412,9 @@ public class MyLocationView extends View {
}
}
+ /**
+ * Called when the hosting activity is stopping, for internal use only.
+ */
public void onStop() {
compassListener.onPause();
toggleGps(false);
@@ -382,6 +446,9 @@ public class MyLocationView extends View {
}
}
+ /**
+ * Update current locationstate.
+ */
public void update() {
if (isEnabled()) {
myLocationBehavior.invalidate();
@@ -396,17 +463,33 @@ public class MyLocationView extends View {
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 isCustomLocationSource Flag handling for handling user provided custom location source
+ */
public void setEnabled(boolean enabled, boolean isCustomLocationSource) {
super.setEnabled(enabled);
setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
toggleGps(enabled, isCustomLocationSource);
}
+ /**
+ * 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();
@@ -415,6 +498,11 @@ public class MyLocationView extends View {
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) {
@@ -430,7 +518,7 @@ public class MyLocationView extends View {
}
/**
- * Enabled / Disable GPS location updates along with updating the UI
+ * 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
*/
@@ -463,10 +551,20 @@ public class MyLocationView extends View {
}
}
+ /**
+ * 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;
@@ -482,10 +580,20 @@ public class MyLocationView extends View {
}
}
+ /**
+ * 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 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()) {
@@ -502,6 +610,11 @@ public class MyLocationView extends View {
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);
@@ -522,17 +635,32 @@ public class MyLocationView extends View {
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 */);
}
@@ -560,14 +688,29 @@ public class MyLocationView extends View {
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;
}
@@ -577,6 +720,11 @@ public class MyLocationView extends View {
contentPaddingY = (padding[1] - padding[3]) / 2;
}
+ /**
+ * Set the location source from which location updates are received, for internal use only.
+ *
+ * @param locationSource The location source to receive updates from
+ */
public void setLocationSource(LocationEngine locationSource) {
toggleGps(false);
this.locationSource = locationSource;
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
index e9d823ebda..2ad1bf7ebc 100644
--- 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
@@ -5,9 +5,9 @@ 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.MyLocationTracking;
import com.mapbox.mapboxsdk.maps.FocalPointChangeListener;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.Projection;
@@ -77,6 +77,11 @@ public class MyLocationViewSettings {
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)) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java
index 7be56fa694..a1bd98b780 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java
@@ -24,7 +24,10 @@ public class ConnectivityReceiver extends BroadcastReceiver {
private static ConnectivityReceiver INSTANCE;
/**
- * Get or create the singleton instance
+ * Get a single instance of ConnectivityReceiver.
+ *
+ * @param context the context to extract the application context from
+ * @return single instance of ConnectivityReceiver
*/
public static synchronized ConnectivityReceiver instance(Context context) {
if (INSTANCE == null) {
@@ -74,7 +77,7 @@ public class ConnectivityReceiver extends BroadcastReceiver {
}
/**
- * @see BroadcastReceiver#onReceive(Context, Intent)
+ * {@inheritDoc}
*/
@Override
public void onReceive(Context context, Intent intent) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java
index 95cb7d66c4..d572d696db 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java
@@ -115,6 +115,12 @@ public class OfflineManager {
}).start();
}
+ /**
+ * Get the single instance of offline manager.
+ *
+ * @param context the context used to host the offline manager
+ * @return the single instance of offline manager
+ */
public static synchronized OfflineManager getInstance(Context context) {
if (instance == null) {
instance = new OfflineManager(context);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
index baa815491f..1c78d5979e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java
@@ -393,6 +393,7 @@ public class OfflineRegion {
* After you call this method, you may not call any additional methods on this object.
*
*
+ * @param bytes the metadata in bytes
* @param callback the callback to be invoked
*/
public void updateMetadata(@NonNull final byte[] bytes, @NonNull final OfflineRegionUpdateMetadataCallback callback) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegionStatus.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegionStatus.java
index 9c3655fbec..fe12dd46c4 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegionStatus.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegionStatus.java
@@ -7,6 +7,7 @@ package com.mapbox.mapboxsdk.offline;
*
* Note that the total required size in bytes is not currently available. A
* future API release may provide an estimate of this number.
+ *
*/
public class OfflineRegionStatus {
@@ -51,6 +52,7 @@ public class OfflineRegionStatus {
* Specifically, it is false during early phases of an offline download. Once
* style and tile sources have been downloaded, it is possible to calculate the
* precise number of required resources, at which point it is set to true.
+ *
*/
private boolean requiredResourceCountIsPrecise = true;
@@ -73,37 +75,93 @@ public class OfflineRegionStatus {
}
/**
- * Is the region complete?
+ * Validates if the region download has completed
+ *
+ * @return true if download is complete, false if not
*/
public boolean isComplete() {
return (completedResourceCount == requiredResourceCount);
}
+ /**
+ * Returns the download state.
+ *
+ * State is defined as
+ *
+ *
+ * - {@link OfflineRegion#STATE_ACTIVE}
+ * - {@link OfflineRegion#STATE_INACTIVE}
+ *
+ *
+ * @return the download state.
+ */
@OfflineRegion.DownloadState
public int getDownloadState() {
return downloadState;
}
+ /**
+ * Get the number of resources (inclusive of tiles) that have been fully downloaded
+ * and are ready for offline access.
+ *
+ * @return the amount of resources that have finished downloading.
+ */
public long getCompletedResourceCount() {
return completedResourceCount;
}
+ /**
+ * The cumulative size, in bytes, of all resources (inclusive of tiles) that have
+ * been fully downloaded.
+ *
+ * @return the size of the resources that have finished downloading
+ */
public long getCompletedResourceSize() {
return completedResourceSize;
}
+ /**
+ * Get the number of tiles that have been fully downloaded and are ready for
+ * offline access.
+ *
+ * @return the completed tile count
+ */
public long getCompletedTileCount() {
return completedTileCount;
}
+ /**
+ * Get the cumulative size, in bytes, of all tiles that have been fully downloaded.
+ *
+ * @return the completed tile size
+ */
public long getCompletedTileSize() {
return completedTileSize;
}
+ /**
+ * Get the number of resources that are known to be required for this region. See the
+ * documentation for `requiredResourceCountIsPrecise` for an important caveat
+ * about this number.
+ *
+ * @return the amount of resources that are required
+ */
public long getRequiredResourceCount() {
return requiredResourceCount;
}
+ /**
+ * Returns when the value of requiredResourceCount is a precise
+ * count of the number of required resources, and false when it is merely a lower
+ * bound.
+ *
+ * Specifically, it is false during early phases of an offline download. Once
+ * style and tile sources have been downloaded, it is possible to calculate the
+ * precise number of required resources, at which point it is set to true.
+ *
+ *
+ * @return True if the required resource count is precise, false if not
+ */
public boolean isRequiredResourceCountPrecise() {
return requiredResourceCountIsPrecise;
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java
index 06676d76a1..eafef80e8d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java
@@ -3,9 +3,9 @@ package com.mapbox.mapboxsdk.storage;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.res.AssetManager;
import android.os.Environment;
import android.support.annotation.NonNull;
-import android.content.res.AssetManager;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
@@ -28,8 +28,9 @@ public class FileSource {
/**
* Called whenever a URL needs to be transformed.
*
- * @param kind The kind of URL to be transformed.
- * @return A URL that will now be downloaded.
+ * @param kind the kind of URL to be transformed.
+ * @param url the URL to be transformed
+ * @return a URL that will now be downloaded.
*/
String onURL(@Resource.Kind int kind, String url);
@@ -38,6 +39,12 @@ public class FileSource {
// File source instance is kept alive after initialization
private static FileSource INSTANCE;
+ /**
+ * Get the single instance of FileSource.
+ *
+ * @param context the context to derive the cache path from
+ * @return the single instance of FileSource
+ */
public static synchronized FileSource getInstance(Context context) {
if (INSTANCE == null) {
String cachePath = getCachePath(context);
@@ -47,6 +54,12 @@ public class FileSource {
return INSTANCE;
}
+ /**
+ * Get the cache path for a context.
+ *
+ * @param context the context to derive the cache path from
+ * @return the cache path
+ */
public static String getCachePath(Context context) {
// Default value
boolean setStorageExternal = MapboxConstants.DEFAULT_SET_STORAGE_EXTERNAL;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java
index 68727c8a4f..a57c440df4 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyValue.java
@@ -30,14 +30,29 @@ public class PropertyValue {
this.value = value;
}
+ /**
+ * Returns if this is null
+ *
+ * @return true if this is null, false if not
+ */
public boolean isNull() {
return value == null;
}
+ /**
+ * Returns if this is a function.
+ *
+ * @return true if is a function, false if not
+ */
public boolean isFunction() {
return !isNull() && value instanceof Function;
}
+ /**
+ * Returns if this is a value.
+ *
+ * @return true if is a value, false if not
+ */
public boolean isValue() {
return !isNull() && !isFunction();
}
@@ -53,6 +68,11 @@ public class PropertyValue {
}
}
+ /**
+ * Get the value of the property.
+ *
+ * @return the property value
+ */
@Nullable
public T getValue() {
if (isValue()) {
@@ -64,6 +84,11 @@ public class PropertyValue {
}
}
+ /**
+ * Get the color int value of the property if the value is a color.
+ *
+ * @return the color int value of the property, null if not a color value
+ */
@ColorInt
@Nullable
public Integer getColorInt() {
@@ -80,6 +105,11 @@ public class PropertyValue {
}
}
+ /**
+ * Get the string representation of a property value.
+ *
+ * @return the string representation
+ */
@Override
public String toString() {
return String.format("%s: %s", name, value);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java
index b66a50b8a4..cb6465a6b1 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Light.java
@@ -13,7 +13,7 @@ import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
/**
* The global light source.
*
- * @see The online documentation
+ * @see The online documentation
*/
@UiThread
public class Light {
@@ -43,7 +43,8 @@ public class Light {
*
* @return anchor as String
*/
- @Property.ANCHOR public String getAnchor() {
+ @Property.ANCHOR
+ public String getAnchor() {
return nativeGetAnchor();
}
@@ -106,7 +107,7 @@ public class Light {
*
* @return color as String
*/
- public String getColor() {
+ public String getColor() {
return nativeGetColor();
}
@@ -142,7 +143,7 @@ public class Light {
*
* @return intensity as Float
*/
- public float getIntensity() {
+ public float getIntensity() {
return nativeGetIntensity();
}
@@ -165,17 +166,30 @@ public class Light {
}
private native void nativeSetAnchor(String anchor);
+
private native String nativeGetAnchor();
+
private native void nativeSetPosition(Position position);
+
private native Position nativeGetPosition();
+
private native TransitionOptions nativeGetPositionTransition();
+
private native void nativeSetPositionTransition(long duration, long delay);
+
private native void nativeSetColor(String color);
+
private native String nativeGetColor();
+
private native TransitionOptions nativeGetColorTransition();
+
private native void nativeSetColorTransition(long duration, long delay);
+
private native void nativeSetIntensity(float intensity);
+
private native float nativeGetIntensity();
+
private native TransitionOptions nativeGetIntensityTransition();
+
private native void nativeSetIntensityTransition(long duration, long delay);
}
\ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java
index 215db03ad2..cd6218d3e2 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/Position.java
@@ -18,7 +18,7 @@ public class Position {
private float polarAngle;
/**
- * Creates a Position from a radial coordinate, an azimuthal angle & a polar angle.
+ * Creates a Position from a radial coordinate, an azimuthal angle and a polar angle.
*
* @param radialCoordinate the distance from the center of the base of an object to its light
* @param azimuthalAngle the position of the light relative to 0°
@@ -31,7 +31,7 @@ public class Position {
}
/**
- * Returns a Position from a radial coordinate, an azimuthal angle & a polar angle
+ * Returns a Position from a radial coordinate, an azimuthal angle and a polar angle
*
* @param radialCoordinate the radial coordinate
* @param azimuthalAngle the azimuthal angle
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs
index 067efe1092..80d927128d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs
@@ -17,7 +17,7 @@ import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
/**
* The global light source.
*
- * @see The online documentation
+ * @see The online documentation
*/
@UiThread
public class Light {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java
index e3fc765734..af3a79539f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java
@@ -5,8 +5,17 @@ import android.graphics.Canvas;
import android.support.annotation.NonNull;
import android.view.View;
+/**
+ * Utility class for creating bitmaps
+ */
public class BitmapUtils {
+ /**
+ * Convert a view to a bitmap.
+ *
+ * @param view the view to convert
+ * @return the converted bitmap
+ */
public static Bitmap createBitmapFromView(@NonNull View view) {
view.setDrawingCacheEnabled(true);
view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
@@ -22,6 +31,13 @@ public class BitmapUtils {
return snapshot;
}
+ /**
+ * Create a bitmap from a background and a foreground bitmap
+ *
+ * @param background The bitmap placed in the background
+ * @param foreground The bitmap placed in the foreground
+ * @return the merged bitmap
+ */
public static Bitmap mergeBitmap(@NonNull Bitmap background, @NonNull Bitmap foreground) {
Bitmap result = Bitmap.createBitmap(background.getWidth(), background.getHeight(), background.getConfig());
Canvas canvas = new Canvas(result);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
index 24c76243d9..14b18b00dc 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ColorUtils.java
@@ -23,7 +23,7 @@ import java.util.regex.Pattern;
public class ColorUtils {
/**
- * Returns a color integer associated as primary color from a theme based on a {@link Context}.
+ * Returns a color integer associated as primary color from a theme based on a Context.
*
* @param context The context used to style the color attributes.
* @return The primary color value of current theme in the form 0xAARRGGBB.
@@ -37,7 +37,7 @@ public class ColorUtils {
}
/**
- * Returns a color integer associated as primary dark color from a theme based on a {@link Context}.
+ * Returns a color integer associated as primary dark color from a theme based on a Context.
*
* @param context The context used to style the color attributes.
* @return The primary dark color value of current theme in the form 0xAARRGGBB.
@@ -51,7 +51,7 @@ public class ColorUtils {
}
/**
- * Returns a color integer associated as accent color from a theme based on a {@link Context}.
+ * Returns a color integer associated as accent color from a theme based on a Context.
*
* @param context The context used to style the color attributes.
* @return The accent color value of current theme in the form 0xAARRGGBB.
@@ -65,7 +65,7 @@ public class ColorUtils {
}
/**
- * Returns a color state list associated with a theme based on a {@link Context}
+ * Returns a color state list associated with a theme based on a Context.
*
* @param color The color used for tinting.
* @return A ColorStateList object containing the primary color of a theme
@@ -85,7 +85,7 @@ public class ColorUtils {
}
/**
- * Set a color tint list to the {@link Drawable} of an {@link ImageView}.
+ * Set a color tint list to the Drawable of an ImageView.
*
* @param imageView The view to set the default tint list.
* @param tintColor The color to tint.
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java
index f810d6231d..007880acd1 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MapFragmentUtils.java
@@ -18,12 +18,25 @@ import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
*/
public class MapFragmentUtils {
+ /**
+ * Convert MapboxMapOptions to a bundle of fragment arguments.
+ *
+ * @param options The MapboxMapOptions to convert
+ * @return a bundle of converted fragment arguments
+ */
public static Bundle createFragmentArgs(MapboxMapOptions options) {
Bundle bundle = new Bundle();
bundle.putParcelable(MapboxConstants.FRAG_ARG_MAPBOXMAPOPTIONS, options);
return bundle;
}
+ /**
+ * Convert a bundle of fragment arguments to MapboxMapOptions.
+ *
+ * @param context The context of the activity hosting the fragment
+ * @param args The fragment arguments
+ * @return converted MapboxMapOptions
+ */
public static MapboxMapOptions resolveArgs(Context context, Bundle args) {
MapboxMapOptions options;
if (args != null && args.containsKey(MapboxConstants.FRAG_ARG_MAPBOXMAPOPTIONS)) {
--
cgit v1.2.1
From 200d184738a2a5c8e7cb19a0f5eaa06d34cb1774 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Thu, 29 Jun 2017 09:29:23 +0200
Subject: OnCameraIdle hook into quickzoom gesture (#9339)
* [android] - OnCameraIdle hook into quickzoom gesture
* double tap fix
* show MyLocationView bearing for GPS when Compass is not available, only show error about missing compass once, fix test activity.
* fix accessor lint warning
---
.../mapboxsdk/maps/CameraChangeDispatcher.java | 8 +++++---
.../mapbox/mapboxsdk/maps/MapGestureDetector.java | 21 +++++++++++++++++----
.../java/com/mapbox/mapboxsdk/maps/Transform.java | 7 +++++--
.../mapboxsdk/maps/widgets/MyLocationView.java | 18 ++++++++++++------
4 files changed, 39 insertions(+), 15 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
index bd028aecb6..6f7d7c0080 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
@@ -2,8 +2,8 @@ package com.mapbox.mapboxsdk.maps;
import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener;
import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveCanceledListener;
-import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener;
import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveListener;
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener;
class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, MapboxMap.OnCameraMoveListener,
MapboxMap.OnCameraMoveCanceledListener, OnCameraIdleListener {
@@ -59,9 +59,11 @@ class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, M
@Override
public void onCameraIdle() {
- if (onCameraIdleListener != null && !idle) {
+ if (!idle) {
idle = true;
- onCameraIdleListener.onCameraIdle();
+ if (onCameraIdleListener != null) {
+ onCameraIdleListener.onCameraIdle();
+ }
}
}
}
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 5346baa4e2..3607703ab1 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
@@ -57,6 +57,7 @@ final class MapGestureDetector {
private boolean quickZoom = false;
private boolean scrollInProgress = false;
private boolean scaleGestureOccurred = false;
+ private boolean recentScaleGestureOccurred = false;
MapGestureDetector(Context context, Transform transform, Projection projection, UiSettings uiSettings,
TrackingSettings trackingSettings, AnnotationManager annotationManager,
@@ -148,7 +149,7 @@ final class MapGestureDetector {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
// First pointer down, reset scaleGestureOccurred, used to avoid triggering a fling after a scale gesture #7666
- scaleGestureOccurred = false;
+ recentScaleGestureOccurred = false;
transform.setGestureInProgress(true);
break;
@@ -274,7 +275,7 @@ final class MapGestureDetector {
break;
case MotionEvent.ACTION_UP:
if (quickZoom) {
- // insert here?
+ cameraChangeDispatcher.onCameraIdle();
quickZoom = false;
break;
}
@@ -341,7 +342,7 @@ final class MapGestureDetector {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
- if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || scaleGestureOccurred) {
+ if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || recentScaleGestureOccurred) {
// don't allow a fling is scroll is disabled
// and ignore when a scale gesture has occurred
return false;
@@ -392,12 +393,17 @@ final class MapGestureDetector {
return false;
}
+ if (scaleGestureOccurred) {
+ return false;
+ }
+
if (!scrollInProgress) {
scrollInProgress = true;
// Cancel any animation
transform.cancelTransitions();
cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
+
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent(
getLocationFromGesture(e1.getX(), e1.getY()),
MapboxEvent.GESTURE_PAN_START, transform));
@@ -432,6 +438,7 @@ final class MapGestureDetector {
}
scaleGestureOccurred = true;
+ recentScaleGestureOccurred = true;
beginTime = detector.getEventTime();
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent(
getLocationFromGesture(detector.getFocusX(), detector.getFocusY()),
@@ -442,9 +449,11 @@ final class MapGestureDetector {
// Called when fingers leave screen
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
+ scaleGestureOccurred = false;
beginTime = 0;
scaleFactor = 1.0f;
zoomStarted = false;
+ cameraChangeDispatcher.onCameraIdle();
}
// Called each time a finger moves
@@ -480,6 +489,9 @@ final class MapGestureDetector {
}
// Gesture is a quickzoom if there aren't two fingers
+ if (!quickZoom && !twoTap) {
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
+ }
quickZoom = !twoTap;
// make an assumption here; if the zoom center is specified by the gesture, it's NOT going
@@ -492,6 +504,7 @@ final class MapGestureDetector {
// arround user provided focal point
transform.zoomBy(Math.log(detector.getScaleFactor()) / Math.log(2), focalPoint.x, focalPoint.y);
} else if (quickZoom) {
+ cameraChangeDispatcher.onCameraMove();
// clamp scale factors we feed to core #7514
float scaleFactor = MathUtils.clamp(detector.getScaleFactor(),
MapboxConstants.MINIMUM_SCALE_FACTOR_CLAMP,
@@ -553,7 +566,7 @@ final class MapGestureDetector {
// If rotate is large enough ignore a tap
// Also is zoom already started, don't rotate
totalAngle += detector.getRotationDegreesDelta();
- if (!zoomStarted && ((totalAngle > 20.0f) || (totalAngle < -20.0f))) {
+ if (totalAngle > 20.0f || totalAngle < -20.0f) {
started = true;
}
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 89fbb79504..d788b7772b 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
@@ -215,6 +215,9 @@ final class Transform implements MapView.OnMapChangedListener {
if (cameraPosition != null) {
int newZoom = (int) Math.round(cameraPosition.zoom + (zoomIn ? 1 : -1));
setZoom(newZoom, focalPoint, MapboxConstants.ANIMATION_DURATION);
+ } else {
+ // we are not transforming, notify about being idle
+ cameraChangeDispatcher.onCameraIdle();
}
}
@@ -227,8 +230,8 @@ final class Transform implements MapView.OnMapChangedListener {
@Override
public void onMapChanged(int change) {
if (change == MapView.REGION_DID_CHANGE_ANIMATED) {
- mapView.removeOnMapChangedListener(this);
cameraChangeDispatcher.onCameraIdle();
+ mapView.removeOnMapChangedListener(this);
}
}
});
@@ -327,7 +330,7 @@ final class Transform implements MapView.OnMapChangedListener {
mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
@Override
public void onMapChanged(int change) {
- if (change == MapView.DID_FINISH_RENDERING_MAP_FULLY_RENDERED) {
+ if (change == MapView.REGION_DID_CHANGE_ANIMATED) {
mapView.removeOnMapChangedListener(this);
cameraChangeDispatcher.onCameraIdle();
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
index 72868a91d8..8b6b93e03a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
@@ -348,12 +348,17 @@ public class MyLocationView extends View {
}
// draw foreground
- if (myBearingTrackingMode == MyBearingTracking.NONE || !compassListener.isSensorAvailable()) {
+ if (myBearingTrackingMode == MyBearingTracking.NONE) {
if (foregroundDrawable != null) {
foregroundDrawable.draw(canvas);
}
} else if (foregroundBearingDrawable != null && foregroundBounds != null) {
- foregroundBearingDrawable.draw(canvas);
+ if (myBearingTrackingMode == MyBearingTracking.GPS || compassListener.isSensorAvailable()) {
+ foregroundBearingDrawable.draw(canvas);
+ } else {
+ // We are tracking MyBearingTracking.COMPASS, but sensor is not available.
+ foregroundDrawable.draw(canvas);
+ }
}
}
@@ -774,9 +779,9 @@ public class MyLocationView extends View {
private final SensorManager sensorManager;
private Sensor rotationVectorSensor;
- float[] matrix = new float[9];
- float[] orientation = new float[3];
-
+ private float[] matrix = new float[9];
+ private float[] orientation = new float[3];
+ private boolean reportMissingSensor = true;
// Compass data
private long compassUpdateNextTimestamp = 0;
@@ -794,7 +799,8 @@ public class MyLocationView extends View {
}
public boolean isSensorAvailable() {
- if (rotationVectorSensor == null) {
+ 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;
--
cgit v1.2.1
From 95735c06f6c394bde67532913fd7b51b2938cbc1 Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Fri, 30 Jun 2017 11:21:39 +0200
Subject: Downgrade location provider dependency (#9394)
* [android] - downgrade LOST to Mapbox SDK 5.0.2 version.
* bump LOST back to Mapbox Android SDK version 4.x
---
platform/android/MapboxGLAndroidSDK/build.gradle | 4 ++-
.../mapbox/mapboxsdk/location/LocationSource.java | 33 ++++++----------------
2 files changed, 11 insertions(+), 26 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle
index 5e19e94f5d..018294d462 100644
--- a/platform/android/MapboxGLAndroidSDK/build.gradle
+++ b/platform/android/MapboxGLAndroidSDK/build.gradle
@@ -6,7 +6,9 @@ dependencies {
compile rootProject.ext.dep.supportDesign
compile rootProject.ext.dep.timber
compile rootProject.ext.dep.okhttp3
- compile rootProject.ext.dep.lost
+ compile(rootProject.ext.dep.lost) {
+ exclude group: 'com.google.guava'
+ }
// Mapbox Android Services (GeoJSON support)
compile(rootProject.ext.dep.mapboxJavaGeoJSON) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
index 12e3300429..6652142be3 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationSource.java
@@ -28,7 +28,7 @@ import com.mapzen.android.lost.api.LostApiClient;
* in the history stack.
*
*/
-public class LocationSource extends LocationEngine implements LostApiClient.ConnectionCallbacks, LocationListener {
+public class LocationSource extends LocationEngine implements LocationListener {
private Context context;
private LostApiClient lostApiClient;
@@ -41,9 +41,7 @@ public class LocationSource extends LocationEngine implements LostApiClient.Conn
public LocationSource(Context context) {
super();
this.context = context.getApplicationContext();
- lostApiClient = new LostApiClient.Builder(this.context)
- .addConnectionCallbacks(this)
- .build();
+ lostApiClient = new LostApiClient.Builder(this.context).build();
}
/**
@@ -55,6 +53,9 @@ public class LocationSource extends LocationEngine implements LostApiClient.Conn
if (!lostApiClient.isConnected()) {
lostApiClient.connect();
}
+ for (LocationEngineListener listener : locationListeners) {
+ listener.onConnected();
+ }
}
/**
@@ -80,23 +81,6 @@ public class LocationSource extends LocationEngine implements LostApiClient.Conn
return lostApiClient.isConnected();
}
- /**
- * Invoked when the location provider has connected.
- */
- @Override
- public void onConnected() {
- for (LocationEngineListener listener : locationListeners) {
- listener.onConnected();
- }
- }
-
- /**
- * Invoked when the location provider connection has been suspended.
- */
- @Override
- public void onConnectionSuspended() {
- }
-
/**
* Returns the Last known location is the location provider is connected and location permissions are granted.
*
@@ -107,9 +91,8 @@ public class LocationSource extends LocationEngine implements LostApiClient.Conn
public Location getLastLocation() {
if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context)) {
//noinspection MissingPermission
- return LocationServices.FusedLocationApi.getLastLocation(lostApiClient);
+ return LocationServices.FusedLocationApi.getLastLocation();
}
-
return null;
}
@@ -137,7 +120,7 @@ public class LocationSource extends LocationEngine implements LostApiClient.Conn
if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context)) {
//noinspection MissingPermission
- LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
+ LocationServices.FusedLocationApi.requestLocationUpdates(request, this);
}
}
@@ -147,7 +130,7 @@ public class LocationSource extends LocationEngine implements LostApiClient.Conn
@Override
public void removeLocationUpdates() {
if (lostApiClient.isConnected()) {
- LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
+ LocationServices.FusedLocationApi.removeLocationUpdates(this);
}
}
--
cgit v1.2.1
From d2d8a575be2d4f28894c0c1f845cbb464869d97c Mon Sep 17 00:00:00 2001
From: Tobrun
Date: Sat, 1 Jul 2017 17:38:44 +0200
Subject: [android] - update changelog for 5.1.0 release (#9405)
---
platform/android/MapboxGLAndroidSDK/gradle.properties | 2 +-
.../resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'platform/android/MapboxGLAndroidSDK')
diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties
index 9f555da5f8..078fdbc801 100644
--- a/platform/android/MapboxGLAndroidSDK/gradle.properties
+++ b/platform/android/MapboxGLAndroidSDK/gradle.properties
@@ -1,5 +1,5 @@
GROUP=com.mapbox.mapboxsdk
-VERSION_NAME=5.1.0-SNAPSHOT
+VERSION_NAME=5.2.0-SNAPSHOT
POM_DESCRIPTION=Mapbox GL Android SDK
POM_URL=https://github.com/mapbox/mapbox-gl-native
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties
index bc0350fe1f..029d25e046 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties
+++ b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties
@@ -1,3 +1,3 @@
fabric-identifier=com.mapbox.mapboxsdk.mapbox-android-sdk
-fabric-version=5.0.1
+fabric-version=5.1.0
fabric-build-type=binary
--
cgit v1.2.1