[android] Move into platform subdirectory

This commit is contained in:
John Firebaugh
2015-12-11 12:39:43 -08:00
parent 0db9f229f2
commit 13d5b18eba
227 changed files with 28 additions and 23 deletions

View File

@@ -0,0 +1,44 @@
package com.mapbox.mapboxsdk.testapp;
import android.app.Activity;
import com.mapbox.mapboxsdk.testapp.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);
}
});
}
}

View File

@@ -0,0 +1,34 @@
package com.mapbox.mapboxsdk.testapp;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
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);
}
}

View File

@@ -0,0 +1,34 @@
package com.mapbox.mapboxsdk.testapp;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
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);
}
}

View File

@@ -0,0 +1,34 @@
package com.mapbox.mapboxsdk.testapp;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
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);
}
}

View File

@@ -0,0 +1,66 @@
package com.mapbox.mapboxsdk.testapp;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.doubleClick;
import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
/**
* Tests on MainActivity with screenshots
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityScreenTest extends BaseTest {
private final static String HOME_BUTTON_STRING = "Navigate up";
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
MainActivity.class);
private MainActivity mActivity = null;
@Before
public void setActivity() {
mActivity = mActivityRule.getActivity();
}
@Test
public void testSanity() {
checkViewIsDisplayed(R.id.mainMapView);
}
/*
* Take a screenshot of Mapbox Streets to monitor #1649
*/
@Test
public void testMapboxStreetsBlackAndWhite() {
// Click home and switch to Mapbox streets
onView(withContentDescription(HOME_BUTTON_STRING))
.perform(click());
onView(withText(R.string.styleMapboxStreets))
.perform(click());
// Zoom in
onView(withId(R.id.mainMapView))
.perform(doubleClick());
onView(withId(R.id.mainMapView))
.perform(doubleClick());
// Standard screenshot
takeNamedScreenshot(mActivity, "testMapboxStreetsBlackAndWhite");
}
}

View File

@@ -0,0 +1,289 @@
package com.mapbox.mapboxsdk.testapp;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.doubleClick;
import static android.support.test.espresso.action.ViewActions.longClick;
import static android.support.test.espresso.action.ViewActions.swipeDown;
import static android.support.test.espresso.action.ViewActions.swipeLeft;
import static android.support.test.espresso.action.ViewActions.swipeRight;
import static android.support.test.espresso.action.ViewActions.swipeUp;
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.withContentDescription;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.not;
/**
* Tests on MainActivity
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityTest extends BaseTest {
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
MainActivity.class);
private MainActivity mActivity = null;
@Before
public void setActivity() {
mActivity = mActivityRule.getActivity();
}
/*
* Note that we need to keep the `test` prefix if we want to be able to run these
* tests on AWS Device Farm, annotations are not enough:
* https://github.com/awslabs/aws-device-farm-sample-app-for-android/issues/5#issuecomment-138258444
*/
@Test
public void testSanity() {
checkViewIsDisplayed(R.id.mainMapView);
}
/*
* Check UI ids are visible
*/
@Test
public void testDrawerLayoutIsDisplayed() {
onView(withId(R.id.drawer_layout))
.check(matches(isDisplayed()));
}
@Test
public void testToolbarIsDisplayed() {
onView(withId(R.id.toolbar))
.check(matches(isDisplayed()));
}
@Test
public void testContentFrameIsDisplayed() {
onView(withId(R.id.content_frame))
.check(matches(isDisplayed()));
}
@Test
public void testViewFpsIsDisplayed() {
// By default, R.id.view_fps is not displayed
onView(withId(R.id.view_fps))
.check(matches(not(isDisplayed())));
}
@Test
public void testLocationFABIsDisplayed() {
onView(withId(R.id.locationFAB))
.check(matches(isDisplayed()));
}
@Test
public void testNavViewIsNotDisplayed() {
// By default, nav_view not displayed
onView(withId(R.id.nav_view))
.check(matches(not(isDisplayed())));
}
@Test
public void testNavViewIsDisplayed() {
// However, it's displayed when we click the home icon
onView(withContentDescription(HOME_BUTTON_STRING))
.perform(click());
onView(withId(R.id.nav_view))
.check(matches(isDisplayed()));
}
/*
* Some more tests on the map view (clicks, gestures)
*/
@Test
public void testClickMap() {
onView(withId(R.id.mainMapView))
.perform(click())
.check(matches(isDisplayed()));
}
@Test
public void testDoubleClickMap() {
onView(withId(R.id.mainMapView))
.perform(doubleClick())
.check(matches(isDisplayed()));
}
@Test
public void testLongClickMap() {
onView(withId(R.id.mainMapView))
.perform(longClick())
.check(matches(isDisplayed()));
}
@Test
public void testSwipeLeftMap() {
onView(withId(R.id.mainMapView))
.perform(swipeLeft())
.check(matches(isDisplayed()));
}
@Test
public void testSwipeRightMap() {
onView(withId(R.id.mainMapView))
.perform(swipeRight())
.check(matches(isDisplayed()));
}
@Test
public void testSwipeDownMap() {
onView(withId(R.id.mainMapView))
.perform(swipeDown())
.check(matches(isDisplayed()));
}
@Test
public void testSwipeUpMap() {
onView(withId(R.id.mainMapView))
.perform(swipeUp())
.check(matches(isDisplayed()));
}
/*
* Test the main drawer options
*/
@Test
public void testNavViewActionDebug() {
onView(withContentDescription(HOME_BUTTON_STRING))
.perform(click());
onView(withText(R.string.action_debug))
.perform(click());
// Clicking the item closes the drawer
onView(withId(R.id.nav_view))
.check(matches(not(isDisplayed())));
}
@Test
public void testNavViewActionPointAnnotations() {
onView(withContentDescription(HOME_BUTTON_STRING))
.perform(click());
onView(withText(R.string.action_point_annotations))
.perform(click());
// Clicking the item closes the drawer
onView(withId(R.id.nav_view))
.check(matches(not(isDisplayed())));
}
@Test
public void testNavViewActionCompass() {
onView(withContentDescription(HOME_BUTTON_STRING))
.perform(click());
onView(withText(R.string.action_compass))
.perform(click());
// Clicking the item closes the drawer
onView(withId(R.id.nav_view))
.check(matches(not(isDisplayed())));
}
@Test
public void testNavViewStyleMapboxStreets() {
onView(withContentDescription(HOME_BUTTON_STRING))
.perform(click());
onView(withText(R.string.styleMapboxStreets))
.perform(click());
// Clicking the item closes the drawer
onView(withId(R.id.nav_view))
.check(matches(not(isDisplayed())));
}
@Test
public void testNavViewStyleEmerald() {
onView(withContentDescription(HOME_BUTTON_STRING))
.perform(click());
onView(withText(R.string.styleEmerald))
.perform(click());
// Clicking the item closes the drawer
onView(withId(R.id.nav_view))
.check(matches(not(isDisplayed())));
}
@Test
public void testNavViewStyleLight() {
onView(withContentDescription(HOME_BUTTON_STRING))
.perform(click());
onView(withText(R.string.styleLight))
.perform(click());
// Clicking the item closes the drawer
onView(withId(R.id.nav_view))
.check(matches(not(isDisplayed())));
}
@Test
public void testNavViewStyleDark() {
onView(withContentDescription(HOME_BUTTON_STRING))
.perform(click());
onView(withText(R.string.styleDark))
.perform(click());
// Clicking the item closes the drawer
onView(withId(R.id.nav_view))
.check(matches(not(isDisplayed())));
}
@Test
public void testNavViewStyleSatellite() {
onView(withContentDescription(HOME_BUTTON_STRING))
.perform(click());
onView(withText(R.string.styleSatellite))
.perform(click());
// Clicking the item closes the drawer
onView(withId(R.id.nav_view))
.check(matches(not(isDisplayed())));
}
/*
* We can also check the map inner elements are visible
*/
@Test
public void testMapIconContentDescription() {
// Mapbox logo
onView(withContentDescription(mActivity.getResources()
.getString(R.string.mapboxIconContentDescription)))
.check(matches(isDisplayed()));
}
// @Test
// public void testMapCompassContentDescription() {
// //FIXME this is currently broken hence compass view is only being showed when rotating the map
// // Map compass
//// onView(withContentDescription(mActivity.getResources()
//// .getString(R.string.compassContentDescription)))
//// .check(matches(isDisplayed()));
// }
@Test
public void testMapAttributionsIconContentDescription() {
// Attribution icon
onView(withContentDescription(mActivity.getResources()
.getString(R.string.attributionsIconContentDescription)))
.check(matches(isDisplayed()));
}
}

View File

@@ -0,0 +1,36 @@
package com.mapbox.mapboxsdk.testapp;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
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
}

View File

@@ -0,0 +1,33 @@
package com.mapbox.mapboxsdk.testapp;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
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);
}
}

View File

@@ -0,0 +1,34 @@
package com.mapbox.mapboxsdk.testapp;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
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);
}
}

View File

@@ -0,0 +1,35 @@
package com.mapbox.mapboxsdk.testapp;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Tests on PressForMarkerActivity
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class PressForMarkerActivityTest extends BaseTest {
@Rule
public ActivityTestRule<PressForMarkerActivity> mActivityRule = new ActivityTestRule<>(
PressForMarkerActivity.class);
private PressForMarkerActivity mActivity = null;
@Before
public void setActivity() {
mActivity = mActivityRule.getActivity();
}
@Test
public void testSanity() {
// we are adding mapview on the fly.. just validating if we have a toolbar
checkViewIsDisplayed(R.id.secondToolBar);
}
}

View File

@@ -0,0 +1,27 @@
package com.mapbox.mapboxsdk.testapp;
import android.support.test.rule.ActivityTestRule;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
public class TiltActivityTest extends BaseTest {
@Rule
public ActivityTestRule<TiltActivity> mActivityRule = new ActivityTestRule<>(
TiltActivity.class);
private TiltActivity mActivity = null;
@Before
public void setActivity() {
mActivity = mActivityRule.getActivity();
}
@Test
public void testSanity() {
checkViewIsDisplayed(R.id.tiltMapView);
}
}

View File

@@ -0,0 +1,34 @@
package com.mapbox.mapboxsdk.testapp;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Tests on VisibleCoordinateBoundsActivity
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class VisibleCoordinateBoundsActivityTest extends BaseTest {
@Rule
public ActivityTestRule<VisibleCoordinateBoundsActivity> mActivityRule = new ActivityTestRule<>(
VisibleCoordinateBoundsActivity.class);
private VisibleCoordinateBoundsActivity mActivity = null;
@Before
public void setActivity() {
mActivity = mActivityRule.getActivity();
}
@Test
public void testSanity() {
checkViewIsDisplayed(R.id.mapView);
}
}

View File

