summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2016-08-17 08:53:33 +0200
committerGitHub <noreply@github.com>2016-08-17 08:53:33 +0200
commitfff0ebaa1754aabd9584c994624b7b948bec95af (patch)
tree745006b1a761856e6651738cd7d26e0e08c6cbbf /platform/android
parent0062cf2f949fe1b0080e2de45aaf0b3d5e028bf3 (diff)
downloadqtlocation-mapboxgl-fff0ebaa1754aabd9584c994624b7b948bec95af.tar.gz
5859 generate sanity tests (#5870)
* [android] #5859 - generate espresso tests [android] #5859 - cleanup xml files, use all the same resource id for map view [android] #5859 - update scripts [android] #5859 - update Activity to match mapboxMap naming [android] #5859 - make SurfaceViewMediaControlActivity compatible [android] #5859 - make MarkerViewScaleActivity test generation compatible [android] #5859 - make PolygonActivity test generation compatible [android] #5859 - integration within make file [android] #5859 - made CameraPostion generation safe [android] #5859 - generate sanity test [android] #5859 - add generated test cases [android] #5859 - add documentation * [android] #5859 - remove generated files, introduce gen package, added gitignore to package * [android] #5859 - regenerated test code * [android] #5859 - added AWS gradle plugin + bitrise configuration * [android] #5859 - fixes running locally without having the properties configured * [android] #6010 - remove python from android sdk * [android] #5859 - update docs about aws gradle plugin
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/.gitignore4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/build.gradle41
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseMapboxMapTest.java36
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseTest.java52
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BulkMarkerActivityTest.java37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/DirectionsActivityTest.java37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/DynamicMarkerChangeActivityTest.java35
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/GeocoderActivityTest.java37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/InfoWindowActivityTest.java37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/InfoWindowAdapterActivityTest.java37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/LatLngBoundsActivityTest.java37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/ManualZoomActivityTest.java37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MapFragmentActivityTest.java39
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MapPaddingActivityTest.java37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MaxMinZoomActivityTest.java37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MyLocationTrackingModeActivityTest.java36
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/PolylineActivityTest.java37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/ScrollByActivityTest.java29
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/SupportMapFragmentActivityTest.java38
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/activity.junit.ejs37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/RotateTest.java17
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/TiltTest.java17
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/ZoomTest.java17
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/BackgroundLayerTest.java5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/BaseTest.java44
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/CircleLayerTest.java5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/FillLayerTest.java5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/LineLayerTest.java5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RasterLayerTest.java5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTests.java3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTimingTests.java3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/SymbolLayerTest.java5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/layer.junit.ejs5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/DrawerUtils.java (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/DrawerUtils.java)2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/GestureUtils.java (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/GestureUtils.java)2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/OnMapReadyIdlingResource.java (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/OnMapReadyIdlingResource.java)2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/ScreenshotUtil.java (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/ScreenshotUtil.java)2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/ViewUtils.java (renamed from platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/ViewUtils.java)2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java19
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java53
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java23
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java14
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java192
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java99
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java37
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java63
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java12
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java45
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java13
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java50
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java75
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java38
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SurfaceViewMediaControlActivity.java11
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java12
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java20
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java20
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_layer.xml16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_dynamic_marker.xml2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow.xml4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter.xml4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter_dynamic.xml4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_concurrent.xml24
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_location_picker.xml22
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml8
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_padding.xml5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_maxmin_zoom.xml2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml1
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline.xml2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polyline.xml4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_press_for_marker.xml14
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_print.xml4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_runtime_style.xml10
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_scroll_by.xml16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_surfaceview_mediacontrols.xml2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_double_map.xml8
-rw-r--r--platform/android/bitrise.yml36
-rw-r--r--platform/android/build.gradle6
-rw-r--r--platform/android/scripts/generate-test-code.js60
-rw-r--r--platform/android/tests/docs/ACTIVITY_SANITY_TEST.md17
-rw-r--r--platform/android/tests/docs/UI_TESTS.md89
-rw-r--r--platform/android/tests/scripts/devicefarm.py132
97 files changed, 890 insertions, 1422 deletions
diff --git a/platform/android/.gitignore b/platform/android/.gitignore
index 53e7540178..5ede06a831 100644
--- a/platform/android/.gitignore
+++ b/platform/android/.gitignore
@@ -27,3 +27,7 @@ fabric.properties
# Capture files
captures/
+
+# Generated test cases
+MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/gen/
+
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
index 852fb4dc48..f52309cab3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
+++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
@@ -1,6 +1,7 @@
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'checkstyle'
+apply plugin: 'devicefarm'
task accessToken {
def tokenFile = new File("MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml")
@@ -109,6 +110,46 @@ checkstyle {
showViolations true
}
+
+def getAccessKeyDeviceFarm() {
+ return hasProperty('AWS_ACCESS_KEY_ID_DEVICE_FARM') ? AWS_ACCESS_KEY_ID_DEVICE_FARM : ""
+}
+
+def getSecretAccessKeyDeviceFarm() {
+ return hasProperty('AWS_SECRET_ACCESS_KEY_DEVICE_FARM') ? AWS_SECRET_ACCESS_KEY_DEVICE_FARM : ""
+}
+
+devicefarm {
+
+ projectName "Mapbox GL Android" // required: Must already exists.
+ devicePool "sanity" // optional: Defaults to "Top Devices"
+
+ authentication {
+ accessKey getAccessKeyDeviceFarm()
+ secretKey getSecretAccessKeyDeviceFarm()
+ }
+
+ // optional block, radios default to 'on' state, all parameters optional
+ devicestate {
+ ///extraDataZipFile file("path/to/zip") // or ‘null’ if you have no extra data. Default is null.
+ //auxiliaryApps files(file("path/to/app"), file("path/to/app2")) // or ‘files()’ if you have no auxiliary apps. Default is an empty list.
+ wifi "on"
+ bluetooth "off"
+ gps "on"
+ nfc "on"
+ latitude 47.6204 // default
+ longitude - 122.3491 // default
+ }
+
+ // Instrumentation
+ // optional filter "my-filter"
+ // See AWS Developer docs
+ instrumentation {
+
+ }
+}
+
+
android.applicationVariants.all { variant ->
def name = variant.buildType.name
def checkstyle = project.tasks.create "checkstyle${name.capitalize()}", Checkstyle
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseMapboxMapTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseMapboxMapTest.java
deleted file mode 100644
index 1b1211b94c..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseMapboxMapTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.app.Activity;
-import android.support.test.espresso.Espresso;
-import android.util.Log;
-
-import com.mapbox.mapboxsdk.activity.utils.OnMapReadyIdlingResource;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.testapp.R;
-
-import org.junit.After;
-import org.junit.Before;
-
-public abstract class BaseMapboxMapTest extends BaseTest {
-
- private OnMapReadyIdlingResource idlingResource;
- protected MapboxMap mapboxMap;
-
- @Before
- public void registerIdlingResource() {
- Log.e(MapboxConstants.TAG, "@Before test");
- idlingResource = new OnMapReadyIdlingResource(getActivity());
- Espresso.registerIdlingResources(idlingResource);
- checkViewIsDisplayed(R.id.mapView);
- mapboxMap = idlingResource.getMapboxMap();
- }
-
- public abstract Activity getActivity();
-
- @After
- public void unregisterIdlingResource() {
- Log.e(MapboxConstants.TAG, "@After test");
- Espresso.unregisterIdlingResources(idlingResource);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseTest.java
index ac2816cba4..c5543222f1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseTest.java
@@ -1,44 +1,62 @@
package com.mapbox.mapboxsdk.activity;
import android.app.Activity;
+import android.support.test.espresso.Espresso;
+import android.support.test.rule.ActivityTestRule;
+import android.util.Log;
-import com.mapbox.mapboxsdk.activity.utils.ScreenshotUtil;
+import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.utils.ScreenshotUtil;
+import com.mapbox.mapboxsdk.constants.MapboxConstants;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.testapp.R;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
-/**
- * Base Espresso class for all tests, helps working with ActivityInstrumentationTestCase2
- */
-public class BaseTest {
+public abstract class BaseTest {
+
+ @Rule
+ public ActivityTestRule<Activity> rule = new ActivityTestRule<>(getActivityClass());
+ protected MapboxMap mapboxMap;
+ protected OnMapReadyIdlingResource idlingResource;
- protected final static String HOME_BUTTON_STRING = "Navigate up";
+ @Before
+ public void beforeTest() {
+ Log.e(MapboxConstants.TAG, "@Before test: register idle resource");
+ idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
+ Espresso.registerIdlingResources(idlingResource);
+ checkViewIsDisplayed(R.id.mapView);
+ mapboxMap = idlingResource.getMapboxMap();
+ }
- /*
- * Shortcuts for common UI tests
- */
+ protected abstract Class getActivityClass();
protected void checkViewIsDisplayed(int id) {
onView(withId(id))
.check(matches(isDisplayed()));
}
- /*
- * Screenshots logic
- */
-
- protected void takeNamedScreenshot(final Activity activity, final String name) {
-
- // Screenshots need to be taken on the UI thread
+ protected void takeScreenshot(final String name) {
+ final Activity activity = rule.getActivity();
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
ScreenshotUtil.take(activity, name);
}
});
-
}
+ @After
+ public void afterTest() {
+ Log.e(MapboxConstants.TAG, "@After test: unregister idle resource");
+ Espresso.unregisterIdlingResources(idlingResource);
+ }
}
+
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BulkMarkerActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BulkMarkerActivityTest.java
deleted file mode 100644
index 8fc3d2b2ed..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BulkMarkerActivityTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.annotation.BulkMarkerActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on BulkMarkerActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class BulkMarkerActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<BulkMarkerActivity> mActivityRule = new ActivityTestRule<>(
- BulkMarkerActivity.class);
-
- private BulkMarkerActivity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/DirectionsActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/DirectionsActivityTest.java
deleted file mode 100644
index 4c5b3e1f3d..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/DirectionsActivityTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.app.Activity;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.directions.DirectionsActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on DirectionsActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class DirectionsActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<DirectionsActivity> mActivityRule = new ActivityTestRule<>(DirectionsActivity.class);
-
- private Activity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/DynamicMarkerChangeActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/DynamicMarkerChangeActivityTest.java
deleted file mode 100644
index 07b1489f34..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/DynamicMarkerChangeActivityTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.activity.utils.ViewUtils;
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.annotation.DynamicMarkerChangeActivity;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on DynamicMarkerChange
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class DynamicMarkerChangeActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<DynamicMarkerChangeActivity> mActivityRule = new ActivityTestRule<>(
- DynamicMarkerChangeActivity.class);
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-
- @Test
- public void testFabClick() {
- ViewUtils.clickView(R.id.fab);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/GeocoderActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/GeocoderActivityTest.java
deleted file mode 100644
index 0197388543..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/GeocoderActivityTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.app.Activity;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.geocoding.GeocoderActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on GeocoderActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class GeocoderActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<GeocoderActivity> mActivityRule = new ActivityTestRule<>(GeocoderActivity.class);
-
- private Activity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/InfoWindowActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/InfoWindowActivityTest.java
deleted file mode 100644
index df32ec9e9e..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/InfoWindowActivityTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.infowindow.InfoWindowActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on InfoWindowActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class InfoWindowActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<InfoWindowActivity> mActivityRule = new ActivityTestRule<>(
- InfoWindowActivity.class);
-
- private InfoWindowActivity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/InfoWindowAdapterActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/InfoWindowAdapterActivityTest.java
deleted file mode 100644
index 34dc06ed1b..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/InfoWindowAdapterActivityTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.infowindow.InfoWindowAdapterActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on InfoWindowAdapterActivity.
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class InfoWindowAdapterActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<InfoWindowAdapterActivity> mActivityRule = new ActivityTestRule<>(
- InfoWindowAdapterActivity.class);
-
- private InfoWindowAdapterActivity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/LatLngBoundsActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/LatLngBoundsActivityTest.java
deleted file mode 100644
index 09d164c975..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/LatLngBoundsActivityTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.camera.LatLngBoundsActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on LatLngBoundsActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class LatLngBoundsActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<LatLngBoundsActivity> mActivityRule = new ActivityTestRule<>(
- LatLngBoundsActivity.class);
-
- private LatLngBoundsActivity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/ManualZoomActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/ManualZoomActivityTest.java
deleted file mode 100644
index 3fa1390e9a..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/ManualZoomActivityTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.app.Activity;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.camera.ManualZoomActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on ManualZoomActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class ManualZoomActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<ManualZoomActivity> mActivityRule = new ActivityTestRule<>(ManualZoomActivity.class);
-
- private Activity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.manualZoomMapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MapFragmentActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MapFragmentActivityTest.java
deleted file mode 100644
index 1847e2db02..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MapFragmentActivityTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.fragment.MapFragmentActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on MapFragmentActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class MapFragmentActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<MapFragmentActivity> mActivityRule = new ActivityTestRule<>(
- MapFragmentActivity.class);
-
- private MapFragmentActivity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.fragment_container);
- }
-
- // FIXME need a way to check if fragment was correctly added to Activity
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MapPaddingActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MapPaddingActivityTest.java
deleted file mode 100644
index 5edca393f4..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MapPaddingActivityTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.app.Activity;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.maplayout.MapPaddingActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on MapPaddingActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class MapPaddingActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<MapPaddingActivity> mActivityRule = new ActivityTestRule<>(MapPaddingActivity.class);
-
- private Activity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MaxMinZoomActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MaxMinZoomActivityTest.java
deleted file mode 100644
index 901d2b0b2a..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MaxMinZoomActivityTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.app.Activity;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.camera.MaxMinZoomActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on MaxMinZoomActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class MaxMinZoomActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<MaxMinZoomActivity> mActivityRule = new ActivityTestRule<>(MaxMinZoomActivity.class);
-
- private Activity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MyLocationTrackingModeActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MyLocationTrackingModeActivityTest.java
deleted file mode 100644
index 8a4b7d856d..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/MyLocationTrackingModeActivityTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.userlocation.MyLocationTrackingModeActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on User LocationTrackingModeActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class MyLocationTrackingModeActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<MyLocationTrackingModeActivity> mActivityRule = new ActivityTestRule<>(MyLocationTrackingModeActivity.class);
-
- private MyLocationTrackingModeActivity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/PolylineActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/PolylineActivityTest.java
deleted file mode 100644
index 2172d226d1..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/PolylineActivityTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.annotation.PolylineActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on PolyLineActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class PolylineActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<PolylineActivity> mActivityRule = new ActivityTestRule<>(
- PolylineActivity.class);
-
- private PolylineActivity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/ScrollByActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/ScrollByActivityTest.java
deleted file mode 100644
index f337f38c79..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/ScrollByActivityTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.camera.ScrollByActivity;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on ScrollByActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class ScrollByActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<ScrollByActivity> mActivityRule = new ActivityTestRule<>(ScrollByActivity.class);
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.mapView);
- }
-}
-
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/SupportMapFragmentActivityTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/SupportMapFragmentActivityTest.java
deleted file mode 100644
index bc32cd8d85..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/SupportMapFragmentActivityTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.mapbox.mapboxsdk.activity;
-
-import android.app.Activity;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.testapp.activity.fragment.SupportMapFragmentActivity;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests on SupportMapFragmentActivity
- */
-@RunWith(AndroidJUnit4.class)
-@LargeTest
-public class SupportMapFragmentActivityTest extends BaseTest {
-
- @Rule
- public ActivityTestRule<SupportMapFragmentActivity> mActivityRule = new ActivityTestRule<>(SupportMapFragmentActivity.class);
-
- private Activity mActivity = null;
-
- @Before
- public void setActivity() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void testSanity() {
- checkViewIsDisplayed(R.id.fragment_container);
- }
-}
-
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/activity.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/activity.junit.ejs
new file mode 100644
index 0000000000..df75f8633d
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/activity.junit.ejs
@@ -0,0 +1,37 @@
+<%
+ const activity = locals[0];
+ const subPackage = locals[1];
+-%>
+// This file is generated. Edit android/platform/scripts/generate-test-code.js, then run `make generate-test-android`.
+package com.mapbox.mapboxsdk.activity.gen.<%- subPackage %>;
+
+import android.support.test.runner.AndroidJUnit4;
+
+import com.mapbox.mapboxsdk.activity.BaseTest;
+import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.activity.<%- subPackage %>.<%- activity %>;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+
+/**
+ * Sanity test for <%- activity %>
+ */
+@RunWith(AndroidJUnit4.class)
+public class <%- activity %>Test extends BaseTest {
+
+ @Test
+ public void testSanity() {
+ onView(withId(R.id.mapView)).check(matches(isDisplayed()));
+ }
+
+ @Override
+ protected Class getActivityClass() {
+ return <%- activity %>.class;
+ }
+}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/RotateTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/RotateTest.java
index 948ed99570..4fe2a66043 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/RotateTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/RotateTest.java
@@ -1,38 +1,33 @@
package com.mapbox.mapboxsdk.camera;
-import android.app.Activity;
import android.support.test.espresso.UiController;
import android.support.test.espresso.ViewAction;
-import android.support.test.rule.ActivityTestRule;
import android.view.View;
-import com.mapbox.mapboxsdk.activity.BaseMapboxMapTest;
+import com.mapbox.mapboxsdk.activity.BaseTest;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMapUtils;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.infowindow.InfoWindowActivity;
import org.hamcrest.Matcher;
-import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
-public class RotateTest extends BaseMapboxMapTest {
-
- @Rule
- public final ActivityTestRule<InfoWindowActivity> rule = new ActivityTestRule<>(InfoWindowActivity.class);
+public class RotateTest extends BaseTest {
@Test
+ // longer testing change second param
public void testRotate() {
- onView(withId(R.id.mapView)).perform(new RotateAction(0, 180));
+ onView(withId(R.id.mapView)).perform(new RotateAction(0, 1));
}
@Override
- public Activity getActivity() {
- return rule.getActivity();
+ public Class getActivityClass() {
+ return InfoWindowActivity.class;
}
private class RotateAction implements ViewAction {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/TiltTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/TiltTest.java
index 28061ae1ff..c404bd3143 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/TiltTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/TiltTest.java
@@ -1,38 +1,33 @@
package com.mapbox.mapboxsdk.camera;
-import android.app.Activity;
import android.support.test.espresso.UiController;
import android.support.test.espresso.ViewAction;
-import android.support.test.rule.ActivityTestRule;
import android.view.View;
-import com.mapbox.mapboxsdk.activity.BaseMapboxMapTest;
+import com.mapbox.mapboxsdk.activity.BaseTest;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMapUtils;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.annotation.DynamicMarkerChangeActivity;
import org.hamcrest.Matcher;
-import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
-public class TiltTest extends BaseMapboxMapTest {
-
- @Rule
- public final ActivityTestRule<DynamicMarkerChangeActivity> rule = new ActivityTestRule<>(DynamicMarkerChangeActivity.class);
+public class TiltTest extends BaseTest {
@Test
+ // longer testing change param
public void testTilt() {
- onView(withId(R.id.mapView)).perform(new TiltAction(0, 60));
+ onView(withId(R.id.mapView)).perform(new TiltAction(0, 1));
}
@Override
- public Activity getActivity() {
- return rule.getActivity();
+ public Class getActivityClass() {
+ return DynamicMarkerChangeActivity.class;
}
private class TiltAction implements ViewAction {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/ZoomTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/ZoomTest.java
index f84bcaa2a0..01f8dcb48e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/ZoomTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/camera/ZoomTest.java
@@ -1,38 +1,33 @@
package com.mapbox.mapboxsdk.camera;
-import android.app.Activity;
import android.support.test.espresso.UiController;
import android.support.test.espresso.ViewAction;
-import android.support.test.rule.ActivityTestRule;
import android.view.View;
-import com.mapbox.mapboxsdk.activity.BaseMapboxMapTest;
+import com.mapbox.mapboxsdk.activity.BaseTest;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.maplayout.DebugModeActivity;
import org.hamcrest.Matcher;
-import org.junit.Rule;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
-public class ZoomTest extends BaseMapboxMapTest {
-
- @Rule
- public final ActivityTestRule<DebugModeActivity> rule = new ActivityTestRule<>(DebugModeActivity.class);
+public class ZoomTest extends BaseTest {
@Test
+ // longer testing increase second param
public void testZoom() throws Exception {
- onView(withId(R.id.mapView)).perform(new ZoomAction(MapboxConstants.MINIMUM_ZOOM, MapboxConstants.MAXIMUM_ZOOM));
+ onView(withId(R.id.mapView)).perform(new ZoomAction(MapboxConstants.MINIMUM_ZOOM, MapboxConstants.MINIMUM_ZOOM - 1));
}
@Override
- public Activity getActivity() {
- return rule.getActivity();
+ public Class getActivityClass() {
+ return DebugModeActivity.class;
}
private class ZoomAction implements ViewAction {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java
index 4c793a7db1..a88e5aeda5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java
@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.maps;
/**
- * Utility class to fetch a MapboxMap instance by bypassing package visibility
+ * Utility class to bypass package visibility
*/
public class MapboxMapUtils {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/BackgroundLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/BackgroundLayerTest.java
index be5dd8fc74..f6c2d971f7 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/BackgroundLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/BackgroundLayerTest.java
@@ -11,8 +11,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
-import com.mapbox.mapboxsdk.activity.BaseTest;
-import com.mapbox.mapboxsdk.activity.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
@@ -25,7 +24,7 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
- * Basic smoke tests for BackgroundLayera
+ * Basic smoke tests for BackgroundLayer
*/
@RunWith(AndroidJUnit4.class)
public class BackgroundLayerTest extends BaseTest {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/BaseTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/BaseTest.java
new file mode 100644
index 0000000000..c79820f42e
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/BaseTest.java
@@ -0,0 +1,44 @@
+package com.mapbox.mapboxsdk.style;
+
+import android.app.Activity;
+
+import com.mapbox.mapboxsdk.utils.ScreenshotUtil;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+
+/**
+ * Base Espresso class for all tests, helps working with ActivityInstrumentationTestCase2
+ */
+public class BaseTest {
+
+ protected final static String HOME_BUTTON_STRING = "Navigate up";
+
+ /*
+ * Shortcuts for common UI tests
+ */
+
+ protected void checkViewIsDisplayed(int id) {
+ onView(withId(id))
+ .check(matches(isDisplayed()));
+ }
+
+ /*
+ * Screenshots logic
+ */
+
+ protected void takeNamedScreenshot(final Activity activity, final String name) {
+
+ // Screenshots need to be taken on the UI thread
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ ScreenshotUtil.take(activity, name);
+ }
+ });
+
+ }
+
+}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/CircleLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/CircleLayerTest.java
index e67fb12d4e..60a793981c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/CircleLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/CircleLayerTest.java
@@ -11,8 +11,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
-import com.mapbox.mapboxsdk.activity.BaseTest;
-import com.mapbox.mapboxsdk.activity.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
@@ -25,7 +24,7 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
- * Basic smoke tests for CircleLayera
+ * Basic smoke tests for CircleLayer
*/
@RunWith(AndroidJUnit4.class)
public class CircleLayerTest extends BaseTest {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/FillLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/FillLayerTest.java
index 9fab90705a..749e4b7ebe 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/FillLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/FillLayerTest.java
@@ -11,8 +11,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
-import com.mapbox.mapboxsdk.activity.BaseTest;
-import com.mapbox.mapboxsdk.activity.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
@@ -25,7 +24,7 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
- * Basic smoke tests for FillLayera
+ * Basic smoke tests for FillLayer
*/
@RunWith(AndroidJUnit4.class)
public class FillLayerTest extends BaseTest {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/LineLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/LineLayerTest.java
index 799b0fffb9..5a2adb6646 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/LineLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/LineLayerTest.java
@@ -11,8 +11,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.LineLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
-import com.mapbox.mapboxsdk.activity.BaseTest;
-import com.mapbox.mapboxsdk.activity.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
@@ -25,7 +24,7 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
- * Basic smoke tests for LineLayera
+ * Basic smoke tests for LineLayer
*/
@RunWith(AndroidJUnit4.class)
public class LineLayerTest extends BaseTest {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RasterLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RasterLayerTest.java
index 0002e1b9f0..a42793013e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RasterLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RasterLayerTest.java
@@ -11,8 +11,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
-import com.mapbox.mapboxsdk.activity.BaseTest;
-import com.mapbox.mapboxsdk.activity.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
@@ -25,7 +24,7 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
- * Basic smoke tests for RasterLayera
+ * Basic smoke tests for RasterLayer
*/
@RunWith(AndroidJUnit4.class)
public class RasterLayerTest extends BaseTest {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTests.java
index a99a84ea9f..f73e1fb03d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTests.java
@@ -10,8 +10,7 @@ import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.sources.VectorSource;
-import com.mapbox.mapboxsdk.activity.BaseTest;
-import com.mapbox.mapboxsdk.activity.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTimingTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTimingTests.java
index fd166b7b33..4d327433c0 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTimingTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/RuntimeStyleTimingTests.java
@@ -4,8 +4,7 @@ import android.support.test.espresso.Espresso;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import com.mapbox.mapboxsdk.activity.BaseTest;
-import com.mapbox.mapboxsdk.activity.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTimingTestActivity;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/SymbolLayerTest.java
index cf55c9a2ed..2dd8a4aafd 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/SymbolLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/SymbolLayerTest.java
@@ -11,8 +11,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
-import com.mapbox.mapboxsdk.activity.BaseTest;
-import com.mapbox.mapboxsdk.activity.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
@@ -25,7 +24,7 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
- * Basic smoke tests for SymbolLayera
+ * Basic smoke tests for SymbolLayer
*/
@RunWith(AndroidJUnit4.class)
public class SymbolLayerTest extends BaseTest {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/layer.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/layer.junit.ejs
index fe9e93fc19..6c2c3f0255 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/layer.junit.ejs
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/style/layer.junit.ejs
@@ -15,8 +15,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
-import com.mapbox.mapboxsdk.activity.BaseTest;
-import com.mapbox.mapboxsdk.activity.utils.OnMapReadyIdlingResource;
+import com.mapbox.mapboxsdk.utils.OnMapReadyIdlingResource;
import org.junit.After;
import org.junit.Before;
@@ -29,7 +28,7 @@ import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
/**
- * Basic smoke tests for <%- camelize(type) %>Layera
+ * Basic smoke tests for <%- camelize(type) %>Layer
*/
@RunWith(AndroidJUnit4.class)
public class <%- camelize(type) %>LayerTest extends BaseTest {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/DrawerUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/DrawerUtils.java
index c1ee47d05e..8b39503d45 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/DrawerUtils.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/DrawerUtils.java
@@ -1,4 +1,4 @@
-package com.mapbox.mapboxsdk.activity.utils;
+package com.mapbox.mapboxsdk.utils;
import android.support.annotation.StringRes;
import android.support.test.espresso.Espresso;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/GestureUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/GestureUtils.java
index da26e938b2..38d76f5d83 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/GestureUtils.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/GestureUtils.java
@@ -1,4 +1,4 @@
-package com.mapbox.mapboxsdk.activity.utils;
+package com.mapbox.mapboxsdk.utils;
import android.support.annotation.IdRes;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/OnMapReadyIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/OnMapReadyIdlingResource.java
index 95db88d96b..43f3c07589 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/OnMapReadyIdlingResource.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/OnMapReadyIdlingResource.java
@@ -1,4 +1,4 @@
-package com.mapbox.mapboxsdk.activity.utils;
+package com.mapbox.mapboxsdk.utils;
import android.app.Activity;
import android.support.test.espresso.IdlingResource;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/ScreenshotUtil.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/ScreenshotUtil.java
index f28780b9e2..87b2d181f9 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/ScreenshotUtil.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/ScreenshotUtil.java
@@ -1,4 +1,4 @@
-package com.mapbox.mapboxsdk.activity.utils;
+package com.mapbox.mapboxsdk.utils;
import android.app.Activity;
import android.graphics.Bitmap;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/ViewUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/ViewUtils.java
index 9ba02f8e6a..739fce1cfb 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/utils/ViewUtils.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/utils/ViewUtils.java
@@ -1,4 +1,4 @@
-package com.mapbox.mapboxsdk.activity.utils;
+package com.mapbox.mapboxsdk.utils;
import android.support.annotation.IdRes;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java
index c06e58dc26..282ac9b18c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java
@@ -32,7 +32,7 @@ import java.util.Random;
public class AnimatedMarkerActivity extends AppCompatActivity {
private MapView mMapView;
- private MapboxMap mMapboxMap;
+ private MapboxMap mapboxMap;
private LatLng dupontCircle = new LatLng(38.90962, -77.04341);
@@ -59,9 +59,9 @@ public class AnimatedMarkerActivity extends AppCompatActivity {
@Override
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
- mMapboxMap = mapboxMap;
+ AnimatedMarkerActivity.this.mapboxMap = mapboxMap;
setupMap();
-
+
for (int i = 0; i < 10; i++) {
addRandomCar();
}
@@ -78,7 +78,7 @@ public class AnimatedMarkerActivity extends AppCompatActivity {
.target(dupontCircle)
.zoom(15)
.build();
- mMapboxMap.setCameraPosition(cameraPosition);
+ mapboxMap.setCameraPosition(cameraPosition);
}
private void addPassenger() {
@@ -87,7 +87,7 @@ public class AnimatedMarkerActivity extends AppCompatActivity {
if (passengerMarker == null) {
Icon icon = IconFactory.getInstance(AnimatedMarkerActivity.this)
.fromResource(R.drawable.ic_directions_run_black_24dp);
- passengerMarker = mMapboxMap.addMarker(new MarkerViewOptions()
+ passengerMarker = mapboxMap.addMarker(new MarkerViewOptions()
.position(randomLatLng)
.icon(icon));
} else {
@@ -105,7 +105,7 @@ public class AnimatedMarkerActivity extends AppCompatActivity {
}
// Make sure the car marker is selected so that it's always brought to the front (#5285)
- mMapboxMap.selectMarker(carMarker);
+ mapboxMap.selectMarker(carMarker);
}
private void animateMoveToPassenger(final MarkerView car) {
@@ -154,19 +154,19 @@ public class AnimatedMarkerActivity extends AppCompatActivity {
.fromResource(carResource);
//View Markers
- return mMapboxMap.addMarker(new MarkerViewOptions()
+ return mapboxMap.addMarker(new MarkerViewOptions()
.position(start)
.icon(icon));
//GL Markers
-// return mMapboxMap.addMarker(new MarkerOptions()
+// return mapboxMap.addMarker(new MarkerOptions()
// .position(start)
// .icon(icon));
}
private LatLng getLatLngInBounds() {
- LatLngBounds bounds = mMapboxMap.getProjection().getVisibleRegion().latLngBounds;
+ LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;
Random generator = new Random();
double randomLat = bounds.getLatSouth() + generator.nextDouble() * (bounds.getLatNorth() - bounds.getLatSouth());
double randomLon = bounds.getLonWest() + generator.nextDouble() * (bounds.getLonEast() - bounds.getLonWest());
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java
index e4bf383c96..f49407626d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java
@@ -43,7 +43,7 @@ import java.util.Random;
public class BulkMarkerActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
- private MapboxMap mMapboxMap;
+ private MapboxMap mapboxMap;
private MapView mMapView;
private boolean mCustomMarkerView;
private List<LatLng> mLocations;
@@ -68,7 +68,7 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mMapboxMap = mapboxMap;
+ BulkMarkerActivity.this.mapboxMap = mapboxMap;
if (actionBar != null) {
ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(), R.array.bulk_marker_list, android.R.layout.simple_spinner_item);
@@ -102,7 +102,7 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
}
private void showMarkers(int amount) {
- mMapboxMap.clear();
+ mapboxMap.clear();
if (mLocations.size() < amount) {
amount = mLocations.size();
@@ -128,7 +128,7 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
for (int i = 0; i < amount; i++) {
randomIndex = random.nextInt(mLocations.size());
LatLng latLng = mLocations.get(randomIndex);
- mMapboxMap.addMarker(new MarkerViewOptions()
+ mapboxMap.addMarker(new MarkerViewOptions()
.position(latLng)
.icon(icon)
.title(String.valueOf(i))
@@ -151,7 +151,7 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
.snippet(formatter.format(latLng.getLatitude()) + ", " + formatter.format(latLng.getLongitude())));
}
- mMapboxMap.addMarkers(markerOptionsList);
+ mapboxMap.addMarkers(markerOptionsList);
}
@Override
@@ -203,7 +203,7 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
private class FabClickListener implements View.OnClickListener {
@Override
public void onClick(final View v) {
- if (mMapboxMap != null) {
+ if (mapboxMap != null) {
mCustomMarkerView = true;
// remove fab
@@ -226,7 +226,7 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
@Override
public void onMapChanged(@MapView.MapChange int change) {
if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) {
- if (!mMapboxMap.getMarkerViewManager().getMarkerViewAdapters().isEmpty()) {
+ if (!mapboxMap.getMarkerViewManager().getMarkerViewAdapters().isEmpty()) {
TextView viewCountView = (TextView) findViewById(R.id.countView);
viewCountView.setText("ViewCache size " + (mMapView.getChildCount() - 5));
}
@@ -234,7 +234,7 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
}
});
- mMapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(new MapboxMap.OnMarkerViewClickListener() {
+ mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(new MapboxMap.OnMarkerViewClickListener() {
@Override
public boolean onMarkerClick(@NonNull Marker marker, @NonNull View view, @NonNull MapboxMap.MarkerViewAdapter adapter) {
Toast.makeText(BulkMarkerActivity.this, "Hello " + marker.getId(), Toast.LENGTH_SHORT).show();
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java
index 0c4eeae5ad..ce86a78099 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java
@@ -5,7 +5,6 @@ import android.animation.AnimatorInflater;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
-import android.graphics.PointF;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
@@ -42,7 +41,7 @@ import java.util.Random;
public class MarkerViewActivity extends AppCompatActivity {
- private MapboxMap mMapboxMap;
+ private MapboxMap mapboxMap;
private MapView mMapView;
private MarkerView movingMarkerOne, movingMarkerTwo;
@@ -80,7 +79,7 @@ public class MarkerViewActivity extends AppCompatActivity {
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mMapboxMap = mapboxMap;
+ MarkerViewActivity.this.mapboxMap = mapboxMap;
final MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager();
@@ -89,7 +88,7 @@ public class MarkerViewActivity extends AppCompatActivity {
// add default ViewMarker markers
for (int i = 0; i < LAT_LNGS.length; i++) {
- mMapboxMap.addMarker(new MarkerViewOptions()
+ MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
.position(LAT_LNGS[i])
.title(String.valueOf(i))
.alpha(0.5f)
@@ -106,22 +105,22 @@ public class MarkerViewActivity extends AppCompatActivity {
options.flat(true);
mapboxMap.addMarker(options);
- mMapboxMap.addMarker(new MarkerOptions()
+ MarkerViewActivity.this.mapboxMap.addMarker(new MarkerOptions()
.title("United States")
.position(new LatLng(38.902580, -77.050102))
);
- mMapboxMap.addMarker(new TextMarkerViewOptions()
+ MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
.text("A")
.position(new LatLng(38.889876, -77.008849))
);
- mMapboxMap.addMarker(new TextMarkerViewOptions()
+ MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
.text("B")
.position(new LatLng(38.907327, -77.041293))
);
- mMapboxMap.addMarker(new TextMarkerViewOptions()
+ MarkerViewActivity.this.mapboxMap.addMarker(new TextMarkerViewOptions()
.text("C")
.position(new LatLng(38.897642, -77.041980))
);
@@ -144,7 +143,7 @@ public class MarkerViewActivity extends AppCompatActivity {
});
// add a OnMarkerView click listener
- mMapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(new MapboxMap.OnMarkerViewClickListener() {
+ MarkerViewActivity.this.mapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(new MapboxMap.OnMarkerViewClickListener() {
@Override
public boolean onMarkerClick(@NonNull Marker marker, @NonNull View view, @NonNull MapboxMap.MarkerViewAdapter adapter) {
Toast.makeText(MarkerViewActivity.this, "Hello " + marker.getId(), Toast.LENGTH_SHORT).show();
@@ -152,7 +151,7 @@ public class MarkerViewActivity extends AppCompatActivity {
}
});
- movingMarkerOne = mMapboxMap.addMarker(new MarkerViewOptions()
+ movingMarkerOne = MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions()
.position(CarLocation.CAR_0_LNGS[0])
.icon(IconFactory.getInstance(mMapView.getContext())
.fromResource(R.drawable.ic_chelsea))
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java
index 37b1d32a68..bd183b9ab9 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java
@@ -21,10 +21,11 @@ import com.mapbox.mapboxsdk.testapp.R;
import java.util.Locale;
-public class MarkerViewScaleActivity extends AppCompatActivity {
+public class MarkerViewScaleActivity extends AppCompatActivity implements OnMapReadyCallback {
- private MapView mMapView;
- private View mMarkerView;
+ private MapboxMap mapboxMap;
+ private MapView mapView;
+ private View markerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -44,22 +45,23 @@ public class MarkerViewScaleActivity extends AppCompatActivity {
TextView xText = (TextView) findViewById(R.id.textview_factor);
xBar.setOnSeekBarChangeListener(new FactorChangeListener(xText));
- mMapView = (MapView) findViewById(R.id.mapView);
- mMapView.onCreate(savedInstanceState);
- mMapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap mapboxMap) {
- Icon icon = IconFactory.getInstance(MarkerViewScaleActivity.this)
- .fromResource(R.drawable.ic_circle);
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
- MarkerView mMarker = mapboxMap.addMarker(new MarkerViewOptions()
- .position(new LatLng(38.907192, -77.036871))
- .icon(icon)
- .flat(true));
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ Icon icon = IconFactory.getInstance(MarkerViewScaleActivity.this)
+ .fromResource(R.drawable.ic_circle);
- mMarkerView = mapboxMap.getMarkerViewManager().getView(mMarker);
- }
- });
+ MarkerView mMarker = mapboxMap.addMarker(new MarkerViewOptions()
+ .position(new LatLng(38.907192, -77.036871))
+ .icon(icon)
+ .flat(true));
+
+ markerView = mapboxMap.getMarkerViewManager().getView(mMarker);
}
@Override
@@ -76,31 +78,31 @@ public class MarkerViewScaleActivity extends AppCompatActivity {
@Override
public void onResume() {
super.onResume();
- mMapView.onResume();
+ mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
- mMapView.onPause();
+ mapView.onPause();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- mMapView.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
- mMapView.onDestroy();
+ mapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
- mMapView.onLowMemory();
+ mapView.onLowMemory();
}
private class FactorChangeListener implements SeekBar.OnSeekBarChangeListener {
@@ -115,10 +117,9 @@ public class MarkerViewScaleActivity extends AppCompatActivity {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
float newScale = getScale(progress);
xText.setText(String.format(Locale.US, "Scale: %.1f", newScale));
- if (MarkerViewScaleActivity.this.mMarkerView != null) {
- mMarkerView.setScaleX(newScale);
- mMarkerView.setScaleY(newScale);
-
+ if (MarkerViewScaleActivity.this.markerView != null) {
+ markerView.setScaleX(newScale);
+ markerView.setScaleY(newScale);
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java
index 9f3940bd3f..e4dbaf54db 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java
@@ -23,7 +23,7 @@ import com.mapbox.mapboxsdk.testapp.R;
import java.util.ArrayList;
import java.util.List;
-public class PolygonActivity extends AppCompatActivity {
+public class PolygonActivity extends AppCompatActivity implements OnMapReadyCallback {
private static final int BLUE_COLOR = Color.parseColor("#3bb2d0");
private static final int RED_COLOR = Color.parseColor("#AF0000");
@@ -52,6 +52,7 @@ public class PolygonActivity extends AppCompatActivity {
}};
private MapView mapView;
+ private MapboxMap mapboxMap;
private Polygon polygon;
private boolean fullAlpha = true;
@@ -85,22 +86,24 @@ public class PolygonActivity extends AppCompatActivity {
// create map
mapView = new MapView(this, options);
+ mapView.setId(R.id.mapView);
mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(MapboxMap mapboxMap) {
- POINTS.addAll(ADDITIONAL_POINTS);
- polygon = mapboxMap.addPolygon(new PolygonOptions()
- .addAll(POINTS)
- .fillColor(BLUE_COLOR));
- }
- });
+ mapView.getMapAsync(this);
// add to layout
((ViewGroup) findViewById(R.id.container)).addView(mapView);
}
@Override
+ public void onMapReady(MapboxMap mapboxMap) {
+ this.mapboxMap = mapboxMap;
+ POINTS.addAll(ADDITIONAL_POINTS);
+ polygon = mapboxMap.addPolygon(new PolygonOptions()
+ .addAll(POINTS)
+ .fillColor(BLUE_COLOR));
+ }
+
+ @Override
public void onResume() {
super.onResume();
mapView.onResume();
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java
index 5b45223da0..7dec4e9038 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java
@@ -40,7 +40,7 @@ public class PolylineActivity extends AppCompatActivity {
private List<Polyline> mPolylines;
private ArrayList<PolylineOptions> mPolylineOptions = new ArrayList<>();
private MapView mMapView;
- private MapboxMap mMapboxMap;
+ private MapboxMap mapboxMap;
private boolean fullAlpha = true;
private boolean visible = true;
@@ -72,7 +72,7 @@ public class PolylineActivity extends AppCompatActivity {
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mMapboxMap = mapboxMap;
+ PolylineActivity.this.mapboxMap = mapboxMap;
mPolylines = mapboxMap.addPolylines(mPolylineOptions);
}
});
@@ -82,19 +82,19 @@ public class PolylineActivity extends AppCompatActivity {
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (mMapboxMap != null) {
+ if (mapboxMap != null) {
if (mPolylines != null && mPolylines.size() > 0) {
if (mPolylines.size() == 1) {
// test for removing annotation
- mMapboxMap.removeAnnotation(mPolylines.get(0));
+ mapboxMap.removeAnnotation(mPolylines.get(0));
} else {
// test for removing annotations
- mMapboxMap.removeAnnotations(mPolylines);
+ mapboxMap.removeAnnotations(mPolylines);
}
}
mPolylineOptions.clear();
mPolylineOptions.addAll(getRandomLine());
- mPolylines = mMapboxMap.addPolylines(mPolylineOptions);
+ mPolylines = mapboxMap.addPolylines(mPolylineOptions);
}
}
@@ -172,7 +172,7 @@ public class PolylineActivity extends AppCompatActivity {
case R.id.action_id_remove:
// test to remove all annotations
mPolylineOptions.clear();
- mMapboxMap.clear();
+ mapboxMap.clear();
return true;
case R.id.action_id_alpha:
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java
index 0c014f7693..6784ac0914 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java
@@ -44,7 +44,7 @@ public class PressForMarkerActivity extends AppCompatActivity {
actionBar.setDisplayShowHomeEnabled(true);
}
- mapView = (MapView) findViewById(R.id.pressForMarkerMapView);
+ mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java
index 44758cd146..6494fff9f5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java
@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.testapp.activity.camera;
import android.os.Bundle;
-import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
@@ -10,24 +9,24 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
+import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.maps.MapView;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
-import com.mapbox.mapboxsdk.maps.MapView;
-public class CameraAnimationTypeActivity extends AppCompatActivity {
+public class CameraAnimationTypeActivity extends AppCompatActivity implements OnMapReadyCallback {
private static final String TAG = "CameraActivity";
+ private static final LatLng LAT_LNG_LONDON_EYE = new LatLng(51.50325, -0.11968);
+ private static final LatLng LAT_LNG_TOWER_BRIDGE = new LatLng(51.50550, -0.07520);
+ private MapboxMap mapboxMap;
private MapView mapView;
-
private boolean cameraState;
- private static final LatLng LAT_LNG_LONDON_EYE = new LatLng(51.50325, -0.11968);
- private static final LatLng LAT_LNG_TOWER_BRIDGE = new LatLng(51.50550, -0.07520);
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -44,92 +43,103 @@ public class CameraAnimationTypeActivity extends AppCompatActivity {
}
mapView = (MapView) findViewById(R.id.mapView);
- mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
+ if (mapView != null) {
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.getUiSettings().setAttributionEnabled(false);
+ mapboxMap.getUiSettings().setLogoEnabled(false);
+ mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
@Override
- public void onMapReady(@NonNull final MapboxMap mapboxMap) {
- mapboxMap.getUiSettings().setAttributionEnabled(false);
- mapboxMap.getUiSettings().setLogoEnabled(false);
- mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
- @Override
- public void onCameraChange(CameraPosition position) {
- Log.v(MapboxConstants.TAG, position.toString());
- }
- });
-
- // handle move button clicks
- findViewById(R.id.cameraMoveButton).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- CameraPosition cameraPosition = new CameraPosition.Builder()
- .target(getNextLatLng())
- .zoom(14)
- .tilt(30)
- .tilt(0)
- .build();
-
- mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
- }
- });
-
- // handle ease button clicks
- findViewById(R.id.cameraEaseButton).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- CameraPosition cameraPosition = new CameraPosition.Builder()
- .target(getNextLatLng())
- .zoom(15)
- .bearing(180)
- .tilt(30)
- .build();
-
- MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
- Log.i(TAG, "Duration onCancel Callback called.");
- Toast.makeText(CameraAnimationTypeActivity.this, "Ease onCancel Callback called.", Toast.LENGTH_LONG).show();
- }
-
- @Override
- public void onFinish() {
- Log.i(TAG, "Duration onFinish Callback called.");
- Toast.makeText(CameraAnimationTypeActivity.this, "Ease onFinish Callback called.", Toast.LENGTH_LONG).show();
- }
- };
-
- mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
- }
- });
-
- // handle animate button clicks
- findViewById(R.id.cameraAnimateButton).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- CameraPosition cameraPosition = new CameraPosition.Builder()
- .target(getNextLatLng())
- .bearing(270)
- .tilt(20)
- .build();
-
- MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
- Log.i(TAG, "Duration onCancel Callback called.");
- Toast.makeText(CameraAnimationTypeActivity.this, "Duration onCancel Callback called.", Toast.LENGTH_LONG).show();
- }
-
- @Override
- public void onFinish() {
- Log.i(TAG, "Duration onFinish Callback called.");
- Toast.makeText(CameraAnimationTypeActivity.this, "Duration onFinish Callback called.", Toast.LENGTH_LONG).show();
- }
- };
-
- mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
- }
- });
+ public void onCameraChange(CameraPosition position) {
+ Log.v(MapboxConstants.TAG, position.toString());
}
});
+
+ // handle move button clicks
+ View moveButton = findViewById(R.id.cameraMoveButton);
+ if (moveButton != null) {
+ moveButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ CameraPosition cameraPosition = new CameraPosition.Builder()
+ .target(getNextLatLng())
+ .zoom(14)
+ .tilt(30)
+ .tilt(0)
+ .build();
+ mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
+ }
+ });
+ }
+
+ // handle ease button clicks
+ View easeButton = findViewById(R.id.cameraEaseButton);
+ if (easeButton != null) {
+ easeButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ CameraPosition cameraPosition = new CameraPosition.Builder()
+ .target(getNextLatLng())
+ .zoom(15)
+ .bearing(180)
+ .tilt(30)
+ .build();
+
+ MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
+ @Override
+ public void onCancel() {
+ Log.i(TAG, "Duration onCancel Callback called.");
+ Toast.makeText(CameraAnimationTypeActivity.this, "Ease onCancel Callback called.", Toast.LENGTH_LONG).show();
+ }
+
+ @Override
+ public void onFinish() {
+ Log.i(TAG, "Duration onFinish Callback called.");
+ Toast.makeText(CameraAnimationTypeActivity.this, "Ease onFinish Callback called.", Toast.LENGTH_LONG).show();
+ }
+ };
+
+ mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
+ }
+ });
+ }
+
+ // handle animate button clicks
+ View animateButton = findViewById(R.id.cameraAnimateButton);
+ if (animateButton != null) {
+ animateButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ CameraPosition cameraPosition = new CameraPosition.Builder()
+ .target(getNextLatLng())
+ .bearing(270)
+ .tilt(20)
+ .build();
+
+ MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
+ @Override
+ public void onCancel() {
+ Log.i(TAG, "Duration onCancel Callback called.");
+ Toast.makeText(CameraAnimationTypeActivity.this, "Duration onCancel Callback called.", Toast.LENGTH_LONG).show();
+ }
+
+ @Override
+ public void onFinish() {
+ Log.i(TAG, "Duration onFinish Callback called.");
+ Toast.makeText(CameraAnimationTypeActivity.this, "Duration onFinish Callback called.", Toast.LENGTH_LONG).show();
+ }
+ };
+
+ mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
+ }
+ });
+ }
}
private LatLng getNextLatLng() {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
index 220bef197b..3f4763ba48 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
@@ -30,6 +30,7 @@ import com.mapbox.mapboxsdk.testapp.R;
public class CameraPositionActivity extends AppCompatActivity implements OnMapReadyCallback {
private MapView mapView;
+ private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -52,6 +53,7 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe
@Override
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
+ this.mapboxMap = mapboxMap;
// add a listener to FAB
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, R.color.primary));
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java
index 3ab8f7e763..311991d0d1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java
@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.testapp.activity.camera;
import android.os.Bundle;
-import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
@@ -23,12 +22,13 @@ import com.mapbox.mapboxsdk.testapp.R;
import java.util.ArrayList;
import java.util.List;
-public class LatLngBoundsActivity extends AppCompatActivity {
+public class LatLngBoundsActivity extends AppCompatActivity implements OnMapReadyCallback {
private static final LatLng LOS_ANGELES = new LatLng(34.053940, -118.242622);
private static final LatLng NEW_YORK = new LatLng(40.712730, -74.005953);
- private MapView mMapView;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -44,77 +44,78 @@ public class LatLngBoundsActivity extends AppCompatActivity {
actionBar.setDisplayShowHomeEnabled(true);
}
- mMapView = (MapView) findViewById(R.id.mapView);
- mMapView.setStyleUrl(Style.DARK);
- mMapView.onCreate(savedInstanceState);
- mMapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull final MapboxMap mapboxMap) {
-
- UiSettings uiSettings = mapboxMap.getUiSettings();
- uiSettings.setAllGesturesEnabled(false);
-
- mapboxMap.addMarker(new MarkerOptions()
- .title("Los Angeles")
- .snippet("City Hall")
- .position(LOS_ANGELES));
-
- mapboxMap.addMarker(new MarkerOptions()
- .title("New York")
- .snippet("City Hall")
- .position(NEW_YORK));
-
- List<LatLng> points = new ArrayList<>();
- points.add(NEW_YORK);
- points.add(LOS_ANGELES);
-
- // Create Bounds
- final LatLngBounds bounds = new LatLngBounds.Builder()
- .includes(points)
- .build();
-
- // Add map padding
- int mapPadding = (int) getResources().getDimension(R.dimen.fab_margin);
- mapboxMap.setPadding(mapPadding, mapPadding, mapPadding, mapPadding);
-
- // Move camera to the bounds with added padding
- int padding = (int) getResources().getDimension(R.dimen.coordinatebounds_margin);
- mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));
-
- // Call mapboxMap.getProjection().getVisibleRegion().latLngBounds to retrieve the bounds
- Log.v(MapboxConstants.TAG, mapboxMap.getProjection().getVisibleRegion().latLngBounds.toString());
- }
- });
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.setStyleUrl(Style.DARK);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ UiSettings uiSettings = mapboxMap.getUiSettings();
+ uiSettings.setAllGesturesEnabled(false);
+
+ mapboxMap.addMarker(new MarkerOptions()
+ .title("Los Angeles")
+ .snippet("City Hall")
+ .position(LOS_ANGELES));
+
+ mapboxMap.addMarker(new MarkerOptions()
+ .title("New York")
+ .snippet("City Hall")
+ .position(NEW_YORK));
+
+ List<LatLng> points = new ArrayList<>();
+ points.add(NEW_YORK);
+ points.add(LOS_ANGELES);
+
+ // Create Bounds
+ final LatLngBounds bounds = new LatLngBounds.Builder()
+ .includes(points)
+ .build();
+
+ // Add map padding
+ int mapPadding = (int) getResources().getDimension(R.dimen.fab_margin);
+ mapboxMap.setPadding(mapPadding, mapPadding, mapPadding, mapPadding);
+
+ // Move camera to the bounds with added padding
+ int padding = (int) getResources().getDimension(R.dimen.coordinatebounds_margin);
+ mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));
+
+ // Log data
+ Log.e(MapboxConstants.TAG, "Move to bounds: " + bounds.toString());
+ Log.e(MapboxConstants.TAG, "Resulting bounds:" + mapboxMap.getProjection().getVisibleRegion().latLngBounds.toString());
}
@Override
public void onResume() {
super.onResume();
- mMapView.onResume();
+ mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
- mMapView.onPause();
+ mapView.onPause();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- mMapView.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
- mMapView.onDestroy();
+ mapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
- mMapView.onLowMemory();
+ mapView.onLowMemory();
}
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java
index 897380d1aa..477ef64e86 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java
@@ -20,7 +20,7 @@ import com.mapbox.mapboxsdk.testapp.R;
public class ManualZoomActivity extends AppCompatActivity {
- private MapboxMap mMapboxMap;
+ private MapboxMap mapboxMap;
private MapView mMapView;
@Override
@@ -37,15 +37,15 @@ public class ManualZoomActivity extends AppCompatActivity {
actionBar.setDisplayShowHomeEnabled(true);
}
- mMapView = (MapView) findViewById(R.id.manualZoomMapView);
+ mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setStyleUrl(Style.SATELLITE);
mMapView.onCreate(savedInstanceState);
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
- mMapboxMap = mapboxMap;
+ ManualZoomActivity.this.mapboxMap = mapboxMap;
- UiSettings uiSettings = mMapboxMap.getUiSettings();
+ UiSettings uiSettings = ManualZoomActivity.this.mapboxMap.getUiSettings();
uiSettings.setAllGesturesEnabled(false);
}
});
@@ -67,23 +67,23 @@ public class ManualZoomActivity extends AppCompatActivity {
return true;
case R.id.action_zoom_in:
- mMapboxMap.animateCamera(CameraUpdateFactory.zoomIn());
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomIn());
return true;
case R.id.action_zoom_out:
- mMapboxMap.animateCamera(CameraUpdateFactory.zoomOut());
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomOut());
return true;
case R.id.action_zoom_by:
- mMapboxMap.animateCamera(CameraUpdateFactory.zoomBy(2));
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(2));
return true;
case R.id.action_zoom_to:
- mMapboxMap.animateCamera(CameraUpdateFactory.zoomTo(2));
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(2));
return true;
case R.id.action_zoom_to_point:
View view = getWindow().getDecorView();
- mMapboxMap.animateCamera(CameraUpdateFactory.zoomBy(1, new Point(view.getMeasuredWidth() / 4, view.getMeasuredHeight() / 4)));
+ mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(1, new Point(view.getMeasuredWidth() / 4, view.getMeasuredHeight() / 4)));
return true;
default:
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java
index e9a9647d45..9fcdfa3880 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java
@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.testapp.activity.camera;
import android.os.Bundle;
-import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
@@ -10,14 +9,15 @@ import android.view.MenuItem;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
-import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.mapboxsdk.testapp.R;
-public class MaxMinZoomActivity extends AppCompatActivity {
+public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyCallback {
- private MapView mMapView;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
@Override
+
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maxmin_zoom);
@@ -31,15 +31,16 @@ public class MaxMinZoomActivity extends AppCompatActivity {
actionBar.setDisplayShowHomeEnabled(true);
}
- mMapView = (MapView) findViewById(R.id.mapView);
- mMapView.onCreate(savedInstanceState);
- mMapView.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull final MapboxMap mapboxMap) {
- mapboxMap.setMinZoom(3);
- mapboxMap.setMaxZoom(5);
- }
- });
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.setMinZoom(3);
+ mapboxMap.setMaxZoom(5);
}
@Override
@@ -55,31 +56,31 @@ public class MaxMinZoomActivity extends AppCompatActivity {
@Override
public void onResume() {
super.onResume();
- mMapView.onResume();
+ mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
- mMapView.onPause();
+ mapView.onPause();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- mMapView.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
- mMapView.onDestroy();
+ mapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
- mMapView.onLowMemory();
+ mapView.onLowMemory();
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java
index 729a08758e..1154cccb6e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java
@@ -20,11 +20,13 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.mapboxsdk.testapp.R;
-public class ScrollByActivity extends AppCompatActivity {
+public class ScrollByActivity extends AppCompatActivity implements OnMapReadyCallback {
public static final int MULTIPLIER_PER_PIXEL = 50;
- private MapView mMapView;
+ private MapView mapView;
+ private MapboxMap mapboxMap;
+ private SeekBar xBar, yBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -40,35 +42,36 @@ public class ScrollByActivity extends AppCompatActivity {
actionBar.setDisplayShowHomeEnabled(true);
}
- final SeekBar xBar = (SeekBar) findViewById(R.id.seekbar_move_x);
+ xBar = (SeekBar) findViewById(R.id.seekbar_move_x);
TextView xText = (TextView) findViewById(R.id.textview_x);
xBar.setOnSeekBarChangeListener(new PixelBarChangeListener(xText, R.string.scrollby_x_value));
- final SeekBar yBar = (SeekBar) findViewById(R.id.seekbar_move_y);
+ yBar = (SeekBar) findViewById(R.id.seekbar_move_y);
TextView yText = (TextView) findViewById(R.id.textview_y);
yBar.setOnSeekBarChangeListener(new PixelBarChangeListener(yText, R.string.scrollby_y_value));
- mMapView = (MapView) findViewById(R.id.mapView);
- mMapView.setTag(true);
- mMapView.onCreate(savedInstanceState);
- mMapView.getMapAsync(new OnMapReadyCallback() {
+ mapView = (MapView) findViewById(R.id.mapView);
+ mapView.setTag(true);
+ mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ UiSettings uiSettings = mapboxMap.getUiSettings();
+ uiSettings.setLogoEnabled(false);
+ uiSettings.setAttributionEnabled(false);
+
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ fab.setColorFilter(ContextCompat.getColor(ScrollByActivity.this, R.color.primary));
+ fab.setOnClickListener(new View.OnClickListener() {
@Override
- public void onMapReady(@NonNull final MapboxMap mapboxMap) {
- UiSettings uiSettings = mapboxMap.getUiSettings();
- uiSettings.setLogoEnabled(false);
- uiSettings.setAttributionEnabled(false);
-
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setColorFilter(ContextCompat.getColor(ScrollByActivity.this, R.color.primary));
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mapboxMap.easeCamera(CameraUpdateFactory.scrollBy(
- xBar.getProgress() * MULTIPLIER_PER_PIXEL,
- yBar.getProgress() * MULTIPLIER_PER_PIXEL)
- );
- }
- });
+ public void onClick(View v) {
+ mapboxMap.easeCamera(CameraUpdateFactory.scrollBy(
+ xBar.getProgress() * MULTIPLIER_PER_PIXEL,
+ yBar.getProgress() * MULTIPLIER_PER_PIXEL)
+ );
}
});
}
@@ -76,31 +79,31 @@ public class ScrollByActivity extends AppCompatActivity {
@Override
public void onResume() {
super.onResume();
- mMapView.onResume();
+ mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
- mMapView.onPause();
+ mapView.onPause();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- mMapView.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
- mMapView.onDestroy();
+ mapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
- mMapView.onLowMemory();
+ mapView.onLowMemory();
}
@Override
@@ -141,6 +144,4 @@ public class ScrollByActivity extends AppCompatActivity {
}
}
-
-
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java
index 7d46cdb6bb..c725d9a7d7 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java
@@ -35,7 +35,7 @@ public class DirectionsActivity extends AppCompatActivity {
private final static String LOG_TAG = "DirectionsActivity";
private MapView mMapView;
- private MapboxMap mMapboxMap;
+ private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -56,7 +56,7 @@ public class DirectionsActivity extends AppCompatActivity {
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mMapboxMap = mapboxMap;
+ DirectionsActivity.this.mapboxMap = mapboxMap;
loadRoute();
}
});
@@ -74,17 +74,17 @@ public class DirectionsActivity extends AppCompatActivity {
(origin.getLatitude() + destination.getLatitude()) / 2,
(origin.getLongitude() + destination.getLongitude()) / 2);
- mMapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder()
+ mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder()
.target(centroid)
.zoom(14)
.build()));
// Add origin and destination to the map
- mMapboxMap.addMarker(new MarkerOptions()
+ mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(origin.getLatitude(), origin.getLongitude()))
.title("Origin")
.snippet("Dupont Circle"));
- mMapboxMap.addMarker(new MarkerOptions()
+ mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(destination.getLatitude(), destination.getLongitude()))
.title("Destination")
.snippet("The White House"));
@@ -142,7 +142,7 @@ public class DirectionsActivity extends AppCompatActivity {
}
// Draw Points on MapView
- mMapboxMap.addPolyline(builder);
+ mapboxMap.addPolyline(builder);
}
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java
index 9d72c2b02a..8233e59fd4 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp.activity.fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
-import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
@@ -18,7 +17,9 @@ import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
-public class MapFragmentActivity extends AppCompatActivity {
+public class MapFragmentActivity extends AppCompatActivity implements OnMapReadyCallback {
+
+ private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -68,12 +69,13 @@ public class MapFragmentActivity extends AppCompatActivity {
mapFragment = (MapFragment) getFragmentManager().findFragmentByTag("com.mapbox.map");
}
- mapFragment.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().tilt(45.0).build()), 10000);
- }
- });
+ mapFragment.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().tilt(45.0).build()), 10000);
}
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java
index cc61eb4698..cb3db5f2d3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java
@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.testapp.activity.fragment;
import android.os.Bundle;
-import android.support.annotation.NonNull;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
@@ -18,7 +17,9 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.SupportMapFragment;
import com.mapbox.mapboxsdk.testapp.R;
-public class SupportMapFragmentActivity extends AppCompatActivity {
+public class SupportMapFragmentActivity extends AppCompatActivity implements OnMapReadyCallback {
+
+ private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -68,12 +69,13 @@ public class SupportMapFragmentActivity extends AppCompatActivity {
mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentByTag("com.mapbox.map");
}
- mapFragment.getMapAsync(new OnMapReadyCallback() {
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().tilt(45.0).build()), 10000);
- }
- });
+ mapFragment.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().tilt(45.0).build()), 10000);
}
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java
index 18b4daf3a7..42cc5d8618 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java
@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.testapp.activity.geocoding;
import android.graphics.PointF;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
@@ -14,6 +13,7 @@ import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
+
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
@@ -34,13 +34,14 @@ import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
-import retrofit2.Retrofit;
-public class GeocoderActivity extends AppCompatActivity {
+public class GeocoderActivity extends AppCompatActivity implements OnMapReadyCallback {
private static final String LOG_TAG = "GeocoderActivity";
+ private MapboxMap mapboxMap;
private MapView mapView;
+ private ImageView dropPinView;
private TextView textView;
@Override
@@ -64,34 +65,34 @@ public class GeocoderActivity extends AppCompatActivity {
mapView.setStyleUrl(Style.MAPBOX_STREETS);
mapView.onCreate(savedInstanceState);
- final ImageView dropPinView = new ImageView(this);
+ dropPinView = new ImageView(this);
dropPinView.setImageResource(R.drawable.ic_droppin_24dp);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER);
dropPinView.setLayoutParams(params);
mapView.addView(dropPinView);
+ mapView.getMapAsync(this);
+ }
- mapView.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ final Projection projection = mapboxMap.getProjection();
+ final int width = mapView.getMeasuredWidth();
+ final int height = mapView.getMeasuredHeight();
+
+ // Click listener
+ mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
@Override
- public void onMapReady(@NonNull final MapboxMap mapboxMap) {
- final Projection projection = mapboxMap.getProjection();
- final int width = mapView.getMeasuredWidth();
- final int height = mapView.getMeasuredHeight();
+ public void onMapClick(@NonNull LatLng point) {
+ PointF centerPoint = new PointF(width / 2, (height + dropPinView.getHeight()) / 2);
+ LatLng centerLatLng = new LatLng(projection.fromScreenLocation(centerPoint));
- // Click listener
- mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
- @Override
- public void onMapClick(@NonNull LatLng point) {
- PointF centerPoint = new PointF(width / 2, (height + dropPinView.getHeight()) / 2);
- LatLng centerLatLng = new LatLng(projection.fromScreenLocation(centerPoint));
+ setMessage("Geocoding...");
- setMessage("Geocoding...");
+ mapboxMap.removeAnnotations();
+ mapboxMap.addMarker(new MarkerOptions().position(centerLatLng));
- mapboxMap.removeAnnotations();
- mapboxMap.addMarker(new MarkerOptions().position(centerLatLng));
-
- geocode(centerLatLng);
- }
- });
+ geocode(centerLatLng);
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java
index 4d19b4702e..935851c445 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java
@@ -1,9 +1,7 @@
package com.mapbox.mapboxsdk.testapp.activity.imagegenerator;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.os.Bundle;
-import android.app.Activity;
import android.support.annotation.NonNull;
import android.support.v4.print.PrintHelper;
import android.support.v7.app.ActionBar;
@@ -11,19 +9,16 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.Spinner;
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.mapboxsdk.testapp.activity.annotation.BulkMarkerActivity;
public class PrintActivity extends AppCompatActivity implements MapboxMap.SnapshotReadyCallback {
private MapView mMapView;
- private MapboxMap mMapboxMap;
+ private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -44,7 +39,7 @@ public class PrintActivity extends AppCompatActivity implements MapboxMap.Snapsh
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mMapboxMap = mapboxMap;
+ PrintActivity.this.mapboxMap = mapboxMap;
}
});
@@ -53,8 +48,8 @@ public class PrintActivity extends AppCompatActivity implements MapboxMap.Snapsh
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if(mMapboxMap!=null) {
- mMapboxMap.snapshot(PrintActivity.this);
+ if(mapboxMap !=null) {
+ mapboxMap.snapshot(PrintActivity.this);
}
}
});
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java
index 84e394c72d..356bf6677b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.testapp.activity.imagegenerator;
import android.graphics.Bitmap;
import android.os.Bundle;
-import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
@@ -12,15 +11,17 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
+
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
-public class SnapshotActivity extends AppCompatActivity {
+public class SnapshotActivity extends AppCompatActivity implements OnMapReadyCallback, View.OnClickListener {
private MapView mapView;
+ private MapboxMap mapboxMap;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -38,28 +39,31 @@ public class SnapshotActivity extends AppCompatActivity {
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(new OnMapReadyCallback() {
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ mapboxMap.setStyleUrl(Style.OUTDOORS);
+ FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
+ if (fab != null) {
+ fab.setColorFilter(ContextCompat.getColor(SnapshotActivity.this, R.color.primary));
+ fab.setOnClickListener(this);
+ }
+ }
+
+ @Override
+ public void onClick(View v) {
+ final long startTime = System.nanoTime();
+ mapboxMap.snapshot(new MapboxMap.SnapshotReadyCallback() {
@Override
- public void onMapReady(@NonNull final MapboxMap mapboxMap) {
- mapboxMap.setStyleUrl(Style.OUTDOORS);
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setColorFilter(ContextCompat.getColor(SnapshotActivity.this, R.color.primary));
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- final long startTime = System.nanoTime();
- mapboxMap.snapshot(new MapboxMap.SnapshotReadyCallback() {
- @Override
- public void onSnapshotReady(Bitmap snapshot) {
- long endTime = System.nanoTime();
- long duration = (long) ((endTime - startTime) / 1e6);
- ImageView snapshotView = (ImageView) findViewById(R.id.imageView);
- snapshotView.setImageBitmap(snapshot);
- Toast.makeText(SnapshotActivity.this, String.format("Snapshot taken in %d ms", duration), Toast.LENGTH_LONG).show();
- }
- });
- }
- });
+ public void onSnapshotReady(Bitmap snapshot) {
+ long endTime = System.nanoTime();
+ long duration = (long) ((endTime - startTime) / 1e6);
+ ImageView snapshotView = (ImageView) findViewById(R.id.imageView);
+ snapshotView.setImageBitmap(snapshot);
+ Toast.makeText(SnapshotActivity.this, String.format("Snapshot taken in %d ms", duration), Toast.LENGTH_LONG).show();
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java
index 5b2cae5e04..cf522d7f39 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java
@@ -29,8 +29,9 @@ import com.mapbox.mapboxsdk.testapp.R;
/**
* Shows how to dynamically update InfoWindow when Using an MapboxMap.InfoWindowAdapter
*/
-public class DynamicInfoWindowAdapterActivity extends AppCompatActivity {
+public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implements OnMapReadyCallback {
+ private MapboxMap mapboxMap;
private MapView mapView;
private LatLng paris = new LatLng(48.864716, 2.349014);
@@ -44,45 +45,47 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity {
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
+ mapView.getMapAsync(this);
+ }
+
+ @Override
+ public void onMapReady(MapboxMap map) {
+
+ mapboxMap = map;
+
+ //Add info window adapter
+ addCustomInfoWindowAdapter(mapboxMap);
+
+ //Keep info windows open on click
+ mapboxMap.getUiSettings().setDeselectMarkersOnTap(false);
- mapView.getMapAsync(new OnMapReadyCallback() {
+ //Add a marker
+ final MarkerView marker = addMarker(mapboxMap);
+ mapboxMap.selectMarker(marker);
+
+ //On map click, change the info window contents
+ mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
@Override
- public void onMapReady(@NonNull final MapboxMap mapboxMap) {
- //Add info window adapter
- addCustomInfoWindowAdapter(mapboxMap);
-
- //Keep info windows open on click
- mapboxMap.getUiSettings().setDeselectMarkersOnTap(false);
-
- //Add a marker
- final MarkerView marker = addMarker(mapboxMap);
- mapboxMap.selectMarker(marker);
-
- //On map click, change the info window contents
- mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
- @Override
- public void onMapClick(@NonNull LatLng point) {
- //Distance from click to marker
- double distanceKm = marker.getPosition().distanceTo(point) / 1000;
-
- //Get the info window
- InfoWindow infoWindow = marker.getInfoWindow();
-
- //Get the view from the info window
- if (infoWindow != null && infoWindow.getView() != null) {
- //Set the new text on the text view in the info window
- ((TextView) infoWindow.getView()).setText(String.format("%.2fkm", distanceKm));
-
- //Update the info window position (as the text length changes)
- infoWindow.update();
- }
- }
- });
-
- //Focus on Paris
- mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(paris));
+ public void onMapClick(@NonNull LatLng point) {
+ //Distance from click to marker
+ double distanceKm = marker.getPosition().distanceTo(point) / 1000;
+
+ //Get the info window
+ InfoWindow infoWindow = marker.getInfoWindow();
+
+ //Get the view from the info window
+ if (infoWindow != null && infoWindow.getView() != null) {
+ //Set the new text on the text view in the info window
+ ((TextView) infoWindow.getView()).setText(String.format("%.2fkm", distanceKm));
+
+ //Update the info window position (as the text length changes)
+ infoWindow.update();
+ }
}
});
+
+ //Focus on Paris
+ mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(paris));
}
private MarkerView addMarker(MapboxMap mapboxMap) {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java
index 2c74702253..8066dbc60e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java
@@ -13,20 +13,21 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.annotations.Icon;
-import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.IconFactory;
+import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.maps.MapView;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.model.annotations.CityStateMarker;
import com.mapbox.mapboxsdk.testapp.model.annotations.CityStateMarkerOptions;
-import com.mapbox.mapboxsdk.maps.MapView;
public class InfoWindowAdapterActivity extends AppCompatActivity {
private MapView mapView;
+ private MapboxMap mapboxMap;
private IconFactory iconFactory;
private Drawable iconDrawable;
@@ -51,14 +52,15 @@ public class InfoWindowAdapterActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- addMarkers(mapboxMap);
- addCustomInfoWindowAdapter(mapboxMap);
+ public void onMapReady(@NonNull MapboxMap map) {
+ mapboxMap = map;
+ addMarkers();
+ addCustomInfoWindowAdapter();
}
});
}
- private void addMarkers(MapboxMap mapboxMap){
+ private void addMarkers() {
mapboxMap.addMarker(generateCityStateMarker("Andorra", 42.505777, 1.52529, "#F44336"));
mapboxMap.addMarker(generateCityStateMarker("Luxembourg", 49.815273, 6.129583, "#3F51B5"));
mapboxMap.addMarker(generateCityStateMarker("Monaco", 43.738418, 7.424616, "#673AB7"));
@@ -79,7 +81,7 @@ public class InfoWindowAdapterActivity extends AppCompatActivity {
return marker;
}
- private void addCustomInfoWindowAdapter(MapboxMap mapboxMap){
+ private void addCustomInfoWindowAdapter() {
mapboxMap.setInfoWindowAdapter(new MapboxMap.InfoWindowAdapter() {
private int tenDp = (int) getResources().getDimension(R.dimen.attr_margin);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java
index ee54461357..ffea7594d9 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.testapp.activity.maplayout;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
@@ -29,6 +30,9 @@ public class DoubleMapActivity extends AppCompatActivity {
private static final String TAG_FRAGMENT = "map";
+ // used for ui tests
+ private MapboxMap mapboxMap;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -53,12 +57,35 @@ public class DoubleMapActivity extends AppCompatActivity {
}
}
+ public void setMapboxMap(MapboxMap map) {
+ // we need to set mapboxmap on the parent activity,
+ // for auto-generated ui tests
+
+ mapboxMap = map;
+ mapboxMap.setStyleUrl(Style.DARK);
+ mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(18));
+ try {
+ TrackingSettings settings = mapboxMap.getTrackingSettings();
+ settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
+ } catch (SecurityException e) {
+ // permission is handled in MainActivity
+ finish();
+ }
+ }
+
public static class DoubleMapFragment extends Fragment {
+ private DoubleMapActivity activity;
private MapView mMapView;
private MapView mMapViewMini;
@Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ activity = (DoubleMapActivity) context;
+ }
+
+ @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_double_map, container, false);
}
@@ -73,15 +100,8 @@ public class DoubleMapActivity extends AppCompatActivity {
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mapboxMap.setStyleUrl(Style.DARK);
-
- mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(18));
- try {
- TrackingSettings settings = mapboxMap.getTrackingSettings();
- settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
- } catch (SecurityException e) {
- // permission is handled in MainActivity
- getActivity().finish();
+ if (activity != null) {
+ activity.setMapboxMap(mapboxMap);
}
}
});
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java
index 62762f7116..f90741ee83 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java
@@ -22,7 +22,7 @@ import com.mapbox.mapboxsdk.testapp.R;
public class MapPaddingActivity extends AppCompatActivity {
private MapView mMapView;
- private MapboxMap mMapboxMap;
+ private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -45,7 +45,7 @@ public class MapPaddingActivity extends AppCompatActivity {
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mMapboxMap = mapboxMap;
+ MapPaddingActivity.this.mapboxMap = mapboxMap;
int paddingLeft = (int) getResources().getDimension(R.dimen.map_padding_left);
int paddingBottom = (int) getResources().getDimension(R.dimen.map_padding_bottom);
@@ -96,9 +96,9 @@ public class MapPaddingActivity extends AppCompatActivity {
private void toggleGps(boolean enable) {
try {
// Enable user location
- mMapboxMap.setMyLocationEnabled(enable);
+ mapboxMap.setMyLocationEnabled(enable);
- TrackingSettings trackingSettings = mMapboxMap.getTrackingSettings();
+ TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
trackingSettings.setDismissTrackingOnGesture(false);
trackingSettings.setMyLocationTrackingMode(enable ? MyLocationTracking.TRACKING_FOLLOW : MyLocationTracking.TRACKING_NONE);
} catch (SecurityException e) {
@@ -118,8 +118,8 @@ public class MapPaddingActivity extends AppCompatActivity {
.tilt(45)
.build();
- mMapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
- mMapboxMap.addMarker(new MarkerOptions().title("Center map").position(bangalore));
+ mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
+ mapboxMap.addMarker(new MarkerOptions().title("Center map").position(bangalore));
}
@Override
@@ -130,13 +130,13 @@ public class MapPaddingActivity extends AppCompatActivity {
return true;
case R.id.action_user_tracking:
- if (mMapboxMap != null) {
+ if (mapboxMap != null) {
toggleGps(true);
}
return true;
case R.id.action_bangalore:
- if (mMapboxMap != null) {
+ if (mapboxMap != null) {
moveToBangalore();
}
return true;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java
index baa4142489..46afd11674 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java
@@ -5,7 +5,6 @@ import android.app.Fragment;
import android.app.FragmentManager;
import android.content.SharedPreferences;
import android.content.res.Configuration;
-import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar;
@@ -26,12 +25,15 @@ import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapFragment;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
+import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.testapp.R;
public class NavigationDrawerActivity extends AppCompatActivity {
private boolean firstStyle = true;
+ private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -58,17 +60,29 @@ public class NavigationDrawerActivity extends AppCompatActivity {
// update the main content by replacing fragments
switch (position) {
case 0:
+ // options
MapboxMapOptions options = new MapboxMapOptions();
options.styleUrl(firstStyle ? Style.LIGHT : Style.SATELLITE);
options.camera(new CameraPosition.Builder()
.target(new LatLng(39.913271, 116.413891))
.zoom(12)
.build());
+
+ // fragment
+ MapFragment mapFragment = MapFragment.newInstance(options);
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
- .replace(R.id.container, MapFragment.newInstance(options))
+ .replace(R.id.container, mapFragment)
.commit();
+ // get callback when map is ready
+ mapFragment.getMapAsync(new OnMapReadyCallback() {
+ @Override
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
+ }
+ });
+
firstStyle = !firstStyle;
break;
case 1:
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SurfaceViewMediaControlActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SurfaceViewMediaControlActivity.java
index 4e193573dd..ed87d75ca0 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SurfaceViewMediaControlActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SurfaceViewMediaControlActivity.java
@@ -12,14 +12,17 @@ import android.view.MotionEvent;
import android.widget.FrameLayout;
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 javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
-public class SurfaceViewMediaControlActivity extends AppCompatActivity {
+public class SurfaceViewMediaControlActivity extends AppCompatActivity implements OnMapReadyCallback {
private MapView mMapView;
+ private MapboxMap mapboxMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -37,6 +40,7 @@ public class SurfaceViewMediaControlActivity extends AppCompatActivity {
mMapView = (MapView) findViewById(R.id.mapView);
mMapView.onCreate(savedInstanceState);
+ mMapView.getMapAsync(this);
// add another SurfaceView to the Layout
FrameLayout container = (FrameLayout) findViewById(R.id.container);
@@ -46,6 +50,11 @@ public class SurfaceViewMediaControlActivity extends AppCompatActivity {
}
@Override
+ public void onMapReady(MapboxMap mapboxMap) {
+ this.mapboxMap = mapboxMap;
+ }
+
+ @Override
public void onResume() {
super.onResume();
mMapView.onResume();
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java
index 8819168478..4d5e2552fd 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java
@@ -47,7 +47,7 @@ public class OfflineActivity extends AppCompatActivity
* UI elements
*/
private MapView mMapView;
- private MapboxMap mMapboxMap;
+ private MapboxMap mapboxMap;
private ProgressBar mProgressBar;
private Button downloadRegion;
private Button listRegions;
@@ -82,7 +82,7 @@ public class OfflineActivity extends AppCompatActivity
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
Log.d(LOG_TAG, "Map is ready");
- mMapboxMap = mapboxMap;
+ OfflineActivity.this.mapboxMap = mapboxMap;
// Set initial position to UNHQ in NYC
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
@@ -240,10 +240,10 @@ public class OfflineActivity extends AppCompatActivity
startProgress();
// Definition
- String styleURL = mMapboxMap.getStyleUrl();
- LatLngBounds bounds = mMapboxMap.getProjection().getVisibleRegion().latLngBounds;
- double minZoom = mMapboxMap.getCameraPosition().zoom;
- double maxZoom = mMapboxMap.getMaxZoom();
+ String styleURL = mapboxMap.getStyleUrl();
+ LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;
+ double minZoom = mapboxMap.getCameraPosition().zoom;
+ double maxZoom = mapboxMap.getMaxZoom();
float pixelRatio = this.getResources().getDisplayMetrics().density;
OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
styleURL, bounds, minZoom, maxZoom, pixelRatio);
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 d630ee6d21..d19e55d508 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
@@ -7,7 +7,6 @@ import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.annotation.UiThread;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
@@ -17,7 +16,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
@@ -70,6 +68,7 @@ public class MyLocationDrawableActivity extends AppCompatActivity implements Loc
mapboxMapOptions.myLocationAccuracyAlpha(155);
mapView = new MapView(this, mapboxMapOptions);
+ mapView.setId(R.id.mapView);
ViewGroup parent = (ViewGroup) findViewById(R.id.container);
parent.addView(mapView);
@@ -102,7 +101,7 @@ public class MyLocationDrawableActivity extends AppCompatActivity implements Loc
Location location = mapboxMap.getMyLocation();
if (location != null) {
onLocationChanged(location);
- }else{
+ } else {
LocationServices.getLocationServices(this).addLocationListener(this);
}
} else {
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 ba86fa5774..3fc793ad1d 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
@@ -30,7 +30,7 @@ import com.mapbox.mapboxsdk.testapp.R;
public class MyLocationTintActivity extends AppCompatActivity implements LocationListener {
private MapView mapView;
- private MapboxMap map;
+ private MapboxMap mapboxMap;
private boolean firstRun;
private static final int PERMISSIONS_LOCATION = 0;
@@ -53,8 +53,8 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
- public void onMapReady(MapboxMap mapboxMap) {
- map = mapboxMap;
+ public void onMapReady(MapboxMap map) {
+ mapboxMap = map;
toggleGps(!mapboxMap.isMyLocationEnabled());
final MyLocationViewSettings myLocationViewSettings = mapboxMap.getMyLocationViewSettings();
@@ -92,8 +92,8 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio
@Override
public void onLocationChanged(Location location) {
- if (map != null && firstRun) {
- map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15));
+ if (mapboxMap != null && firstRun) {
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15));
firstRun = false;
}
}
@@ -167,12 +167,14 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio
private void enableLocation(boolean enabled) {
if (enabled) {
- map.setMyLocationEnabled(true);
- if (map.getMyLocation() != null) {
- map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(map.getMyLocation().getLatitude(), map.getMyLocation().getLongitude()), 15));
+ mapboxMap.setMyLocationEnabled(true);
+ if (mapboxMap.getMyLocation() != null) {
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
+ new LatLng(mapboxMap.getMyLocation().getLatitude(),
+ mapboxMap.getMyLocation().getLongitude()), 15));
}
} else {
- map.setMyLocationEnabled(false);
+ mapboxMap.setMyLocationEnabled(false);
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java
index 36fc87630e..d65eeda9f0 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java
@@ -35,7 +35,7 @@ import com.mapbox.mapboxsdk.testapp.R;
public class MyLocationTrackingModeActivity extends AppCompatActivity implements MapboxMap.OnMyLocationChangeListener, AdapterView.OnItemSelectedListener {
private MapView mMapView;
- private MapboxMap mMapboxMap;
+ private MapboxMap mapboxMap;
private Spinner mLocationSpinner, mBearingSpinner;
private Location mLocation;
private static final int PERMISSIONS_LOCATION = 0;
@@ -60,7 +60,7 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
- mMapboxMap = mapboxMap;
+ MyLocationTrackingModeActivity.this.mapboxMap = mapboxMap;
// disable dismissal when a gesture occurs
TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
@@ -126,13 +126,13 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements
private void enableLocation(boolean enabled) {
if (enabled) {
- mMapboxMap.setMyLocationEnabled(true);
- Location location = mMapboxMap.getMyLocation();
+ mapboxMap.setMyLocationEnabled(true);
+ Location location = mapboxMap.getMyLocation();
if (location != null) {
setInitialPosition(new LatLng(location));
}
} else {
- mMapboxMap.setMyLocationEnabled(false);
+ mapboxMap.setMyLocationEnabled(false);
}
}
@@ -148,8 +148,8 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements
}
private void setInitialPosition(LatLng latLng) {
- mMapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14));
- mMapboxMap.setMyLocationEnabled(true);
+ mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14));
+ mapboxMap.setMyLocationEnabled(true);
mLocationSpinner.setEnabled(true);
mBearingSpinner.setEnabled(true);
}
@@ -189,7 +189,7 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) throws SecurityException {
- TrackingSettings trackingSettings = mMapboxMap.getTrackingSettings();
+ TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
if (parent.getId() == R.id.spinner_location) {
switch (position) {
case 0:
@@ -267,13 +267,13 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements
return true;
case R.id.action_toggle_dismissible_tracking:
state = !item.isChecked();
- mMapboxMap.getTrackingSettings().setDismissLocationTrackingOnGesture(state);
+ mapboxMap.getTrackingSettings().setDismissLocationTrackingOnGesture(state);
Toast.makeText(this, "Dismiss tracking mode on gesture = " + state, Toast.LENGTH_SHORT).show();
item.setChecked(state);
return true;
case R.id.action_toggle_dismissible_bearing:
state = !item.isChecked();
- mMapboxMap.getTrackingSettings().setDismissBearingTrackingOnGesture(state);
+ mapboxMap.getTrackingSettings().setDismissBearingTrackingOnGesture(state);
Toast.makeText(this, "Dismiss bearing mode on gesture = " + state, Toast.LENGTH_SHORT).show();
item.setChecked(state);
return true;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml
index b9bfa701a8..eabfc30b25 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml
@@ -13,7 +13,7 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar"
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_layer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_layer.xml
index 2b52f7d8fd..247d10bf86 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_layer.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_layer.xml
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
@@ -17,8 +17,7 @@
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- >
+ android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator_layout"
@@ -26,7 +25,7 @@
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@@ -37,8 +36,7 @@
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_layers_24dp"
- app:backgroundTint="@android:color/white"
- />
+ app:backgroundTint="@android:color/white" />
</android.support.design.widget.CoordinatorLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_dynamic_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_dynamic_marker.xml
index 73592448b2..6d9a15af89 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_dynamic_marker.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_dynamic_marker.xml
@@ -23,7 +23,7 @@
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml
index cce6883541..002ece58bf 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml
@@ -13,7 +13,7 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow.xml
index eccd3ea8eb..e69983941a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow.xml
@@ -13,12 +13,12 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:style_url="@string/style_mapbox_streets"
app:center_latitude="38.897705003219784"
app:center_longitude="-77.03655168667463"
+ app:style_url="@string/style_mapbox_streets"
app:zoom="15" />
</LinearLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter.xml
index ccced6bbff..dde63c8420 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter.xml
@@ -13,12 +13,12 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:style_url="@string/style_mapbox_streets"
app:center_latitude="47.798202"
app:center_longitude="7.573781"
+ app:style_url="@string/style_mapbox_streets"
app:zoom="4" />
</LinearLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter_dynamic.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter_dynamic.xml
index ccced6bbff..dde63c8420 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter_dynamic.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter_dynamic.xml
@@ -13,12 +13,12 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:style_url="@string/style_mapbox_streets"
app:center_latitude="47.798202"
app:center_longitude="7.573781"
+ app:style_url="@string/style_mapbox_streets"
app:zoom="4" />
</LinearLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_concurrent.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_concurrent.xml
deleted file mode 100644
index 062726fcb2..0000000000
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_concurrent.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <android.support.v7.widget.Toolbar
- android:id="@+id/toolbar"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:background="@color/primary"
- android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
-
- <com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/infoWindowConcurrentMapView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:style_url="@string/style_mapbox_streets"
- app:center_latitude="38.897705003219784"
- app:center_longitude="-77.03655168667463"
- app:zoom="15" />
-
-</LinearLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_location_picker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_location_picker.xml
index f9fe77bfec..f6a89c0149 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_location_picker.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_location_picker.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
@@ -11,31 +11,31 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_below="@id/toolbar"/>
+ android:layout_below="@id/toolbar" />
<ImageButton
android:id="@+id/clearDisplayViewButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:src="@drawable/ic_clear_24dp"
- android:background="@color/accent"
- android:visibility="gone"
- android:layout_marginLeft="@dimen/full_button_margin"
android:layout_above="@+id/selectLocationButton"
android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"/>
+ android:layout_alignParentStart="true"
+ android:layout_marginLeft="@dimen/full_button_margin"
+ android:background="@color/accent"
+ android:src="@drawable/ic_clear_24dp"
+ android:visibility="gone" />
<Button
android:id="@+id/selectLocationButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
android:layout_margin="@dimen/full_button_margin"
android:background="@color/primary"
android:text="@string/navigation_select_location_button_text"
- android:textColor="@android:color/white"
- android:layout_alignParentBottom="true"/>
+ android:textColor="@android:color/white" />
</RelativeLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml
index 6a90a8eafb..746b8ffb11 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml
@@ -11,12 +11,10 @@
android:background="@color/primary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
-
-
<com.mapbox.mapboxsdk.maps.MapView
- android:layout_below="@id/toolbar"
- android:id="@+id/manualZoomMapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"
+ android:layout_below="@id/toolbar" />
</RelativeLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_padding.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_padding.xml
index f0e635f29c..cd61fef44b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_padding.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_padding.xml
@@ -5,7 +5,7 @@
android:orientation="vertical">
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@@ -27,7 +27,6 @@
android:alpha="0.5"
android:background="@color/mapbox_blue" />
-
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
@@ -40,8 +39,8 @@
android:layout_width="@dimen/map_padding_right"
android:layout_height="match_parent"
android:layout_gravity="end"
- android:alpha="0.5"
android:layout_marginTop="?attr/actionBarSize"
+ android:alpha="0.5"
android:background="@color/mapbox_blue" />
</FrameLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_maxmin_zoom.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_maxmin_zoom.xml
index 611766acb1..951344e35a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_maxmin_zoom.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_maxmin_zoom.xml
@@ -13,7 +13,7 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar"
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml
index 75218423fb..262128703f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml
@@ -25,5 +25,4 @@
</FrameLayout>
-
</LinearLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml
index e8204117a3..8ca01ef411 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -21,8 +20,7 @@
<com.mapbox.mapboxsdk.maps.MapView
android:id="@id/mapView"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- />
+ android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabLocationToggle"
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline.xml
index c774e21175..434cb59115 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline.xml
@@ -21,7 +21,7 @@
android:visibility="gone" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/progress_bar" />
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polyline.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polyline.xml
index 8ff9f82b09..9e2f875192 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polyline.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polyline.xml
@@ -13,13 +13,13 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar"
+ app:attribution_tint="@android:color/holo_green_dark"
app:center_latitude="47.798202"
app:center_longitude="7.573781"
- app:attribution_tint="@android:color/holo_green_dark"
app:style_url="@string/style_mapbox_streets"
app:zoom="4" />
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_press_for_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_press_for_marker.xml
index 86a97017b9..9ff79686d2 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_press_for_marker.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_press_for_marker.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
@@ -10,19 +10,19 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
- android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/pressForMarkerMapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_below="@id/toolbar"
+ app:attribution_gravity="top|end"
app:center_latitude="45.1855569"
app:center_longitude="5.7215506"
- app:zoom="11"
- app:style_url="@string/style_mapbox_streets"
app:logo_gravity="top|end"
- app:attribution_gravity="top|end"
app:logo_margin_right="10dp"
- android:layout_below="@id/toolbar"/>
+ app:style_url="@string/style_mapbox_streets"
+ app:zoom="11" />
</RelativeLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_print.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_print.xml
index 10e312e8c6..76451f5918 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_print.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_print.xml
@@ -25,7 +25,7 @@
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@@ -36,7 +36,7 @@
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_print_24dp"
- app:backgroundTint="@color/accent"/>
+ app:backgroundTint="@color/accent" />
</android.support.design.widget.CoordinatorLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_runtime_style.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_runtime_style.xml
index 4c0d067c14..34823b0da1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_runtime_style.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_runtime_style.xml
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
- android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_below="@id/toolbar"/>
+ android:layout_below="@id/toolbar" />
</RelativeLayout>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_scroll_by.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_scroll_by.xml
index eb0d0a2245..c5bb8d71b3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_scroll_by.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_scroll_by.xml
@@ -22,16 +22,16 @@
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:paddingBottom="8dp"
- android:textSize="20sp"
+ android:text="Move the map by x/y pixels"
android:textColor="#FFFFFF"
- android:text="Move the map by x/y pixels" />
+ android:textSize="20sp" />
<TextView
android:id="@+id/textview_x"
- android:layout_alignBottom="@+id/seekbar_move_x"
- android:layout_below="@id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_alignBottom="@+id/seekbar_move_x"
+ android:layout_below="@id/title"
android:text="X: 0000" />
<SeekBar
@@ -56,8 +56,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/seekbar_move_x"
android:layout_marginBottom="8dp"
- android:layout_marginTop="16dp"
android:layout_marginLeft="56dp"
+ android:layout_marginTop="16dp"
android:max="50"
android:progress="0" />
@@ -77,13 +77,13 @@
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
+ android:layout_height="match_parent"
app:center_latitude="37.176546"
app:center_longitude="-3.599007"
app:style_url="@string/style_emerald"
- app:zoom="15"
- android:layout_height="match_parent" />
+ app:zoom="15" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_surfaceview_mediacontrols.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_surfaceview_mediacontrols.xml
index 15394f8f33..8fa94041ff 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_surfaceview_mediacontrols.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_surfaceview_mediacontrols.xml
@@ -13,7 +13,7 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar"
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml
index dfa61e6ba2..17a5c27942 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml
@@ -12,7 +12,7 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_double_map.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_double_map.xml
index db50720257..b976013ead 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_double_map.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_double_map.xml
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.mapbox.mapboxsdk.maps.MapView
- android:id="@+id/mapView"
+ android:id="@id/mapView"
android:layout_width="match_parent"
- android:layout_height="match_parent"/>
+ android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/map_card"
@@ -20,7 +19,6 @@
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mini_map"
android:layout_width="100dp"
- android:layout_height="100dp"
- />
+ android:layout_height="100dp" />
</FrameLayout>
</RelativeLayout>
diff --git a/platform/android/bitrise.yml b/platform/android/bitrise.yml
index 12a1ab8eab..249e13d6dd 100644
--- a/platform/android/bitrise.yml
+++ b/platform/android/bitrise.yml
@@ -2,6 +2,8 @@
format_version: 1.0.0
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
trigger_map:
+- pattern: devicefarmUpload
+ workflow: devicefarmUpload
- pattern: scheduled
workflow: scheduled
- pattern: "*"
@@ -79,3 +81,37 @@ workflows:
cd platform/android
./gradlew uploadArchives
+ devicefarmUpload:
+ steps:
+ - script:
+ title: Build
+ inputs:
+ - content: |-
+ #!/bin/bash
+ set -eu -o pipefail
+ curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
+ sudo apt-get install -y pkg-config nodejs cmake
+
+ echo "AWS_ACCESS_KEY_ID_DEVICE_FARM=$AWS_ACCESS_KEY_ID_DEVICE_FARM
+ AWS_SECRET_ACCESS_KEY_DEVICE_FARM=$AWS_SECRET_ACCESS_KEY_DEVICE_FARM"
+ >> platform/android/MapboxGLAndroidSDK/gradle.properties
+
+ export BUILDTYPE=Release
+ make apackage
+
+ make android-generate-test
+ cd platform/android/
+ ./gradlew devicefarmUpload
+ - slack:
+ title: Post to Slack
+ inputs:
+ - webhook_url: "$SLACK_HOOK_URL"
+ - channel: "#gl-bots"
+ - from_username: 'Bitrise Android'
+ - from_username_on_error: 'Bitrise Android'
+ - message: '<${BITRISE_BUILD_URL}|Build #${BITRISE_BUILD_NUMBER}>
+ for devicefarmUpload passed'
+ - message_on_error: '<${BITRISE_BUILD_URL}|Build #${BITRISE_BUILD_NUMBER}>
+ for devicefarmUpload failed'
+ - icon_url: https://bitrise-public-content-production.s3.amazonaws.com/slack/bitrise-slack-icon-128.png
+ - icon_url_on_error: https://bitrise-public-content-production.s3.amazonaws.com/slack/bitrise-slack-error-icon-128.png
diff --git a/platform/android/build.gradle b/platform/android/build.gradle
index 422575298b..53971cb7a7 100644
--- a/platform/android/build.gradle
+++ b/platform/android/build.gradle
@@ -1,5 +1,3 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
buildscript {
repositories {
jcenter()
@@ -8,9 +6,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.github.JakeWharton:sdk-manager-plugin:220bf7a88a7072df3ed16dc8466fb144f2817070'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.amazonaws:aws-devicefarm-gradle-plugin:1.2'
}
}
diff --git a/platform/android/scripts/generate-test-code.js b/platform/android/scripts/generate-test-code.js
new file mode 100644
index 0000000000..1580949fda
--- /dev/null
+++ b/platform/android/scripts/generate-test-code.js
@@ -0,0 +1,60 @@
+'use strict';
+
+const fs = require('fs');
+const ejs = require('ejs');
+
+global.iff = function (condition, val) {
+ return condition() ? val : "";
+}
+
+global.camelize = function (str) {
+ return str.replace(/(?:^|-)(.)/g, function (_, x) {
+ return x.toUpperCase();
+ });
+}
+
+
+const excludeActivities = ["GeoJsonClusteringActivity","RuntimeStyleTestActivity", "AnimatedMarkerActivity", "ViewPagerActivity","MapFragmentActivity","SupportMapFragmentActivity","SnapshotActivity","NavigationDrawerActivity"];
+const appBasePath = 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity';
+const testBasePath = 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/gen';
+const subPackages = fs.readdirSync(appBasePath);
+const ejsConversionTask = ejs.compile(fs.readFileSync('platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/activity.junit.ejs', 'utf8'), {strict: true});
+
+if (!fs.existsSync(testBasePath)){
+ fs.mkdirSync(testBasePath);
+}
+
+for(const subPackage of subPackages) {
+ if(!(subPackage.slice(-5) == '.java')) {
+ const activities = fs.readdirSync(appBasePath+'/'+subPackage);
+
+ // create directories for package
+ if (!fs.existsSync(testBasePath+"/"+subPackage)){
+ fs.mkdirSync(testBasePath+"/"+subPackage);
+ }
+
+ for (const activity of activities) {
+ // strip .java from input file
+ const activityName = activity.slice(0, -5);
+
+ // create path for test file
+ const filePath = testBasePath+"/"+subPackage+"/"+activityName+'Test.java';
+
+ // try removing previous generated files
+ try {
+ fs.accessSync(filePath, fs.F_OK);
+ fs.unlinkSync(filePath);
+ console.log("Removed file: "+filePath);
+ } catch (e) {
+ console.log("No file found: "+filePath);
+ }
+
+ // only generate test file if not part of exclude list
+ if (!(excludeActivities.indexOf(activityName) > -1)) {
+ console.log("Created file: "+filePath);
+ fs.writeFileSync(filePath, ejsConversionTask([activityName, subPackage]));
+ }
+ }
+ }
+}
+
diff --git a/platform/android/tests/docs/ACTIVITY_SANITY_TEST.md b/platform/android/tests/docs/ACTIVITY_SANITY_TEST.md
new file mode 100644
index 0000000000..14e4335111
--- /dev/null
+++ b/platform/android/tests/docs/ACTIVITY_SANITY_TEST.md
@@ -0,0 +1,17 @@
+# Activity Sanity Tests
+
+This type of test checks if an Activity doesn't crash at start up. For this project this type of test is usefull since a lot of core crashes occurs at this point and are ideal to test regressions. The only run for 1 sec each so there are fast and fairly reliable. We are currently generating the test stack from every Activity found in the following package:
+
+> com.mapbox.mapboxsdk.testapp
+
+The generation is done by executing:
+
+> make android-generate-test
+
+This command underneath executes the following js file found in:
+
+> node scripts/android-generate-test
+
+and uses the following ejs file as a template.
+
+>platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/activity.junit.ejs
diff --git a/platform/android/tests/docs/UI_TESTS.md b/platform/android/tests/docs/UI_TESTS.md
index 4d7addea0d..9341cf1e1e 100644
--- a/platform/android/tests/docs/UI_TESTS.md
+++ b/platform/android/tests/docs/UI_TESTS.md
@@ -59,92 +59,9 @@ You can generate JaCoCo reports from espresso tests by
- running the gradle task `createMockDebugCoverageReport` when executing tests.
## Running Espresso test automatically on AWS Device Farm
-To automatically execute Espresso tests as part of our CI build, we have created a Python script called [`devicefarm.py`](https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/tests/scripts/devicefarm.py).
-
-This script is responsible for:
- - uploading an APK + test APK
- - scheduling tests
- - exiting with a return code
- - 0 -> all tests have passed
- - 1 otherwise
-
-### Requirements
-
- * [Boto 3](http://boto3.readthedocs.org)
- * [Requests](http://www.python-requests.org)
-
-### Running the script
-
- A sample run would be as follows:
-
- ```
- $ python devicefarm.py \
- --project-arn "arn:aws:devicefarm:us-west-2:XXXXX" \
- --device-pool-arn "arn:aws:devicefarm:us-west-2::devicepool:YYYYY" \
- --app-apk-path app/build/outputs/apk/app-debug-unaligned.apk \
- --test-apk-path app/build/outputs/apk/app-debug-androidTest-unaligned.apk
- ```
-
- Where you need to insert your actual project and device ARNs. We follow Boto 3
- conventions to to [set up the AWS credentials](https://github.com/boto/boto3#quick-start).
-
- You can build the `app-debug-androidTest-unaligned.apk` package with Gradle:
-
- ```
- ./gradlew assembleAndroidTest
- ```
-
- To run tests locally, you can use `./gradlew assemble` to build the app APK, and
- `./gradlew test --continue` to run unit tests. Finally, `./gradlew connectedAndroidTest`
- will run the Espresso tests in a local device.
-
- A sample output would be as follows:
-
- ```
- Starting upload: ANDROID_APP
- Uploading: ../app/build/outputs/apk/app-debug-unaligned.apk
- Checking if the upload succeeded.
- Upload not ready (status is INITIALIZED), waiting for 5 seconds.
- Starting upload: INSTRUMENTATION_TEST_PACKAGE
- Uploading: ../app/build/outputs/apk/app-debug-androidTest-unaligned.apk
- Checking if the upload succeeded.
- Upload not ready (status is INITIALIZED), waiting for 5 seconds.
- Scheduling a run.
- Checking if the run succeeded.
- Run not completed (status is SCHEDULING), waiting for 60 seconds.
- Run not completed (status is RUNNING), waiting for 60 seconds.
- Run not completed (status is RUNNING), waiting for 60 seconds.
- Run not completed (status is RUNNING), waiting for 60 seconds.
- Run not completed (status is RUNNING), waiting for 60 seconds.
- Run not completed (status is RUNNING), waiting for 60 seconds.
- Run completed: PASSED
- ```
-
-### Available commands
-
- You can use the `--help` command to get a list of all available options:
-
- ```
- $ python devicefarm.py --help
- usage: Device Farm Runner [-h] [--project-arn PROJECT_ARN]
- [--device-pool-arn DEVICE_POOL_ARN]
- [--app-apk-path APP_APK_PATH]
- [--test-apk-path TEST_APK_PATH]
-
- Runs the Espresso tests on AWS Device Farm.
-
- optional arguments:
- -h, --help show this help message and exit
- --project-arn PROJECT_ARN
- The project ARN (Amazon Resource Name) (default: None)
- --device-pool-arn DEVICE_POOL_ARN
- The device pool ARN (Amazon Resource Name) (default:
- None)
- --app-apk-path APP_APK_PATH
- Path to the app APK (default: None)
- --test-apk-path TEST_APK_PATH
- Path to the tests APK (default: None)
- ```
+To run tests on AWS device farm you need to execute `./gradlew devicefarmUpload`.
+You can configure the different steps in the testapp `build.gradle`.
+AWS credentials are found in bitrise.
diff --git a/platform/android/tests/scripts/devicefarm.py b/platform/android/tests/scripts/devicefarm.py
deleted file mode 100644
index 6c0a337403..0000000000
--- a/platform/android/tests/scripts/devicefarm.py
+++ /dev/null
@@ -1,132 +0,0 @@
-'''
-Uploads an APK and a test APK to AWS Device Farm and runs the Espresso tests.
-Exit code is 0 if all tests pass, 1 otherwise. See README.md for details.
-'''
-
-from time import sleep
-import argparse
-import boto3
-import requests
-
-'''
-Parser
-'''
-
-parser = argparse.ArgumentParser(
- prog='Device Farm Runner',
- description='Runs the Espresso tests on AWS Device Farm.',
- formatter_class=argparse.ArgumentDefaultsHelpFormatter,
- add_help=True)
-
-parser.add_argument('--project-arn',
- type=str, help='The project ARN (Amazon Resource Name)')
-parser.add_argument('--device-pool-arn',
- type=str, help='The device pool ARN (Amazon Resource Name)')
-parser.add_argument('--app-apk-path',
- type=str, help='Path to the app APK')
-parser.add_argument('--test-apk-path',
- type=str, help='Path to the tests APK')
-
-args = vars(parser.parse_args())
-project_arn = args.get('project_arn')
-device_pool_arn = args.get('device_pool_arn')
-app_apk_path = args.get('app_apk_path')
-test_apk_path = args.get('test_apk_path')
-
-# Check
-if not project_arn or not device_pool_arn:
- raise Exception('You need to set both the project and the device pool ARN.')
-elif not app_apk_path or not test_apk_path:
- raise Exception('You need to set both the app and test APK path.')
-
-'''
-The AWS Device Farm client
-'''
-
-client = boto3.client('devicefarm', region_name='us-west-2')
-
-'''
-Methods
-'''
-
-def upload_apk(apk_name, apk_path, apk_type):
- print 'Starting upload: %s' % apk_type
- result = client.create_upload(
- projectArn=project_arn, name=apk_name, type=apk_type)
- presigned_url = result.get('upload').get('url')
- upload_arn = result.get('upload').get('arn')
-
- # PUT the file content and wait
- put_file(apk_path=apk_path, presigned_url=presigned_url)
- wait_for_upload(upload_arn=upload_arn)
- return upload_arn
-
-def put_file(apk_path, presigned_url):
- print 'Uploading: %s' % apk_path
- with open(apk_path, 'rb') as f:
- data = f.read()
- result = requests.put(presigned_url, data=data)
- if result.status_code != 200:
- raise Exception(
- 'PUT failed with status code: %s' % result.status_code)
-
-def wait_for_upload(upload_arn):
- print 'Checking if the upload succeeded.'
- succeeded = False
- while not succeeded:
- result = client.get_upload(arn=upload_arn)
- status = result.get('upload').get('status')
- succeeded = (status == 'SUCCEEDED')
- if status == 'FAILED':
- raise Exception('Upload failed.')
- elif not succeeded:
- print 'Upload is not ready (status is %s), waiting for 5 seconds.' % status
- sleep(5)
-
-def schedule_run(app_arn, test_arn):
- print 'Scheduling a run.'
- result = client.schedule_run(
- projectArn=project_arn,
- appArn=app_arn,
- devicePoolArn=device_pool_arn,
- name='automated_run',
- test={ 'type': 'INSTRUMENTATION', 'testPackageArn': test_arn})
- run_arn = result.get('run').get('arn')
- return_code = wait_for_run(run_arn=run_arn)
- return return_code
-
-def wait_for_run(run_arn):
- print 'Checking if the run succeeded.'
- return_code = ''
- succeeded = False
- while not succeeded:
- result = client.get_run(arn=run_arn)
- status = result.get('run').get('status')
- return_code = result.get('run').get('result')
- succeeded = (status == 'COMPLETED')
- if not succeeded:
- print 'Run not completed (status is %s), waiting for 60 seconds.' % status
- sleep(60)
- return return_code
-
-'''
-Main flow
-'''
-
-# 1. Upload the app APK
-app_arn = upload_apk(
- apk_name='app-debug-unaligned.apk',
- apk_path=app_apk_path,
- apk_type='ANDROID_APP')
-
-# 2. Upload the test APK
-test_arn = upload_apk(
- apk_name='app-debug-androidTest-unaligned.apk',
- apk_path=test_apk_path,
- apk_type='INSTRUMENTATION_TEST_PACKAGE')
-
-# 3. Schedule the run
-return_code = schedule_run(app_arn=app_arn, test_arn=test_arn)
-exit_code = 0 if return_code == 'PASSED' else 1
-print 'Run completed: %s' % return_code
-exit(exit_code) \ No newline at end of file