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
This commit is contained in:
4
Makefile
4
Makefile
@@ -464,6 +464,10 @@ apackage:
|
||||
style-code-android:
|
||||
node platform/android/scripts/generate-style-code.js
|
||||
|
||||
.PHONY: android-generate-test
|
||||
android-generate-test:
|
||||
node platform/android/scripts/generate-test-code.js
|
||||
|
||||
#### Miscellaneous targets #####################################################
|
||||
|
||||
.PHONY: style-code
|
||||
|
||||
4
platform/android/.gitignore
vendored
4
platform/android/.gitignore
vendored
@@ -27,3 +27,7 @@ fabric.properties
|
||||
|
||||
# Capture files
|
||||
captures/
|
||||
|
||||
# Generated test cases
|
||||
MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/gen/
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
protected final static String HOME_BUTTON_STRING = "Navigate up";
|
||||
@Rule
|
||||
public ActivityTestRule<Activity> rule = new ActivityTestRule<>(getActivityClass());
|
||||
protected MapboxMap mapboxMap;
|
||||
protected OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
/*
|
||||
* Shortcuts for common UI tests
|
||||
*/
|
||||
@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();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.activity.utils;
|
||||
package com.mapbox.mapboxsdk.utils;
|
||||
|
||||
import android.support.annotation.IdRes;
|
||||
|
||||
@@ -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;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.activity.utils;
|
||||
package com.mapbox.mapboxsdk.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.activity.utils;
|
||||
package com.mapbox.mapboxsdk.utils;
|
||||
|
||||
import android.support.annotation.IdRes;
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,21 +86,23 @@ 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();
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,25 +9,25 @@ 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 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);
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapView mapView;
|
||||
private boolean cameraState;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(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() {
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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) {
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.setStyleUrl(Style.DARK);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(this);
|
||||
}
|
||||
|
||||
UiSettings uiSettings = mapboxMap.getUiSettings();
|
||||
uiSettings.setAllGesturesEnabled(false);
|
||||
@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("Los Angeles")
|
||||
.snippet("City Hall")
|
||||
.position(LOS_ANGELES));
|
||||
|
||||
mapboxMap.addMarker(new MarkerOptions()
|
||||
.title("New York")
|
||||
.snippet("City Hall")
|
||||
.position(NEW_YORK));
|
||||
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);
|
||||
List<LatLng> points = new ArrayList<>();
|
||||
points.add(NEW_YORK);
|
||||
points.add(LOS_ANGELES);
|
||||
|
||||
// Create Bounds
|
||||
final LatLngBounds bounds = new LatLngBounds.Builder()
|
||||
.includes(points)
|
||||
.build();
|
||||
// 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);
|
||||
// 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));
|
||||
// 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());
|
||||
}
|
||||
});
|
||||
// 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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
@Override
|
||||
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
|
||||
UiSettings uiSettings = mapboxMap.getUiSettings();
|
||||
uiSettings.setLogoEnabled(false);
|
||||
uiSettings.setAttributionEnabled(false);
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.setTag(true);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(this);
|
||||
}
|
||||
|
||||
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)
|
||||
);
|
||||
}
|
||||
});
|
||||
@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 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 {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
|
||||
mapboxMap = map;
|
||||
|
||||
//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 onMapReady(@NonNull final MapboxMap mapboxMap) {
|
||||
//Add info window adapter
|
||||
addCustomInfoWindowAdapter(mapboxMap);
|
||||
public void onMapClick(@NonNull LatLng point) {
|
||||
//Distance from click to marker
|
||||
double distanceKm = marker.getPosition().distanceTo(point) / 1000;
|
||||
|
||||
//Keep info windows open on click
|
||||
mapboxMap.getUiSettings().setDeselectMarkersOnTap(false);
|
||||
//Get the info window
|
||||
InfoWindow infoWindow = marker.getInfoWindow();
|
||||
|
||||
//Add a marker
|
||||
final MarkerView marker = addMarker(mapboxMap);
|
||||
mapboxMap.selectMarker(marker);
|
||||
//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));
|
||||
|
||||
//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));
|
||||
//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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,11 +57,34 @@ 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
@@ -45,6 +49,11 @@ public class SurfaceViewMediaControlActivity extends AppCompatActivity {
|
||||
container.addView(mediaControlSurfaceView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
this.mapboxMap = mapboxMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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" />
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -25,5 +25,4 @@
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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" />
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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" />
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
60
platform/android/scripts/generate-test-code.js
Normal file
60
platform/android/scripts/generate-test-code.js
Normal file
@@ -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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
platform/android/tests/docs/ACTIVITY_SANITY_TEST.md
Normal file
17
platform/android/tests/docs/ACTIVITY_SANITY_TEST.md
Normal file
@@ -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
|
||||
@@ -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.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user