Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-conversions
Conflicts: android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java
This commit is contained in:
@@ -3,7 +3,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.0.0'
|
||||
classpath 'com.android.tools.build:gradle:1.1.0'
|
||||
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.1'
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ android {
|
||||
|
||||
lintOptions {
|
||||
checkAllWarnings true
|
||||
warningsAsErrors true
|
||||
disable 'IconMissingDensityFolder'
|
||||
}
|
||||
|
||||
@@ -232,7 +233,6 @@ afterEvaluate { project ->
|
||||
}
|
||||
|
||||
task androidJavadocs(type: Javadoc) {
|
||||
failOnError false
|
||||
source = android.sourceSets.main.java.sourceFiles
|
||||
classpath = files(android.bootClasspath)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import android.support.v4.view.ScaleGestureDetectorCompat;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.ScaleGestureDetector;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
@@ -45,9 +44,6 @@ public class MapView extends SurfaceView {
|
||||
// Static members
|
||||
//
|
||||
|
||||
// Tag used for logging
|
||||
private static final String TAG = "MapView";
|
||||
|
||||
// Used for animation
|
||||
private static final long ANIMATION_DURATION = 300;
|
||||
|
||||
@@ -129,7 +125,6 @@ public class MapView extends SurfaceView {
|
||||
|
||||
// Common initialization code goes here
|
||||
private void initialize(Context context, AttributeSet attrs) {
|
||||
Log.v(TAG, "initialize");
|
||||
|
||||
// Save the context
|
||||
mContext = context;
|
||||
@@ -401,7 +396,6 @@ public class MapView extends SurfaceView {
|
||||
// Called when we need to restore instance state
|
||||
// Must be called from Activity onCreate
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Log.v(TAG, "onCreate");
|
||||
if (savedInstanceState != null) {
|
||||
setCenterCoordinate((LatLng) savedInstanceState.getParcelable(STATE_CENTER_COORDINATE));
|
||||
setZoomLevel(savedInstanceState.getDouble(STATE_ZOOM_LEVEL)); // need to set zoom level first because of limitation on rotating when zoomed out
|
||||
@@ -430,7 +424,6 @@ public class MapView extends SurfaceView {
|
||||
// Called when we need to save instance state
|
||||
// Must be called from Activity onSaveInstanceState
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
Log.v(TAG, "onSaveInstanceState");
|
||||
outState.putParcelable(STATE_CENTER_COORDINATE, getCenterCoordinate());
|
||||
outState.putDouble(STATE_ZOOM_LEVEL, getZoomLevel()); // need to set zoom level first because of limitation on rotating when zoomed out
|
||||
outState.putDouble(STATE_CENTER_DIRECTION, getDirection());
|
||||
@@ -447,7 +440,6 @@ public class MapView extends SurfaceView {
|
||||
// Called when we need to clean up
|
||||
// Must be called from Activity onDestroy
|
||||
public void onDestroy() {
|
||||
Log.v(TAG, "onDestroy");
|
||||
mNativeMapView.stop();
|
||||
mNativeMapView.terminateContext();
|
||||
mNativeMapView.terminateDisplay();
|
||||
@@ -456,21 +448,17 @@ public class MapView extends SurfaceView {
|
||||
// Called when we need to create the GL context
|
||||
// Must be called from Activity onStart
|
||||
public void onStart() {
|
||||
Log.v(TAG, "onStart");
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Called when we need to terminate the GL context
|
||||
// Must be called from Activity onPause
|
||||
public void onStop() {
|
||||
Log.v(TAG, "onStop");
|
||||
//mNativeMapView.stop();
|
||||
}
|
||||
|
||||
// Called when we need to stop the render thread
|
||||
// Must be called from Activity onPause
|
||||
public void onPause() {
|
||||
Log.v(TAG, "onPause");
|
||||
|
||||
// Register for connectivity changes
|
||||
getContext().unregisterReceiver(mConnectivityReceiver);
|
||||
mConnectivityReceiver = null;
|
||||
@@ -482,8 +470,6 @@ public class MapView extends SurfaceView {
|
||||
// Must be called from Activity onResume
|
||||
|
||||
public void onResume() {
|
||||
Log.v(TAG, "onResume");
|
||||
|
||||
// Register for connectivity changes
|
||||
mConnectivityReceiver = new ConnectivityReceiver();
|
||||
mContext.registerReceiver(mConnectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
||||
@@ -498,7 +484,6 @@ public class MapView extends SurfaceView {
|
||||
// Must do all EGL/GL ES initialization here
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
Log.v(TAG, "surfaceCreated");
|
||||
mNativeMapView.createSurface(holder.getSurface());
|
||||
}
|
||||
|
||||
@@ -506,7 +491,6 @@ public class MapView extends SurfaceView {
|
||||
// Must do all EGL/GL ES destruction here
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
Log.v(TAG, "surfaceDestroyed");
|
||||
mNativeMapView.destroySurface();
|
||||
}
|
||||
|
||||
@@ -516,8 +500,6 @@ public class MapView extends SurfaceView {
|
||||
@Override
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
||||
int height) {
|
||||
Log.v(TAG, "surfaceChanged");
|
||||
Log.i(TAG, "resize " + format + " " + width + " " + height);
|
||||
mNativeMapView.resize((int) (width / mScreenDensity), (int) (height / mScreenDensity), mScreenDensity, width, height);
|
||||
}
|
||||
}
|
||||
@@ -530,7 +512,6 @@ public class MapView extends SurfaceView {
|
||||
// flicker (see Android SDK documentation)
|
||||
@Override
|
||||
public void surfaceRedrawNeeded(SurfaceHolder holder) {
|
||||
Log.v(TAG, "surfaceRedrawNeeded");
|
||||
mNativeMapView.update();
|
||||
}
|
||||
}
|
||||
@@ -1168,7 +1149,6 @@ public class MapView extends SurfaceView {
|
||||
// Called when an action we are listening to in the manifest has been sent
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.v(TAG, "ConnectivityReceiver.onReceive: action = " + intent.getAction());
|
||||
if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
|
||||
boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
|
||||
onConnectivityChanged(!noConnectivity);
|
||||
@@ -1178,7 +1158,6 @@ public class MapView extends SurfaceView {
|
||||
|
||||
// Called when our Internet connectivity has changed
|
||||
private void onConnectivityChanged(boolean isConnected) {
|
||||
Log.v(TAG, "onConnectivityChanged: " + isConnected);
|
||||
mNativeMapView.setReachability(isConnected);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,6 @@ class NativeMapView {
|
||||
// Static members
|
||||
//
|
||||
|
||||
// Tag used for logging
|
||||
private static final String TAG = "NativeMapView";
|
||||
|
||||
//
|
||||
// Instance members
|
||||
//
|
||||
|
||||
@@ -3,7 +3,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.0.0'
|
||||
classpath 'com.android.tools.build:gradle:1.1.0'
|
||||
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.1'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -24,7 +23,6 @@ import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
//import com.mapbox.mapboxgl.geometry.LatLngZoom;
|
||||
import com.mapbox.mapboxgl.views.MapView;
|
||||
import com.mapzen.android.lost.api.LocationListener;
|
||||
import com.mapzen.android.lost.api.LocationRequest;
|
||||
@@ -39,9 +37,6 @@ public class MainActivity extends ActionBarActivity {
|
||||
// Static members
|
||||
//
|
||||
|
||||
// Tag used for logging
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
// Used for saving instance state
|
||||
private static final String STATE_IS_GPS_ON = "isGpsOn";
|
||||
|
||||
@@ -67,8 +62,6 @@ public class MainActivity extends ActionBarActivity {
|
||||
private ImageView mGpsMarker;
|
||||
private Location mGpsLocation;
|
||||
private MenuItem mGpsMenuItem;
|
||||
//private boolean mLockGpsCenter = true;
|
||||
//private boolean mLockGpsZoom = true;
|
||||
|
||||
// Used for compass
|
||||
private SensorManager mSensorManager;
|
||||
@@ -91,7 +84,6 @@ public class MainActivity extends ActionBarActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.v(TAG, "onCreate");
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mIsGpsOn = savedInstanceState.getBoolean(STATE_IS_GPS_ON, false);
|
||||
@@ -156,32 +148,23 @@ public class MainActivity extends ActionBarActivity {
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
Log.v(TAG, "onPause");
|
||||
|
||||
// Cancel GPS
|
||||
if (mIsGpsOn) {
|
||||
stopGps();
|
||||
}
|
||||
toggleGps(false);
|
||||
}
|
||||
|
||||
// Called when our app comes into the foreground
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Log.v(TAG, "onResume");
|
||||
|
||||
// Restart GPS
|
||||
// Cancel any outstanding GPS
|
||||
if (mIsGpsOn) {
|
||||
startGps();
|
||||
}
|
||||
toggleGps(true);
|
||||
}
|
||||
|
||||
// Called when we need to save instance state
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
Log.v(TAG, "onSaveInstanceState");
|
||||
|
||||
outState.putBoolean(STATE_IS_GPS_ON, mIsGpsOn);
|
||||
}
|
||||
@@ -211,16 +194,7 @@ public class MainActivity extends ActionBarActivity {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_gps:
|
||||
// Toggle GPS position updates
|
||||
// TODO: how to persist this
|
||||
if (mIsGpsOn) {
|
||||
// Turn off
|
||||
stopGps();
|
||||
mIsGpsOn = false;
|
||||
} else {
|
||||
// Turn on
|
||||
startGps();
|
||||
mIsGpsOn = true;
|
||||
}
|
||||
toggleGps(!mIsGpsOn);
|
||||
updateMap();
|
||||
return true;
|
||||
|
||||
@@ -242,29 +216,38 @@ public class MainActivity extends ActionBarActivity {
|
||||
}
|
||||
}
|
||||
|
||||
// Turns the GPS location updates on
|
||||
private void startGps() {
|
||||
if (mGpsMenuItem != null) {
|
||||
mGpsMenuItem.setIcon(R.drawable.ic_action_location_found);
|
||||
}
|
||||
mGpsLocation = null;
|
||||
mLocationClient.connect();
|
||||
updateLocation(LocationServices.FusedLocationApi.getLastLocation());
|
||||
LocationServices.FusedLocationApi.requestLocationUpdates(mLocationRequest, new GpsListener());
|
||||
mSensorManager.registerListener(mCompassListener, mSensorAccelerometer, SensorManager.SENSOR_DELAY_UI);
|
||||
mSensorManager.registerListener(mCompassListener, mSensorMagneticField, SensorManager.SENSOR_DELAY_UI);
|
||||
}
|
||||
/**
|
||||
* 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) {
|
||||
|
||||
// Turns the GPS location updates off
|
||||
private void stopGps() {
|
||||
if (mGpsMenuItem != null) {
|
||||
mGpsMenuItem.setIcon(R.drawable.ic_action_location_searching);
|
||||
if (enableGps) {
|
||||
if (!mIsGpsOn) {
|
||||
mIsGpsOn = true;
|
||||
if (mGpsMenuItem != null) {
|
||||
mGpsMenuItem.setIcon(R.drawable.ic_action_location_found);
|
||||
}
|
||||
mGpsLocation = null;
|
||||
mLocationClient.connect();
|
||||
updateLocation(LocationServices.FusedLocationApi.getLastLocation());
|
||||
LocationServices.FusedLocationApi.requestLocationUpdates(mLocationRequest, new GpsListener());
|
||||
mSensorManager.registerListener(mCompassListener, mSensorAccelerometer, SensorManager.SENSOR_DELAY_UI);
|
||||
mSensorManager.registerListener(mCompassListener, mSensorMagneticField, SensorManager.SENSOR_DELAY_UI);
|
||||
}
|
||||
} else {
|
||||
if (mIsGpsOn) {
|
||||
mIsGpsOn = false;
|
||||
if (mGpsMenuItem != null) {
|
||||
mGpsMenuItem.setIcon(R.drawable.ic_action_location_searching);
|
||||
}
|
||||
LocationServices.FusedLocationApi.removeLocationUpdates(mGpsListener);
|
||||
mLocationClient.disconnect();
|
||||
mSensorManager.unregisterListener(mCompassListener, mSensorAccelerometer);
|
||||
mSensorManager.unregisterListener(mCompassListener, mSensorMagneticField);
|
||||
mGpsLocation = null;
|
||||
}
|
||||
}
|
||||
LocationServices.FusedLocationApi.removeLocationUpdates(mGpsListener);
|
||||
mLocationClient.disconnect();
|
||||
mSensorManager.unregisterListener(mCompassListener, mSensorAccelerometer);
|
||||
mSensorManager.unregisterListener(mCompassListener, mSensorMagneticField);
|
||||
mGpsLocation = null;
|
||||
}
|
||||
|
||||
// This class forwards location updates to updateLocation()
|
||||
@@ -323,15 +306,6 @@ public class MainActivity extends ActionBarActivity {
|
||||
private void updateLocation(Location location) {
|
||||
if (location != null) {
|
||||
mGpsLocation = location;
|
||||
/*LatLng coordinate = new LatLng(mGpsLocation);
|
||||
LatLngZoom zoomedCoordinate = new LatLngZoom(coordinate, 16);
|
||||
if (mLockGpsCenter) {
|
||||
if (mLockGpsZoom) {
|
||||
mMapFragment.getMap().setCenterCoordinate(zoomedCoordinate, true);
|
||||
} else {
|
||||
mMapFragment.getMap().setCenterCoordinate(coordinate, true);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
updateMap();
|
||||
@@ -342,7 +316,7 @@ public class MainActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
switch(position) {
|
||||
switch (position) {
|
||||
// Bright
|
||||
case 0:
|
||||
mMapFragment.getMap().setStyleUrl("asset://styles/bright-v7.json");
|
||||
@@ -416,7 +390,7 @@ public class MainActivity extends ActionBarActivity {
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
ArrayList<String> classes = new ArrayList<>(1);
|
||||
|
||||
switch(position) {
|
||||
switch (position) {
|
||||
// Day
|
||||
case 0:
|
||||
classes.add("day");
|
||||
@@ -448,7 +422,7 @@ public class MainActivity extends ActionBarActivity {
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
ArrayList<String> classes = new ArrayList<>(2);
|
||||
|
||||
switch(position) {
|
||||
switch (position) {
|
||||
// Labels + Contours
|
||||
case 0:
|
||||
classes.add("labels");
|
||||
|
||||
Reference in New Issue
Block a user