From 17ded82d87ae46e788378e746acf4603c3647d12 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 6 Apr 2015 17:36:54 -0500 Subject: [PATCH 1/4] #1215 - Refactoring cellularNetworkType and wifi to support nil data if no cell type or wifi is found. --- platform/ios/MGLMapboxEvents.m | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index d21a723d9..c9c125dee 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -265,8 +265,21 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [evt setValue:@(100 * [UIDevice currentDevice].batteryLevel) forKey:@"batteryLevel"]; [evt setValue:@(weakSelf.scale) forKey:@"resolution"]; [evt setValue:weakSelf.carrier forKey:@"carrier"]; - [evt setValue:[weakSelf getCurrentCellularNetworkConnectionType] forKey:@"cellularNetworkType"]; - [evt setValue:[weakSelf getWifiNetworkName] forKey:@"wifi"]; + + NSString *cell = [weakSelf getCurrentCellularNetworkConnectionType]; + if (cell) { + [evt setValue:cell forKey:@"cellularNetworkType"]; + } else { + [evt setObject:[NSNull null] forKey:@"cellularNetworkType"]; + } + + NSString *wifi = [weakSelf getWifiNetworkName]; + if (wifi) { + [evt setValue:wifi forKey:@"wifi"]; + } else { + [evt setObject:[NSNull null] forKey:@"wifi"]; + } + [evt setValue:@([weakSelf getContentSizeScale]) forKey:@"accessibilityFontScale"]; // Make Immutable Version @@ -505,17 +518,13 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; // - (NSString *) getWifiNetworkName { - NSString *ssid = @""; + NSString *ssid = nil; CFArrayRef interfaces = CNCopySupportedInterfaces(); if (interfaces) { NSDictionary *info = (__bridge NSDictionary *)CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(interfaces, 0)); if (info) { ssid = info[@"SSID"]; - } else { - ssid = @"NONE"; } - } else { - ssid = @"NONE"; } return ssid; @@ -528,7 +537,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; NSString *radioTech = telephonyInfo.currentRadioAccessTechnology; if (radioTech == nil) { - return @"NONE"; + return nil; } else if ([radioTech isEqualToString:CTRadioAccessTechnologyGPRS]) { return @"GPRS"; } else if ([radioTech isEqualToString:CTRadioAccessTechnologyEdge]) { From 67ce07cadaecfc47cb766abcf7eb858950d91d12 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 6 Apr 2015 17:50:02 -0500 Subject: [PATCH 2/4] #1217 - Changing date formatter to use device's system timezone and to give both timezone abbreviation as well as hour offset --- platform/ios/MGLMapboxEvents.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index c9c125dee..bd9fc9165 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -164,8 +164,9 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; [_rfc3339DateFormatter setLocale:enUSPOSIXLocale]; - [_rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"]; - [_rfc3339DateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; + [_rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss z Z"]; + [NSTimeZone resetSystemTimeZone]; + [_rfc3339DateFormatter setTimeZone:[NSTimeZone systemTimeZone]]; } return self; } From efdcdfb70d3c1988a48ace30ce8c12e5c1c5e62f Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 6 Apr 2015 17:51:24 -0500 Subject: [PATCH 3/4] #1217 - Documenting why [NSTimeZone resetSystemTimeZone] is called --- platform/ios/MGLMapboxEvents.m | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index bd9fc9165..63ec786d4 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -165,6 +165,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; [_rfc3339DateFormatter setLocale:enUSPOSIXLocale]; [_rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss z Z"]; + // Clear Any System TimeZone Cache [NSTimeZone resetSystemTimeZone]; [_rfc3339DateFormatter setTimeZone:[NSTimeZone systemTimeZone]]; } From 86d05d7eceaddd0fd49c5b75dfda0cb8688accd9 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 6 Apr 2015 19:12:05 -0500 Subject: [PATCH 4/4] #1217 - Changing date format to ISO 8601 --- platform/ios/MGLMapboxEvents.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 63ec786d4..2dfecbd77 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -164,7 +164,7 @@ NSString *const MGLEventGestureRotateStart = @"Rotation"; NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; [_rfc3339DateFormatter setLocale:enUSPOSIXLocale]; - [_rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss z Z"]; + [_rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ssZ"]; // Clear Any System TimeZone Cache [NSTimeZone resetSystemTimeZone]; [_rfc3339DateFormatter setTimeZone:[NSTimeZone systemTimeZone]];