[android] Move into platform subdirectory
@@ -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>
|
||||
|
After Width: | Height: | Size: 831 B |
136346
platform/android/MapboxGLAndroidSDKTestApp/src/main/assets/points.geojson
Normal 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]]}}]}
|
||||
@@ -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]]]}}]}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 913 B |
|
After Width: | Height: | Size: 913 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||