@@ -0,0 +1,130 @@
package com.mapbox.mapboxsdk.testapp.utils;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.Environment;
import android.util.Log;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* The built-in Fuzz Suite on AWS Device Farm takes screenshots after every test. However,
* this doesn't happen with Espresso unless we manually do it. This class fixes it.
*/
public class ScreenshotUtil {
private static final String LOG_TAG = ScreenshotUtil.class.getName();
// Where to store the files. This path is required by AWS Device Farm:
// http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-instrumentation.html#test-types-android-instrumentation-screenshots
private static final String SCREENSHOT_FOLDER = "test-screenshots";
// Image type and quality
private static final String DEFAULT_IMAGE_EXTENSION = ".png";
private static final Bitmap.CompressFormat DEFAULT_IMAGE_FORMAT = Bitmap.CompressFormat.PNG;
private static final int DEFAULT_IMAGE_QUALITY = 100;
public static void take(Activity activity, String testName) {
// Check if storage is available
if (!isExternalStorageWritable()) {
Log.d(LOG_TAG, "External storage is not available.");
return;
}
// Get a bitmap from the activity root view. When the drawing cache is enabled,
// the next call to getDrawingCache() will draw the view in a bitmap.
View rootView = activity.getWindow().getDecorView().getRootView();
rootView.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(rootView.getDrawingCache());
rootView.setDrawingCacheEnabled(false);
// Add the SurfaceView bit (see getAllTextureViews() below)
List<TextureView> tilingViews = getAllTextureViews(rootView);
if (tilingViews.size() > 0) {
Canvas canvas = new Canvas(bitmap);
for (TextureView TextureView : tilingViews) {
Bitmap b = TextureView.getBitmap(TextureView.getWidth(), TextureView.getHeight());
int[] location = new int[2];
TextureView.getLocationInWindow(location);
int[] location2 = new int[2];
TextureView.getLocationOnScreen(location2);
canvas.drawBitmap(b, location[0], location[1], null);
}
}
// Save the bitmap in external storage
String uniqueAbsolutePath = getUniqueAbsolutePath(testName);
File outputFile = new File(uniqueAbsolutePath);
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(outputFile);
bitmap.compress(DEFAULT_IMAGE_FORMAT, DEFAULT_IMAGE_QUALITY, outputStream);
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/*
* The classic way of taking a screenshot (above) doesn't work with TextureView, this fixes it:
* http://stackoverflow.com/questions/19704060/screen-capture-textureview-is-black-using-drawingcache
*/
public static List<TextureView> getAllTextureViews(View view)
{
List<TextureView> tilingViews = new ArrayList<TextureView>();
if (view instanceof TextureView) {
tilingViews.add((TextureView)view);
} else if(view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup)view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
tilingViews.addAll(getAllTextureViews(viewGroup.getChildAt(i)));
}
}
return tilingViews;
}
/*
* Utils
*/
public static boolean isExternalStorageWritable() {
// Checks if external storage is available for read and write
String state = Environment.getExternalStorageState();
return Environment.MEDIA_MOUNTED.equals(state);
}
private static String getUniqueAbsolutePath(String testName) {
// A screenshot after every test vs. manual tests
String filename = UUID.randomUUID().toString() + DEFAULT_IMAGE_EXTENSION;
if (testName != null && !testName.isEmpty()) {
filename = testName + DEFAULT_IMAGE_EXTENSION;
}
String externalPath = Environment.getExternalStorageDirectory().toString();
String path = externalPath + File.separator + SCREENSHOT_FOLDER + File.separator + filename;
Log.d(LOG_TAG, "Screenshot path: " + path);
return path;
}
}

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapbox.mapboxsdk.testapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@drawable/icon_burned"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".VisibleCoordinateBoundsActivity"
android:label="@string/activity_visible_coordinate_bounds" />
<activity
android:name=".InfoWindowAdapterActivity"
android:label="@string/activity_infowindow_adapter" />
<activity
android:name=".InfoWindowActivity"
android:label="@string/activity_info_window" />
<activity
android:name=".InfoWindowConcurrentActivity"
android:label="@string/activity_info_window_concurrent" />
<activity
android:name=".BulkMarkerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/action_add_bulk_markers" />
<activity
android:name=".TiltActivity"
android:label="@string/activity_tilt" />
<activity
android:name=".MapFragmentActivity"
android:label="@string/activity_map_fragment" />
<activity
android:name=".PressForMarkerActivity"
android:label="@string/activity_press_for_marker" />
<activity
android:name=".ManualZoomActivity"
android:label="@string/action_manual_zoom" />
<activity
android:name=".MyLocationTrackingModeActivity"
android:label="@string/activity_user_tracking_mode" />
<activity
android:name=".PolylineActivity"
android:label="@string/activity_polyline" />
<activity
android:name=".CoordinateChangeActivity"
android:label="@string/activity_animate_coordinate_change" />
<meta-data
android:name="io.fabric.ApiKey"
android:value="9724157045ff7d083492c6d9ae03e60e8609d461" />
<meta-data
android:name="com.mapbox.AccessToken"
android:value="" />
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[-121.3714599609375,38.64583568648869],[-121.48681640624999,38.64047263931154],[-121.53076171875,38.61579745317875],[-121.56509399414061,38.57823196583313],[-121.75186157226561,38.533127435052776],[-121.97021484374999,38.35350340353833],[-122.08007812499999,38.24680876017446],[-122.16796875,38.19718009396176],[-122.23800659179686,38.09457899232253],[-122.27371215820312,38.01455819225337],[-122.33551025390625,37.94094845586459],[-122.27371215820312,37.81846319511331],[-122.4151611328125,37.7652868250379]]}}]}

View File

@@ -0,0 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-122.28813171386719,38.617406963286136],[-122.26959228515624,38.6833657775237],[-122.18238830566406,38.55568323796419],[-122.10617065429688,38.51378825951165],[-122.11509704589845,38.50465406475561],[-122.18307495117188,38.542795073979015],[-122.19955444335938,38.496593518947556],[-122.28813171386719,38.617406963286136]]]}}]}

View File

@@ -0,0 +1,211 @@
package com.mapbox.mapboxsdk.testapp;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngZoom;
import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil;
import com.mapbox.mapboxsdk.testapp.utils.TimingLogger;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
import org.json.JSONException;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
public class BulkMarkerActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
private MapView mMapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_marker_bulk);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.onCreate(savedInstanceState);
mMapView.setCenterCoordinate(new LatLngZoom(38.87031, -77.00897, 10));
mMapView.setCompassEnabled(false);
ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(), R.array.bulk_marker_list, android.R.layout.simple_spinner_item);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setAdapter(spinnerAdapter);
spinner.setOnItemSelectedListener(this);
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
int markersAmount = Integer.valueOf(getResources().getStringArray(R.array.bulk_marker_list)[position]);
new LoadBulkMarkerTask(mMapView, markersAmount).execute();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private static class LoadBulkMarkerTask extends AsyncTask<Void, Integer, List<MarkerOptions>> {
private static final String TAG = "LoadBulkMarkerTask";
private WeakReference<MapView> mMapView;
private Context mAppContext;
private ProgressDialog mProgressDialog;
private int mAmount;
public LoadBulkMarkerTask(MapView mapView, int amount) {
Context context = mapView.getContext();
mapView.removeAllAnnotations();
mMapView = new WeakReference<>(mapView);
mProgressDialog = ProgressDialog.show(context, "Loading", "Fetching markers", false);
mAppContext = context.getApplicationContext();
mAmount = amount;
}
@Override
protected List<MarkerOptions> doInBackground(Void... params) {
//Debug.startMethodTracing("bulk-marker");
TimingLogger timings = new TimingLogger(TAG, "doInBackground");
//Log.d(TAG, "isLoggable " + Log.isLoggable(TAG, Log.VERBOSE));
List<MarkerOptions> markerOptions = new ArrayList<>(mAmount);
timings.addSplit("create ArrayList");
try {
DecimalFormat formatter = new DecimalFormat("#.#####");
String json = GeoParseUtil.loadStringFromAssets(mAppContext, "points.geojson");
timings.addSplit("loadStringFromAssets");
List<LatLng> locations = GeoParseUtil.parseGeoJSONCoordinates(json);
timings.addSplit("parseGeoJSONCoordinates");
if (locations.size() < mAmount) {
mAmount = locations.size();
}
LatLng location;
for (int i = 0; i < mAmount; i++) {
location = locations.get(i);
Log.v(TAG, "marker " + i + " of " + mAmount + " added with " + location.getLatitude() + " " + location.getLongitude());
markerOptions.add(new MarkerOptions()
.position(location)
.title("Marker")
.snippet(formatter.format(location.getLatitude()) + ", " + formatter.format(location.getLongitude())));
}
timings.addSplit("create all MarkerOptions");
} catch (IOException | JSONException e) {
Log.e(TAG, "Could not add markers,", e);
}
timings.dumpToLog();
return markerOptions;
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(List<MarkerOptions> markerOptions) {
super.onPostExecute(markerOptions);
TimingLogger timings = new TimingLogger(TAG, "onPostExecute");
MapView mapView = mMapView.get();
if (mapView != null) {
List<Marker> markers = mapView.addMarkers(markerOptions);
Log.v(TAG, "Markers added " + markers.size());
}
timings.addSplit("addMarkers");
timings.dumpToLog();
mProgressDialog.hide();
//Debug.stopMethodTracing();
}
}
}

View File

@@ -0,0 +1,113 @@
package com.mapbox.mapboxsdk.testapp;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngZoom;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
public class CoordinateChangeActivity extends AppCompatActivity {
private MapView mMapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animate_coordinate);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setTag(true);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.onCreate(savedInstanceState);
mMapView.setStyle(Style.MAPBOX_STREETS);
mMapView.setCenterCoordinate(new LatLngZoom(38.87031, -77.00897, 16));
mMapView.setCompassEnabled(false);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setColorFilter(ContextCompat.getColor(this, R.color.primary));
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mMapView.setCenterCoordinate(getCoordinate(), true);
}
});
}
private LatLng getCoordinate() {
boolean first = (boolean) mMapView.getTag();
mMapView.setTag(!first);
return first ? new LatLng(38.87000, -77.00800) : new LatLng(38.87031, -77.00897);
}
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -0,0 +1,12 @@
package com.mapbox.mapboxsdk.testapp;
public class ExampleCustomLayer {
static {
System.loadLibrary("example-custom-layer");
}
public native static long createContext();
public static long InitializeFunction;
public static long RenderFunction;
public static long DeinitializeFunction;
}

View File

