Merge branch 'master' of github.com:mapbox/mapbox-gl-native into geoAPI

This commit is contained in:
Brad Leege
2015-02-12 18:51:23 -08:00
7 changed files with 40 additions and 30 deletions

View File

@@ -12,7 +12,7 @@ POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=mapbox
POM_DEVELOPER_NAME=Mapbox
ANDROID_MIN_SDK=14
ANDROID_MIN_SDK=8
ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_TOOLS_VERSION=21.1.2
ANDROID_BUILD_SDK_VERSION=21

View File

@@ -1,5 +1,6 @@
package com.mapbox.mapboxgl.lib;
import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -177,7 +178,11 @@ public class MapView extends SurfaceView {
requestFocus();
// Register the SurfaceHolder callbacks
getHolder().addCallback(new Callbacks());
if (android.os.Build.VERSION.SDK_INT >= 9) {
getHolder().addCallback(new Callbacks2());
} else {
getHolder().addCallback(new Callbacks());
}
// Touch gesture detectors
mGestureDetector = new GestureDetectorCompat(context, new GestureListener());
@@ -332,7 +337,7 @@ public class MapView extends SurfaceView {
private void validateAccessToken(String accessToken) {
if (accessToken.isEmpty() | (!accessToken.startsWith("pk.") && !accessToken.startsWith("sk."))) {
if (!accessToken.startsWith("pk.") && !accessToken.startsWith("sk.")) {
throw new RuntimeException("Using MapView requires setting a valid access token. See the README.md");
}
}
@@ -425,11 +430,11 @@ public class MapView extends SurfaceView {
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());
outState.putBoolean(STATE_ZOOM_ENABLED, isZoomEnabled());
outState.putBoolean(STATE_SCROLL_ENABLED, isScrollEnabled());
outState.putBoolean(STATE_ROTATE_ENABLED, isRotateEnabled());
outState.putBoolean(STATE_ZOOM_ENABLED, mZoomEnabled);
outState.putBoolean(STATE_SCROLL_ENABLED, mScrollEnabled);
outState.putBoolean(STATE_ROTATE_ENABLED, mRotateEnabled);
outState.putBoolean(STATE_DEBUG_ACTIVE, isDebugActive());
outState.putString(STATE_STYLE_URL, getStyleUrl());
outState.putString(STATE_STYLE_URL, mStyleUrl);
outState.putString(STATE_ACCESS_TOKEN, getAccessToken());
outState.putStringArrayList(STATE_CLASSES, new ArrayList<String>(getClasses()));
outState.putLong(STATE_DEFAULT_TRANSITION_DURATION, mNativeMapView.getDefaultTransitionDuration());
@@ -483,16 +488,7 @@ public class MapView extends SurfaceView {
}
// This class handles SurfaceHolder callbacks
private class Callbacks implements SurfaceHolder.Callback2 {
// Called when we need to redraw the view
// This is called before our view is first visible to prevent an initial
// flicker (see Android SDK documentation)
@Override
public void surfaceRedrawNeeded(SurfaceHolder holder) {
Log.v(TAG, "surfaceRedrawNeeded");
mNativeMapView.update();
}
private class Callbacks implements SurfaceHolder.Callback {
// Called when the native surface buffer has been created
// Must do all EGL/GL ES initialization here
@@ -522,6 +518,19 @@ public class MapView extends SurfaceView {
}
}
@TargetApi(9)
private class Callbacks2 extends Callbacks implements SurfaceHolder.Callback2 {
// Called when we need to redraw the view
// This is called before our view is first visible to prevent an initial
// flicker (see Android SDK documentation)
@Override
public void surfaceRedrawNeeded(SurfaceHolder holder) {
Log.v(TAG, "surfaceRedrawNeeded");
mNativeMapView.update();
}
}
// TODO examine how GLSurvaceView hadles attach/detach from window
// Called when view is no longer connected
@@ -577,10 +586,10 @@ public class MapView extends SurfaceView {
}
// Called when user touches the screen, all positions are absolute
@Override
@Override @TargetApi(14)
public boolean onTouchEvent(@NonNull MotionEvent event) {
// Check and ignore non touch or left clicks
if ((event.getButtonState() != 0) && (event.getButtonState() != MotionEvent.BUTTON_PRIMARY)) {
if ((android.os.Build.VERSION.SDK_INT >= 14) && (event.getButtonState() != 0) && (event.getButtonState() != MotionEvent.BUTTON_PRIMARY)) {
return false;
}
@@ -1093,7 +1102,7 @@ public class MapView extends SurfaceView {
// Called for events that don't fit the other handlers
// such as mouse scroll events, mouse moves, joystick, trackpad
@Override
@Override @TargetApi(12)
public boolean onGenericMotionEvent(MotionEvent event) {
// Mouse events
// TODO: SOURCE_TOUCH_NAVIGATION?
@@ -1131,7 +1140,7 @@ public class MapView extends SurfaceView {
// Called when the mouse pointer enters or exits the view
// or when it fades in or out due to movement
@Override
@Override @TargetApi(14)
public boolean onHoverEvent(@NonNull MotionEvent event) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_HOVER_ENTER: