diff --git a/README.md b/README.md index 1631370..e19ca6d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is a lovely feature for most apps, but if your app displays sensitive infor This plugin flags your app so that it doesn't show your users' sensitive data in the task switcher. It sets the [FLAG_SECURE](http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE) flag in Android (which also prevents manual screenshots from being taken) and hides the window in iOS. -On iOS this plugin will try to show your splashscreen in the app switcher. It will search for splashscreens prefixed by `Default` or the value of the key `UILaunchImageFile` in your .plist file. +On iOS this plugin will try to show your splashscreen in the app switcher. It will search for splashscreens prefixed by `Default`, the value of the key `UILaunchImageFile` in your .plist file or use the provided Storyboard image. If it fails to find a splashscreen for a specific device or orientation (portrait or landscape), a black screen is shown instead. Installation diff --git a/package.json b/package.json index 46b9128..d19f744 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-privacyscreen", - "version": "0.4.0", + "version": "0.4.1", "description": "Secures your app from displaying a screenshot in task switchers under Android and iOS. Keeps sensitive information private.", "cordova": { "id": "cordova-plugin-privacyscreen", @@ -18,9 +18,11 @@ "cordova", "ecosystem:cordova", "cordova-android", - "cordova-ios" + "cordova-ios", + "storyboard" ], "author": "Tommy-Carlos Willaims <tommy@devgeeks.org>", + "contributors": ["Holger Grosse-Plankermann <holger.grosse-plankermann@codecentric.de>"], "license": "MIT", "bugs": { "url": "https://github.com/devgeeks/PrivacyScreenPlugin/issues" diff --git a/src/ios/PrivacyScreenPlugin.m b/src/ios/PrivacyScreenPlugin.m index 67303ee..cdbdb3c 100644 --- a/src/ios/PrivacyScreenPlugin.m +++ b/src/ios/PrivacyScreenPlugin.m @@ -40,6 +40,11 @@ - (void)onAppWillResignActive:(UIApplication *)application imageView = [[UIImageView alloc]initWithFrame:[self.viewController.view bounds]]; [imageView setImage:splash]; + if ([self isUsingCDVLaunchScreen]) { + // launch screen expects the image to be scaled using AspectFill. + imageView.contentMode = UIViewContentModeScaleAspectFill; + } + #ifdef __CORDOVA_4_0_0 [[UIApplication sharedApplication].keyWindow addSubview:imageView]; #else @@ -74,6 +79,16 @@ - (CDV_iOSDevice) getCurrentDevice return device; } +- (BOOL) isUsingCDVLaunchScreen { + NSString* launchStoryboardName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchStoryboardName"]; + if (launchStoryboardName) { + return ([launchStoryboardName isEqualToString:@"CDVLaunchScreen"]); + } else { + return NO; + } +} + + - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(id<CDVScreenOrientationDelegate>)orientationDelegate device:(CDV_iOSDevice)device { // Use UILaunchImageFile if specified in plist. Otherwise, use Default. @@ -81,6 +96,13 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations]; + // detect if we are using CB-9762 Launch Storyboard; if so, return the associated image instead + if ([self isUsingCDVLaunchScreen]) { + imageName = @"LaunchStoryboard"; + return imageName; + } + + // Checks to see if the developer has locked the orientation to use only one of Portrait or Landscape BOOL supportsLandscape = (supportedOrientations & UIInterfaceOrientationMaskLandscape); BOOL supportsPortrait = (supportedOrientations & UIInterfaceOrientationMaskPortrait || supportedOrientations & UIInterfaceOrientationMaskPortraitUpsideDown);