summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <friedbunny@users.noreply.github.com>2019-09-16 09:19:51 -0700
committerJulian Rex <julian.rex@mapbox.com>2019-09-16 12:19:51 -0400
commitcb8b3c454e678cdfa349eb3957b16cfbaf538dab (patch)
treea227b84cf8f38f6a7278955851d2d5724366afc3
parent2afda968c77d776671db86183c3f6ea3a55ffcb3 (diff)
downloadqtlocation-mapboxgl-cb8b3c454e678cdfa349eb3957b16cfbaf538dab.tar.gz
[ios] iOS 13 cherry-picks for ios-v5.3.1 (queso) (#15612)
* [ios] Fix compass font weight being too light on iOS 13 * [ios] Allow MGLScaleBar to support dark mode on iOS 13 Add changelog PR link * [ios] Refactor way location permissions are requested
-rw-r--r--platform/ios/CHANGELOG.md6
-rw-r--r--platform/ios/src/MGLCompassButton.mm9
-rw-r--r--platform/ios/src/MGLMapView.mm48
-rw-r--r--platform/ios/src/MGLScaleBar.mm3
4 files changed, 33 insertions, 33 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index 98dc2111b0..bdaa7085fc 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -2,10 +2,10 @@
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 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/MGLCompassButton.mm b/platform/ios/src/MGLCompassButton.mm
index 94a6820a74..acb25a560c 100644
--- a/platform/ios/src/MGLCompassButton.mm
+++ b/platform/ios/src/MGLCompassButton.mm
@@ -63,9 +63,16 @@
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,
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 51102233cf..502c811fbb 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -5291,35 +5291,29 @@ public:
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."];
+ }
}
}
diff --git a/platform/ios/src/MGLScaleBar.mm b/platform/ios/src/MGLScaleBar.mm
index 993852d8b9..cd8bc1d030 100644
--- a/platform/ios/src/MGLScaleBar.mm
+++ b/platform/ios/src/MGLScaleBar.mm
@@ -101,7 +101,6 @@ static const CGFloat MGLFeetPerMeter = 3.28084;
- (void)drawTextInRect:(CGRect)rect {
CGSize shadowOffset = self.shadowOffset;
- UIColor *textColor = self.textColor;
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2);
@@ -112,7 +111,7 @@ static const CGFloat MGLFeetPerMeter = 3.28084;
[super drawTextInRect:rect];
CGContextSetTextDrawingMode(context, kCGTextFill);
- self.textColor = textColor;
+ self.textColor = [UIColor blackColor];
self.shadowOffset = CGSizeMake(0, 0);
[super drawTextInRect:rect];