@@ -0,0 +1,108 @@
package com.mapbox.mapboxsdk.testapp;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
public class InfoWindowActivity extends AppCompatActivity {
private MapView mMapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_infowindow);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.onCreate(savedInstanceState);
// Enable to let concurrent multiple infowindows to be shown.
//mMapView.setAllowConcurrentMultipleOpenInfoWindows(true);
mMapView.addMarker(new MarkerOptions()
.title("Intersection")
.snippet("H St NW with 15th St NW")
.position(new LatLng(38.9002073, -77.03364419)));
mMapView.addMarker(new MarkerOptions()
.title("White House")
.snippet("The official residence and principal workplace of the President of the United States, located at 1600 Pennsylvania Avenue NW in Washington, D.C. It has been the residence of every U.S. president since John Adams in 1800.")
.position(new LatLng(38.897705003219784, -77.03655168667463)));
mMapView.addMarker(new MarkerOptions().title("Intersection")
.snippet("E St NW with 17th St NW")
.position(new LatLng(38.8954236, -77.0394623)));
}
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -0,0 +1,141 @@
package com.mapbox.mapboxsdk.testapp;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.annotations.Sprite;
import com.mapbox.mapboxsdk.annotations.SpriteFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
public class InfoWindowAdapterActivity extends AppCompatActivity {
private MapView mMapView;
private SpriteFactory mSpriteFactory;
private Drawable mIconDrawable;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_infowindow_adapter);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.onCreate(savedInstanceState);
mSpriteFactory = new SpriteFactory(mMapView);
mIconDrawable = ContextCompat.getDrawable(this, R.drawable.ic_location_city_24dp);
mMapView.setInfoWindowAdapter(new MapView.InfoWindowAdapter() {
private int tenDp = (int) getResources().getDimension(R.dimen.attr_margin);
@Override
public View getInfoWindow(@NonNull Marker marker) {
TextView textView = new TextView(InfoWindowAdapterActivity.this);
textView.setText(marker.getTitle());
textView.setTextColor(Color.WHITE);
textView.setBackgroundColor(Color.parseColor(marker.getSnippet()));
textView.setPadding(tenDp, tenDp, tenDp, tenDp);
return textView;
}
});
// Enable to let concurrent multiple infowindows to be shown.
//mMapView.setAllowConcurrentMultipleOpenInfoWindows(true);
mMapView.addMarker(generateMarker("Andorra", 42.505777, 1.52529, "#F44336"));
mMapView.addMarker(generateMarker("Luxembourg", 49.815273, 6.129583, "#3F51B5"));
mMapView.addMarker(generateMarker("Monaco", 43.738418, 7.424616, "#673AB7"));
mMapView.addMarker(generateMarker("Vatican City", 41.902916, 12.453389, "#009688"));
mMapView.addMarker(generateMarker("San Marino", 43.942360, 12.457777, "#795548"));
mMapView.addMarker(generateMarker("Liechtenstein", 47.166000, 9.555373, "#FF5722"));
}
private MarkerOptions generateMarker(String title, double lat, double lng, String color) {
MarkerOptions marker = new MarkerOptions();
marker.title(title);
marker.snippet(color);
marker.position(new LatLng(lat, lng));
mIconDrawable.setColorFilter(Color.parseColor(marker.getSnippet()), PorterDuff.Mode.SRC_IN);
Sprite icon = mSpriteFactory.fromDrawable(mIconDrawable);
marker.icon(icon);
return marker;
}
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -0,0 +1,107 @@
package com.mapbox.mapboxsdk.testapp;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
public class InfoWindowConcurrentActivity extends AppCompatActivity {
private MapView mMapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_infowindow_concurrent);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
mMapView = (MapView) findViewById(R.id.infoWindowConcurrentMapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.onCreate(savedInstanceState);
// Enable to let concurrent multiple infowindows to be shown.
mMapView.setAllowConcurrentMultipleOpenInfoWindows(true);
mMapView.addMarker(new MarkerOptions()
.title("Intersection")
.snippet("H St NW with 15th St NW")
.position(new LatLng(38.9002073, -77.03364419)));
mMapView.addMarker(new MarkerOptions()
.title("White House")
.snippet("The official residence and principal workplace of the President of the United States, located at 1600 Pennsylvania Avenue NW in Washington, D.C. It has been the residence of every U.S. president since John Adams in 1800.")
.position(new LatLng(38.897705003219784, -77.03655168667463)));
mMapView.addMarker(new MarkerOptions().title("Intersection")
.snippet("E St NW with 17th St NW")
.position(new LatLng(38.8954236, -77.0394623)));
}
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -0,0 +1,597 @@
package com.mapbox.mapboxsdk.testapp;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.annotations.Sprite;
import com.mapbox.mapboxsdk.constants.MyBearingTracking;
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.layers.CustomLayer;
import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import io.fabric.sdk.android.Fabric;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
//
// Static members
//
// Used for saving instance state
private static final String STATE_IS_ANNOTATIONS_ON = "isAnnotationsOn";
private static final String STATE_SELECTED_STYLE = "selectedStyle";
private static final String STATE_MARKER_LIST = "markerList";
// Used for permissions requests
private static final int PERMISSIONS_LOCATION = 0;
private static final int PERMISSIONS_TRACKING_MODE_ACTIVITY = 1;
// Used for info window
private static final DecimalFormat LAT_LON_FORMATTER = new DecimalFormat("#.#####");
//
// Instance members
//
// Used for the UI
private DrawerLayout mDrawerLayout;
private MapView mMapView;
private TextView mFpsTextView;
private int mSelectedStyle = R.id.actionStyleMapboxStreets;
private NavigationView mNavigationView;
private CoordinatorLayout mCoordinatorLayout;
// Used for GPS
private FloatingActionButton mLocationFAB;
// Used for Annotations
private boolean mIsAnnotationsOn = false;
private ArrayList<MarkerOptions> mMarkerList = new ArrayList<>();
//
// Lifecycle events
//
// Called when activity is created
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
// Load the layout
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setHomeAsUpIndicator(R.drawable.ic_menu_24dp);
ab.setDisplayHomeAsUpEnabled(true);
}
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mNavigationView = (NavigationView) findViewById(R.id.nav_view);
if (mNavigationView != null) {
setupDrawerContent(mNavigationView);
}
mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout);
mMapView = (MapView) findViewById(R.id.mainMapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.onCreate(savedInstanceState);
mMapView.setOnFpsChangedListener(new MyOnFpsChangedListener());
mMapView.setOnMapLongClickListener(new MapView.OnMapLongClickListener() {
@Override
public void onMapLongClick(@NonNull LatLng point) {
MarkerOptions marker = new MarkerOptions()
.position(point)
.title("Dropped Pin")
.snippet(LAT_LON_FORMATTER.format(point.getLatitude()) + ", " +
LAT_LON_FORMATTER.format(point.getLongitude()))
.icon(null);
mMarkerList.add(marker);
mMapView.addMarker(marker);
}
});
mMapView.setOnMapClickListener(new MapView.OnMapClickListener() {
@Override
public void onMapClick(@NonNull LatLng point) {
String location = LAT_LON_FORMATTER.format(point.getLatitude()) + ", " +
LAT_LON_FORMATTER.format(point.getLongitude());
Snackbar.make(mCoordinatorLayout, "Map Click Listener " + location, Snackbar.LENGTH_SHORT).show();
}
});
mMapView.setOnMarkerClickListener(new MapView.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(@NonNull Marker marker) {
Snackbar.make(mCoordinatorLayout, "Marker Click Listener for " + marker.getTitle(), Snackbar.LENGTH_SHORT).show();
return false;
}
});
mMapView.setOnInfoWindowClickListener(new MapView.OnInfoWindowClickListener() {
@Override
public boolean onMarkerClick(@NonNull Marker marker) {
Snackbar.make(mCoordinatorLayout, "InfoWindow Click Listener for " + marker.getTitle(), Snackbar.LENGTH_SHORT).show();
marker.hideInfoWindow();
return true;
}
});
mMapView.setOnMyLocationChangeListener(new MapView.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(@Nullable Location location) {
String desc = "Loc Chg: ";
boolean noInfo = true;
if (location.hasSpeed()) {
desc += String.format("Spd = %.1f km/h ", location.getSpeed() * 3.6f);
noInfo = false;
}
if (location.hasAltitude()) {
desc += String.format("Alt = %.0f m ", location.getAltitude());
noInfo = false;
}
if (noInfo) {
desc += "No extra info";
}
Snackbar.make(mCoordinatorLayout, desc, Snackbar.LENGTH_SHORT).show();
}
});
mFpsTextView = (TextView) findViewById(R.id.view_fps);
mFpsTextView.setText("");
mLocationFAB = (FloatingActionButton) findViewById(R.id.locationFAB);
mLocationFAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Toggle GPS position updates
toggleGps(!mMapView.isMyLocationEnabled());
}
});
// Restore saved state
if (savedInstanceState != null) {
mIsAnnotationsOn = savedInstanceState.getBoolean(STATE_IS_ANNOTATIONS_ON);
mSelectedStyle = savedInstanceState.getInt(STATE_SELECTED_STYLE);
mMarkerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST);
mMapView.addMarkers(mMarkerList);
}
// Set default UI state
mNavigationView.getMenu().findItem(R.id.action_compass).setChecked(mMapView.isCompassEnabled());
mNavigationView.getMenu().findItem(R.id.action_debug).setChecked(mMapView.isDebugActive());
mNavigationView.getMenu().findItem(R.id.action_markers).setChecked(mIsAnnotationsOn);
changeMapStyle(mSelectedStyle);
toggleGps(mMapView.isMyLocationEnabled());
}
/**
* Dispatch onStart() to all fragments. Ensure any created loaders are
* now started.
*/
@Override
protected void onStart() {
super.onStart();
// We need to recheck permissions in case user revoked them via settings app
if ((ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED)) {
toggleGps(false);
}
mMapView.onStart();
}
// Called when our app comes into the foreground
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
// Called when our app goes into the background
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
// Called when we need to save instance state
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
outState.putBoolean(STATE_IS_ANNOTATIONS_ON, mIsAnnotationsOn);
outState.putInt(STATE_SELECTED_STYLE, mSelectedStyle);
outState.putParcelableArrayList(STATE_MARKER_LIST, mMarkerList);
}
// Called when the system is running low on memory
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
//
// Other events
//
// Called when pressing action bar items
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
mDrawerLayout.openDrawer(GravityCompat.START);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
switch (requestCode) {
case PERMISSIONS_LOCATION:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
enableGps();
}
break;
case PERMISSIONS_TRACKING_MODE_ACTIVITY:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
startActivity(new Intent(getApplicationContext(), MyLocationTrackingModeActivity.class));
}
break;
}
}
private void setupDrawerContent(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
mDrawerLayout.closeDrawers();
// Respond To Selection
switch (menuItem.getItemId()) {
case R.id.action_debug:
// Cycle map debug options
mMapView.cycleDebugOptions();
toggleFpsCounter(mMapView.isDebugActive());
return true;
case R.id.action_markers:
// Toggle markers
toggleAnnotations(!mIsAnnotationsOn);
return true;
case R.id.action_compass:
// Toggle compass
mMapView.setCompassEnabled(!mMapView.isCompassEnabled());
return true;
case R.id.action_info_window_adapter:
startActivity(new Intent(getApplicationContext(), InfoWindowAdapterActivity.class));
return true;
case R.id.action_tilt:
startActivity(new Intent(getApplicationContext(), TiltActivity.class));
return true;
case R.id.action_map_fragment:
startActivity(new Intent(getApplicationContext(), MapFragmentActivity.class));
return true;
case R.id.action_press_for_marker:
startActivity(new Intent(getApplicationContext(), PressForMarkerActivity.class));
return true;
case R.id.action_manual_zoom:
startActivity(new Intent(getApplicationContext(), ManualZoomActivity.class));
return true;
case R.id.action_coordinate_change:
startActivity(new Intent(getApplicationContext(), CoordinateChangeActivity.class));
return true;
case R.id.action_bulk_markers:
startActivity(new Intent(getApplicationContext(), BulkMarkerActivity.class));
return true;
case R.id.action_info_window:
startActivity(new Intent(getApplicationContext(), InfoWindowActivity.class));
return true;
case R.id.action_info_window_concurrent:
startActivity(new Intent(getApplicationContext(), InfoWindowConcurrentActivity.class));
return true;
case R.id.action_visible_bounds:
startActivity(new Intent(getApplicationContext(), VisibleCoordinateBoundsActivity.class));
return true;
case R.id.action_user_tracking_mode:
if ((ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED)) {
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION},
PERMISSIONS_TRACKING_MODE_ACTIVITY);
} else {
startActivity(new Intent(getApplicationContext(), MyLocationTrackingModeActivity.class));
}
return true;
case R.id.action_polyline:
startActivity(new Intent(getApplicationContext(), PolylineActivity.class));
return true;
case R.id.action_custom_layer:
addCustomLayer();
return true;
default:
return changeMapStyle(menuItem.getItemId());
}
}
});
}
private void toggleFpsCounter(boolean enableFps) {
// Show the FPS counter
if (enableFps) {
mFpsTextView.setVisibility(View.VISIBLE);
mFpsTextView.setText(getResources().getString(R.string.label_fps));
} else {
mFpsTextView.setVisibility(View.INVISIBLE);
}
}
private boolean changeMapStyle(int id) {
switch (id) {
case R.id.actionStyleMapboxStreets:
mMapView.setStyle(Style.MAPBOX_STREETS);
mSelectedStyle = id;
return true;
case R.id.actionStyleEmerald:
mMapView.setStyle(Style.EMERALD);
mSelectedStyle = id;
return true;
case R.id.actionStyleLight:
mMapView.setStyle(Style.LIGHT);
mSelectedStyle = id;
return true;
case R.id.actionStyleDark:
mMapView.setStyle(Style.DARK);
mSelectedStyle = id;
return true;
case R.id.actionStyleSatellite:
mMapView.setStyle(Style.SATELLITE);
mSelectedStyle = id;
return true;
case R.id.actionStyleSatelliteStreets:
mMapView.setStyle(Style.SATELLITE_STREETS);
mSelectedStyle = id;
return true;
default:
return false;
}
}
/**
* Enabled / Disable GPS location updates along with updating the UI
*
* @param enableGps true if GPS is to be enabled, false if GPS is to be disabled
*/
private void toggleGps(boolean enableGps) {
if (enableGps) {
if ((ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) ||
(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED)) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION},
PERMISSIONS_LOCATION);
} else {
enableGps();
}
} else {
mMapView.setMyLocationEnabled(false);
mLocationFAB.setColorFilter(Color.TRANSPARENT);
}
}
private void enableGps() {
mMapView.setOnMyLocationChangeListener(new MapView.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(@Nullable Location location) {
if (location != null) {
mMapView.setZoomLevel(16);
mMapView.setCenterCoordinate(new LatLng(location));
mMapView.setOnMyLocationChangeListener(null);
}
}
});
mMapView.setMyLocationEnabled(true);
mMapView.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
mMapView.setMyBearingTrackingMode(MyBearingTracking.GPS);
mLocationFAB.setColorFilter(ContextCompat.getColor(this, R.color.primary));
}
/**
* Enable / Disable Annotations.
*
* @param enableAnnotations True to display, False to hide
*/
private void toggleAnnotations(boolean enableAnnotations) {
if (enableAnnotations) {
if (!mIsAnnotationsOn) {
mIsAnnotationsOn = true;
addMarkers();
addPolyline();
addPolygon();
mMapView.setZoomLevel(7);
mMapView.setCenterCoordinate(new LatLng(38.11727, -122.22839));
}
} else {
if (mIsAnnotationsOn) {
mIsAnnotationsOn = false;
removeAnnotations();
}
}
}
private void addMarkers() {
List<MarkerOptions> markerOptionsList = new ArrayList<>();
final MarkerOptions backLot = generateMarker("Back Lot", "The back lot behind my house", null, 38.649441, -121.369064);
markerOptionsList.add(backLot);
final Sprite dogIcon = mMapView.getSpriteFactory().fromAsset("dog-park-24.png");
final MarkerOptions cheeseRoom = generateMarker("Cheese Room", "The only air conditioned room on the property", dogIcon, 38.531577, -122.010646);
markerOptionsList.add(cheeseRoom);
List<Marker> markers = mMapView.addMarkers(markerOptionsList);
}
private MarkerOptions generateMarker(String title, String snippet, Sprite icon, double lat, double lng) {
return new MarkerOptions()
.position(new LatLng(lat, lng))
.title(title)
.icon(icon)
.snippet(snippet);
}
private void addPolyline() {
try {
String geojsonStr = GeoParseUtil.loadStringFromAssets(this, "small_line.geojson");
List<LatLng> latLngs = GeoParseUtil.parseGeoJSONCoordinates(geojsonStr);
MapView map = mMapView;
map.addPolyline(new PolylineOptions()
.add(latLngs.toArray(new LatLng[latLngs.size()]))
.width(2)
.color(Color.RED));
} catch (Exception e) {
Log.e(TAG, "Error adding Polyline: " + e);
e.printStackTrace();
}
}
private void addPolygon() {
try {
String geojsonStr = GeoParseUtil.loadStringFromAssets(this, "small_poly.geojson");
List<LatLng> latLngs = GeoParseUtil.parseGeoJSONCoordinates(geojsonStr);
MapView map = mMapView;
ArrayList<PolygonOptions> opts = new ArrayList<>();
opts.add(new PolygonOptions()
.add(latLngs.toArray(new LatLng[latLngs.size()]))
.strokeColor(Color.MAGENTA)
.fillColor(Color.BLUE).alpha(0.5f));
map.addPolygons(opts).get(0);
} catch (Exception e) {
Log.e(TAG, "Error adding Polygon: " + e);
e.printStackTrace();
}
}
private void removeAnnotations() {
mMarkerList.clear();
mMapView.removeAllAnnotations();
}
private void addCustomLayer() {
mMapView.addCustomLayer(
new CustomLayer("custom",
ExampleCustomLayer.createContext(),
ExampleCustomLayer.InitializeFunction,
ExampleCustomLayer.RenderFunction,
ExampleCustomLayer.DeinitializeFunction),
null);
}
// Called when FPS changes
private class MyOnFpsChangedListener implements MapView.OnFpsChangedListener {
@Override
public void onFpsChanged(double fps) {
mFpsTextView.setText(getResources().getString(R.string.label_fps) + String.format(" %4.2f", fps));
}
}
}

