summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp
diff options
context:
space:
mode:
authorAntonio Zugaldia <antonio@mapbox.com>2017-02-03 15:12:13 -0500
committerGitHub <noreply@github.com>2017-02-03 15:12:13 -0500
commitc97ec3be0397290e172299c49361f5033270f150 (patch)
treec66ceec30a95c484e5df9fabe1a22d8381bd8b19 /platform/android/MapboxGLAndroidSDKTestApp
parente5c9db47931174911f0403a1f640a5ae33814b60 (diff)
downloadqtlocation-mapboxgl-c97ec3be0397290e172299c49361f5033270f150.tar.gz
[android] Extract telemetry into MAS
* [android] add the mapbox-android-telemetry module dependency. * update javadoc
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java13
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java15
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java29
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/ExponentialBackOffTest.java19
6 files changed, 40 insertions, 42 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java
index ac10d11922..c8a983351b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java
@@ -16,7 +16,7 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.constants.MyBearingTracking;
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.location.LocationServices;
+import com.mapbox.mapboxsdk.location.LocationSource;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
import com.mapbox.mapboxsdk.testapp.R;
@@ -123,7 +123,7 @@ public class MyLocationViewTest {
mapboxMap.moveCamera(
CameraUpdateFactory.newCameraPosition(
new CameraPosition.Builder()
- .target(new LatLng(LocationServices.getLocationServices(view.getContext()).getLastLocation()))
+ .target(new LatLng(LocationSource.getLocationEngine(view.getContext()).getLastLocation()))
.build()
)
);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
index eabd8d5c9d..23372b49e3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
@@ -596,7 +596,7 @@
<!-- android:name="com.mapbox.SetStorageExternal" -->
<!-- android:value="true" /> -->
- <service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService"/>
+ <service android:name="com.mapbox.services.android.telemetry.service.TelemetryService"/>
</application>
</manifest>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java
index 3984e765e1..c15e3b6058 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java
@@ -16,15 +16,15 @@ import android.view.ViewGroup;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.location.LocationListener;
-import com.mapbox.mapboxsdk.location.LocationServices;
+import com.mapbox.mapboxsdk.location.LocationSource;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.services.android.telemetry.location.LocationEngineListener;
-public class MyLocationDrawableActivity extends AppCompatActivity implements LocationListener {
+public class MyLocationDrawableActivity extends AppCompatActivity implements LocationEngineListener {
private static final int PERMISSIONS_LOCATION = 0;
@@ -92,7 +92,7 @@ public class MyLocationDrawableActivity extends AppCompatActivity implements Loc
if (location != null) {
onLocationChanged(location);
} else {
- LocationServices.getLocationServices(this).addLocationListener(this);
+ LocationSource.getLocationEngine(this).addLocationEngineListener(this);
}
} else {
mapboxMap.setMyLocationEnabled(false);
@@ -109,6 +109,11 @@ public class MyLocationDrawableActivity extends AppCompatActivity implements Loc
}
@Override
+ public void onConnected() {
+ // Nothing
+ }
+
+ @Override
public void onLocationChanged(Location location) {
if (mapboxMap != null) {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 14));
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java
index f5dfc90247..332dea2963 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java
@@ -18,16 +18,16 @@ import android.view.View;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.location.LocationListener;
-import com.mapbox.mapboxsdk.location.LocationServices;
+import com.mapbox.mapboxsdk.location.LocationSource;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.TrackingSettings;
import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.services.android.telemetry.location.LocationEngineListener;
-public class MyLocationTintActivity extends AppCompatActivity implements LocationListener {
+public class MyLocationTintActivity extends AppCompatActivity implements LocationEngineListener {
private MapView mapView;
private MapboxMap mapboxMap;
@@ -121,6 +121,11 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio
}
@Override
+ public void onConnected() {
+ // Nothing
+ }
+
+ @Override
public void onLocationChanged(Location location) {
if (mapboxMap != null && firstRun) {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15));
@@ -132,7 +137,7 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio
protected void onStart() {
super.onStart();
mapView.onStart();
- LocationServices.getLocationServices(this).addLocationListener(this);
+ LocationSource.getLocationEngine(this).addLocationEngineListener(this);
}
@Override
@@ -150,7 +155,7 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio
@Override
protected void onStop() {
super.onStop();
- LocationServices.getLocationServices(this).removeLocationListener(this);
+ LocationSource.getLocationEngine(this).removeLocationEngineListener(this);
mapView.onStop();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java
index e6991c201f..8bf40e3cf5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java
@@ -13,12 +13,14 @@ import android.view.View;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.location.LocationListener;
-import com.mapbox.mapboxsdk.location.LocationServices;
+import com.mapbox.mapboxsdk.location.LocationSource;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.services.android.telemetry.location.LocationEngine;
+import com.mapbox.services.android.telemetry.location.LocationEngineListener;
+import com.mapbox.services.android.telemetry.permissions.PermissionsManager;
public class MyLocationToggleActivity extends AppCompatActivity {
@@ -26,8 +28,8 @@ public class MyLocationToggleActivity extends AppCompatActivity {
private MapboxMap mapboxMap;
private FloatingActionButton locationToggleFab;
- private LocationServices locationServices;
- private LocationListener locationListener;
+ private LocationEngine locationServices;
+ private LocationEngineListener locationListener;
private static final int PERMISSIONS_LOCATION = 0;
@@ -36,7 +38,7 @@ public class MyLocationToggleActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_location_toggle);
- locationServices = LocationServices.getLocationServices(MyLocationToggleActivity.this);
+ locationServices = LocationSource.getLocationEngine(this);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
@@ -95,7 +97,7 @@ public class MyLocationToggleActivity extends AppCompatActivity {
// Ensure no memory leak occurs if we register the location listener but the call hasn't
// been made yet.
if (locationListener != null) {
- locationServices.removeLocationListener(locationListener);
+ locationServices.removeLocationEngineListener(locationListener);
}
}
@@ -108,7 +110,7 @@ public class MyLocationToggleActivity extends AppCompatActivity {
@UiThread
public void toggleGps(boolean enableGps) {
if (enableGps) {
- if (!LocationServices.getLocationServices(MyLocationToggleActivity.this).areLocationPermissionsGranted()) {
+ if (!PermissionsManager.areLocationPermissionsGranted(this)) {
ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
} else {
@@ -123,7 +125,7 @@ public class MyLocationToggleActivity extends AppCompatActivity {
if (enabled) {
// To move the camera instantly, we attempt to get the last known location and either
// ease or animate the camera to that position depending on the zoom level.
- Location lastLocation = LocationServices.getLocationServices(this).getLastLocation();
+ Location lastLocation = LocationSource.getLocationEngine(this).getLastLocation();
if (lastLocation != null) {
if (mapboxMap.getCameraPosition().zoom > 15.99) {
@@ -132,16 +134,21 @@ public class MyLocationToggleActivity extends AppCompatActivity {
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lastLocation), 16), 1000);
}
} else {
- locationListener = new LocationListener() {
+ locationListener = new LocationEngineListener() {
+ @Override
+ public void onConnected() {
+ // Nothing
+ }
+
@Override
public void onLocationChanged(Location location) {
if (location != null) {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 16));
- locationServices.removeLocationListener(this);
+ locationServices.removeLocationEngineListener(this);
}
}
};
- locationServices.addLocationListener(locationListener);
+ locationServices.addLocationEngineListener(locationListener);
}
locationToggleFab.setImageResource(R.drawable.ic_location_disabled_24dp);
} else {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/ExponentialBackOffTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/ExponentialBackOffTest.java
deleted file mode 100644
index fcaef9fa88..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/ExponentialBackOffTest.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.mapbox.mapboxsdk.telemetry;
-
-import org.junit.Test;
-
-import static junit.framework.Assert.assertEquals;
-
-public class ExponentialBackOffTest {
-
- @Test
- public void testExponentialBackOff() {
- MapboxEventManager.ExponentialBackoffCounter counter = new MapboxEventManager.ExponentialBackoffCounter();
- assertEquals(30000, counter.getNextCount());
- assertEquals(60000, counter.getNextCount());
- assertEquals(90000, counter.getNextCount());
- assertEquals(120000, counter.getNextCount());
- assertEquals(150000, counter.getNextCount());
- assertEquals(180000, counter.getNextCount());
- }
-}