diff options
Diffstat (limited to 'android')
-rw-r--r-- | android/cpp/jni.cpp | 58 | ||||
-rw-r--r-- | android/cpp/native_map_view.cpp | 2 | ||||
-rw-r--r-- | android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/MapView.java | 20 | ||||
-rw-r--r-- | android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/NativeMapView.java | 50 | ||||
-rwxr-xr-x | android/scripts/common.sh | 2 |
5 files changed, 66 insertions, 66 deletions
diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp index 9123d9aba8..d3934921b6 100644 --- a/android/cpp/jni.cpp +++ b/android/cpp/jni.cpp @@ -380,19 +380,19 @@ jobject JNICALL nativeGetClasses(JNIEnv *env, jobject obj, jlong nativeMapViewPt } void JNICALL nativeSetDefaultTransitionDuration(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, - jlong milliseconds) { + jlong duration) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetDefaultTransitionDuration"); assert(nativeMapViewPtr != 0); - assert(milliseconds >= 0); + assert(duration >= 0); NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr); - nativeMapView->getMap().setDefaultTransitionDuration(milliseconds); + nativeMapView->getMap().setDefaultTransitionDuration(std::chrono::milliseconds(duration)); } jlong JNICALL nativeGetDefaultTransitionDuration(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetDefaultTransitionDuration"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr); - return nativeMapView->getMap().getDefaultTransitionDuration(); + return std::chrono::duration_cast<std::chrono::milliseconds>(nativeMapView->getMap().getDefaultTransitionDuration()).count(); } void JNICALL nativeSetStyleURL(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jstring url) { @@ -441,15 +441,15 @@ void JNICALL nativeCancelTransitions(JNIEnv *env, jobject obj, jlong nativeMapVi } void JNICALL nativeMoveBy(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble dx, jdouble dy, - jdouble duration) { + jlong duration) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeMoveBy"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr); - nativeMapView->getMap().moveBy(dx, dy, duration); + nativeMapView->getMap().moveBy(dx, dy, std::chrono::milliseconds(duration)); } void JNICALL nativeSetLonLat(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jobject lonLat, - jdouble duration) { + jlong duration) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetLonLat"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr); @@ -466,7 +466,7 @@ void JNICALL nativeSetLonLat(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, j return; } - nativeMapView->getMap().setLonLat(lon, lat, duration); + nativeMapView->getMap().setLonLat(lon, lat, std::chrono::milliseconds(duration)); } jobject JNICALL nativeGetLonLat(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { @@ -507,19 +507,19 @@ void JNICALL nativeResetPosition(JNIEnv *env, jobject obj, jlong nativeMapViewPt } void JNICALL nativeScaleBy(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble ds, jdouble cx, - jdouble cy, jdouble duration) { + jdouble cy, jlong duration) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeScaleBy"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr); - nativeMapView->getMap().scaleBy(ds, cx, cy, duration); + nativeMapView->getMap().scaleBy(ds, cx, cy, std::chrono::milliseconds(duration)); } void JNICALL nativeSetScale(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble scale, - jdouble cx, jdouble cy, jdouble duration) { + jdouble cx, jdouble cy, jlong duration) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetScale"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr); - nativeMapView->getMap().setScale(scale, cx, cy, duration); + nativeMapView->getMap().setScale(scale, cx, cy, std::chrono::milliseconds(duration)); } jdouble JNICALL nativeGetScale(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { @@ -530,11 +530,11 @@ jdouble JNICALL nativeGetScale(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) } void JNICALL -nativeSetZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble zoom, jdouble duration) { +nativeSetZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble zoom, jlong duration) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetZoom"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr); - nativeMapView->getMap().setZoom(zoom, duration); + nativeMapView->getMap().setZoom(zoom, std::chrono::milliseconds(duration)); } jdouble JNICALL nativeGetZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { @@ -545,7 +545,7 @@ jdouble JNICALL nativeGetZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) } void JNICALL nativeSetLonLatZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, - jobject lonLatZoom, jdouble duration) { + jobject lonLatZoom, jlong duration) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetLonLatZoom"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr); @@ -568,7 +568,7 @@ void JNICALL nativeSetLonLatZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPt return; } - nativeMapView->getMap().setLonLatZoom(lon, lat, zoom, duration); + nativeMapView->getMap().setLonLatZoom(lon, lat, zoom, std::chrono::milliseconds(duration)); } jobject JNICALL nativeGetLonLatZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) { @@ -623,19 +623,19 @@ jdouble JNICALL nativeGetMaxZoom(JNIEnv *env, jobject obj, jlong nativeMapViewPt } void JNICALL nativeRotateBy(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble sx, - jdouble sy, jdouble ex, jdouble ey, jdouble duration) { + jdouble sy, jdouble ex, jdouble ey, jlong duration) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeRotateBy"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr); - nativeMapView->getMap().rotateBy(sx, sy, ex, ey, duration); + nativeMapView->getMap().rotateBy(sx, sy, ex, ey, std::chrono::milliseconds(duration)); } void JNICALL nativeSetBearing(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble degrees, - jdouble duration) { + jlong duration) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetBearing"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr); - nativeMapView->getMap().setBearing(degrees, duration); + nativeMapView->getMap().setBearing(degrees, std::chrono::milliseconds(duration)); } void JNICALL nativeSetBearing(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble degrees, @@ -889,20 +889,20 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { {"nativeGetAccessToken", "(J)Ljava/lang/String;", reinterpret_cast<void *>(&nativeGetAccessToken)}, {"nativeCancelTransitions", "(J)V", reinterpret_cast<void *>(&nativeCancelTransitions)}, - {"nativeMoveBy", "(JDDD)V", reinterpret_cast<void *>(&nativeMoveBy)}, - {"nativeSetLonLat", "(JLcom/mapbox/mapboxgl/lib/LonLat;D)V", + {"nativeMoveBy", "(JDDJ)V", reinterpret_cast<void *>(&nativeMoveBy)}, + {"nativeSetLonLat", "(JLcom/mapbox/mapboxgl/lib/LonLat;J)V", reinterpret_cast<void *>(&nativeSetLonLat)}, {"nativeGetLonLat", "(J)Lcom/mapbox/mapboxgl/lib/LonLat;", reinterpret_cast<void *>(&nativeGetLonLat)}, {"nativeStartPanning", "(J)V", reinterpret_cast<void *>(&nativeStartPanning)}, {"nativeStopPanning", "(J)V", reinterpret_cast<void *>(&nativeStopPanning)}, {"nativeResetPosition", "(J)V", reinterpret_cast<void *>(&nativeResetPosition)}, - {"nativeScaleBy", "(JDDDD)V", reinterpret_cast<void *>(&nativeScaleBy)}, - {"nativeSetScale", "(JDDDD)V", reinterpret_cast<void *>(&nativeSetScale)}, + {"nativeScaleBy", "(JDDDJ)V", reinterpret_cast<void *>(&nativeScaleBy)}, + {"nativeSetScale", "(JDDDJ)V", reinterpret_cast<void *>(&nativeSetScale)}, {"nativeGetScale", "(J)D", reinterpret_cast<void *>(&nativeGetScale)}, - {"nativeSetZoom", "(JDD)V", reinterpret_cast<void *>(&nativeSetZoom)}, + {"nativeSetZoom", "(JDJ)V", reinterpret_cast<void *>(&nativeSetZoom)}, {"nativeGetZoom", "(J)D", reinterpret_cast<void *>(&nativeGetZoom)}, - {"nativeSetLonLatZoom", "(JLcom/mapbox/mapboxgl/lib/LonLatZoom;D)V", + {"nativeSetLonLatZoom", "(JLcom/mapbox/mapboxgl/lib/LonLatZoom;J)V", reinterpret_cast<void *>(&nativeSetLonLatZoom)}, {"nativeGetLonLatZoom", "(J)Lcom/mapbox/mapboxgl/lib/LonLatZoom;", reinterpret_cast<void *>(&nativeGetLonLatZoom)}, @@ -911,10 +911,10 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { {"nativeStopPanning", "(J)V", reinterpret_cast<void *>(&nativeStopScaling)}, {"nativeGetMinZoom", "(J)D", reinterpret_cast<void *>(&nativeGetMinZoom)}, {"nativeGetMaxZoom", "(J)D", reinterpret_cast<void *>(&nativeGetMaxZoom)}, - {"nativeRotateBy", "(JDDDDD)V", reinterpret_cast<void *>(&nativeRotateBy)}, - {"nativeSetBearing", "(JDD)V", + {"nativeRotateBy", "(JDDDDJ)V", reinterpret_cast<void *>(&nativeRotateBy)}, + {"nativeSetBearing", "(JDJ)V", reinterpret_cast<void *>( - static_cast<void JNICALL (*)(JNIEnv *, jobject, jlong, jdouble, jdouble)>( + static_cast<void JNICALL (*)(JNIEnv *, jobject, jlong, jdouble, jlong)>( &nativeSetBearing))}, {"nativeSetBearing", "(JDDD)V", reinterpret_cast<void *>( diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp index e177fd4976..71db99ff8a 100644 --- a/android/cpp/native_map_view.cpp +++ b/android/cpp/native_map_view.cpp @@ -718,7 +718,7 @@ void NativeMapView::resume() { } } -void NativeMapView::notifyMapChange(mbgl::MapChange, mbgl::timestamp) { +void NativeMapView::notifyMapChange(mbgl::MapChange, std::chrono::steady_clock::duration) { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::notifyMapChange()"); assert(vm != nullptr); diff --git a/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/MapView.java b/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/MapView.java index 36e530a179..4c51df6542 100644 --- a/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/MapView.java +++ b/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/MapView.java @@ -46,6 +46,9 @@ public class MapView extends SurfaceView { // Tag used for logging private static final String TAG = "MapView"; + // Used for animation + private static final long ANIMATION_DURATION = 300; + // Used for saving instance state private static final String STATE_CENTER_COORDINATE = "centerCoordinate"; private static final String STATE_CENTER_DIRECTION = "centerDirection"; @@ -188,7 +191,7 @@ public class MapView extends SurfaceView { if (!isInEditMode()) { if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) { mZoomButtonsController = new ZoomButtonsController(this); - mZoomButtonsController.setZoomSpeed(300); + mZoomButtonsController.setZoomSpeed(ANIMATION_DURATION); mZoomButtonsController.setOnZoomListener(new OnZoomListener()); } @@ -213,7 +216,7 @@ public class MapView extends SurfaceView { } public void setCenterCoordinate(LonLat centerCoordinate, boolean animated) { - double duration = animated ? 0.3 : 0.0; + long duration = animated ? ANIMATION_DURATION : 0; mNativeMapView.setLonLat(centerCoordinate, duration); } @@ -223,7 +226,7 @@ public class MapView extends SurfaceView { public void setCenterCoordinate(LonLatZoom centerCoordinate, boolean animated) { - double duration = animated ? 0.3 : 0.0; + long duration = animated ? ANIMATION_DURATION : 0; mNativeMapView.setLonLatZoom(centerCoordinate, duration); } @@ -243,8 +246,7 @@ public class MapView extends SurfaceView { } public void setDirection(double direction, boolean animated) { - double duration = animated ? 0.3 : 0.0; - + long duration = animated ? ANIMATION_DURATION : 0; mNativeMapView.setBearing(-direction, duration); } @@ -265,7 +267,7 @@ public class MapView extends SurfaceView { } public void setZoomLevel(double zoomLevel, boolean animated) { - double duration = animated ? 0.3 : 0.0; + long duration = animated ? ANIMATION_DURATION : 0; mNativeMapView.setZoom(zoomLevel, duration); } @@ -565,10 +567,10 @@ public class MapView extends SurfaceView { mNativeMapView.cancelTransitions(); if (zoomIn) { - mNativeMapView.scaleBy(2.0, x / mScreenDensity, y / mScreenDensity, 0.3); + mNativeMapView.scaleBy(2.0, x / mScreenDensity, y / mScreenDensity, ANIMATION_DURATION); } else { // TODO two finger tap zoom out - mNativeMapView.scaleBy(0.5, x / mScreenDensity, y / mScreenDensity, 0.3); + mNativeMapView.scaleBy(0.5, x / mScreenDensity, y / mScreenDensity, ANIMATION_DURATION); } } @@ -695,7 +697,7 @@ public class MapView extends SurfaceView { // Cancel any animation mNativeMapView.cancelTransitions(); - mNativeMapView.moveBy(velocityX * duration / 2.0 / mScreenDensity, velocityY * duration / 2.0 / mScreenDensity, duration); + mNativeMapView.moveBy(velocityX * duration / 2.0 / mScreenDensity, velocityY * duration / 2.0 / mScreenDensity, (long)(duration * 1000.0f)); return true; } diff --git a/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/NativeMapView.java b/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/NativeMapView.java index 845decbe8d..de8e8df75a 100644 --- a/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/NativeMapView.java +++ b/android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/NativeMapView.java @@ -234,18 +234,18 @@ class NativeMapView { } public void moveBy(double dx, double dy) { - moveBy(dx, dy, 0.0); + moveBy(dx, dy, 0); } - public void moveBy(double dx, double dy, double duration) { + public void moveBy(double dx, double dy, long duration) { nativeMoveBy(mNativeMapViewPtr, dx, dy, duration); } public void setLonLat(LonLat lonLat) { - setLonLat(lonLat, 0.0); + setLonLat(lonLat, 0); } - public void setLonLat(LonLat lonLat, double duration) { + public void setLonLat(LonLat lonLat, long duration) { nativeSetLonLat(mNativeMapViewPtr, lonLat, duration); } @@ -270,10 +270,10 @@ class NativeMapView { } public void scaleBy(double ds, double cx, double cy) { - scaleBy(ds, cx, cy, 0.0); + scaleBy(ds, cx, cy, 0); } - public void scaleBy(double ds, double cx, double cy, double duration) { + public void scaleBy(double ds, double cx, double cy, long duration) { nativeScaleBy(mNativeMapViewPtr, ds, cx, cy, duration); } @@ -282,10 +282,10 @@ class NativeMapView { } public void setScale(double scale, double cx, double cy) { - setScale(scale, cx, cy, 0.0); + setScale(scale, cx, cy, 0); } - public void setScale(double scale, double cx, double cy, double duration) { + public void setScale(double scale, double cx, double cy, long duration) { nativeSetScale(mNativeMapViewPtr, scale, cx, cy, duration); } @@ -294,10 +294,10 @@ class NativeMapView { } public void setZoom(double zoom) { - setZoom(zoom, 0.0); + setZoom(zoom, 0); } - public void setZoom(double zoom, double duration) { + public void setZoom(double zoom, long duration) { nativeSetZoom(mNativeMapViewPtr, zoom, duration); } @@ -306,10 +306,10 @@ class NativeMapView { } public void setLonLatZoom(LonLatZoom lonLatZoom) { - setLonLatZoom(lonLatZoom, 0.0); + setLonLatZoom(lonLatZoom, 0); } - public void setLonLatZoom(LonLatZoom lonLatZoom, double duration) { + public void setLonLatZoom(LonLatZoom lonLatZoom, long duration) { nativeSetLonLatZoom(mNativeMapViewPtr, lonLatZoom, duration); } @@ -338,19 +338,19 @@ class NativeMapView { } public void rotateBy(double sx, double sy, double ex, double ey) { - rotateBy(sx, sy, ex, ey, 0.0); + rotateBy(sx, sy, ex, ey, 0); } public void rotateBy(double sx, double sy, double ex, double ey, - double duration) { + long duration) { nativeRotateBy(mNativeMapViewPtr, sx, sy, ex, ey, duration); } public void setBearing(double degrees) { - setBearing(degrees, 0.0); + setBearing(degrees, 0); } - public void setBearing(double degrees, double duration) { + public void setBearing(double degrees, long duration) { nativeSetBearing(mNativeMapViewPtr, degrees, duration); } @@ -468,7 +468,7 @@ class NativeMapView { private native List<String> nativeGetClasses(long nativeMapViewPtr); private native void nativeSetDefaultTransitionDuration( - long nativeMapViewPtr, long milliseconds); + long nativeMapViewPtr, long duration); private native long nativeGetDefaultTransitionDuration(long nativeMapViewPtr); @@ -486,10 +486,10 @@ class NativeMapView { private native void nativeCancelTransitions(long nativeMapViewPtr); private native void nativeMoveBy(long nativeMapViewPtr, double dx, - double dy, double duration); + double dy, long duration); private native void nativeSetLonLat(long nativeMapViewPtr, LonLat lonLat, - double duration); + long duration); private native LonLat nativeGetLonLat(long nativeMapViewPtr); @@ -500,20 +500,20 @@ class NativeMapView { private native void nativeResetPosition(long nativeMapViewPtr); private native void nativeScaleBy(long nativeMapViewPtr, double ds, - double cx, double cy, double duration); + double cx, double cy, long duration); private native void nativeSetScale(long nativeMapViewPtr, double scale, - double cx, double cy, double duration); + double cx, double cy, long duration); private native double nativeGetScale(long nativeMapViewPtr); private native void nativeSetZoom(long nativeMapViewPtr, double zoom, - double duration); + long duration); private native double nativeGetZoom(long nativeMapViewPtr); private native void nativeSetLonLatZoom(long nativeMapViewPtr, - LonLatZoom lonLatZoom, double duration); + LonLatZoom lonLatZoom, long duration); private native LonLatZoom nativeGetLonLatZoom(long nativeMapViewPtr); @@ -528,10 +528,10 @@ class NativeMapView { private native double nativeGetMaxZoom(long nativeMapViewPtr); private native void nativeRotateBy(long nativeMapViewPtr, double sx, - double sy, double ex, double ey, double duration); + double sy, double ex, double ey, long duration); private native void nativeSetBearing(long nativeMapViewPtr, double degrees, - double duration); + long duration); private native void nativeSetBearing(long nativeMapViewPtr, double degrees, double cx, double cy); diff --git a/android/scripts/common.sh b/android/scripts/common.sh index b594fd2448..5c214fe256 100755 --- a/android/scripts/common.sh +++ b/android/scripts/common.sh @@ -7,8 +7,6 @@ NAME=$1 export JOBS=2 export CC=clang CXX=clang++ -export CXXFLAGS="-Wno-unknown-warning-option -Wno-unused-local-typedefs -Wno-unknown-pragmas ${CXXFLAGS}"; - export MASON_PLATFORM=android mkdir ./android/java/app/src/main/res/raw/ |