View File

@@ -0,0 +1,88 @@
package com.mapbox.mapboxsdk.testapp;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
public class ManualZoomActivity extends AppCompatActivity {
private MapView mMapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manual_zoom);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
mMapView = (MapView) findViewById(R.id.manualZoomMapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.setStyle(Style.MAPBOX_STREETS);
mMapView.onCreate(savedInstanceState);
}
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -0,0 +1,73 @@
package com.mapbox.mapboxsdk.testapp;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import com.mapbox.mapboxsdk.MapFragment;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.views.MapView;
public class MapFragmentActivity extends AppCompatActivity {
private static final String TAG_FRAGMENT = "map";
private MyMapFragment mMapFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_fragment);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
if (savedInstanceState == null) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.fragment_container, mMapFragment = new MyMapFragment(), TAG_FRAGMENT);
transaction.commit();
} else {
mMapFragment = (MyMapFragment) getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT);
}
}
public static class MyMapFragment extends MapFragment {
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
MapView mapView = getMap();
mapView.setStyleUrl(Style.EMERALD);
mapView.setZoomLevel(12);
mapView.setCenterCoordinate(new LatLng(50.853658, 4.352419));
// move attribution control to right of screen
mapView.setAttributionGravity(Gravity.BOTTOM | Gravity.END);
int tenDp = (int) getResources().getDimension(R.dimen.attr_margin);
mapView.setAttributionMargins(0, 0, tenDp, tenDp);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -0,0 +1,186 @@
package com.mapbox.mapboxsdk.testapp;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import com.mapbox.mapboxsdk.constants.MyBearingTracking;
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
public class MyLocationTrackingModeActivity extends AppCompatActivity implements MapView.OnMyLocationChangeListener, AdapterView.OnItemSelectedListener {
private MapView mMapView;
private Spinner mLocationSpinner, mBearingSpinner;
private Location mLocation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_location_tracking);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
ArrayAdapter<CharSequence> locationTrackingAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(), R.array.user_tracking_mode, android.R.layout.simple_spinner_item);
locationTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mLocationSpinner = (Spinner) findViewById(R.id.spinner_location);
mLocationSpinner.setAdapter(locationTrackingAdapter);
mLocationSpinner.setOnItemSelectedListener(this);
// mLocationSpinner.setEnabled(false);
ArrayAdapter<CharSequence> bearingTrackingAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(), R.array.user_bearing_mode, android.R.layout.simple_spinner_item);
bearingTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mBearingSpinner = (Spinner) findViewById(R.id.spinner_bearing);
mBearingSpinner.setAdapter(bearingTrackingAdapter);
mBearingSpinner.setOnItemSelectedListener(this);
// mBearingSpinner.setEnabled(false);
mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.onCreate(savedInstanceState);
mMapView.setOnMyLocationChangeListener(this);
mMapView.setMyLocationEnabled(true);
}
@Override
public void onMyLocationChange(@Nullable Location location) {
if (location != null) {
if (mLocation == null) {
// initial location to reposition map
mMapView.setCenterCoordinate(new LatLng(location.getLatitude(), location.getLongitude()));
mLocationSpinner.setEnabled(true);
mBearingSpinner.setEnabled(true);
}
mLocation = location;
showSnackBar();
}
}
private void showSnackBar() {
String desc = "Loc Chg: ";
boolean noInfo = true;
if (mLocation.hasSpeed()) {
desc += String.format("Spd = %.1f km/h ", mLocation.getSpeed() * 3.6f);
noInfo = false;
}
if (mLocation.hasAltitude()) {
desc += String.format("Alt = %.0f m ", mLocation.getAltitude());
noInfo = false;
}
if (noInfo) {
desc += "No extra info";
}
Snackbar.make(findViewById(android.R.id.content), desc, Snackbar.LENGTH_SHORT).show();
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (parent.getId() == R.id.spinner_location) {
switch (position) {
case 0:
mMapView.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
break;
case 1:
mMapView.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
break;
}
} else if (parent.getId() == R.id.spinner_bearing) {
switch (position) {
case 0:
mMapView.setMyBearingTrackingMode(MyBearingTracking.NONE);
break;
case 1:
mMapView.setMyBearingTrackingMode(MyBearingTracking.GPS);
break;
case 2:
mMapView.setMyBearingTrackingMode(MyBearingTracking.COMPASS);
break;
// case 3:
// mMapView.setMyBearingTrackingMode(MyBearingTracking.COMBINED);
// break;
}
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -0,0 +1,180 @@
package com.mapbox.mapboxsdk.testapp;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import com.mapbox.mapboxsdk.annotations.Polyline;
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class PolylineActivity extends AppCompatActivity {
private static final String STATE_POLYLINE_OPTIONS = "polylineOptions";
private List<Polyline> mPolylines;
private ArrayList<PolylineOptions> mPolylineOptions = new ArrayList<>();
private MapView mMapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_polyline);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.onCreate(savedInstanceState);
if (savedInstanceState != null) {
mPolylineOptions = savedInstanceState.getParcelableArrayList(STATE_POLYLINE_OPTIONS);
} else {
mPolylineOptions.addAll(PolylineProvider.getAll());
}
mPolylines = mMapView.addPolylines(mPolylineOptions);
findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mPolylines != null && mPolylines.size() > 0) {
if (mPolylines.size() == 1) {
// test for removing annotation
mMapView.removeAnnotation(mPolylines.get(0));
} else {
// test for removing annotations
mMapView.removeAnnotations(mPolylines);
}
}
mPolylineOptions.clear();
mPolylineOptions.addAll(PolylineProvider.getRandomLine());
mPolylines = mMapView.addPolylines(mPolylineOptions);
}
});
}
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
outState.putParcelableArrayList(STATE_POLYLINE_OPTIONS, mPolylineOptions);
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_polyline, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_id_remove:
// test to remove all annotations
mPolylineOptions.clear();
mMapView.removeAllAnnotations();
return true;
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private static class PolylineProvider {
private static final LatLng ANDORRA = new LatLng(42.505777, 1.52529);
private static final LatLng LUXEMBOURG = new LatLng(49.815273, 6.129583);
private static final LatLng MONACO = new LatLng(43.738418, 7.424616);
private static final LatLng VATICAN_CITY = new LatLng(41.902916, 12.453389);
private static final LatLng SAN_MARINO = new LatLng(43.942360, 12.457777);
private static final LatLng LIECHTENSTEIN = new LatLng(47.166000, 9.555373);
private static final List<PolylineOptions> POLYLINES = new ArrayList<PolylineOptions>() {{
add(generatePolyline(ANDORRA, LUXEMBOURG, "#F44336"));
add(generatePolyline(ANDORRA, MONACO, "#FF5722"));
add(generatePolyline(MONACO, VATICAN_CITY, "#673AB7"));
add(generatePolyline(VATICAN_CITY, SAN_MARINO, "#009688"));
add(generatePolyline(SAN_MARINO, LIECHTENSTEIN, "#795548"));
add(generatePolyline(LIECHTENSTEIN, LUXEMBOURG, "#3F51B5"));
}};
private static PolylineOptions generatePolyline(LatLng start, LatLng end, String color) {
PolylineOptions line = new PolylineOptions();
line.add(start);
line.add(end);
line.color(Color.parseColor(color));
return line;
}
public static List<PolylineOptions> getAll() {
return POLYLINES;
}
public static List<PolylineOptions> getRandomLine() {
List<PolylineOptions> randomLines = new ArrayList<>();
Collections.shuffle(POLYLINES);
randomLines.add(POLYLINES.get(0));
return randomLines;
}
}
}

View File

