From b33058f48bc92519e4d183d91b2a8e218466d731 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Fri, 5 Aug 2016 16:46:01 -0400 Subject: [PATCH 1/2] Do not show privacy screen when app is in foreground while inactive --- src/ios/PrivacyScreenPlugin.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ios/PrivacyScreenPlugin.m b/src/ios/PrivacyScreenPlugin.m index 67303ee..f29c5a1 100644 --- a/src/ios/PrivacyScreenPlugin.m +++ b/src/ios/PrivacyScreenPlugin.m @@ -12,14 +12,14 @@ @implementation PrivacyScreenPlugin - (void)pluginInitialize { - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidBecomeActive:) - name:UIApplicationDidBecomeActiveNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillEnterForeground:) + name:UIApplicationWillEnterForegroundNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillResignActive:) - name:UIApplicationWillResignActiveNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidEnterBackground:) + name:UIApplicationDidEnterBackgroundNotification object:nil]; } -- (void)onAppDidBecomeActive:(UIApplication *)application +- (void)onAppWillEnterForeground:(UIApplication *)application { if (imageView == NULL) { self.viewController.view.window.hidden = NO; @@ -28,7 +28,7 @@ - (void)onAppDidBecomeActive:(UIApplication *)application } } -- (void)onAppWillResignActive:(UIApplication *)application +- (void)onAppDidEnterBackground:(UIApplication *)application { CDVViewController *vc = (CDVViewController*)self.viewController; NSString *imgName = [self getImageName:self.viewController.interfaceOrientation delegate:(id)vc device:[self getCurrentDevice]]; @@ -152,4 +152,4 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i return imageName; } -@end \ No newline at end of file +@end From d09bd3d377578a38b54989d926e24c83544f92c8 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Fri, 28 Oct 2016 14:16:03 -0400 Subject: [PATCH 2/2] Setting image size to UIScreen instead of view size for ipad pro split view; Support ios new ios info plist launch image key; Using portait launchimage for iphone 5/6 landscape mode --- src/ios/PrivacyScreenPlugin.m | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ios/PrivacyScreenPlugin.m b/src/ios/PrivacyScreenPlugin.m index f29c5a1..6d769d9 100644 --- a/src/ios/PrivacyScreenPlugin.m +++ b/src/ios/PrivacyScreenPlugin.m @@ -37,7 +37,8 @@ - (void)onAppDidEnterBackground:(UIApplication *)application imageView = NULL; self.viewController.view.window.hidden = YES; } else { - imageView = [[UIImageView alloc]initWithFrame:[self.viewController.view bounds]]; + imageView = [[UIImageView alloc]initWithFrame:[[UIScreen mainScreen] bounds]]; + imageView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); [imageView setImage:splash]; #ifdef __CORDOVA_4_0_0 @@ -79,6 +80,10 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i // Use UILaunchImageFile if specified in plist. Otherwise, use Default. NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"]; + if (imageName == nil && [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImages"] != nil){ + imageName = @"LaunchImage"; + } + NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations]; // Checks to see if the developer has locked the orientation to use only one of Portrait or Landscape @@ -111,11 +116,11 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i BOOL isLandscape = supportsLandscape && (currentOrientation == UIInterfaceOrientationLandscapeLeft || currentOrientation == UIInterfaceOrientationLandscapeRight); - if (device.iPhone5) { // does not support landscape - imageName = isLandscape ? nil : [imageName stringByAppendingString:@"-568h"]; - } else if (device.iPhone6) { // does not support landscape - imageName = isLandscape ? nil : [imageName stringByAppendingString:@"-667h"]; - } else if (device.iPhone6Plus) { // supports landscape + if (device.iPhone5) { // does not support landscape, so use landscape image instead of showing a black screen + imageName = [imageName stringByAppendingString:@"-568h"]; + } else if (device.iPhone6) { // does not support landscape, so use landscape image instead of showing a black screen + imageName = [imageName stringByAppendingString:@"-667h"]; + } else if (device.iPhone6Plus) { // supports landscape if (isOrientationLocked) { imageName = [imageName stringByAppendingString:(supportsLandscape ? @"-Landscape" : @"")]; } else {