Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic functionality to use storyboard images on iOS #62

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -18,9 +18,11 @@
"cordova",
"ecosystem:cordova",
"cordova-android",
"cordova-ios"
"cordova-ios",
"storyboard"
],
"author": "Tommy-Carlos Willaims <[email protected]>",
"contributors": ["Holger Grosse-Plankermann <[email protected]>"],
"license": "MIT",
"bugs": {
"url": "https://github.com/devgeeks/PrivacyScreenPlugin/issues"
Expand Down
22 changes: 22 additions & 0 deletions src/ios/PrivacyScreenPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -74,13 +79,30 @@ - (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.
NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];

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);
Expand Down