@@ -0,0 +1,138 @@
package com.mapbox.mapboxsdk.testapp;
import android.graphics.PointF;
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;
import android.view.MenuItem;
import android.view.ViewGroup;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
import java.text.DecimalFormat;
import java.util.ArrayList;
public class PressForMarkerActivity extends AppCompatActivity implements MapView.OnMapLongClickListener {
private MapView mMapView;
private ArrayList<MarkerOptions> mMarkerList = new ArrayList<>();
private static final DecimalFormat LAT_LON_FORMATTER = new DecimalFormat("#.#####");
private static String STATE_MARKER_LIST = "markerList";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_press_for_marker);
Toolbar toolbar = (Toolbar) findViewById(R.id.secondToolBar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
mMapView = new MapView(this, ApiAccess.getToken(this));
mMapView.setStyleUrl(Style.EMERALD);
mMapView.onCreate(savedInstanceState);
mMapView.setCenterCoordinate(new LatLng(45.1855569, 5.7215506));
mMapView.setZoomLevel(11);
mMapView.setOnMapLongClickListener(this);
((ViewGroup) findViewById(R.id.activity_container)).addView(mMapView);
if (savedInstanceState != null) {
mMarkerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST);
mMapView.addMarkers(mMarkerList);
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
outState.putParcelableArrayList(STATE_MARKER_LIST, mMarkerList);
}
@Override
public void onMapLongClick(@NonNull LatLng point) {
final PointF pixel = mMapView.toScreenLocation(point);
String title = LAT_LON_FORMATTER.format(point.getLatitude()) + ", " + LAT_LON_FORMATTER.format(point.getLongitude());
String snippet = "X = " + (int) pixel.x + ", Y = " + (int) pixel.y;
MarkerOptions marker = new MarkerOptions()
.position(point)
.title(title)
.snippet(snippet);
mMarkerList.add(marker);
mMapView.addMarker(marker);
}
/**
* Dispatch onStart() to all fragments. Ensure any created loaders are
* now started.
*/
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
// Called when our app goes into the background
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
// Called when our app comes into the foreground
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
// Called when the system is running low on memory
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -0,0 +1,92 @@
package com.mapbox.mapboxsdk.testapp;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
public class TiltActivity extends AppCompatActivity {
private MapView mMapView = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tilt);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
LatLng dc = new LatLng(38.90252, -77.02291);
// Set up the map
mMapView = (MapView) findViewById(R.id.tiltMapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.setStyleUrl(Style.MAPBOX_STREETS);
mMapView.setCenterCoordinate(dc);
mMapView.setZoomLevel(11);
mMapView.onCreate(savedInstanceState);
}
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
// Tilt Map 45 degrees over 10 seconds
mMapView.setTilt(45.0, 10000l);
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -0,0 +1,122 @@
package com.mapbox.mapboxsdk.testapp;
import android.graphics.RectF;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.geometry.CoordinateBounds;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
public class VisibleCoordinateBoundsActivity extends AppCompatActivity {
private MapView mMapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_visible_bounds);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setAccessToken(ApiAccess.getToken(this));
mMapView.setStyle(Style.DARK);
mMapView.onCreate(savedInstanceState);
final LatLng losAngeles = new LatLng(34.053940, -118.242622);
final LatLng newYork = new LatLng(40.712730, -74.005953);
mMapView.addMarker(new MarkerOptions()
.title("Los Angeles")
.snippet("City Hall")
.position(losAngeles));
mMapView.addMarker(new MarkerOptions()
.title("New York")
.snippet("City Hall")
.position(newYork));
Snackbar.make(findViewById(android.R.id.content), R.string.action_visible_bounds_explanation, Snackbar.LENGTH_INDEFINITE)
.setAction(android.R.string.ok, new View.OnClickListener() {
@Override
public void onClick(View v) {
// Disable UserInput
mMapView.setScrollEnabled(false);
mMapView.setZoomEnabled(false);
// Reposition coordinate bounds
float margin = getResources().getDimension(R.dimen.coordinatebounds_margin);
mMapView.setVisibleCoordinateBounds(new CoordinateBounds(losAngeles, newYork), new RectF(margin, 0, margin, 0), true);
}
}).show();
}
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -0,0 +1,73 @@
package com.mapbox.mapboxsdk.testapp.utils;
import android.content.Context;
import android.text.TextUtils;
import com.mapbox.mapboxsdk.geometry.LatLng;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
public class GeoParseUtil {
public static String loadStringFromAssets(final Context context, final String fileName) throws IOException {
if (TextUtils.isEmpty(fileName)) {
throw new NullPointerException("No GeoJSON File Name passed in.");
}
InputStream is = context.getAssets().open(fileName);
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
return readAll(rd);
}
public static List<LatLng> parseGeoJSONCoordinates(String geojsonStr) throws JSONException {
List<LatLng> latLngs = new ArrayList<>();
JSONObject jsonObject = new JSONObject(geojsonStr);
JSONArray features = jsonObject.getJSONArray("features");
int featureLength = features.length();
for (int j = 0; j < featureLength; ++j) {
JSONObject feature = features.getJSONObject(j);
JSONObject geometry = feature.getJSONObject("geometry");
String type = geometry.getString("type");
JSONArray coordinates;
if (type.equals("Polygon")) {
coordinates = geometry.getJSONArray("coordinates").getJSONArray(0);
} else {
coordinates = geometry.getJSONArray("coordinates");
}
int len = coordinates.length();
for (int i = 0; i < len; ++i) {
if (coordinates.get(i) instanceof JSONArray) {
JSONArray coord = coordinates.getJSONArray(i);
double lng = coord.getDouble(0);
double lat = coord.getDouble(1);
latLngs.add(new LatLng(lat, lng));
} else {
double lng = coordinates.getDouble(0);
double lat = coordinates.getDouble(1);
latLngs.add(new LatLng(lat, lng));
break;
}
}
}
return latLngs;
}
private static String readAll(Reader rd) throws IOException {
StringBuilder sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1) {
sb.append((char) cp);
}
return sb.toString();
}
}

View File

