From 9c9ad538f8f097f19837cdbe4865ced8ba19e81e Mon Sep 17 00:00:00 2001 From: Jesse Bounds Date: Wed, 27 Dec 2017 12:01:39 -0800 Subject: [PATCH 01/19] [ios] Dispatch location auth status check to background This attempts to work around reports of repeated calls to [CLLocationManager authorizationStatus] blocking the main thread by dispatching it to the background, serial queue that is already available in MGLMapboxEvents. This also adds a guard to the handler for the user defaults change event so that the call to pause or resume if required is done only if a user defaults value changes that would require an update to the pause / resume state. The guard works by utilizing two new state variables that keep track of the previous values for account type and metrics enabled configuration variables. The call to pause/resume is only done if the latest relevant values in the user defaults dictionary are actually different than the previous ones. The default values for the new state variables assume an account value of 0 and metrics enabled == true so there can be a small inefficiency if a user prevously opted out of telemetry, kills the app, and restarts it. In that case, the pause/resume method would get invoked one time when it would not technically need to. This should not be an issue in practice though. --- platform/ios/src/MGLMapboxEvents.m | 103 +++++++++++++++++++---------- 1 file changed, 67 insertions(+), 36 deletions(-) diff --git a/platform/ios/src/MGLMapboxEvents.m b/platform/ios/src/MGLMapboxEvents.m index 4f1413d30..d59972f5b 100644 --- a/platform/ios/src/MGLMapboxEvents.m +++ b/platform/ios/src/MGLMapboxEvents.m @@ -54,6 +54,9 @@ static NSString *const MGLEventKeySessionId = @"sessionId"; static NSString *const MGLEventKeyApplicationState = @"applicationState"; static NSString *const MGLEventKeyAltitude = @"altitude"; +static NSString *const MGLMapboxAccountType = @"MGLMapboxAccountType"; +static NSString *const MGLMapboxMetricsEnabled = @"MGLMapboxMetricsEnabled"; + // SDK event source static NSString *const MGLEventSource = @"mapbox"; @@ -124,6 +127,8 @@ const NSTimeInterval MGLFlushInterval = 180; @property (nonatomic) NSTimer *timer; @property (nonatomic) NSDate *instanceIDRotationDate; @property (nonatomic) NSDate *nextTurnstileSendDate; +@property (nonatomic) NSNumber *currentAccountTypeValue; +@property (nonatomic) BOOL currentMetricsEnabledValue; @end @@ -135,10 +140,10 @@ const NSTimeInterval MGLFlushInterval = 180; + (void)initialize { if (self == [MGLMapboxEvents class]) { NSBundle *bundle = [NSBundle mainBundle]; - NSNumber *accountTypeNumber = [bundle objectForInfoDictionaryKey:@"MGLMapboxAccountType"]; + NSNumber *accountTypeNumber = [bundle objectForInfoDictionaryKey:MGLMapboxAccountType]; [[NSUserDefaults standardUserDefaults] registerDefaults:@{ - @"MGLMapboxAccountType": accountTypeNumber ?: @0, - @"MGLMapboxMetricsEnabled": @YES, + MGLMapboxAccountType: accountTypeNumber ?: @0, + MGLMapboxMetricsEnabled: @YES, @"MGLMapboxMetricsDebugLoggingEnabled": @NO, }]; } @@ -152,8 +157,8 @@ const NSTimeInterval MGLFlushInterval = 180; if ([NSProcessInfo instancesRespondToSelector:@selector(isLowPowerModeEnabled)]) { isLowPowerModeEnabled = [[NSProcessInfo processInfo] isLowPowerModeEnabled]; } - return ([[NSUserDefaults standardUserDefaults] boolForKey:@"MGLMapboxMetricsEnabled"] && - [[NSUserDefaults standardUserDefaults] integerForKey:@"MGLMapboxAccountType"] == 0 && + return ([[NSUserDefaults standardUserDefaults] boolForKey:MGLMapboxMetricsEnabled] && + [[NSUserDefaults standardUserDefaults] integerForKey:MGLMapboxAccountType] == 0 && !isLowPowerModeEnabled); #endif } @@ -167,6 +172,9 @@ const NSTimeInterval MGLFlushInterval = 180; - (instancetype) init { self = [super init]; if (self) { + _currentAccountTypeValue = @0; + _currentMetricsEnabledValue = YES; + _appBundleId = [[NSBundle mainBundle] bundleIdentifier]; _apiClient = [[MGLAPIClient alloc] init]; @@ -249,38 +257,61 @@ const NSTimeInterval MGLFlushInterval = 180; } - (void)userDefaultsDidChange:(NSNotification *)notification { - dispatch_async(dispatch_get_main_queue(), ^{ - [self pauseOrResumeMetricsCollectionIfRequired]; - }); + + // Guard against over calling pause / resume if the values this implementation actually + // cares about have not changed + + if ([[notification object] respondsToSelector:@selector(objectForKey:)]) { + NSUserDefaults *userDefaults = [notification object]; + + NSNumber *accountType = [userDefaults objectForKey:MGLMapboxAccountType]; + BOOL metricsEnabled = [[userDefaults objectForKey:MGLMapboxMetricsEnabled] boolValue]; + + if (![accountType isEqualToNumber:self.currentAccountTypeValue] || metricsEnabled != self.currentMetricsEnabledValue) { + [self pauseOrResumeMetricsCollectionIfRequired]; + self.currentAccountTypeValue = accountType; + self.currentMetricsEnabledValue = metricsEnabled; + } + } + } - (void)pauseOrResumeMetricsCollectionIfRequired { - UIApplication *application = [UIApplication sharedApplication]; - - // Prevent blue status bar when host app has `when in use` permission only and it is not in foreground - if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse && - application.applicationState == UIApplicationStateBackground) { - - if (_backgroundTaskIdentifier == UIBackgroundTaskInvalid) { - _backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{ - [application endBackgroundTask:_backgroundTaskIdentifier]; - _backgroundTaskIdentifier = UIBackgroundTaskInvalid; - }]; - [self flush]; - } - - [self pauseMetricsCollection]; - return; - } - - // Toggle pause based on current pause state, user opt-out state, and low-power state. - BOOL enabled = [[self class] isEnabled]; - if (self.paused && enabled) { - [self resumeMetricsCollection]; - } else if (!self.paused && !enabled) { - [self flush]; - [self pauseMetricsCollection]; - } + + // [CLLocationManager authorizationStatus] has been found to block in some cases so + // dispatch the call to a non-UI thread + dispatch_async(self.serialQueue, ^{ + CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; + + // Checking application state must be done on the main thread for safety and + // to avoid a thread sanitizer error + dispatch_async(dispatch_get_main_queue(), ^{ + UIApplication *application = [UIApplication sharedApplication]; + UIApplicationState state = application.applicationState; + + // Prevent blue status bar when host app has `when in use` permission only and it is not in foreground + if (status == kCLAuthorizationStatusAuthorizedWhenInUse && state == UIApplicationStateBackground) { + if (_backgroundTaskIdentifier == UIBackgroundTaskInvalid) { + _backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{ + [application endBackgroundTask:_backgroundTaskIdentifier]; + _backgroundTaskIdentifier = UIBackgroundTaskInvalid; + }]; + [self flush]; + } + [self pauseMetricsCollection]; + return; + } + + // Toggle pause based on current pause state, user opt-out state, and low-power state. + BOOL enabled = [[self class] isEnabled]; + if (self.paused && enabled) { + [self resumeMetricsCollection]; + } else if (!self.paused && !enabled) { + [self flush]; + [self pauseMetricsCollection]; + } + }); + }); } - (void)pauseMetricsCollection { @@ -602,7 +633,7 @@ const NSTimeInterval MGLFlushInterval = 180; BOOL metricsEnabledSettingShownInAppFlag = [shownInAppNumber boolValue]; if (!metricsEnabledSettingShownInAppFlag && - [[NSUserDefaults standardUserDefaults] integerForKey:@"MGLMapboxAccountType"] == 0) { + [[NSUserDefaults standardUserDefaults] integerForKey:MGLMapboxAccountType] == 0) { // Opt-out is not configured in UI, so check for Settings.bundle id defaultEnabledValue; NSString *appSettingsBundle = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"]; @@ -612,7 +643,7 @@ const NSTimeInterval MGLFlushInterval = 180; NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[appSettingsBundle stringByAppendingPathComponent:@"Root.plist"]]; NSArray *preferences = settings[@"PreferenceSpecifiers"]; for (NSDictionary *prefSpecification in preferences) { - if ([prefSpecification[@"Key"] isEqualToString:@"MGLMapboxMetricsEnabled"]) { + if ([prefSpecification[@"Key"] isEqualToString:MGLMapboxMetricsEnabled]) { defaultEnabledValue = prefSpecification[@"DefaultValue"]; } } From 4f194ab15c09cf17edd51c5377fd8ce62ee26879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 22 Dec 2017 16:40:03 -0800 Subject: [PATCH 02/19] [macos] Fixed macosapp deployment --- platform/macos/scripts/deploy-packages.sh | 45 +++++++++++++++-------- platform/macos/scripts/package.sh | 39 ++++++++++++-------- 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/platform/macos/scripts/deploy-packages.sh b/platform/macos/scripts/deploy-packages.sh index 90c3c2930..0d053aef4 100755 --- a/platform/macos/scripts/deploy-packages.sh +++ b/platform/macos/scripts/deploy-packages.sh @@ -19,20 +19,31 @@ function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } function finish { >&2 echo -en "\033[0m"; } trap finish EXIT -buildPackageStyle() { - local package=$1 style="" - if [[ ${#} -eq 2 ]]; then - style="$2" - fi - step "Building: make ${package} ${style}" - make ${package} - step "Publishing ${package} with ${style}" +publish() { + OPTRESET=1 + OPTIND= + local arg + local rule= + local suffix= + local app= + while getopts 'r:s:a:' arg; do + case ${arg} in + r) rule=${OPTARG};; + s) suffix=${OPTARG};; + a) app=${OPTARG};; + *) "Usage: [-r rule] [-s suffix] [-a app]"; return + esac + done + + step "Building: make ${rule} ${suffix}" + make ${rule} + step "Publishing ${rule} with ${suffix}" local file_name="" - if [ -z ${style} ] + if [ -z ${suffix} ] then file_name=mapbox-macos-sdk-${PUBLISH_VERSION}.zip else - file_name=mapbox-macos-sdk-${PUBLISH_VERSION}-${style}.zip + file_name=mapbox-macos-sdk-${PUBLISH_VERSION}-${suffix}.zip fi step "Compressing ${file_name}…" cd build/macos/pkg @@ -46,16 +57,18 @@ buildPackageStyle() { --name ${file_name} \ --file "${BINARY_DIRECTORY}/${file_name}" > /dev/null fi - if [[ ${DEPLOY_APP} == true ]]; then + if [ ${app} ]; then + file_name="Mapbox GL.app.zip" + step "Compressing ${file_name}…" cd build/macos/app - rm -f 'Mapbox GL.app.zip' - zip -yr '../deploy/Mapbox GL.app.zip' 'Mapbox GL.app' + rm -f "${file_name}" + zip -yr "../deploy/${file_name}" 'Mapbox GL.app' cd - if [[ "${GITHUB_RELEASE}" == true ]]; then echo "Uploading ${file_name} to GitHub" github-release upload \ --tag "macos-v${PUBLISH_VERSION}" \ - --name ${file_name} \ + --name "${file_name}" \ --file "${BINARY_DIRECTORY}/${file_name}" > /dev/null fi fi @@ -126,7 +139,7 @@ if [[ "${GITHUB_RELEASE}" == true ]]; then --draft ${PUBLISH_PRE_FLAG} fi -buildPackageStyle "xpackage" "symbols" -DEPLOY_APP=true buildPackageStyle "xpackage SYMBOLS=NO" +publish -r xpackage -s symbols +publish -r "xpackage SYMBOLS=NO" -a true step "Finished deploying ${PUBLISH_VERSION} in $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds" diff --git a/platform/macos/scripts/package.sh b/platform/macos/scripts/package.sh index a5aae24e0..6a04b4b94 100755 --- a/platform/macos/scripts/package.sh +++ b/platform/macos/scripts/package.sh @@ -8,10 +8,10 @@ NAME=Mapbox OUTPUT=build/macos/pkg APP_OUTPUT=build/macos/app DERIVED_DATA=build/macos -PRODUCTS=${DERIVED_DATA} BUILDTYPE=${BUILDTYPE:-Release} SYMBOLS=${SYMBOLS:-YES} +PRODUCTS=${DERIVED_DATA}/${BUILDTYPE} function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } function finish { >&2 echo -en "\033[0m"; } @@ -24,15 +24,7 @@ PROJ_VERSION=$(git rev-list --count HEAD) SEM_VERSION=$( git describe --tags --match=macos-v*.*.* --abbrev=0 | sed 's/^macos-v//' ) SHORT_VERSION=${SEM_VERSION%-*} -XCODEBUILD_SCHEME=dynamic -XCODEBUILD_ACTION=build -if [[ ${BUILDTYPE} == Release ]]; then - XCODEBUILD_SCHEME=macosapp - XCODEBUILD_ACTION=archive - mkdir -p ${APP_OUTPUT} -fi - -step "Building targets (build ${PROJ_VERSION}, version ${SEM_VERSION})…" +step "Building dynamic framework (build ${PROJ_VERSION}, version ${SEM_VERSION})…" xcodebuild \ CURRENT_PROJECT_VERSION=${PROJ_VERSION} \ CURRENT_SHORT_VERSION=${SHORT_VERSION} \ @@ -41,16 +33,33 @@ xcodebuild \ -derivedDataPath ${DERIVED_DATA} \ -archivePath "${APP_OUTPUT}/macosapp.xcarchive" \ -workspace ./platform/macos/macos.xcworkspace \ - -scheme ${XCODEBUILD_SCHEME} \ + -scheme dynamic \ -configuration ${BUILDTYPE} \ -jobs ${JOBS} \ - ${XCODEBUILD_ACTION} | xcpretty + build | xcpretty step "Copying dynamic framework into place" mkdir -p "${OUTPUT}/${NAME}.framework" -ditto ${PRODUCTS}/${BUILDTYPE}/${NAME}.framework "${OUTPUT}/${NAME}.framework" -if [[ -e ${PRODUCTS}/${BUILDTYPE}/${NAME}.framework.dSYM ]]; then - cp -r ${PRODUCTS}/${BUILDTYPE}/${NAME}.framework.dSYM "${OUTPUT}" +ditto ${PRODUCTS}/${NAME}.framework "${OUTPUT}/${NAME}.framework" +if [[ -e ${PRODUCTS}/${NAME}.framework.dSYM ]]; then + cp -r ${PRODUCTS}/${NAME}.framework.dSYM "${OUTPUT}" +fi + +step "Building and archiving Mapbox GL.app (build ${PROJ_VERSION}, version ${SEM_VERSION})…" +if [[ ${BUILDTYPE} == Release ]]; then + mkdir -p ${APP_OUTPUT} + xcodebuild \ + CURRENT_PROJECT_VERSION=${PROJ_VERSION} \ + CURRENT_SHORT_VERSION=${SHORT_VERSION} \ + CURRENT_SEMANTIC_VERSION=${SEM_VERSION} \ + CURRENT_COMMIT_HASH=${HASH} \ + -derivedDataPath ${DERIVED_DATA} \ + -archivePath "${APP_OUTPUT}/macosapp.xcarchive" \ + -workspace ./platform/macos/macos.xcworkspace \ + -scheme macosapp \ + -configuration ${BUILDTYPE} \ + -jobs ${JOBS} \ + archive | xcpretty fi if [[ ${SYMBOLS} = NO ]]; then From 4731e0c7f127a94196fdb73029e616c42a3750fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 4 Jan 2018 17:24:23 -0800 Subject: [PATCH 03/19] [ios, macos] Updated changelogs --- platform/ios/CHANGELOG.md | 6 ++++++ platform/macos/CHANGELOG.md | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index e3e2768e2..292075f0c 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,6 +2,12 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. +## 3.7.3 + +* Fixed a crash while zooming while annotations are present on the map. ([#10791](https://github.com/mapbox/mapbox-gl-native/pull/10791)) +* CJK characters can be displayed in a locally installed font or a custom font bundled with the application, reducing map download times. Specify the font name using the `MGLIdeographicFontFamilyName` key in the application’s Info.plist file. ([#10522](https://github.com/mapbox/mapbox-gl-native/pull/10522)) +* Fixed a hang that could occur if the application makes many changes to user defaults immediately after launching. ([#10803](https://github.com/mapbox/mapbox-gl-native/pull/10803)) + ## 3.7.2 - December 21, 2017 ### Packaging diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index b86ebae58..1b954f9e4 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog for Mapbox Maps SDK for macOS +## v0.6.1 + +* Fixed a crash while zooming while annotations are present on the map. ([#10791](https://github.com/mapbox/mapbox-gl-native/pull/10791)) +* CJK characters can be displayed in a locally installed font or a custom font bundled with the application, reducing map download times. Specify the font name using the `MGLIdeographicFontFamilyName` key in the application’s Info.plist file. ([#10522](https://github.com/mapbox/mapbox-gl-native/pull/10522)) + ## v0.6.0 ### Packaging From cc25d6911bedacc420373566f10c14185a6fc0ce Mon Sep 17 00:00:00 2001 From: Pablo Guardiola Date: Mon, 8 Jan 2018 10:32:57 +0100 Subject: [PATCH 04/19] [android] fix sending more than once double tap event on a single double tap gesture (#10854) --- .../java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index 6424de342..214fa2279 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -344,13 +344,12 @@ final class MapGestureDetector { // Zoom in on gesture transform.zoom(true, new PointF(e.getX(), e.getY())); } + MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( + getLocationFromGesture(e.getX(), e.getY()), + MapboxEvent.GESTURE_DOUBLETAP, transform)); break; } - MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent( - getLocationFromGesture(e.getX(), e.getY()), - MapboxEvent.GESTURE_DOUBLETAP, transform)); - return true; } From ce817a57f66fed2cb672d6708609de1817d376ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 8 Jan 2018 13:33:17 -0800 Subject: [PATCH 05/19] [core] blacklist binary program loading for Vivante GC4000 GPUs --- src/mbgl/gl/context.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 22b446e6d..d8ade8b8b 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -270,10 +270,13 @@ bool Context::supportsProgramBinaries() const { // Blacklist Adreno 3xx, 4xx, and 5xx GPUs due to known bugs: // https://bugs.chromium.org/p/chromium/issues/detail?id=510637 // https://chromium.googlesource.com/chromium/src/gpu/+/master/config/gpu_driver_bug_list.json#2316 + // Blacklist Vivante GC4000 due to bugs when linking loaded programs: + // https://github.com/mapbox/mapbox-gl-native/issues/10704 const std::string renderer = reinterpret_cast(glGetString(GL_RENDERER)); if (renderer.find("Adreno (TM) 3") != std::string::npos || renderer.find("Adreno (TM) 4") != std::string::npos - || renderer.find("Adreno (TM) 5") != std::string::npos) { + || renderer.find("Adreno (TM) 5") != std::string::npos + || renderer.find("Vivante GC4000") != std::string::npos) { return false; } From a32fddf6ddb923819dc50eed904f7340e904e716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Wed, 20 Dec 2017 17:25:53 +0100 Subject: [PATCH 06/19] [android] getting bitmap from drawable fix --- .../mapbox/mapboxsdk/utils/BitmapUtils.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java index 765ca431d..78503f9df 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/BitmapUtils.java @@ -54,13 +54,25 @@ public class BitmapUtils { /** * Extract an underlying bitmap from a drawable - * @param drawable The source drawable + * + * @param sourceDrawable The source drawable * @return The underlying bitmap */ - public static Bitmap getBitmapFromDrawable(Drawable drawable) { - if (drawable instanceof BitmapDrawable) { - return ((BitmapDrawable) drawable).getBitmap(); + public static Bitmap getBitmapFromDrawable(Drawable sourceDrawable) { + if (sourceDrawable == null) { + return null; + } + + if (sourceDrawable instanceof BitmapDrawable) { + return ((BitmapDrawable) sourceDrawable).getBitmap(); } else { + //copying drawable object to not manipulate on the same reference + Drawable.ConstantState constantState = sourceDrawable.getConstantState(); + if (constantState == null) { + return null; + } + Drawable drawable = constantState.newDrawable().mutate(); + Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); @@ -72,6 +84,7 @@ public class BitmapUtils { /** * Create a byte array out of drawable + * * @param drawable The source drawable * @return The byte array of source drawable */ @@ -79,7 +92,11 @@ public class BitmapUtils { if (drawable == null) { return null; } + Bitmap bitmap = getBitmapFromDrawable(drawable); + if (bitmap == null) { + return null; + } ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); return stream.toByteArray(); @@ -87,8 +104,9 @@ public class BitmapUtils { /** * Decode byte array to drawable object + * * @param context Context to obtain {@link android.content.res.Resources} - * @param array The source byte array + * @param array The source byte array * @return The drawable created from source byte array */ public static Drawable getDrawableFromByteArray(Context context, byte[] array) { From ed84dca3344b9d53cc60adb49eb92c8b7fd645fc Mon Sep 17 00:00:00 2001 From: tobrun Date: Tue, 2 Jan 2018 11:17:47 +0100 Subject: [PATCH 07/19] [android] - use US local when converting between int color and RGBA String. --- .../com/mapbox/mapboxsdk/style/layers/PropertyFactory.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java index d4ddbe48e..c43977aec 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java @@ -8,6 +8,8 @@ import android.support.annotation.ColorInt; import com.mapbox.mapboxsdk.style.functions.Function; import com.mapbox.mapboxsdk.style.functions.CameraFunction; +import java.util.Locale; + /** * Constructs paint/layout properties for Layers * @@ -2352,7 +2354,6 @@ public class PropertyFactory { } - /** * If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not. * @@ -2364,9 +2365,9 @@ public class PropertyFactory { return new LayoutPropertyValue<>("text-optional", function); } - @SuppressLint("DefaultLocale") public static String colorToRgbaString(@ColorInt int value) { - return String.format("rgba(%d, %d, %d, %d)", (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, (value >> 24) & 0xFF); + return String.format(Locale.US,"rgba(%d, %d, %d, %d)", + (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, (value >> 24) & 0xFF); } } From 1985bb83f40b1f4ef3433137fb5434956cd265ac Mon Sep 17 00:00:00 2001 From: tobrun Date: Tue, 2 Jan 2018 11:30:48 +0100 Subject: [PATCH 08/19] [android] - refactor surface destruction NPE fix --- .../com/mapbox/mapboxsdk/maps/MapView.java | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 77d2ac0e2..d03882b5c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -296,51 +296,43 @@ public class MapView extends FrameLayout { mapRenderer = new TextureViewMapRenderer(getContext(), textureView, options.getLocalIdeographFontFamily()) { @Override protected void onSurfaceCreated(GL10 gl, EGLConfig config) { - MapView.this.post(new Runnable() { - @Override - public void run() { - // Initialise only once - if (mapboxMap == null) { - initialiseMap(); - mapboxMap.onStart(); - } - } - }); - + initRenderSurface(); super.onSurfaceCreated(gl, config); } }; + addView(textureView, 0); } else { GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.surfaceView); glSurfaceView.setZOrderMediaOverlay(mapboxMapOptions.getRenderSurfaceOnTop()); - mapRenderer = new GLSurfaceViewMapRenderer(getContext(), glSurfaceView, options.getLocalIdeographFontFamily()) { @Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { - MapView.this.post(new Runnable() { - @Override - public void run() { - // Initialise only once - if (mapboxMap == null) { - initialiseMap(); - mapboxMap.onStart(); - } - } - }); - + initRenderSurface(); super.onSurfaceCreated(gl, config); } }; glSurfaceView.setVisibility(View.VISIBLE); - } nativeMapView = new NativeMapView(this, mapRenderer); nativeMapView.resizeView(getMeasuredWidth(), getMeasuredHeight()); } + private void initRenderSurface() { + post(new Runnable() { + @Override + public void run() { + // Initialise only when not destroyed and only once + if (!destroyed && mapboxMap == null) { + initialiseMap(); + mapboxMap.onStart(); + } + } + }); + } + /** * You must call this method from the parent's Activity#onSaveInstanceState(Bundle) * or Fragment#onSaveInstanceState(Bundle). From 8b1303a183d3b154048f4f8eb7a1190277b88ad8 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 4 Jan 2018 13:40:34 +0100 Subject: [PATCH 09/19] [android] - RTL support --- .../com/mapbox/mapboxsdk/maps/MapboxMapOptions.java | 4 ++-- .../java/com/mapbox/mapboxsdk/maps/UiSettings.java | 10 +++++++++- .../mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java index 34be95832..46dba28b9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java @@ -55,7 +55,7 @@ public class MapboxMapOptions implements Parcelable { @ColorInt private int attributionTintColor = UNDEFINED_COLOR; private boolean attributionEnabled = true; - private int attributionGravity = Gravity.BOTTOM; + private int attributionGravity = Gravity.BOTTOM | Gravity.START; private int[] attributionMargins; private double minZoom = MapboxConstants.MINIMUM_ZOOM; @@ -234,7 +234,7 @@ public class MapboxMapOptions implements Parcelable { mapboxMapOptions.attributionEnabled(typedArray.getBoolean( R.styleable.mapbox_MapView_mapbox_uiAttribution, true)); mapboxMapOptions.attributionGravity(typedArray.getInt( - R.styleable.mapbox_MapView_mapbox_uiAttributionGravity, Gravity.BOTTOM)); + R.styleable.mapbox_MapView_mapbox_uiAttributionGravity, Gravity.BOTTOM | Gravity.START)); mapboxMapOptions.attributionMargins(new int[] { (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginLeft, NINETY_TWO_DP * pxlRatio)), diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java index 084382855..4f37dd6f3 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java @@ -6,6 +6,7 @@ import android.content.res.Resources; import android.graphics.Color; import android.graphics.PointF; import android.graphics.drawable.Drawable; +import android.os.Build; import android.os.Bundle; import android.support.annotation.ColorInt; import android.support.annotation.NonNull; @@ -925,7 +926,7 @@ public final class UiSettings { initMargins[2] = right; initMargins[3] = bottom; - // convert inital margins with padding + // convert initial margins with padding int[] contentPadding = projection.getContentPadding(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams(); left += contentPadding[0]; @@ -933,6 +934,13 @@ public final class UiSettings { right += contentPadding[2]; bottom += contentPadding[3]; layoutParams.setMargins(left, top, right, bottom); + + // support RTL + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + layoutParams.setMarginStart(left); + layoutParams.setMarginEnd(right); + } + view.setLayoutParams(layoutParams); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java index 4f929641f..65bdff41a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java @@ -91,7 +91,7 @@ public class MapboxMapOptionsTest { @Test public void testAttributionGravity() { - assertEquals(Gravity.BOTTOM, new MapboxMapOptions().getAttributionGravity()); + assertEquals(Gravity.BOTTOM | Gravity.START, new MapboxMapOptions().getAttributionGravity()); assertEquals(Gravity.BOTTOM, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity()); assertNotEquals(Gravity.START, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity()); } From c66c8e3de19fde03df9dbea36a2a2ced9bc69f35 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 4 Jan 2018 14:15:12 +0100 Subject: [PATCH 10/19] [android] - include request urls when logging out failed http requests --- .../mapbox/mapboxsdk/http/HTTPRequest.java | 57 ++++++++++++------- .../mapboxsdk/http/HttpRequestUtil.java | 18 +++++- .../activity/camera/LatLngBoundsActivity.java | 3 + .../activity/maplayout/DebugModeActivity.java | 4 +- 4 files changed, 59 insertions(+), 23 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java index 846381479..945fb0ba4 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java @@ -30,10 +30,16 @@ import okhttp3.Response; import okhttp3.internal.Util; import timber.log.Timber; +import static android.util.Log.DEBUG; +import static android.util.Log.INFO; +import static android.util.Log.WARN; + class HTTPRequest implements Callback { private static OkHttpClient mClient = new OkHttpClient.Builder().dispatcher(getDispatcher()).build(); private static boolean logEnabled = true; + private static boolean logRequestUrl = false; + private String USER_AGENT_STRING = null; private static final int CONNECTION_ERROR = 0; @@ -97,7 +103,7 @@ class HTTPRequest implements Callback { mCall = mClient.newCall(mRequest); mCall.enqueue(this); } catch (Exception exception) { - onFailure(exception); + handleFailure(mCall, exception); } } @@ -134,7 +140,7 @@ class HTTPRequest implements Callback { try { body = response.body().bytes(); } catch (IOException ioException) { - onFailure(ioException); + onFailure(call, ioException); // throw ioException; return; } finally { @@ -157,29 +163,16 @@ class HTTPRequest implements Callback { @Override public void onFailure(Call call, IOException e) { - onFailure(e); + handleFailure(call, e); } - private void onFailure(Exception e) { - int type = PERMANENT_ERROR; - if ((e instanceof NoRouteToHostException) || (e instanceof UnknownHostException) || (e instanceof SocketException) - || (e instanceof ProtocolException) || (e instanceof SSLException)) { - type = CONNECTION_ERROR; - } else if ((e instanceof InterruptedIOException)) { - type = TEMPORARY_ERROR; - } - + private void handleFailure(Call call, Exception e) { String errorMessage = e.getMessage() != null ? e.getMessage() : "Error processing the request"; + int type = getFailureType(e); if (logEnabled) { - if (type == TEMPORARY_ERROR) { - Timber.d("Request failed due to a temporary error: %s", errorMessage); - } else if (type == CONNECTION_ERROR) { - Timber.i("Request failed due to a connection error: %s", errorMessage); - } else { - // PERMANENT_ERROR - Timber.w("Request failed due to a permanent error: %s", errorMessage); - } + String requestUrl = call.request().url().toString(); + logFailure(type, errorMessage, requestUrl); } mLock.lock(); @@ -189,6 +182,26 @@ class HTTPRequest implements Callback { mLock.unlock(); } + private int getFailureType(Exception e) { + if ((e instanceof NoRouteToHostException) || (e instanceof UnknownHostException) || (e instanceof SocketException) + || (e instanceof ProtocolException) || (e instanceof SSLException)) { + return CONNECTION_ERROR; + } else if ((e instanceof InterruptedIOException)) { + return TEMPORARY_ERROR; + } + return PERMANENT_ERROR; + } + + private void logFailure(int type, String errorMessage, String requestUrl) { + Timber.log( + type == TEMPORARY_ERROR ? DEBUG : type == CONNECTION_ERROR ? INFO : WARN, + "Request failed due to a %s error: %s %s", + type == TEMPORARY_ERROR ? "temporary" : type == CONNECTION_ERROR ? "connection" : "permanent", + errorMessage, + logRequestUrl ? requestUrl : "" + ); + } + private String getUserAgent() { if (USER_AGENT_STRING == null) { return USER_AGENT_STRING = Util.toHumanReadableAscii( @@ -217,4 +230,8 @@ class HTTPRequest implements Callback { static void enableLog(boolean enabled) { logEnabled = enabled; } + + static void enablePrintRequestUrlOnFailure(boolean enabled) { + logRequestUrl = enabled; + } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java index af39faede..5afe3b657 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java @@ -6,7 +6,7 @@ package com.mapbox.mapboxsdk.http; public class HttpRequestUtil { /** - * Set the log state of HttpRequest. + * Set the log state of HttpRequest. Default value is true. *

