From 7dff7ac3f2abde14655dfb9b97d88ce455b6d202 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Wed, 11 Feb 2015 16:00:24 -0800 Subject: [PATCH 1/6] Add support for Android API level 8 --- .../java/MapboxGLAndroidSDK/gradle.properties | 2 +- .../java/com/mapbox/mapboxgl/lib/MapView.java | 49 +++++++++++-------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/android/java/MapboxGLAndroidSDK/gradle.properties b/android/java/MapboxGLAndroidSDK/gradle.properties index ba69bd9e4..ed8f9fb5a 100644 --- a/android/java/MapboxGLAndroidSDK/gradle.properties +++ b/android/java/MapboxGLAndroidSDK/gradle.properties @@ -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 diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/MapView.java index 05a24fd64..73b64711e 100644 --- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/MapView.java +++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/MapView.java @@ -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; @@ -176,7 +177,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()); @@ -331,7 +336,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"); } } @@ -424,11 +429,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(getClasses())); outState.putLong(STATE_DEFAULT_TRANSITION_DURATION, mNativeMapView.getDefaultTransitionDuration()); @@ -482,16 +487,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 @@ -521,6 +517,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 @@ -576,10 +585,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; } @@ -1092,7 +1101,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? @@ -1130,7 +1139,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: From 4ca21db5dfec46f9052c39eb9b5228bd7a323f41 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Fri, 30 Jan 2015 14:14:11 +1100 Subject: [PATCH 2/6] Use libuv 1.4.0 for arm64 support --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index b818faa07..378adcf29 100755 --- a/configure +++ b/configure @@ -30,7 +30,7 @@ case ${MASON_PLATFORM} in LIBJPEG_VERSION=v9a OPENSSL_VERSION=1.0.1l LIBCURL_VERSION=7.40.0 - LIBUV_VERSION=0.11.29 + LIBUV_VERSION=1.4.0 ZLIB_VERSION=system BOOST_VERSION=1.57.0 NUNICODE_VERSION=1.5.1 From acfeda98990d792280c321a7718ad8010428eddf Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Wed, 11 Feb 2015 19:01:30 -0800 Subject: [PATCH 3/6] Fix #include mixing between C and C++ modes --- include/mbgl/util/uv-messenger.h | 4 ++-- src/mbgl/util/uv-channel.h | 4 ++-- src/mbgl/util/uv-worker.h | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/mbgl/util/uv-messenger.h b/include/mbgl/util/uv-messenger.h index 946867fe8..35c5ce218 100644 --- a/include/mbgl/util/uv-messenger.h +++ b/include/mbgl/util/uv-messenger.h @@ -1,12 +1,12 @@ #ifndef MBGL_UTIL_UV_MESSENGER #define MBGL_UTIL_UV_MESSENGER +#include + #ifdef __cplusplus extern "C" { #endif -#include - typedef struct uv_messenger_s uv_messenger_t; typedef void (*uv_messenger_cb)(void *arg); typedef void (*uv_messenger_stop_cb)(uv_messenger_t *msgr); diff --git a/src/mbgl/util/uv-channel.h b/src/mbgl/util/uv-channel.h index ea5c279f6..0a0d70647 100644 --- a/src/mbgl/util/uv-channel.h +++ b/src/mbgl/util/uv-channel.h @@ -1,12 +1,12 @@ #ifndef MBGL_UTIL_UV_CHANNEL #define MBGL_UTIL_UV_CHANNEL +#include + #ifdef __cplusplus extern "C" { #endif -#include - // Taken from http://navaneeth.github.io/blog/2013/08/02/channels-in-libuv/ typedef struct uv_chan_s uv_chan_t; diff --git a/src/mbgl/util/uv-worker.h b/src/mbgl/util/uv-worker.h index 5640bfd14..65ad42edb 100644 --- a/src/mbgl/util/uv-worker.h +++ b/src/mbgl/util/uv-worker.h @@ -1,14 +1,14 @@ #ifndef MBGL_UTIL_UV_WORKER #define MBGL_UTIL_UV_WORKER -#ifdef __cplusplus -extern "C" { -#endif +#include #include #include -#include +#ifdef __cplusplus +extern "C" { +#endif typedef struct uv_worker_s uv_worker_t; From a855ec1bd9e7ca4d2a416dacaabca1e9c17a5c92 Mon Sep 17 00:00:00 2001 From: Jay Mooney Date: Thu, 12 Feb 2015 10:27:33 -0800 Subject: [PATCH 4/6] put cache.db in the caches folder --- platform/ios/MGLMapView.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 7c1f9eb65..89ebef248 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -24,7 +24,7 @@ // Returns the path to the default cache database on this system. const std::string &defaultCacheDatabase() { static const std::string path = []() -> std::string { - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); if ([paths count] == 0) { // Disable the cache if we don't have a location to write. return ""; From 8cfff736a4bcf87b95a4fc4b30a670b82abac8f7 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Thu, 12 Feb 2015 11:01:02 -0800 Subject: [PATCH 5/6] Archive libmbgl-gl.so with symbols intact --- android/scripts/common.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/android/scripts/common.sh b/android/scripts/common.sh index 3244ed9d4..349569b55 100755 --- a/android/scripts/common.sh +++ b/android/scripts/common.sh @@ -14,5 +14,6 @@ echo "${MAPBOX_ACCESS_TOKEN}" >> ./android/java/MapboxGLAndroidSDKTestApp/src/ma make android -j$JOBS BUILDTYPE=$BUILDTYPE JOBS=$JOBS +aws s3 cp ./build/android-${ANDROID_ABI}/${BUILDTYPE}/lib.target/libmapbox-gl.so s3://mapbox-gl-testing/android/${NAME}/libmapbox-gl.so aws s3 cp ./android/java/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-debug.apk s3://mapbox-gl-testing/android/${NAME}/MapboxGLAndroidSDKTestApp-debug.apk aws s3 cp ./android/java/MapboxGLAndroidSDKTestApp/build/outputs/apk/MapboxGLAndroidSDKTestApp-release-unsigned.apk s3://mapbox-gl-testing/android/${NAME}/MapboxGLAndroidSDKTestApp-release-unsigned.apk From bba8ff0364d89b458c4bafc0bf96741124f270b6 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Thu, 12 Feb 2015 17:27:06 -0800 Subject: [PATCH 6/6] Revert "put cache.db in the caches folder" --- platform/ios/MGLMapView.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 89ebef248..7c1f9eb65 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -24,7 +24,7 @@ // Returns the path to the default cache database on this system. const std::string &defaultCacheDatabase() { static const std::string path = []() -> std::string { - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); if ([paths count] == 0) { // Disable the cache if we don't have a location to write. return "";