@@ -0,0 +1,153 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mapbox.mapboxsdk.testapp.utils;
import java.util.ArrayList;
import android.os.SystemClock;
import android.util.Log;
/**
* A utility class to help log timings splits throughout a method call.
* Typical usage is:
* <p/>
* <pre>
* TimingLogger timings = new TimingLogger(TAG, "methodA");
* // ... do some work A ...
* timings.addSplit("work A");
* // ... do some work B ...
* timings.addSplit("work B");
* // ... do some work C ...
* timings.addSplit("work C");
* timings.dumpToLog();
* </pre>
* <p/>
* <p>The dumpToLog call would add the following to the log:</p>
* <p/>
* <pre>
* D/TAG ( 3459): methodA: begin
* D/TAG ( 3459): methodA: 9 ms, work A
* D/TAG ( 3459): methodA: 1 ms, work B
* D/TAG ( 3459): methodA: 6 ms, work C
* D/TAG ( 3459): methodA: end, 16 ms
* </pre>
*/
public class TimingLogger {
/**
* The Log tag to use for checking Log.isLoggable and for
* logging the timings.
*/
private String mTag;
/**
* A label to be included in every log.
*/
private String mLabel;
/**
* Used to track whether Log.isLoggable was enabled at reset time.
*/
private boolean mDisabled;
/**
* Stores the time of each split.
*/
ArrayList<Long> mSplits;
/**
* Stores the labels for each split.
*/
ArrayList<String> mSplitLabels;
/**
* Create and initialize a TimingLogger object that will log using
* the specific tag. If the Log.isLoggable is not enabled to at
* least the Log.VERBOSE level for that tag at creation time then
* the addSplit and dumpToLog call will do nothing.
*
* @param tag the log tag to use while logging the timings
* @param label a string to be displayed with each log
*/
public TimingLogger(String tag, String label) {
reset(tag, label);
}
/**
* Clear and initialize a TimingLogger object that will log using
* the specific tag. If the Log.isLoggable is not enabled to at
* least the Log.VERBOSE level for that tag at creation time then
* the addSplit and dumpToLog call will do nothing.
*
* @param tag the log tag to use while logging the timings
* @param label a string to be displayed with each log
*/
public void reset(String tag, String label) {
mTag = tag;
mLabel = label;
reset();
}
/**
* Clear and initialize a TimingLogger object that will log using
* the tag and label that was specified previously, either via
* the constructor or a call to reset(tag, label). If the
* Log.isLoggable is not enabled to at least the Log.VERBOSE
* level for that tag at creation time then the addSplit and
* dumpToLog call will do nothing.
*/
public void reset() {
mDisabled = false; //!Log.isLoggable(mTag, Log.VERBOSE);
if (mDisabled) return;
if (mSplits == null) {
mSplits = new ArrayList<Long>();
mSplitLabels = new ArrayList<String>();
} else {
mSplits.clear();
mSplitLabels.clear();
}
addSplit(null);
}
/**
* Add a split for the current time, labeled with splitLabel. If
* Log.isLoggable was not enabled to at least the Log.VERBOSE for
* the specified tag at construction or reset() time then this
* call does nothing.
*
* @param splitLabel a label to associate with this split.
*/
public void addSplit(String splitLabel) {
if (mDisabled) return;
long now = SystemClock.elapsedRealtime();
mSplits.add(now);
mSplitLabels.add(splitLabel);
}
/**
* Dumps the timings to the log using Log.d(). If Log.isLoggable was
* not enabled to at least the Log.VERBOSE for the specified tag at
* construction or reset() time then this call does nothing.
*/
public void dumpToLog() {
if (mDisabled) return;
Log.d(mTag, mLabel + ": begin");
final long first = mSplits.get(0);
long now = first;
for (int i = 1; i < mSplits.size(); i++) {
now = mSplits.get(i);
final String splitLabel = mSplitLabels.get(i);
final long prev = mSplits.get(i - 1);
Log.d(mTag, mLabel + ": " + (now - prev) + " ms, " + splitLabel);
}
Log.d(mTag, mLabel + ": end, " + (now - first) + " ms");
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#000000"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M17,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6 6,-2.69 6,-6 -2.69,-6 -6,-6zM5,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zm0,6c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M6,13c-0.55,0 -1,0.45 -1,1s0.45,1 1,1 1,-0.45 1,-1 -0.45,-1 -1,-1zm0,4c-0.55,0 -1,0.45 -1,1s0.45,1 1,1 1,-0.45 1,-1 -0.45,-1 -1,-1zm0,-8c-0.55,0 -1,0.45 -1,1s0.45,1 1,1 1,-0.45 1,-1 -0.45,-1 -1,-1zm-3,0.5c-0.28,0 -0.5,0.22 -0.5,0.5s0.22,0.5 0.5,0.5 0.5,-0.22 0.5,-0.5 -0.22,-0.5 -0.5,-0.5zM6,5c-0.55,0 -1,0.45 -1,1s0.45,1 1,1 1,-0.45 1,-1 -0.45,-1 -1,-1zm15,5.5c0.28,0 0.5,-0.22 0.5,-0.5s-0.22,-0.5 -0.5,-0.5 -0.5,0.22 -0.5,0.5 0.22,0.5 0.5,0.5zM14,7c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1 -1,0.45 -1,1 0.45,1 1,1zm0,-3.5c0.28,0 0.5,-0.22 0.5,-0.5s-0.22,-0.5 -0.5,-0.5 -0.5,0.22 -0.5,0.5 0.22,0.5 0.5,0.5zm-11,10c-0.28,0 -0.5,0.22 -0.5,0.5s0.22,0.5 0.5,0.5 0.5,-0.22 0.5,-0.5 -0.22,-0.5 -0.5,-0.5zm7,7c-0.28,0 -0.5,0.22 -0.5,0.5s0.22,0.5 0.5,0.5 0.5,-0.22 0.5,-0.5 -0.22,-0.5 -0.5,-0.5zm0,-17c0.28,0 0.5,-0.22 0.5,-0.5s-0.22,-0.5 -0.5,-0.5 -0.5,0.22 -0.5,0.5 0.22,0.5 0.5,0.5zM10,7c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1 -1,0.45 -1,1 0.45,1 1,1zm0,5.5c-0.83,0 -1.5,0.67 -1.5,1.5s0.67,1.5 1.5,1.5 1.5,-0.67 1.5,-1.5 -0.67,-1.5 -1.5,-1.5zm8,0.5c-0.55,0 -1,0.45 -1,1s0.45,1 1,1 1,-0.45 1,-1 -0.45,-1 -1,-1zm0,4c-0.55,0 -1,0.45 -1,1s0.45,1 1,1 1,-0.45 1,-1 -0.45,-1 -1,-1zm0,-8c-0.55,0 -1,0.45 -1,1s0.45,1 1,1 1,-0.45 1,-1 -0.45,-1 -1,-1zm0,-4c-0.55,0 -1,0.45 -1,1s0.45,1 1,1 1,-0.45 1,-1 -0.45,-1 -1,-1zm3,8.5c-0.28,0 -0.5,0.22 -0.5,0.5s0.22,0.5 0.5,0.5 0.5,-0.22 0.5,-0.5 -0.22,-0.5 -0.5,-0.5zM14,17c-0.55,0 -1,0.45 -1,1s0.45,1 1,1 1,-0.45 1,-1 -0.45,-1 -1,-1zm0,3.5c-0.28,0 -0.5,0.22 -0.5,0.5s0.22,0.5 0.5,0.5 0.5,-0.22 0.5,-0.5 -0.22,-0.5 -0.5,-0.5zm-4,-12c-0.83,0 -1.5,0.67 -1.5,1.5s0.67,1.5 1.5,1.5 1.5,-0.67 1.5,-1.5 -0.67,-1.5 -1.5,-1.5zm0,8.5c-0.55,0 -1,0.45 -1,1s0.45,1 1,1 1,-0.45 1,-1 -0.45,-1 -1,-1zm4,-4.5c-0.83,0 -1.5,0.67 -1.5,1.5s0.67,1.5 1.5,1.5 1.5,-0.67 1.5,-1.5 -0.67,-1.5 -1.5,-1.5zm0,-4c-0.83,0 -1.5,0.67 -1.5,1.5s0.67,1.5 1.5,1.5 1.5,-0.67 1.5,-1.5 -0.67,-1.5 -1.5,-1.5z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M20,8h-2.81c-0.45,-0.78 -1.07,-1.45 -1.82,-1.96L17,4.41 15.59,3l-2.17,2.17C12.96,5.06 12.49,5 12,5c-0.49,0 -0.96,0.06 -1.41,0.17L8.41,3 7,4.41l1.62,1.63C7.88,6.55 7.26,7.22 6.81,8H4v2h2.09c-0.05,0.33 -0.09,0.66 -0.09,1v1H4v2h2v1c0,0.34 0.04,0.67 0.09,1H4v2h2.81c1.04,1.79 2.97,3 5.19,3s4.15,-1.21 5.19,-3H20v-2h-2.09c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1H20V8zm-6,8h-4v-2h4v2zm0,-4h-4v-2h4v2z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M17,15h2V7c0,-1.1 -0.9,-2 -2,-2H9v2h8v8zM7,17V1H5v4H1v2h4v10c0,1.1 0.9,2 2,2h10v4h2v-4h4v-2H7z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M5,15H3v4c0,1.1 0.9,2 2,2h4v-2H5v-4zM5,5h4V3H5c-1.1,0 -2,0.9 -2,2v4h2V5zm14,-2h-4v2h4v4h2V5c0,-1.1 -0.9,-2 -2,-2zm0,16h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M3,5H1v16c0,1.1 0.9,2 2,2h16v-2H3V5zm18,-4H7c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-2 -2,-2zm0,16H7V3h14v14z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M9,7H7v2h2V7zm0,4H7v2h2v-2zm0,-8c-1.11,0 -2,0.9 -2,2h2V3zm4,12h-2v2h2v-2zm6,-12v2h2c0,-1.1 -0.9,-2 -2,-2zm-6,0h-2v2h2V3zM9,17v-2H7c0,1.1 0.89,2 2,2zm10,-4h2v-2h-2v2zm0,-4h2V7h-2v2zm0,8c1.1,0 2,-0.9 2,-2h-2v2zM5,7H3v12c0,1.1 0.89,2 2,2h12v-2H5V7zm10,-2h2V3h-2v2zm0,12h2v-2h-2v2z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M3,13h2v-2H3v2zm0,4h2v-2H3v2zm2,4v-2H3c0,1.1 0.89,2 2,2zM3,9h2V7H3v2zm12,12h2v-2h-2v2zm4,-18H9c-1.11,0 -2,0.9 -2,2v10c0,1.1 0.89,2 2,2h10c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2zm0,12H9V5h10v10zm-8,6h2v-2h-2v2zm-4,0h2v-2H7v2z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#000000"
android:pathData="M12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zm8.94,3c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94V1h-2v2.06C6.83,3.52 3.52,6.83 3.06,11H1v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94V23h2v-2.06c4.17,-0.46 7.48,-3.77 7.94,-7.94H23v-2h-2.06zM12,19c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M3,5H1v16c0,1.1 0.9,2 2,2h16v-2H3V5zm18,-4H7c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-2 -2,-2zm0,16H7V3h14v14z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M15,11V5l-3,-3 -3,3v2H3v14h18V11h-6zm-8,8H5v-2h2v2zm0,-4H5v-2h2v2zm0,-4H5V9h2v2zm6,8h-2v-2h2v2zm0,-4h-2v-2h2v2zm0,-4h-2V9h2v2zm0,-4h-2V5h2v2zm6,12h-2v-2h2v2zm0,-4h-2v-2h2v2z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M3,18h18v-2H3v2zm0,-5h18v-2H3v2zm0,-7v2h18V6H3z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M12,2L4.5,20.29l0.71,0.71L12,18l6.79,3 0.71,-0.71z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M13,13v8h8v-8h-8zM3,21h8v-8H3v8zM3,3v8h8V3H3zm13.66,-1.31L11,7.34 16.66,13l5.66,-5.66 -5.66,-5.65z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M18,8c0,-3.31 -2.69,-6 -6,-6S6,4.69 6,8c0,4.5 6,11 6,11s6,-6.5 6,-11zm-8,0c0,-1.1 0.9,-2 2,-2s2,0.9 2,2 -0.89,2 -2,2c-1.1,0 -2,-0.9 -2,-2zM5,20v2h14v-2H5z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zm0,9.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M7.77,6.76L6.23,5.48 0.82,12l5.41,6.52 1.54,-1.28L3.42,12l4.35,-5.24zM7,13h2v-2H7v2zm10,-2h-2v2h2v-2zm-6,2h2v-2h-2v2zm6.77,-7.52l-1.54,1.28L20.58,12l-4.35,5.24 1.54,1.28L23.18,12l-5.41,-6.52z" />
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M16,6l2.29,2.29 -4.88,4.88 -4,-4L2,16.59 3.41,18l6,-6 4,4 6.3,-6.29L22,12V6z" />
</vector>

View File

@@ -0,0 +1,45 @@
<?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">
<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" />
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_animate_coordinates"
app:backgroundTint="@color/white" />
</android.support.design.widget.CoordinatorLayout>
</FrameLayout>
</RelativeLayout>

View File

@@ -0,0 +1,24 @@
<?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.views.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:zoom_level="15" />
</LinearLayout>

View File

@@ -0,0 +1,24 @@
<?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.views.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:zoom_level="4" />
</LinearLayout>

View File

@@ -0,0 +1,24 @@
<?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.views.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_level="15" />
</LinearLayout>

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
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" />
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mainMapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/view_fps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="@string/label_fps"
android:textAppearance="?android:attr/textAppearanceLarge" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/locationFAB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_gps_fixed_24dp"
app:backgroundTint="@color/white" />
</android.support.design.widget.CoordinatorLayout>
</FrameLayout>
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/menu_drawer" />
</android.support.v4.widget.DrawerLayout>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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.views.MapView
android:id="@+id/manualZoomMapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/zoomInButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/zoom_botton"
android:layout_gravity="right"/>
</LinearLayout>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.mapbox.mapboxsdk.testapp.MapFragmentActivity">
<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" />
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@@ -0,0 +1,31 @@
<?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">
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v7.widget.Toolbar>
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:center_latitude="38.897705003219784"
app:center_longitude="-77.03655168667463"
app:style_url="@string/style_mapbox_streets"
app:zoom_level="15" />
</LinearLayout>

View File

@@ -0,0 +1,48 @@
<?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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2">
<Spinner
android:id="@+id/spinner_location"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_weight="1" />
<Spinner
android:id="@+id/spinner_bearing"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
<com.mapbox.mapboxsdk.views.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:style_url="@string/style_mapbox_streets"
app:zoom_level="15" />
</LinearLayout>

View File

@@ -0,0 +1,37 @@
<?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"
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.views.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar"
app:center_latitude="47.798202"
app:center_longitude="7.573781"
app:style_url="@string/style_mapbox_streets"
app:zoom_level="4" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_add_24dp"
app:backgroundTint="@android:color/white" />
</RelativeLayout>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/secondToolBar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</LinearLayout>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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.views.MapView
android:id="@+id/tiltMapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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.views.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/mainActivityMenu"
android:title="@string/navdrawer_menu_title_mainactivity_controls">
<menu>
<group>
<item
android:id="@+id/action_debug"
android:icon="@drawable/ic_bug_report_24dp"
android:title="@string/action_debug" />
<item
android:id="@+id/action_markers"
android:icon="@drawable/ic_place_24dp"
android:title="@string/action_point_annotations" />
<item
android:id="@+id/action_compass"
android:icon="@drawable/ic_navigation_24dp"
android:title="@string/action_compass" />
</group>
</menu>
</item>
<group android:id="@+id/stylesSeparator" />
<item
android:id="@+id/mainActivityStylesMenue"
android:title="@string/navdrawer_menu_title_mainactivity_styles">
<menu>
<group android:id="@+id/stylesGroup">
<item
android:id="@+id/actionStyleMapboxStreets"
android:title="@string/styleMapboxStreets" />
<item
android:id="@+id/actionStyleEmerald"
android:title="@string/styleEmerald" />
<item
android:id="@+id/actionStyleLight"
android:title="@string/styleLight" />
<item
android:id="@+id/actionStyleDark"
android:title="@string/styleDark" />
<item
android:id="@+id/actionStyleSatellite"
android:title="@string/styleSatellite" />
<item
android:id="@+id/actionStyleSatelliteStreets"
android:title="@string/styleSatelliteStreets" />
</group>
</menu>
</item>
<group android:id="@+id/testsSeparator" />
<item
android:id="@+id/testsMenu"
android:title="@string/navdrawer_menu_title_individual_tests">
<menu>
<item
android:id="@+id/action_tilt"
android:checkable="false"
android:icon="@drawable/ic_tilt"
android:title="@string/action_tilt" />
<item
android:id="@+id/action_map_fragment"
android:checkable="false"
android:icon="@drawable/ic_now_widgets_24dp"
android:title="@string/action_map_fragment" />
<item
android:id="@+id/action_info_window"
android:checkable="false"
android:icon="@drawable/ic_flip_to_front_24dp"
android:title="@string/action_info_window" />
<item
android:id="@+id/action_info_window_concurrent"
android:checkable="false"
android:icon="@drawable/ic_flip_to_back_24dp"
android:title="@string/action_info_window_concurrent" />
<item
android:id="@+id/action_info_window_adapter"
android:checkable="false"
android:icon="@drawable/ic_infowindow_adapter"
android:title="@string/action_info_window_adapter" />
<item
android:id="@+id/action_press_for_marker"
android:checkable="false"
android:icon="@drawable/ic_pin_drop_24dp"
android:title="@string/action_press_for_marker" />
<item
android:id="@+id/action_manual_zoom"
android:checkable="false"
android:icon="@drawable/ic_filter_center_focus_24dp"
android:title="@string/action_manual_zoom" />
<item
android:id="@+id/action_coordinate_change"
android:checkable="false"
android:icon="@drawable/ic_animate_coordinates"
android:title="@string/action_animate_coordinate_change" />
<item
android:id="@+id/action_visible_bounds"
android:checkable="false"
android:icon="@drawable/ic_crop_24dp"
android:title="@string/action_visible_bounds" />
<item
android:id="@+id/action_bulk_markers"
android:checkable="false"
android:icon="@drawable/ic_blur_on_24dp"
android:title="@string/action_add_bulk_markers" />
<item
android:id="@+id/action_user_tracking_mode"
android:checkable="false"
android:icon="@drawable/ic_gps_fixed_24dp"
android:title="@string/activity_user_tracking_mode" />
<item
android:id="@+id/action_polyline"
android:checkable="false"
android:icon="@drawable/ic_trending_up_24dp"
android:title="@string/activity_polyline" />
<item
android:id="@+id/action_custom_layer"
android:checkable="false"
android:icon="@drawable/ic_trending_up_24dp"
android:title="@string/activity_custom_layer" />
</menu>
</item>
</menu>

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"></menu>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_id_remove"
android:icon="@drawable/ic_delete_24dp"
android:title="@string/action_remove_polylines"
mapbox:showAsAction="ifRoom" />
</menu>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary">#1E8CAB</color>
<color name="primaryDark">#166B83</color>
<color name="accent">#E55E5E</color>
<color name="white">#FFFFFF</color>
</resources>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="fab_margin">16dp</dimen>
<dimen name="attr_margin">10dp</dimen>
<dimen name="coordinatebounds_margin">32dp</dimen>
</resources>

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Mapbox GL</string>
<!-- Test Activities -->
<string name="activity_tilt">Map Tilt</string>
<string name="activity_infowindow_adapter">InfoWindow Adapter</string>
<string name="activity_map_fragment">Map Fragment Activity</string>
<string name="activity_press_for_marker">Press For Marker Activity</string>
<string name="activity_marker_in_bulk">Add Bulk Markers Activity</string>
<string name="activity_manual_zoom">Manual Zoom Activity</string>
<string name="activity_info_window">InfoWindow Activity</string>
<string name="activity_info_window_concurrent">InfoWindow Activity (Concurrent)</string>
<string name="activity_visible_coordinate_bounds">Visible Coordinate Bounds</string>
<string name="activity_user_tracking_mode">User tracking mode</string>
<string name="activity_polyline">Polyline Activity</string>
<string name="activity_animate_coordinate_change">Animate Coordinate Change</string>
<string name="activity_custom_layer">Custom Layer</string>
<string name="navdrawer_menu_title_mainactivity_controls">Main Activity Controls</string>
<string name="navdrawer_menu_title_mainactivity_styles">Main Activity Styles</string>
<string name="navdrawer_menu_title_individual_tests">Individual Tests</string>
<string name="action_gps">Toggle GPS location</string>
<string name="action_user_location_tracking">User location tracking</string>
<string name="action_compass">Toggle compass</string>
<string name="action_debug">Cycle map debug options</string>
<string name="action_point_annotations">Toggle point annotations</string>
<string name="action_info_window_adapter">InfoWindow Adapter</string>
<string name="action_tilt">Tilt</string>
<string name="action_map_fragment">MapFragment</string>
<string name="action_press_for_marker">Press For Marker</string>
<string name="action_manual_zoom">Manual Zoom</string>
<string name="action_info_window">InfoWindow</string>
<string name="action_animate_coordinate_change">Animate Coordinate Change</string>
<string name="action_info_window_concurrent">InfoWindow (Concurrent)</string>
<string name="action_add_bulk_markers">Add Markers in bulk</string>
<string name="action_visible_bounds">Set Visible Bounds</string>
<string name="action_visible_bounds_explanation">Center map around 2 markers</string>
<string name="action_remove_polylines">Remove polylines</string>
<string name="label_fps">FPS:</string>
<string name="styleMapboxStreets">Mapbox Streets</string>
<string name="styleEmerald">Emerald</string>
<string name="styleLight">Light</string>
<string name="styleDark">Dark</string>
<string name="styleSatellite">Satellite</string>
<string name="styleSatelliteStreets">Satellite Streets</string>
<string-array name="outdoors_class_list">
<item>Day</item>
<item>Night</item>
</string-array>
<string-array name="bulk_marker_list">
<item>10</item>
<item>100</item>
<item>1000</item>
<item>10000</item>
</string-array>
<string-array name="user_tracking_mode">
<item>Disable tracking</item>
<item>Follow tracking mode</item>
</string-array>
<string-array name="user_bearing_mode">
<item>Disable bearing</item>
<item>GPS mode</item>
<item>Compass mode</item>
<!--<item>Combined mode</item>-->
</string-array>
<string name="zoom_botton">Zoom</string>
</resources>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="AppBaseTheme" />
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:windowBackground">@android:color/white</item>
</style>
</resources>

View File

@@ -0,0 +1,180 @@
import com.mapbox.mapboxsdk.geometry.BoundingBox;
import com.mapbox.mapboxsdk.geometry.CoordinateSpan;
import com.mapbox.mapboxsdk.geometry.LatLng;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class BoundingBoxTest {
private BoundingBox mBoundingBox;
@Before
public void setup() {
mBoundingBox = new BoundingBox(20.0, 10.0, 0.0, 0.0);
}
@Test
public void testSanity() {
BoundingBox boundingBox = new BoundingBox(0.0, 0.0, 0.0, 0.0);
assertNotNull("boundingBox should not be null", boundingBox);
}
@Test
public void testDefaultConstructor() {
mBoundingBox = new BoundingBox(0, 0, 0, 0);
assertEquals(mBoundingBox, new BoundingBox());
}
@Test
public void testEqualityConstructors() {
BoundingBox cornerBoundingBox = new BoundingBox(new LatLng(20.0, 10.0), new LatLng(0.0, 0.0));
BoundingBox cloneBoundingBox = new BoundingBox(mBoundingBox);
assertEquals("boundingBoxes should match", mBoundingBox, cornerBoundingBox);
assertEquals("boundingBoxes should match", mBoundingBox, cloneBoundingBox);
}
@Test
public void testValidBox() {
assertTrue(mBoundingBox.isValid());
}
@Test
public void testInvalidLatitudeSpanBox() {
mBoundingBox = new BoundingBox(0.0, 10.0, 10.0, 0.0);
assertFalse(mBoundingBox.isValid());
}
@Test
public void testInvalidLongitudeSpanBox() {
mBoundingBox = new BoundingBox(10.0, 0.0, 0.0, 20.0);
assertFalse(mBoundingBox.isValid());
}
@Test
public void testCenterCoordinate() {
LatLng center = new LatLng(10.0, 5.0);
assertEquals("boundingBox center should match", center, mBoundingBox.getCenter());
}
@Test
public void testUnionSameBox() {
assertEquals(mBoundingBox, mBoundingBox.union(mBoundingBox));
}
@Test
public void testUnionInnerBox() {
BoundingBox innerBox = new BoundingBox(2.0, 2.0, 1.0, 1.0);
assertEquals(mBoundingBox.union(innerBox), mBoundingBox);
}
@Test
public void testUnionOverlapBox() {
BoundingBox resultBox = new BoundingBox(22.0, 12.0, 0.0, 0.0);
BoundingBox overlapBox = new BoundingBox(22.0, 12.0, 1.0, 1.0);
assertEquals(resultBox, mBoundingBox.union(overlapBox));
}
@Test
public void testUnionOuterBox() {
BoundingBox resultBox = new BoundingBox(40.0, 40.0, 0.0, 0.0);
BoundingBox outerBox = new BoundingBox(40.0, 40.0, 0.0, 0.0);
assertEquals(resultBox, mBoundingBox.union(outerBox));
}
@Test
public void testIntersectSameBox() {
assertEquals(mBoundingBox, mBoundingBox.intersect(mBoundingBox));
}
@Test
public void testIntersectInnerBox() {
BoundingBox innerBox = new BoundingBox(2.0, 2.0, 1.0, 1.0);
assertEquals(innerBox, mBoundingBox.intersect(innerBox));
}
@Test
public void testIntersectOuterBox() {
BoundingBox outerBox = new BoundingBox(40.0, 40.0, 0.0, 0.0);
assertEquals(mBoundingBox, mBoundingBox.intersect(outerBox));
}
@Test
public void testIntersectOverlapBox() {
BoundingBox resultBox = new BoundingBox(20.0, 10.0, 1.0, 1.0);
BoundingBox overlapBox = new BoundingBox(22.0, 12.0, 1.0, 1.0);
assertEquals(resultBox, mBoundingBox.intersect(overlapBox));
}
@Test
public void testIntersectNoneBox() {
BoundingBox outsideBox = new BoundingBox(100.0, 100.0, 50.0, 50.0);
assertNull(mBoundingBox.intersect(outsideBox));
}
@Test
public void testContainsCoordinate() {
LatLng coordinate = new LatLng(1.0, 1.0);
assertTrue(mBoundingBox.contains(coordinate));
}
@Test
public void testContainsCoordinateOnBoundary() {
LatLng coordinate = new LatLng(20.0, 9.0);
assertFalse(mBoundingBox.contains(coordinate));
}
@Test
public void testContainsNoCoordinate() {
LatLng coordinate = new LatLng(100.0, 100.0);
assertFalse(mBoundingBox.contains(coordinate));
}
@Test
public void testSpan() {
CoordinateSpan span = new CoordinateSpan(20.0, 10.0);
assertTrue(mBoundingBox.getSpan().equals(span));
}
@Test
public void testLatitudeSpan() {
double height = 20.0;
assertTrue(mBoundingBox.getLatitudeSpan() == height);
}
@Test
public void testLongitudeSpan() {
double width = 10.0;
assertTrue(mBoundingBox.getLongitudeSpan() == width);
}
@Test
public void testEmptySpanEmptyNotEmptyBox(){
assertFalse(mBoundingBox.isEmpty());
}
@Test
public void testEmptySpanEmptyBox() {
mBoundingBox = new BoundingBox();
assertTrue(mBoundingBox.isEmpty());
}
@Test
public void testEmptySpanEmptyLatitude() {
mBoundingBox = new BoundingBox(1.0, 2.0, 0.0, 2.0);
assertTrue(mBoundingBox.isEmpty());
}
@Test
public void testEmptySpanEmptyLongitude(){
mBoundingBox = new BoundingBox(0.0, 3.0, 0.0, 1.0);
assertTrue(mBoundingBox.isEmpty());
}
}

View File

@@ -0,0 +1,58 @@
import com.mapbox.mapboxsdk.geometry.CoordinateBounds;
import com.mapbox.mapboxsdk.geometry.LatLng;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class CoordinateBoundsTest {
@Test
public void testSanity() {
CoordinateBounds coordinateBounds = new CoordinateBounds(null, null);
assertNotNull("coordinateBounds should not be null", coordinateBounds);
}
@Test
public void testSouthWestConstructor() {
LatLng southWest = new LatLng(12, 12);
CoordinateBounds coordinateBounds = new CoordinateBounds(southWest, null);
assertEquals("southWest should match", southWest, coordinateBounds.getSouthWest());
}
@Test
public void testNorthEastConstructor() {
LatLng northEast = new LatLng(12, 12);
CoordinateBounds coordinateBounds = new CoordinateBounds(null, northEast);
assertEquals("northEast should match", northEast, coordinateBounds.getNorthEast());
}
@Test
public void testHashCode() {
LatLng northEast = new LatLng(60, 60);
LatLng southWest = new LatLng(43, 26);
CoordinateBounds coordinateBounds = new CoordinateBounds(northEast, southWest);
assertEquals("hash code should match", coordinateBounds.hashCode(), -1515487232);
}
@Test
public void testToString() {
LatLng northEast = new LatLng(60, 60);
LatLng southWest = new LatLng(43, 26);
CoordinateBounds coordinateBounds = new CoordinateBounds(northEast, southWest);
assertEquals("string should match",
coordinateBounds.toString(),
"CoordinateBounds [northEast[" + coordinateBounds.getNorthEast() + "], southWest[]" + coordinateBounds.getSouthWest() + "]");
}
@Test
public void testEquals() {
LatLng northEast = new LatLng(60, 60);
LatLng southWest = new LatLng(43, 26);
CoordinateBounds firstBounds = new CoordinateBounds(northEast, southWest);
CoordinateBounds sameBounds = new CoordinateBounds(northEast, southWest);
assertTrue(firstBounds.equals(sameBounds));
}
}

View File

@@ -0,0 +1,54 @@
import com.mapbox.mapboxsdk.geometry.CoordinateRegion;
import com.mapbox.mapboxsdk.geometry.CoordinateSpan;
import com.mapbox.mapboxsdk.geometry.LatLng;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class CoordinateRegionTest {
@Test
public void testSanity() {
LatLng center = new LatLng(1.2, 3.4, 5.6);
CoordinateSpan span = new CoordinateSpan(9.8, 7.6);
CoordinateRegion coordinateRegion = new CoordinateRegion(center, span);
assertNotNull("coordinateRegion should not be null", coordinateRegion);
}
@Test
public void testCenterConstructor() {
LatLng center = new LatLng(1.2, 3.4, 5.6);
CoordinateSpan span = new CoordinateSpan(9.8, 7.6);
CoordinateRegion coordinateRegion = new CoordinateRegion(center, span);
assertEquals("center should match", coordinateRegion.getCenter(), center);
}
@Test
public void testSpanConstructor() {
LatLng center = new LatLng(1.2, 3.4, 5.6);
CoordinateSpan span = new CoordinateSpan(9.8, 7.6);
CoordinateRegion coordinateRegion = new CoordinateRegion(center, span);
assertEquals("span should match", coordinateRegion.getSpan(), span);
}
@Test
public void testCenterMethod() {
LatLng center = new LatLng(1.2, 3.4, 5.6);
CoordinateSpan span = new CoordinateSpan(9.8, 7.6);
CoordinateRegion coordinateRegion = new CoordinateRegion(null, span);
coordinateRegion.setCenter(center);
assertEquals("center should match", coordinateRegion.getCenter(), center);
}
@Test
public void testSpanMethod() {
LatLng center = new LatLng(1.2, 3.4, 5.6);
CoordinateSpan span = new CoordinateSpan(9.8, 7.6);
CoordinateRegion coordinateRegion = new CoordinateRegion(center, null);
coordinateRegion.setSpan(span);
assertEquals("span should match", coordinateRegion.getSpan(), span);
}
}

View File

@@ -0,0 +1,48 @@
import com.mapbox.mapboxsdk.geometry.CoordinateSpan;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class CoordinateSpanTest {
private static final double DELTA = 1e-15;
@Test
public void testSanity() {
CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, 0.0);
assertNotNull("coordinateSpan should not be null", coordinateSpan);
}
@Test
public void testLatitudeConstructor() {
double latitude = 1.23;
CoordinateSpan coordinateSpan = new CoordinateSpan(latitude, 0.0);
assertEquals("latitude in constructor", coordinateSpan.getLatitudeSpan(), latitude, DELTA);
}
@Test
public void testLongitudeConstructor() {
double longitude = 1.23;
CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, longitude);
assertEquals("latitude in constructor", coordinateSpan.getLongitudeSpan(), longitude, DELTA);
}
@Test
public void testLatitudeMethod() {
double latitude = 1.23;
CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, 0.0);
coordinateSpan.setLatitudeSpan(latitude);
assertEquals("latitude in constructor", coordinateSpan.getLatitudeSpan(), latitude, DELTA);
}
@Test
public void testLongitudeMethod() {
double longitude = 1.23;
CoordinateSpan coordinateSpan = new CoordinateSpan(0.0, 0.0);
coordinateSpan.setLongitudeSpan(longitude);
assertEquals("latitude in constructor", coordinateSpan.getLongitudeSpan(), longitude, DELTA);
}
}