* This configuration will outlast the lifecycle of the Map. *

@@ -16,4 +16,20 @@ public class HttpRequestUtil { public static void setLogEnabled(boolean enabled) { HTTPRequest.enableLog(enabled); } + + /** + * Enable printing of the request url when an error occurred. Default value is false. + *

+ * Requires {@link #setLogEnabled(boolean)} to be activated. + *

+ *

+ * This configuration will outlast the lifecycle of the Map. + *

+ * + * @param enabled True will print urls, false will disable + */ + public static void setPrintRequestUrlOnFaillure(boolean enabled) { + HTTPRequest.enablePrintRequestUrlOnFailure(enabled); + } + } \ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java index e3a9551b8..a0a8de69a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java @@ -10,6 +10,7 @@ import com.mapbox.mapboxsdk.annotations.MarkerOptions; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; +import com.mapbox.mapboxsdk.http.HttpRequestUtil; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; @@ -52,6 +53,7 @@ public class LatLngBoundsActivity extends AppCompatActivity implements View.OnCl @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + HttpRequestUtil.setLogEnabled(false); setContentView(R.layout.activity_latlngbounds); mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); @@ -153,6 +155,7 @@ public class LatLngBoundsActivity extends AppCompatActivity implements View.OnCl protected void onDestroy() { super.onDestroy(); mapView.onDestroy(); + HttpRequestUtil.setLogEnabled(true); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java index 9220a30c3..3fb91f90e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java @@ -57,7 +57,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - HttpRequestUtil.setLogEnabled(false); + HttpRequestUtil.setPrintRequestUrlOnFaillure(true); setContentView(R.layout.activity_debug_mode); setupToolbar(); setupMapView(savedInstanceState); @@ -231,7 +231,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa protected void onDestroy() { super.onDestroy(); mapView.onDestroy(); - HttpRequestUtil.setLogEnabled(true); + HttpRequestUtil.setPrintRequestUrlOnFaillure(false); } @Override From 0b0f481e7079784e4877e3a279db346031d1bd08 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Fri, 5 Jan 2018 13:47:13 +0100 Subject: [PATCH 11/19] [android] - detect genymotion virtual machines when determening attributes for eglConfig --- .../maps/renderer/egl/EGLConfigChooser.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java index b6f467708..247ffea90 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.maps.renderer.egl; import android.opengl.GLSurfaceView; +import android.os.Build; import android.support.annotation.NonNull; import java.util.ArrayList; @@ -261,9 +262,8 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser { return attributevalue[0]; } - private int[] getConfigAttributes() { - boolean emulator = inEmulator(); + boolean emulator = inEmulator() || inGenymotion(); Timber.i("In emulator: %s", emulator); // Get all configs at least RGB 565 with 16 depth and 8 stencil @@ -290,4 +290,12 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser { private boolean inEmulator() { return System.getProperty("ro.kernel.qemu") != null; } + + /** + * Detect if we are in genymotion + */ + private boolean inGenymotion() { + return Build.MANUFACTURER.contains("Genymotion"); + } + } From 40316ddad03673c61333b79a52de340af89f1d92 Mon Sep 17 00:00:00 2001 From: tobrun Date: Tue, 9 Jan 2018 16:50:46 +0100 Subject: [PATCH 12/19] [android] - use the correct cancelable callback after posting the cancelation --- .../com/mapbox/mapboxsdk/maps/MapboxMap.java | 15 ------------ .../com/mapbox/mapboxsdk/maps/Transform.java | 23 +++++++++++++------ .../camera/CameraPositionActivity.java | 2 -- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 4da2f63ee..ba116e127 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -6,7 +6,6 @@ import android.graphics.PointF; import android.graphics.RectF; import android.location.Location; import android.os.Bundle; -import android.os.Handler; import android.support.annotation.FloatRange; import android.support.annotation.IntRange; import android.support.annotation.NonNull; @@ -713,20 +712,6 @@ public final class MapboxMap { */ public final void moveCamera(final CameraUpdate update, final MapboxMap.CancelableCallback callback) { transform.moveCamera(MapboxMap.this, update, callback); - // MapChange.REGION_DID_CHANGE_ANIMATED is not called for `jumpTo` - // invalidate camera position to provide OnCameraChange event. - invalidateCameraPosition(); - - if (callback != null) { - new Handler().post(new Runnable() { - @Override - public void run() { - if (callback != null) { - callback.onFinish(); - } - } - }); - } } /** diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java index 0d3f0d5e5..b0cc92c62 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java @@ -32,6 +32,7 @@ final class Transform implements MapView.OnMapChangedListener { private final MarkerViewManager markerViewManager; private final TrackingSettings trackingSettings; private final MyLocationView myLocationView; + private final Handler handler = new Handler(); private CameraPosition cameraPosition; private MapboxMap.CancelableCallback cameraCancelableCallback; @@ -83,7 +84,7 @@ final class Transform implements MapView.OnMapChangedListener { if (change == REGION_DID_CHANGE_ANIMATED) { updateCameraPosition(invalidateCameraPosition()); if (cameraCancelableCallback != null) { - new Handler().post(new Runnable() { + handler.post(new Runnable() { @Override public void run() { if (cameraCancelableCallback != null) { @@ -99,7 +100,7 @@ final class Transform implements MapView.OnMapChangedListener { } @UiThread - final void moveCamera(MapboxMap mapboxMap, CameraUpdate update, MapboxMap.CancelableCallback callback) { + final void moveCamera(MapboxMap mapboxMap, CameraUpdate update, final MapboxMap.CancelableCallback callback) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); if (isValidCameraPosition(cameraPosition)) { trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false); @@ -107,6 +108,15 @@ final class Transform implements MapView.OnMapChangedListener { cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION); mapView.jumpTo(cameraPosition.bearing, cameraPosition.target, cameraPosition.tilt, cameraPosition.zoom); cameraChangeDispatcher.onCameraIdle(); + invalidateCameraPosition(); + handler.post(new Runnable() { + @Override + public void run() { + if (callback != null) { + callback.onFinish(); + } + } + }); } } @@ -182,16 +192,15 @@ final class Transform implements MapView.OnMapChangedListener { // notify animateCamera and easeCamera about cancelling if (cameraCancelableCallback != null) { + final MapboxMap.CancelableCallback callback = cameraCancelableCallback; cameraChangeDispatcher.onCameraIdle(); - new Handler().post(new Runnable() { + handler.post(new Runnable() { @Override public void run() { - if (cameraCancelableCallback != null) { - cameraCancelableCallback.onCancel(); - cameraCancelableCallback = null; - } + callback.onCancel(); } }); + cameraCancelableCallback = null; } // cancel ongoing transitions diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java index e5c6a3f58..e01c7a10c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java @@ -13,7 +13,6 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.SeekBar; import android.widget.TextView; - import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -21,7 +20,6 @@ import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; - import timber.log.Timber; /** From 24bcb758232c189c2a98c5c44f963e579fa0743c Mon Sep 17 00:00:00 2001 From: Tobrun Date: Wed, 10 Jan 2018 11:21:08 +0100 Subject: [PATCH 13/19] [android] - update changelog for 5.3.1 release --- platform/android/CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index c22072e1a..a45971ede 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -2,6 +2,17 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started. +## 5.3.1 - January 10, 2018 + - Blacklist binary program loading for Vivante GC4000 GPUs [#10862](https://github.com/mapbox/mapbox-gl-native/pull/10862) + - Support Genymotion [#10841](https://github.com/mapbox/mapbox-gl-native/pull/10841) + - Getting bitmap from drawable fix [#10763](https://github.com/mapbox/mapbox-gl-native/pull/10763) + - Use US locale when converting between int color and RGBA string [#10810](https://github.com/mapbox/mapbox-gl-native/pull/10810) + - Harden map destruction [#10811](https://github.com/mapbox/mapbox-gl-native/pull/10811) + - RTL support [#10828](https://github.com/mapbox/mapbox-gl-native/pull/10828) + - Allow configuring Http url logging when a request fails [#10830](https://github.com/mapbox/mapbox-gl-native/pull/10830) + - Don't send double tap event multiple times for telemetry [#10854](https://github.com/mapbox/mapbox-gl-native/pull/10854) + - Use the correct cancelable callback after posting cancel [#10871](https://github.com/mapbox/mapbox-gl-native/pull/10871) + ## 5.3.0 - December 20, 2017 - Add support for TinySDF [#10706](https://github.com/mapbox/mapbox-gl-native/pull/10706) - Save restore MyLocationViewSettings [#10746](https://github.com/mapbox/mapbox-gl-native/pull/10746) From a3c497f100b488802aba7c04b2096e0617271cdf Mon Sep 17 00:00:00 2001 From: Tobrun Date: Wed, 10 Jan 2018 13:17:34 +0100 Subject: [PATCH 14/19] [android] - bump snapshot version to 5.3.2 --- platform/android/MapboxGLAndroidSDK/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index f1257f346..b4faba88c 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.mapbox.mapboxsdk -VERSION_NAME=5.3.0-SNAPSHOT +VERSION_NAME=5.3.2-SNAPSHOT POM_DESCRIPTION=Mapbox GL Android SDK POM_URL=https://github.com/mapbox/mapbox-gl-native From 0542ece0bf2456db3ca7f0140bb6ac43c4697a97 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Soto Date: Wed, 10 Jan 2018 14:28:55 -0600 Subject: [PATCH 15/19] [ios] Fix the layout constraints on iOS 11 for iPhone X (#10858) * [ios] Fix the layout constraints on iOS 11 for iPhone X for the bottom ornaments. * WIP adding tests for layout of map view attribution logo and other ornaments * Rename * First pass at tests for mapview ornament layout * Additional code changes from call with Fabian and Jason * [ios] Fix ornaments insets margin space. * [ios] Fix map view layout test for pre iOS 11. * [ios] Refactor MGLMapView ornaments layout constraints for iOS 11. * [ios] Remove NSLogs from MGLMapViewLayoutTests --- platform/ios/ios.xcodeproj/project.pbxproj | 4 + platform/ios/src/MGLMapView.mm | 56 +++++------ platform/ios/test/MGLMapViewLayoutTests.m | 108 +++++++++++++++++++++ 3 files changed, 136 insertions(+), 32 deletions(-) create mode 100644 platform/ios/test/MGLMapViewLayoutTests.m diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index c405e92d3..52f33a83b 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 071BBB031EE76146001FB02A /* MGLImageSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 071BBAFC1EE75CD4001FB02A /* MGLImageSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; 071BBB041EE76147001FB02A /* MGLImageSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 071BBAFC1EE75CD4001FB02A /* MGLImageSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; 071BBB071EE77631001FB02A /* MGLImageSourceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 071BBB051EE7761A001FB02A /* MGLImageSourceTests.m */; }; + 16376B491FFEED010000563E /* MGLMapViewLayoutTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 16376B481FFEED010000563E /* MGLMapViewLayoutTests.m */; }; 1753ED421E53CE6F00A9FD90 /* MGLConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 1753ED411E53CE6F00A9FD90 /* MGLConversion.h */; }; 1753ED431E53CE6F00A9FD90 /* MGLConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 1753ED411E53CE6F00A9FD90 /* MGLConversion.h */; }; 1F06668A1EC64F8E001C16D7 /* MGLLight.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F0666881EC64F8E001C16D7 /* MGLLight.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -580,6 +581,7 @@ 071BBAFC1EE75CD4001FB02A /* MGLImageSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLImageSource.h; sourceTree = ""; }; 071BBAFD1EE75CD4001FB02A /* MGLImageSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLImageSource.mm; sourceTree = ""; }; 071BBB051EE7761A001FB02A /* MGLImageSourceTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLImageSourceTests.m; path = ../../darwin/test/MGLImageSourceTests.m; sourceTree = ""; }; + 16376B481FFEED010000563E /* MGLMapViewLayoutTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapViewLayoutTests.m; sourceTree = ""; }; 1753ED411E53CE6F00A9FD90 /* MGLConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLConversion.h; sourceTree = ""; }; 1F0666881EC64F8E001C16D7 /* MGLLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLLight.h; sourceTree = ""; }; 1F0666891EC64F8E001C16D7 /* MGLLight.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLLight.mm; sourceTree = ""; }; @@ -1365,6 +1367,7 @@ DA0CD58F1CF56F6A00A5F5A5 /* MGLFeatureTests.mm */, DA2E885C1CC0382C00F24E7B /* MGLGeometryTests.mm */, DA5DB1291FABF1EE001C2326 /* MGLMapAccessibilityElementTests.m */, + 16376B481FFEED010000563E /* MGLMapViewLayoutTests.m */, 35E208A61D24210F00EC9A46 /* MGLNSDataAdditionsTests.m */, 1F95931C1E6DE2E900D5B294 /* MGLNSDateAdditionsTests.mm */, DAE7DEC11E245455007505A6 /* MGLNSStringAdditionsTests.m */, @@ -2311,6 +2314,7 @@ DA0CD5901CF56F6A00A5F5A5 /* MGLFeatureTests.mm in Sources */, 556660D81E1D085500E2C41B /* MGLVersionNumber.m in Sources */, 4031ACFF1E9FD29F00A3EA26 /* MGLSDKTestHelpers.swift in Sources */, + 16376B491FFEED010000563E /* MGLMapViewLayoutTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index c02446609..0849cbd12 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -753,7 +753,7 @@ public: toItem:viewController.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0 - constant:5.0]]; + constant:8.0]]; } [self.compassViewConstraints addObject: [NSLayoutConstraint constraintWithItem:self.compassView @@ -762,7 +762,7 @@ public: toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 - constant:5.0 + self.contentInset.top]]; + constant:8.0 + self.contentInset.top]]; [self.compassViewConstraints addObject: [NSLayoutConstraint constraintWithItem:self @@ -771,7 +771,7 @@ public: toItem:self.compassView attribute:NSLayoutAttributeTrailing multiplier:1.0 - constant:5.0 + self.contentInset.right]]; + constant:8.0 + self.contentInset.right]]; [containerView addConstraints:self.compassViewConstraints]; @@ -788,7 +788,7 @@ public: toItem:viewController.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0 - constant:5.0]]; + constant:8.0]]; } [self.scaleBarConstraints addObject: [NSLayoutConstraint constraintWithItem:self.scaleBar @@ -797,7 +797,7 @@ public: toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 - constant:5.0 + self.contentInset.top]]; + constant:8.0 + self.contentInset.top]]; [self.scaleBarConstraints addObject: [NSLayoutConstraint constraintWithItem:self.scaleBar attribute:NSLayoutAttributeLeft @@ -831,7 +831,7 @@ public: toItem:self.logoView attribute:NSLayoutAttributeBaseline multiplier:1 - constant:8 + self.contentInset.bottom]]; + constant:8.0 + self.contentInset.bottom]]; [self.logoViewConstraints addObject: [NSLayoutConstraint constraintWithItem:self.logoView attribute:NSLayoutAttributeLeading @@ -855,7 +855,7 @@ public: toItem:self.attributionButton attribute:NSLayoutAttributeBaseline multiplier:1 - constant:8 + self.contentInset.bottom]]; + constant:8.0 + self.contentInset.bottom]]; } [self.attributionButtonConstraints addObject: [NSLayoutConstraint constraintWithItem:self @@ -864,7 +864,7 @@ public: toItem:self.attributionButton attribute:NSLayoutAttributeBaseline multiplier:1 - constant:8 + self.contentInset.bottom]]; + constant:8.0 + self.contentInset.bottom]]; [self.attributionButtonConstraints addObject: [NSLayoutConstraint constraintWithItem:self @@ -873,29 +873,20 @@ public: toItem:self.attributionButton attribute:NSLayoutAttributeTrailing multiplier:1 - constant:8 + self.contentInset.right]]; + constant:8.0 + self.contentInset.right]]; [containerView addConstraints:self.attributionButtonConstraints]; } - (void)updateConstraints { - -// If compiling with the iOS 11+ SDK -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 // If safeAreaLayoutGuide API exists - if ( [self respondsToSelector:@selector(safeAreaLayoutGuide)] ) { - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpartial-availability" + if (@available(iOS 11.0, *)) { UILayoutGuide *safeAreaLayoutGuide = self.safeAreaLayoutGuide; -#pragma clang diagnostic pop + // compass view [self removeConstraints:self.compassViewConstraints]; [self.compassViewConstraints removeAllObjects]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpartial-availability" - [self.compassViewConstraints addObject:[self.compassView.topAnchor constraintEqualToSystemSpacingBelowAnchor:safeAreaLayoutGuide.topAnchor multiplier:1]]; -#pragma clang diagnostic pop + [self.compassViewConstraints addObject:[self constraintForYAxisAnchor:self.compassView.topAnchor belowAnchor:safeAreaLayoutGuide.topAnchor]]; [self.compassViewConstraints addObject:[safeAreaLayoutGuide.rightAnchor constraintEqualToAnchor:self.compassView.rightAnchor constant:8.0 + self.contentInset.right]]; [self addConstraints:self.compassViewConstraints]; @@ -903,10 +894,7 @@ public: // scale bar view [self removeConstraints:self.scaleBarConstraints]; [self.scaleBarConstraints removeAllObjects]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpartial-availability" - [self.scaleBarConstraints addObject:[self.scaleBar.topAnchor constraintEqualToSystemSpacingBelowAnchor:safeAreaLayoutGuide.topAnchor multiplier:1]]; -#pragma clang diagnostic pop + [self.scaleBarConstraints addObject:[self constraintForYAxisAnchor:self.scaleBar.topAnchor belowAnchor:safeAreaLayoutGuide.topAnchor]]; [self.scaleBarConstraints addObject:[self.scaleBar.leftAnchor constraintEqualToAnchor:safeAreaLayoutGuide.leftAnchor constant:8.0 + self.contentInset.left]]; [self addConstraints:self.scaleBarConstraints]; @@ -914,8 +902,7 @@ public: // logo view [self removeConstraints:self.logoViewConstraints]; [self.logoViewConstraints removeAllObjects]; - [self.logoViewConstraints addObject:[safeAreaLayoutGuide.bottomAnchor constraintEqualToAnchor:self.logoView.bottomAnchor - constant:8.0 + self.contentInset.bottom]]; + [self.logoViewConstraints addObject:[self constraintForYAxisAnchor:safeAreaLayoutGuide.bottomAnchor belowAnchor:self.logoView.bottomAnchor]]; [self.logoViewConstraints addObject:[self.logoView.leftAnchor constraintEqualToAnchor:safeAreaLayoutGuide.leftAnchor constant:8.0 + self.contentInset.left]]; [self addConstraints:self.logoViewConstraints]; @@ -923,21 +910,26 @@ public: // attribution button [self removeConstraints:self.attributionButtonConstraints]; [self.attributionButtonConstraints removeAllObjects]; - [self.attributionButtonConstraints addObject:[safeAreaLayoutGuide.bottomAnchor constraintEqualToAnchor:self.attributionButton.bottomAnchor - constant:8.0 + self.contentInset.bottom]]; + [self.attributionButtonConstraints addObject:[self constraintForYAxisAnchor:safeAreaLayoutGuide.bottomAnchor belowAnchor:self.attributionButton.bottomAnchor]]; [self.attributionButtonConstraints addObject:[safeAreaLayoutGuide.rightAnchor constraintEqualToAnchor:self.attributionButton.rightAnchor constant:8.0 + self.contentInset.right]]; [self addConstraints:self.attributionButtonConstraints]; } else { [self updateConstraintsPreiOS11]; } -#else - [self updateConstraintsPreiOS11]; -#endif [super updateConstraints]; } +- (NSLayoutConstraint *)constraintForYAxisAnchor:(NSLayoutYAxisAnchor *)yAxisAnchor belowAnchor:(NSLayoutYAxisAnchor *)anchor +{ + if (@available(iOS 11.0, *)) { + return [yAxisAnchor constraintEqualToSystemSpacingBelowAnchor:anchor multiplier:1]; + } else { + return nil; + } +} + - (BOOL)isOpaque { return _opaque; diff --git a/platform/ios/test/MGLMapViewLayoutTests.m b/platform/ios/test/MGLMapViewLayoutTests.m new file mode 100644 index 000000000..a41e7695f --- /dev/null +++ b/platform/ios/test/MGLMapViewLayoutTests.m @@ -0,0 +1,108 @@ +#import +#import "MGLMapView.h" +#import "MGLMapViewDelegate.h" +#import "MGLAccountManager.h" + + +@interface MGLMapViewLayoutTests : XCTestCase + +@property (nonatomic) UIView *superView; +@property (nonatomic) MGLMapView *mapView; +@property (nonatomic) XCTestExpectation *styleLoadingExpectation; + +@end + +@implementation MGLMapViewLayoutTests + +- (void)setUp { + [super setUp]; + + [MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"]; + NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"]; + + self.superView = [[UIView alloc] initWithFrame:UIScreen.mainScreen.bounds]; + + self.mapView = [[MGLMapView alloc] initWithFrame:UIScreen.mainScreen.bounds styleURL:styleURL]; + self.mapView.delegate = self; + + [self.superView addSubview:self.mapView]; + + UIView *mapView = self.mapView; + NSDictionary *bindings = NSDictionaryOfVariableBindings(mapView); + NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[mapView]-0-|" options:0 metrics:nil views:bindings]; + NSArray *horizonatalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[mapView]-0-|" options:0 metrics:nil views:bindings]; + + [self.superView addConstraints:[verticalConstraints arrayByAddingObjectsFromArray:horizonatalConstraints]]; + + self.styleLoadingExpectation = [self expectationWithDescription:@"Map view should finish loading style."]; + [self waitForExpectationsWithTimeout:1 handler:nil]; + + //set zoom and heading so that scale bar and compass will be shown + [self.mapView setZoomLevel:4.5 animated:NO]; + [self.mapView.camera setHeading:12.0]; + + //invoke layout + [self.superView setNeedsLayout]; + [self.superView layoutIfNeeded]; + +} + +- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style { + XCTAssertNotNil(mapView.style); + XCTAssertEqual(mapView.style, style); + + [self.styleLoadingExpectation fulfill]; +} + +- (void)tearDown { + self.styleLoadingExpectation = nil; + self.mapView = nil; + + [super tearDown]; +} + +- (void)testOrnamentPlacement { + + CGFloat margin = 8.0; + CGFloat bottomSafeAreaInset = 0.0; + double accuracy = 0.01; + + if ( [self.mapView respondsToSelector:@selector(safeAreaInsets)] ) { + bottomSafeAreaInset = self.mapView.safeAreaInsets.bottom; + } + + //compass + UIImageView *compassView = self.mapView.compassView; + + CGFloat expectedCompassOriginX = CGRectGetMaxX(self.mapView.bounds) - margin - CGRectGetWidth(compassView.frame); + CGFloat expectedCompassOriginY = margin; + + XCTAssertEqualWithAccuracy(CGRectGetMinX(compassView.frame), expectedCompassOriginX, accuracy); + XCTAssertEqualWithAccuracy(CGRectGetMinY(compassView.frame), expectedCompassOriginY, accuracy); + + //scale bar + UIView *scaleBar = self.mapView.scaleBar; + + XCTAssertEqualWithAccuracy(CGRectGetMinX(scaleBar.frame), margin, accuracy); + XCTAssertEqualWithAccuracy(CGRectGetMinY(scaleBar.frame), margin, accuracy); + + //attribution button + UIButton *attributionButton = self.mapView.attributionButton; + + CGFloat expectedButtonOriginX = CGRectGetMaxX(self.mapView.bounds) - margin - CGRectGetWidth(attributionButton.frame); + CGFloat expectedButtonOriginY = CGRectGetMaxY(self.mapView.bounds) - margin - bottomSafeAreaInset - CGRectGetHeight(attributionButton.frame); + + XCTAssertEqualWithAccuracy(CGRectGetMinX(attributionButton.frame), expectedButtonOriginX, accuracy); + XCTAssertEqualWithAccuracy(CGRectGetMinY(attributionButton.frame), expectedButtonOriginY, accuracy); + + //mapbox logo + UIImageView *logoView = self.mapView.logoView; + + CGFloat expectedLogoOriginX = margin; + CGFloat expectedLogoOriginY = CGRectGetMaxY(self.mapView.bounds) - margin - bottomSafeAreaInset - CGRectGetHeight(logoView.frame); + + XCTAssertEqualWithAccuracy(CGRectGetMinX(logoView.frame), expectedLogoOriginX, accuracy); + XCTAssertEqualWithAccuracy(CGRectGetMinY(logoView.frame), expectedLogoOriginY, accuracy); +} + +@end From 9e96aa192321b778f6e4f83ff73d363e0259c248 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Wed, 10 Jan 2018 15:05:23 -0600 Subject: [PATCH 16/19] [ios] Bump podspec to v3.7.3 --- platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec | 2 +- platform/ios/Mapbox-iOS-SDK-symbols.podspec | 2 +- platform/ios/Mapbox-iOS-SDK.podspec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec b/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec index 5a1f1ebb7..fb9511e70 100644 --- a/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec +++ b/platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '3.7.2' + version = '3.7.3' m.name = 'Mapbox-iOS-SDK-nightly-dynamic' m.version = "#{version}-nightly" diff --git a/platform/ios/Mapbox-iOS-SDK-symbols.podspec b/platform/ios/Mapbox-iOS-SDK-symbols.podspec index 00b943733..ea8ae667f 100644 --- a/platform/ios/Mapbox-iOS-SDK-symbols.podspec +++ b/platform/ios/Mapbox-iOS-SDK-symbols.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '3.7.2' + version = '3.7.3' m.name = 'Mapbox-iOS-SDK-symbols' m.version = "#{version}-symbols" diff --git a/platform/ios/Mapbox-iOS-SDK.podspec b/platform/ios/Mapbox-iOS-SDK.podspec index 2f2a19300..1e81272d6 100644 --- a/platform/ios/Mapbox-iOS-SDK.podspec +++ b/platform/ios/Mapbox-iOS-SDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '3.7.2' + version = '3.7.3' m.name = 'Mapbox-iOS-SDK' m.version = version From 3c99bfdd1d610875daaa3aae884e86a9fc606443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 10 Jan 2018 13:35:19 -0800 Subject: [PATCH 17/19] [core] update vector-tile dependency to 1.0.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f8825275..4badb29f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ mason_use(polylabel VERSION 1.0.3 HEADER_ONLY) mason_use(wagyu VERSION 0.4.3 HEADER_ONLY) mason_use(shelf-pack VERSION 2.1.1 HEADER_ONLY) mason_use(cheap-ruler VERSION 2.5.3 HEADER_ONLY) -mason_use(vector-tile VERSION 1.0.0-rc7 HEADER_ONLY) +mason_use(vector-tile VERSION 1.0.1 HEADER_ONLY) add_definitions(-DRAPIDJSON_HAS_STDSTRING=1) From 3629a3cd7439bc59ecf7d6ad98146deafb8ca143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 16 Jan 2018 09:24:18 -0800 Subject: [PATCH 18/19] [macos] Added dates to changelog --- platform/macos/CHANGELOG.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 1b954f9e4..7a2c47ced 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -1,11 +1,15 @@ # Changelog for Mapbox Maps SDK for macOS -## v0.6.1 +## v0.6.1 - January 16, 2018 + +This version of the Mapbox macOS SDK corresponds to version 3.7.3 of the Mapbox Maps SDK for iOS. * Fixed a crash while zooming while annotations are present on the map. ([#10791](https://github.com/mapbox/mapbox-gl-native/pull/10791)) * CJK characters can be displayed in a locally installed font or a custom font bundled with the application, reducing map download times. Specify the font name using the `MGLIdeographicFontFamilyName` key in the application’s Info.plist file. ([#10522](https://github.com/mapbox/mapbox-gl-native/pull/10522)) -## v0.6.0 +## v0.6.0 - December 23, 2017 + +This version of the Mapbox macOS SDK corresponds to version 3.7.2 of the Mapbox Maps SDK for iOS. ### Packaging @@ -50,7 +54,7 @@ * Added documentation for usage of coordinate bounds that cross the anti-meridian. ([#10783](https://github.com/mapbox/mapbox-gl-native/pull/10783)) * Removed duplicated variables in `MGLMapSnapshotter`. ([#10702](https://github.com/mapbox/mapbox-gl-native/pull/10702)) -## 0.5.1 +## 0.5.1 - September 26, 2017 This version of the Mapbox macOS SDK corresponds to version 3.6.4 of the Mapbox iOS SDK. @@ -61,7 +65,7 @@ This version of the Mapbox macOS SDK corresponds to version 3.6.4 of the Mapbox * Deprecated `+[MGLStyle trafficDayStyleURL]` and `+[MGLStyle trafficNightStyleURL]` with no replacement method. To use the Traffic Day and Traffic Night styles going forward, we recommend that you use the underlying URL. ([#9918](https://github.com/mapbox/mapbox-gl-native/pull/9918)) * Fixed an issue where stale (but still valid) map data could be ignored in offline mode. ([#10012](https://github.com/mapbox/mapbox-gl-native/pull/10012)) -## 0.5.0 +## 0.5.0 - June 30, 2017 This version of the Mapbox macOS SDK corresponds to version 3.6.0 of the Mapbox iOS SDK. From 2411fb31b70fde6a076886390abdaedde86ea2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 16 Jan 2018 09:20:09 -0800 Subject: [PATCH 19/19] macos-v0.6.1 --- platform/macos/Mapbox-macOS-SDK-symbols.podspec | 2 +- platform/macos/Mapbox-macOS-SDK.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/macos/Mapbox-macOS-SDK-symbols.podspec b/platform/macos/Mapbox-macOS-SDK-symbols.podspec index ba09fce19..f8b5397a7 100644 --- a/platform/macos/Mapbox-macOS-SDK-symbols.podspec +++ b/platform/macos/Mapbox-macOS-SDK-symbols.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '0.6.0' + version = '0.6.1' m.name = 'Mapbox-macOS-SDK-symbols' m.version = "#{version}-symbols" diff --git a/platform/macos/Mapbox-macOS-SDK.podspec b/platform/macos/Mapbox-macOS-SDK.podspec index 6a0e7bbf2..641219006 100644 --- a/platform/macos/Mapbox-macOS-SDK.podspec +++ b/platform/macos/Mapbox-macOS-SDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '0.6.0' + version = '0.6.1' m.name = 'Mapbox-macOS-SDK' m.version = version