From 2c7d0567fa7a2b342b16a5ecea5290aee32aaa77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sun, 17 May 2015 00:10:14 -0700 Subject: [PATCH] Privatized MGLMapboxEvents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `-pauseMetricsCollection` and `-resumeMetricsCollection` were originally introduced to mitigate concerns around battery usage, but `MGLMapboxEvents` has since evolved to tread much lighter on the battery. There’s no longer any need for the client to call these methods directly. The iOS test project now includes MGLMapboxEvents.h explicitly to avoid having to package a header that will go unused. --- gyp/platform-ios.gypi | 3 +-- ios/app/MBXAppDelegate.m | 24 ------------------- platform/ios/MGLAccountManager.m | 2 +- platform/ios/MGLMapView.mm | 9 +++---- .../mbgl => platform}/ios/MGLMapboxEvents.h | 2 ++ platform/ios/MGLMapboxEvents.m | 2 +- platform/ios/MGLMapboxEvents_Private.h | 7 ------ test/ios/MetricsTests.m | 1 - test/ios/ios-tests.xcodeproj/project.pbxproj | 2 ++ 9 files changed, 10 insertions(+), 42 deletions(-) rename {include/mbgl => platform}/ios/MGLMapboxEvents.h (98%) delete mode 100644 platform/ios/MGLMapboxEvents_Private.h diff --git a/gyp/platform-ios.gypi b/gyp/platform-ios.gypi index 0e200f5e1..0034831a9 100644 --- a/gyp/platform-ios.gypi +++ b/gyp/platform-ios.gypi @@ -18,8 +18,7 @@ '../platform/darwin/nsthread.mm', '../platform/darwin/reachability.m', '../include/mbgl/ios/MapboxGL.h', - '../include/mbgl/ios/MGLMapboxEvents.h', - '../platform/ios/MGLMapboxEvents_Private.h', + '../platform/ios/MGLMapboxEvents.h', '../platform/ios/MGLMapboxEvents.m', '../include/mbgl/ios/MGLMapView.h', '../include/mbgl/ios/MGLMapView+IBAdditions.h', diff --git a/ios/app/MBXAppDelegate.m b/ios/app/MBXAppDelegate.m index ce699ce69..dc0410508 100644 --- a/ios/app/MBXAppDelegate.m +++ b/ios/app/MBXAppDelegate.m @@ -1,8 +1,6 @@ #import "MBXAppDelegate.h" #import "MBXViewController.h" #import -#import -#import @implementation MBXAppDelegate @@ -34,26 +32,4 @@ return YES; } -/** -- (void)applicationWillEnterForeground:(UIApplication *)application -{ - // Example of how to resume Metrics Collection - - // Reasons for needing to resume: - // 1. In UIBackground and app starts listening for Location Updates where it previously had not been listening. - // 2. App is entering foreground where it had called pauseMetricsCollection. - [MGLMapboxEvents resumeMetricsCollection]; -} - -- (void)applicationDidEnterBackground:(UIApplication *)application -{ - // Example of how to pause Metrics Collection - - // Reason for needing to pause: - // 1. Either entering or already in UIBackground and app stops listening for Location Updates - // via any CLLocationManager instance it may have. - [MGLMapboxEvents pauseMetricsCollection]; -} -*/ - @end diff --git a/platform/ios/MGLAccountManager.m b/platform/ios/MGLAccountManager.m index 2e3c0a38e..a49433777 100644 --- a/platform/ios/MGLAccountManager.m +++ b/platform/ios/MGLAccountManager.m @@ -1,7 +1,7 @@ #import #import "MGLAccountManager.h" -#import "MGLMapboxEvents_Private.h" +#import "MGLMapboxEvents.h" #import "NSProcessInfo+MGLAdditions.h" @interface MGLAccountManager() diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index dfbb03439..72a2ed0d6 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -15,22 +15,19 @@ #include #include -#import "MGLTypes.h" +#import "MapboxGL.h" + #import "NSBundle+MGLAdditions.h" #import "NSString+MGLAdditions.h" #import "NSProcessInfo+MGLAdditions.h" #import "NSException+MGLAdditions.h" -#import "MGLAccountManager.h" -#import "MGLAnnotation.h" #import "MGLUserLocationAnnotationView.h" #import "MGLUserLocation_Private.h" #import "MGLFileCache.h" +#import "MGLMapboxEvents.h" #import "SMCalloutView.h" -#import "MGLMapboxEvents.h" -#import "MapboxGL.h" - #import class MBGLView; diff --git a/include/mbgl/ios/MGLMapboxEvents.h b/platform/ios/MGLMapboxEvents.h similarity index 98% rename from include/mbgl/ios/MGLMapboxEvents.h rename to platform/ios/MGLMapboxEvents.h index 5c5d8a924..94aa8be78 100644 --- a/include/mbgl/ios/MGLMapboxEvents.h +++ b/platform/ios/MGLMapboxEvents.h @@ -30,6 +30,8 @@ extern NSString *const MGLEventGestureRotateStart; @interface MGLMapboxEvents : NSObject ++ (instancetype)sharedManager; + // You must call these methods from the main thread. // + (void) pauseMetricsCollection; diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 2b9d88777..5663e3f1c 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -1,4 +1,4 @@ -#import "MGLMapboxEvents_Private.h" +#import "MGLMapboxEvents.h" #import #import diff --git a/platform/ios/MGLMapboxEvents_Private.h b/platform/ios/MGLMapboxEvents_Private.h deleted file mode 100644 index 6a48b31f0..000000000 --- a/platform/ios/MGLMapboxEvents_Private.h +++ /dev/null @@ -1,7 +0,0 @@ -#import "MGLMapboxEvents.h" - -@interface MGLMapboxEvents (Private) - -+ (instancetype)sharedManager; - -@end diff --git a/test/ios/MetricsTests.m b/test/ios/MetricsTests.m index 179e7a1ac..5b1a7956e 100644 --- a/test/ios/MetricsTests.m +++ b/test/ios/MetricsTests.m @@ -10,7 +10,6 @@ @interface MGLMapboxEvents (Testing) -+ (instancetype)sharedManager; - (NSString *)appBundleId; - (NSString *)token; - (BOOL)isPaused; diff --git a/test/ios/ios-tests.xcodeproj/project.pbxproj b/test/ios/ios-tests.xcodeproj/project.pbxproj index 50e12595f..4f31a5b4a 100644 --- a/test/ios/ios-tests.xcodeproj/project.pbxproj +++ b/test/ios/ios-tests.xcodeproj/project.pbxproj @@ -81,6 +81,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + DACAD7111B08719F009119DC /* MGLMapboxEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MGLMapboxEvents.h; path = ../../platform/ios/MGLMapboxEvents.h; sourceTree = SOURCE_ROOT; }; DD043323196DB9BC00E6F39D /* Mapbox GL Tests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Mapbox GL Tests.app"; sourceTree = BUILT_PRODUCTS_DIR; }; DD04335F196DBBD500E6F39D /* MGLTAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLTAppDelegate.m; sourceTree = SOURCE_ROOT; }; DD043360196DBBD500E6F39D /* MGLTViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLTViewController.m; sourceTree = SOURCE_ROOT; }; @@ -270,6 +271,7 @@ isa = PBXGroup; children = ( DD0581031ACB661200B112C9 /* Headers */, + DACAD7111B08719F009119DC /* MGLMapboxEvents.h */, DD0581071ACB663200B112C9 /* libMapboxGL.a */, DD0581051ACB661C00B112C9 /* MapboxGL.bundle */, );