Skip to content

Commit

Permalink
Added option for www path image. Version 0.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
MobilityTiago committed Mar 3, 2017
1 parent fcba592 commit 74884d5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-privacyscreen" version="0.3.4">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-privacyscreen" version="0.3.5">

<name>PrivacyScreenPlugin</name>
<description>Secures your app from displaying a screenshot in task switchers under Android and iOS. Keeps sensitive information private.</description>
Expand Down
49 changes: 34 additions & 15 deletions src/ios/PrivacyScreenPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,13 @@ - (void)onAppWillResignActive:(UIApplication *)application
{
CDVViewController *vc = (CDVViewController*)self.viewController;
NSString *imgName = [self getImageName:self.viewController.interfaceOrientation delegate:(id<CDVScreenOrientationDelegate>)vc device:[self getCurrentDevice]];
UIImage *splash = [UIImage imageNamed:imgName];
UIImage* splash = [self getImageFromName:imgName];
if (splash == NULL)
{

//try to take out hyfens and see if that works (Compatbility with Outsystems mobile issue)
imgName = [imgName stringByReplacingOccurrencesOfString:@"-" withString:@""];

splash = [UIImage imageNamed:imgName];
//If still null image doesn't really exist.
if (splash == NULL) {
imageView = NULL;
self.viewController.view.window.hidden = YES;
}
imageView = NULL;
self.viewController.view.window.hidden = YES;
}

//If splash image ended up being initialized
if(splash)
else
{
imageView = [[UIImageView alloc]initWithFrame:[self.viewController.view bounds]];
[imageView setImage:splash];
Expand Down Expand Up @@ -174,8 +164,37 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i
}
}
}

// if(imageName)
// {
// imageName = [imageName stringByAppendingString:@".png"];
// }
return imageName;
}

- (UIImage*) getImageFromName:(NSString*) imageName
{
UIImage *image = [UIImage imageNamed:imageName];
if (image == NULL)
{
//If not in bundle try to go to resources path
NSString* imagePath = [imageName stringByAppendingString:@".png"];
image = [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingString:imagePath]];
if(image)
return image;

//try to take out hyfens and see if that works (Compatbility with Outsystems mobile issue)
imageName = [imageName stringByReplacingOccurrencesOfString:@"-" withString:@""];
image = [UIImage imageNamed:imageName];
if(image == NULL)
{
imagePath = [imageName stringByAppendingString:@".png"];
image = [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingString:imagePath]];
//If still null image doesn't really exist.
}
}


return image;
}

@end

0 comments on commit 74884d5

Please sign in to comment.