From e5a1abf88e51679b47d553979ade0f0ba68186da Mon Sep 17 00:00:00 2001 From: m-stephen Date: Thu, 5 Sep 2019 02:29:05 +0800 Subject: [PATCH 1/3] [ios] Fix compass font weight being too light on iOS 13 --- platform/ios/CHANGELOG.md | 5 ++--- platform/ios/src/MGLCompassButton.mm | 9 ++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 98dc2111b0d..d4083a7ea6b 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,10 +2,9 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. -## master +## 5.3.1 -* Fixed an issue that caused the tilt gesture to trigger too easily and conflict with pinch or pan gestures. ([#15349](https://github.com/mapbox/mapbox-gl-native/pull/15349)) -* Fixed a bug with annotation view positions after camera transitions. ([#15122](https://github.com/mapbox/mapbox-gl-native/pull/15122/)) +* Fixed an issue with the appearance of the compass text in iOS 13. ([#15547](https://github.com/mapbox/mapbox-gl-native/pull/15547)) ## 5.3.0 - August 28, 2019 diff --git a/platform/ios/src/MGLCompassButton.mm b/platform/ios/src/MGLCompassButton.mm index 94a6820a744..acb25a560ce 100644 --- a/platform/ios/src/MGLCompassButton.mm +++ b/platform/ios/src/MGLCompassButton.mm @@ -63,9 +63,16 @@ - (UIImage *)compassImage { UIImage *scaleImage = [UIImage mgl_resourceImageNamed:@"Compass"]; UIGraphicsBeginImageContextWithOptions(scaleImage.size, NO, UIScreen.mainScreen.scale); [scaleImage drawInRect:{CGPointZero, scaleImage.size}]; + + UIFont *northFont; + if (@available(iOS 13.0, *)) { + northFont = [UIFont systemFontOfSize:11 weight:UIFontWeightLight]; + } else { + northFont = [UIFont systemFontOfSize:11 weight:UIFontWeightUltraLight]; + } NSAttributedString *north = [[NSAttributedString alloc] initWithString:NSLocalizedStringWithDefaultValue(@"COMPASS_NORTH", nil, nil, @"N", @"Compass abbreviation for north") attributes:@{ - NSFontAttributeName: [UIFont systemFontOfSize:11 weight:UIFontWeightUltraLight], + NSFontAttributeName: northFont, NSForegroundColorAttributeName: [UIColor whiteColor], }]; CGRect stringRect = CGRectMake((scaleImage.size.width - north.size.width) / 2, From 672b3cb744bb4eb063a0a7ec6914311607015418 Mon Sep 17 00:00:00 2001 From: Nadia Barbosa Date: Thu, 29 Aug 2019 11:22:24 -0700 Subject: [PATCH 2/3] [ios] Allow MGLScaleBar to support dark mode on iOS 13 Add changelog PR link --- platform/ios/CHANGELOG.md | 1 + platform/ios/src/MGLScaleBar.mm | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index d4083a7ea6b..bdaa7085fc4 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -4,6 +4,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ## 5.3.1 +* Fixed an issue where the scale bar text would become illegible if iOS 13 dark mode was enabled. ([#15524](https://github.com/mapbox/mapbox-gl-native/pull/15524)) * Fixed an issue with the appearance of the compass text in iOS 13. ([#15547](https://github.com/mapbox/mapbox-gl-native/pull/15547)) ## 5.3.0 - August 28, 2019 diff --git a/platform/ios/src/MGLScaleBar.mm b/platform/ios/src/MGLScaleBar.mm index 993852d8b9b..cd8bc1d0306 100644 --- a/platform/ios/src/MGLScaleBar.mm +++ b/platform/ios/src/MGLScaleBar.mm @@ -101,7 +101,6 @@ @implementation MGLScaleBarLabel - (void)drawTextInRect:(CGRect)rect { CGSize shadowOffset = self.shadowOffset; - UIColor *textColor = self.textColor; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2); @@ -112,7 +111,7 @@ - (void)drawTextInRect:(CGRect)rect { [super drawTextInRect:rect]; CGContextSetTextDrawingMode(context, kCGTextFill); - self.textColor = textColor; + self.textColor = [UIColor blackColor]; self.shadowOffset = CGSizeMake(0, 0); [super drawTextInRect:rect]; From ec0eabb528369c32d0c658636ff0497317017218 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Mon, 9 Sep 2019 17:25:42 -0700 Subject: [PATCH 3/3] [ios] Refactor way location permissions are requested --- platform/ios/src/MGLMapView.mm | 48 +++++++++++++++------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 51102233cf4..502c811fbba 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -5291,35 +5291,29 @@ - (void)validateLocationServices if (shouldEnableLocationServices) { - if (self.locationManager.authorizationStatus == kCLAuthorizationStatusNotDetermined) - { - BOOL requiresWhenInUseUsageDescription = [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){11,0,0}]; + if (self.locationManager.authorizationStatus == kCLAuthorizationStatusNotDetermined) { BOOL hasWhenInUseUsageDescription = !![[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]; - BOOL hasAlwaysUsageDescription; - if (requiresWhenInUseUsageDescription) - { - hasAlwaysUsageDescription = !![[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysAndWhenInUseUsageDescription"] && hasWhenInUseUsageDescription; - } - else - { - hasAlwaysUsageDescription = !![[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]; - } - if (hasAlwaysUsageDescription) - { - [self.locationManager requestAlwaysAuthorization]; - } - else if (hasWhenInUseUsageDescription) - { - [self.locationManager requestWhenInUseAuthorization]; - } - else - { - NSString *suggestedUsageKeys = requiresWhenInUseUsageDescription ? - @"NSLocationWhenInUseUsageDescription and (optionally) NSLocationAlwaysAndWhenInUseUsageDescription" : - @"NSLocationWhenInUseUsageDescription and/or NSLocationAlwaysUsageDescription"; - [NSException raise:MGLMissingLocationServicesUsageDescriptionException - format:@"This app must have a value for %@ in its Info.plist.", suggestedUsageKeys]; + if (@available(iOS 11.0, *)) { + // A WhenInUse string is required in iOS 11+ and the map never has any need for Always, so it's enough to just ask for WhenInUse. + if (hasWhenInUseUsageDescription) { + [self.locationManager requestWhenInUseAuthorization]; + } else { + [NSException raise:MGLMissingLocationServicesUsageDescriptionException + format:@"To use location services this app must have a NSLocationWhenInUseUsageDescription string in its Info.plist."]; + } + } else { + // We might have to ask for Always if the app does not provide a WhenInUse string. + BOOL hasAlwaysUsageDescription = !![[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]; + + if (hasWhenInUseUsageDescription) { + [self.locationManager requestWhenInUseAuthorization]; + } else if (hasAlwaysUsageDescription) { + [self.locationManager requestAlwaysAuthorization]; + } else { + [NSException raise:MGLMissingLocationServicesUsageDescriptionException + format:@"To use location services this app must have a NSLocationWhenInUseUsageDescription and/or NSLocationAlwaysUsageDescription string in its Info.plist."]; + } } }