View File

@@ -0,0 +1,98 @@
import android.location.Location;
import com.mapbox.mapboxsdk.geometry.LatLng;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class LatLngTest {
private static final double DELTA = 1e-15;
@Test
public void testSanity() {
LatLng latLng = new LatLng(0.0, 0.0);
assertNotNull("latLng should not be null", latLng);
}
@Test
public void testLatitudeConstructor() {
double latitude = 1.2;
LatLng latLng = new LatLng(latitude, 3.4);
assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA);
}
@Test
public void testLongitudeConstructor() {
double longitude = 3.4;
LatLng latLng = new LatLng(1.2, longitude);
assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA);
}
@Test
public void testAltitudeConstructor() {
LatLng latLng1 = new LatLng(1.2, 3.4);
assertEquals("altitude default value", latLng1.getAltitude(), 0.0, DELTA);
double altitude = 5.6;
LatLng latLng2 = new LatLng(1.2, 3.4, altitude);
assertEquals("altitude default value", latLng2.getAltitude(), altitude, DELTA);
}
/*
* A sample test where Mockito is necessary
*/
@Test
public void testLocationProvider() {
double latitude = 1.2;
double longitude = 3.4;
double altitude = 5.6;
// Mock the location class
Location locationMocked = mock(Location.class);
when(locationMocked.getLatitude()).thenReturn(latitude);
when(locationMocked.getLongitude()).thenReturn(longitude);
when(locationMocked.getAltitude()).thenReturn(altitude);
// Test the constructor
LatLng latLng = new LatLng(locationMocked);
assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA);
assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA);
assertEquals("altitude should match", latLng.getAltitude(), altitude, DELTA);
}
@Test
public void testHashCode() {
double latitude = 1.2;
double longitude = 3.4;
double altitude = 5.6;
LatLng latLng = new LatLng(latitude, longitude, altitude);
assertEquals("hash code should match", latLng.hashCode(), -151519232);
}
@Test
public void testToString() {
double latitude = 1.2;
double longitude = 3.4;
double altitude = 5.6;
LatLng latLng = new LatLng(latitude, longitude, altitude);
assertEquals("string should match",
latLng.toString(),
"LatLng [longitude=3.4, latitude=1.2, altitude=5.6]");
}
@Test
public void testDistanceTo() {
LatLng latLng1 = new LatLng(0.0, 0.0);
LatLng latLng2 = new LatLng(1.0, 1.0);
assertEquals("distances should match",
latLng1.distanceTo(latLng2),
157425.53710839353, DELTA);
}
}

View File

@@ -0,0 +1,15 @@
import com.mapbox.mapboxsdk.geometry.LatLngZoom;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
public class LatLngZoomTest {
@Test
public void testSanity() {
LatLngZoom latLngZoom = new LatLngZoom(0.0, 0.0, 0.0);
assertNotNull("latLngZoom should not be null", latLngZoom);
}
}

View File

@@ -0,0 +1,74 @@
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class MarkerTest {
@Test
public void testSanity() {
MarkerOptions markerOptions = new MarkerOptions();
assertNotNull("markerOptions should not be null", markerOptions);
}
@Test
public void testMarker() {
MarkerOptions markerOptions = new MarkerOptions();
assertNotNull("marker should not be null", markerOptions.getMarker());
}
@Test
public void testPosition() {
Marker marker = new MarkerOptions().position(new LatLng(10, 12)).getMarker();
assertEquals(marker.getPosition(), new LatLng(10, 12));
}
@Test
public void testTitle() {
Marker marker = new MarkerOptions().title("Mapbox").getMarker();
assertEquals(marker.getTitle(), "Mapbox");
}
@Test
public void testSnippet() {
Marker marker = new MarkerOptions().snippet("Mapbox").getMarker();
assertEquals(marker.getSnippet(), "Mapbox");
}
@Test
public void testBuilder() {
Marker marker = new MarkerOptions().title("title").snippet("snippet").position(new LatLng(10, 12)).getMarker();
assertEquals(marker.getTitle(), "title");
assertEquals(marker.getSnippet(), "snippet");
assertEquals(marker.getPosition(), new LatLng(10, 12));
}
@Test
public void testSprite() {
// find a way to test Sprite
}
@Test
public void testHashCode() {
Marker marker = new MarkerOptions().position(new LatLng(10, 12)).getMarker();
assertEquals("hash code should match", marker.hashCode(), -1946419200);
}
@Test
public void testEquality() {
Marker markerOne = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
Marker markerTwo = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
assertEquals(markerOne, markerTwo);
}
@Test
public void testToString() {
Marker marker = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
assertEquals(marker.toString(), "Marker [position[" + "LatLng [longitude=0.0, latitude=0.0, altitude=0.0]" + "]]");
}
}

View File

@@ -0,0 +1,77 @@
import com.mapbox.mapboxsdk.annotations.Polygon;
import com.mapbox.mapboxsdk.annotations.PolygonOptions;
import com.mapbox.mapboxsdk.annotations.Polyline;
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class PolygonTest {
@Test
public void testSanity() {
PolygonOptions polygonOptions = new PolygonOptions();
assertNotNull("polygonOptions should not be null", polygonOptions);
}
@Test
public void testPolygon() {
Polygon polygon = new PolygonOptions().getPolygon();
assertNotNull("polyline should not be null", polygon);
}
@Test
public void testAlpha() {
Polygon polygon = new PolygonOptions().alpha(0.5f).getPolygon();
assertEquals(0.5f, polygon.getAlpha(), 0.0f);
}
@Test
public void testStrokeColor() {
Polygon polygon = new PolygonOptions().strokeColor(1).getPolygon();
assertEquals(1, polygon.getStrokeColor());
}
@Test
public void testFillColor() {
Polygon polygon = new PolygonOptions().fillColor(1).getPolygon();
assertEquals(1, polygon.getFillColor());
}
@Test
public void testLatLng() {
Polygon polygon = new PolygonOptions().add(new LatLng(0, 0)).getPolygon();
assertNotNull("points should not be null", polygon.getPoints());
assertEquals(new LatLng(0, 0), polygon.getPoints().get(0));
}
@Test
public void testAddAllLatLng() {
List<LatLng> coordinates = new ArrayList<>();
coordinates.add(new LatLng(0, 0));
Polygon polygon = new PolygonOptions().addAll(coordinates).getPolygon();
assertNotNull(polygon.getPoints());
assertEquals(new LatLng(0, 0), polygon.getPoints().get(0));
}
@Test
public void testBuilder() {
PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.width(1.0f);
polylineOptions.color(2);
polylineOptions.add(new LatLng(0, 0));
Polyline polyline = polylineOptions.getPolyline();
assertEquals(1.0f, polyline.getWidth(), 0);
assertEquals(2, polyline.getColor());
assertNotNull("Points should not be null", polyline.getPoints());
assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
}
}

View File

@@ -0,0 +1,75 @@
import com.mapbox.mapboxsdk.annotations.Polyline;
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.geometry.LatLng;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class PolylineTest {
@Test
public void testSanity() {
PolylineOptions polylineOptions = new PolylineOptions();
assertNotNull("polylineOptions should not be null", polylineOptions);
}
@Test
public void testPolyline() {
Polyline polyline = new PolylineOptions().getPolyline();
assertNotNull("polyline should not be null", polyline);
}
@Test
public void testAlpha() {
Polyline polyline = new PolylineOptions().alpha(0.2f).getPolyline();
assertEquals(0.2f, polyline.getAlpha(), 0.0f);
}
@Test
public void testWidth() {
Polyline polyline = new PolylineOptions().width(1).getPolyline();
assertEquals(1.0f, polyline.getWidth(), 0);
}
@Test
public void testColor() {
Polyline polyline = new PolylineOptions().color(1).getPolyline();
assertEquals(1, polyline.getColor());
}
@Test
public void testAddLatLng() {
Polyline polyline = new PolylineOptions().add(new LatLng(0, 0)).getPolyline();
assertNotNull("Points should not be null", polyline.getPoints());
assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
}
@Test
public void testAddAllLatLng() {
List<LatLng> coordinates = new ArrayList<>();
coordinates.add(new LatLng(0, 0));
Polyline polyline = new PolylineOptions().addAll(coordinates).getPolyline();
assertNotNull(polyline.getPoints());
assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
}
@Test
public void testBuilder() {
PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.width(1.0f);
polylineOptions.color(2);
polylineOptions.add(new LatLng(0, 0));
Polyline polyline = polylineOptions.getPolyline();
assertEquals(1.0f, polyline.getWidth(), 0);
assertEquals(2, polyline.getColor());
assertNotNull("Points should not be null", polyline.getPoints());
assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
}
}

View File

@@ -0,0 +1,15 @@
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
public class ProjectedMetersTest {
@Test
public void testSanity() {
ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 0.0);
assertNotNull("projectedMeters should not be null", projectedMeters);
}
}