diff --git a/README.md b/README.md
index 1631370..0a14892 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,24 @@ For Cordova 3.x.x:
Usage:
------
-This plugin exposes no interface, it simply sets your app to be private. You don't need to do anything except install the plugin.
+This plugin exposes no interface in Android, it simply sets your app to be private. You don't need to do anything except install the plugin.
+
+In iOS the privacy screen fades on page load or in a set time interval, if you want more control you have the following functions:
+- setTimer(successCallback, errorCallback, timeInterval) : sets timer to make privacy screen fade away (default is 3 seconds and can be set through preference).
+- hidePrivacyScreen(successCallback, errorCallback) : Explicitely hides the privacy screen.
+- showPrivacyScreen(successCallback, errorCallback) : Explicitely shows the privacy screen (respects timer interval to fade)
+
+For iOS there are 3 preferences that can be set in config.xml:
+- "PrivacyOnBackground": If set to "true" allows splashscreen to be shown only when app enters background (i.e. switched to another app or pressed the home button)
+- "PrivacyOverrideLaunchImage": If set to "true" allows privacy screen to be the Default image even if LaunchImage is set in the info-plist
+- "PrivacyImageName": String for image name, images should be in the app bundle and follow the size naming convention (i.e. for app name "Test", there should be a "Test-667h.png" in the bundle for iPhone 6)
+- "PrivacyTimer": accepts a value in seconds for the privacy screen timer
+
+When using splash storyboard add images to the config xml.
+(i.e
+
+
+ )
Test this plugin on a real device because the iOS simulator (7.1 at least) does a poor job hiding your app.
@@ -36,4 +53,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
diff --git a/package.json b/package.json
index e4f1ced..a08ddaa 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-privacyscreen",
- "version": "0.3.1",
+ "version": "0.4.3",
"description": "Secures your app from displaying a screenshot in task switchers under Android and iOS. Keeps sensitive information private.",
"cordova": {
"id": "cordova-plugin-privacyscreen",
diff --git a/plugin.xml b/plugin.xml
index 99d0576..a79c1ae 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -1,9 +1,14 @@
-
+
PrivacyScreenPlugin
Secures your app from displaying a screenshot in task switchers under Android and iOS. Keeps sensitive information private.
MIT
+
+
+
+
+
diff --git a/src/android/PrivacyScreenPlugin.java b/src/android/PrivacyScreenPlugin.java
index 691f5a6..310987a 100644
--- a/src/android/PrivacyScreenPlugin.java
+++ b/src/android/PrivacyScreenPlugin.java
@@ -34,4 +34,22 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
Activity activity = this.cordova.getActivity();
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
+ //Not used in Android
+ @Override
+ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
+ if ("setTimer".equals(action)) {
+ callbackContext.success();
+ return true;
+ }
+ else if ("hidePrivacyScreen".equals(action)) {
+ callbackContext.success();
+ return true;
+ }
+ else if ("showPrivacyScreen".equals(action)) {
+ callbackContext.success();
+ return true;
+ }
+
+ return false; // Returning false results in a "MethodNotFound" error.
+ }
}
diff --git a/src/ios/PrivacyScreenPlugin.h b/src/ios/PrivacyScreenPlugin.h
index 6ce5c3a..1fc5e4a 100644
--- a/src/ios/PrivacyScreenPlugin.h
+++ b/src/ios/PrivacyScreenPlugin.h
@@ -15,9 +15,14 @@ typedef struct {
BOOL iPhone6;
BOOL iPhone6Plus;
BOOL retina;
+ BOOL iPhoneX;
} CDV_iOSDevice;
@interface PrivacyScreenPlugin : CDVPlugin
-@end
\ No newline at end of file
+- (void) setTimer:(CDVInvokedUrlCommand*)command;
+- (void) hidePrivacyScreen:(CDVInvokedUrlCommand*)command;
+- (void) showPrivacyScreen:(CDVInvokedUrlCommand*)command;
+
+@end
diff --git a/src/ios/PrivacyScreenPlugin.m b/src/ios/PrivacyScreenPlugin.m
index 67303ee..c68916f 100644
--- a/src/ios/PrivacyScreenPlugin.m
+++ b/src/ios/PrivacyScreenPlugin.m
@@ -6,150 +6,370 @@
*/
#import "PrivacyScreenPlugin.h"
+#define PRIVACY_TIMER_DEFAULT 3.0f;
+
static UIImageView *imageView;
+@interface PrivacyScreenPlugin ()
+
+@property (strong, nonatomic) NSTimer* privacyTimer;
+@property (nonatomic) float privacyTimerInterval;
+@end
+
+
@implementation PrivacyScreenPlugin
+#pragma mark - Initialize
- (void)pluginInitialize
{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidBecomeActive:)
- name:UIApplicationDidBecomeActiveNotification object:nil];
+ NSString* privacyTimerKey = @"privacytimer";
+ NSString* prefTimer = [self.commandDelegate.settings objectForKey:[privacyTimerKey lowercaseString]];
+ //Default value
+ self.privacyTimerInterval = PRIVACY_TIMER_DEFAULT;
+ if(prefTimer)
+ self.privacyTimerInterval = [prefTimer floatValue] > 0.0f ? [prefTimer floatValue] : PRIVACY_TIMER_DEFAULT;
+
+
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidBecomeActive:)
+ name:UIApplicationDidBecomeActiveNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPageDidLoad)
+ name:CDVPageDidLoadNotification object:nil];
+
+ NSString* onBackgroundKey = @"privacyonbackground";
+
+ if([self.commandDelegate.settings objectForKey:[onBackgroundKey lowercaseString]] && [[self.commandDelegate.settings objectForKey:[onBackgroundKey lowercaseString]] isEqualToString:@"true"])
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillResignActive:)
+ name:UIApplicationDidEnterBackgroundNotification object:nil];
+ else
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillResignActive:)
+ name:UIApplicationWillResignActiveNotification object:nil];
+}
+
+#pragma mark - Explicit Commands
+- (void) setTimer:(CDVInvokedUrlCommand*)command
+{
+ if(command.arguments.count > 0)
+ {
+ if(!command.arguments[0] || command.arguments[0] == [NSNull null])
+ {
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString: @"Timer argument is null"];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ return;
+ }
+ //timeInterval argument
+ self.privacyTimerInterval = [command.arguments[0] floatValue];
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ }
+ else
+ {
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString: @"No arguments provided"];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ }
+}
+
+- (void) hidePrivacyScreen:(CDVInvokedUrlCommand*)command
+{
+ [self removePrivacyScreen];
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+}
+
+- (void) showPrivacyScreen:(CDVInvokedUrlCommand*)command
+{
+ [self applyPrivacyScreen];
+ [self.privacyTimer invalidate];
+ self.privacyTimer = [NSTimer scheduledTimerWithTimeInterval:self.privacyTimerInterval
+ target:self
+ selector:@selector(removePrivacyScreen)
+ userInfo:nil
+ repeats:NO];
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+}
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillResignActive:)
- name:UIApplicationWillResignActiveNotification object:nil];
+#pragma mark - Triggered functions
+- (void) onPageDidLoad
+{
+ [self removePrivacyScreen];
}
- (void)onAppDidBecomeActive:(UIApplication *)application
{
- if (imageView == NULL) {
- self.viewController.view.window.hidden = NO;
- } else {
- [imageView removeFromSuperview];
- }
+ [self.privacyTimer invalidate];
+ //if(!self.privacyTimer || !self.privacyTimer.valid)
+ self.privacyTimer = [NSTimer scheduledTimerWithTimeInterval:self.privacyTimerInterval
+ target:self
+ selector:@selector(removePrivacyScreen)
+ userInfo:nil
+ repeats:NO];
}
- (void)onAppWillResignActive:(UIApplication *)application
{
- CDVViewController *vc = (CDVViewController*)self.viewController;
- NSString *imgName = [self getImageName:self.viewController.interfaceOrientation delegate:(id)vc device:[self getCurrentDevice]];
- UIImage *splash = [UIImage imageNamed:imgName];
- if (splash == NULL) {
- imageView = NULL;
- self.viewController.view.window.hidden = YES;
- } else {
- imageView = [[UIImageView alloc]initWithFrame:[self.viewController.view bounds]];
- [imageView setImage:splash];
-
- #ifdef __CORDOVA_4_0_0
+ [self applyPrivacyScreen];
+}
+
+#pragma mark - Helper functions
+-(void) removePrivacyScreen
+{
+ if(imageView)
+ {
+ self.viewController.view.window.hidden = NO;
+
+
+ [UIView animateWithDuration:0.1f
+ animations:^{
+ imageView.alpha = 0.0f;
+ }
+ completion:^(BOOL finished) {
+ [imageView removeFromSuperview];
+ }];
+
+ }
+
+// if(self.privacyTimer || self.privacyTimer.valid)
+// {
+ [self.privacyTimer invalidate];
+ self.privacyTimer = nil;
+// }
+}
+
+-(void) applyPrivacyScreen
+{
+ CDVViewController *vc = (CDVViewController*)self.viewController;
+ NSString *imgName = [self getImageName:(id)vc device:[self getCurrentDevice]];
+ UIImage* splash;
+
+ splash = [self getImageFromName:imgName];
+
+ if (splash == NULL)
+ {
+ self.viewController.view.window.hidden = YES;
+ }
+ else
+ {
+
+ [imageView removeFromSuperview];
+ imageView = nil;
+
+ imageView = [[UIImageView alloc]initWithFrame:[self.viewController.view bounds]];
+ [imageView setImage:splash];
+
+#ifdef __CORDOVA_4_0_0
[[UIApplication sharedApplication].keyWindow addSubview:imageView];
- #else
+#else
[self.viewController.view addSubview:imageView];
- #endif
- }
+#endif
+
+ }
+
}
// Code below borrowed from the CDV splashscreen plugin @ https://github.com/apache/cordova-plugin-splashscreen
// Made some adjustments though, becuase landscape splashscreens are not available for iphone < 6 plus
- (CDV_iOSDevice) getCurrentDevice
{
- CDV_iOSDevice device;
-
- UIScreen* mainScreen = [UIScreen mainScreen];
- CGFloat mainScreenHeight = mainScreen.bounds.size.height;
- CGFloat mainScreenWidth = mainScreen.bounds.size.width;
-
- int limit = MAX(mainScreenHeight,mainScreenWidth);
-
- device.iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
- device.iPhone = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone);
- device.retina = ([mainScreen scale] == 2.0);
- device.iPhone4 = (device.iPhone && limit == 480.0);
- device.iPhone5 = (device.iPhone && limit == 568.0);
- // note these below is not a true device detect, for example if you are on an
- // iPhone 6/6+ but the app is scaled it will prob set iPhone5 as true, but
- // this is appropriate for detecting the runtime screen environment
- device.iPhone6 = (device.iPhone && limit == 667.0);
- device.iPhone6Plus = (device.iPhone && limit == 736.0);
-
- return device;
+ CDV_iOSDevice device;
+
+ UIScreen* mainScreen = [UIScreen mainScreen];
+ CGFloat mainScreenHeight = mainScreen.bounds.size.height;
+ CGFloat mainScreenWidth = mainScreen.bounds.size.width;
+
+ int limit = MAX(mainScreenHeight,mainScreenWidth);
+
+ device.iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
+ device.iPhone = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone);
+ device.retina = ([mainScreen scale] == 2.0);
+ device.iPhone4 = (device.iPhone && limit == 480.0);
+ device.iPhone5 = (device.iPhone && limit == 568.0);
+ // note these below is not a true device detect, for example if you are on an
+ // iPhone 6/6+ but the app is scaled it will prob set iPhone5 as true, but
+ // this is appropriate for detecting the runtime screen environment
+ device.iPhone6 = (device.iPhone && limit == 667.0);
+ device.iPhone6Plus = (device.iPhone && limit == 736.0);
+ device.iPhoneX = (device.iPhone && limit == 812.0);
+
+ return device;
}
-- (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(id)orientationDelegate device:(CDV_iOSDevice)device
+- (void)updateBounds
{
- // Use UILaunchImageFile if specified in plist. Otherwise, use Default.
- NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
-
- NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations];
-
- // 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);
- // this means there are no mixed orientations in there
- BOOL isOrientationLocked = !(supportsPortrait && supportsLandscape);
-
- if (imageName) {
- imageName = [imageName stringByDeletingPathExtension];
- } else {
- imageName = @"Default";
- }
-
- // Add Asset Catalog specific prefixes
- if ([imageName isEqualToString:@"LaunchImage"])
- {
- if(device.iPhone4 || device.iPhone5 || device.iPad) {
- imageName = [imageName stringByAppendingString:@"-700"];
- } else if(device.iPhone6) {
- imageName = [imageName stringByAppendingString:@"-800"];
- } else if(device.iPhone6Plus) {
- imageName = [imageName stringByAppendingString:@"-800"];
- if (currentOrientation == UIInterfaceOrientationPortrait || currentOrientation == UIInterfaceOrientationPortraitUpsideDown) {
- imageName = [imageName stringByAppendingString:@"-Portrait"];
- }
+
+ UIImage* img = imageView.image;
+ CGRect imgBounds = (img) ? CGRectMake(0, 0, img.size.width, img.size.height) : CGRectZero;
+
+ CGSize screenSize = [self.viewController.view convertRect:[UIScreen mainScreen].bounds fromView:nil].size;
+ UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
+ CGAffineTransform imgTransform = CGAffineTransformIdentity;
+
+ /* If and only if an iPhone application is landscape-only as per
+ * UISupportedInterfaceOrientations, the view controller's orientation is
+ * landscape. In this case the image must be rotated in order to appear
+ * correctly.
+ */
+ CDV_iOSDevice device = [self getCurrentDevice];
+ if (UIInterfaceOrientationIsLandscape(orientation) && !device.iPhone6Plus && !device.iPad)
+ {
+ imgTransform = CGAffineTransformMakeRotation(M_PI / 2);
+ imgBounds.size = CGSizeMake(imgBounds.size.height, imgBounds.size.width);
}
- }
-
- 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 (isOrientationLocked) {
- imageName = [imageName stringByAppendingString:(supportsLandscape ? @"-Landscape" : @"")];
- } else {
- switch (currentOrientation) {
- case UIInterfaceOrientationLandscapeLeft:
- case UIInterfaceOrientationLandscapeRight:
- imageName = [imageName stringByAppendingString:@"-Landscape"];
- break;
- default:
- break;
- }
+
+ // There's a special case when the image is the size of the screen.
+ if (CGSizeEqualToSize(screenSize, imgBounds.size))
+ {
+ CGRect statusFrame = [self.viewController.view convertRect:[UIApplication sharedApplication].statusBarFrame fromView:nil];
+ if (!(IsAtLeastiOSVersion(@"7.0")))
+ {
+ imgBounds.origin.y -= statusFrame.size.height;
+ }
}
- imageName = [imageName stringByAppendingString:@"-736h"];
-
- } else if (device.iPad) { // supports landscape
- if (isOrientationLocked) {
- imageName = [imageName stringByAppendingString:(supportsLandscape ? @"-Landscape" : @"-Portrait")];
- } else {
- switch (currentOrientation) {
- case UIInterfaceOrientationLandscapeLeft:
- case UIInterfaceOrientationLandscapeRight:
- imageName = [imageName stringByAppendingString:@"-Landscape"];
- break;
-
- case UIInterfaceOrientationPortrait:
- case UIInterfaceOrientationPortraitUpsideDown:
- default:
- imageName = [imageName stringByAppendingString:@"-Portrait"];
- break;
- }
+ else if (imgBounds.size.width > 0)
+ {
+ CGRect viewBounds = self.viewController.view.bounds;
+ CGFloat imgAspect = imgBounds.size.width / imgBounds.size.height;
+ CGFloat viewAspect = viewBounds.size.width / viewBounds.size.height;
+ // This matches the behaviour of the native splash screen.
+ CGFloat ratio;
+ if (viewAspect > imgAspect)
+ {
+ ratio = viewBounds.size.width / imgBounds.size.width;
+ }
+ else
+ {
+ ratio = viewBounds.size.height / imgBounds.size.height;
+ }
+ imgBounds.size.height *= ratio;
+ imgBounds.size.width *= ratio;
}
- }
-
- return imageName;
+
+ imageView.transform = imgTransform;
+ imageView.frame = imgBounds;
+}
+
+
+
+
+- (NSString*)getImageName:(id)orientationDelegate device:(CDV_iOSDevice)device
+{
+
+ NSString* imageName;
+
+ NSString* privacyImageNameKey = @"privacyimagename";
+ NSString* prefImageName = [self.commandDelegate.settings objectForKey:[privacyImageNameKey lowercaseString]];
+ imageName = prefImageName ? prefImageName : @"Default";
+ //Override Launch images?
+ NSString* privacyOverrideLaunchImage = @"privacyoverridelaunchimage";
+ if([self.commandDelegate.settings objectForKey:[privacyOverrideLaunchImage lowercaseString]] && [[self.commandDelegate.settings objectForKey:[privacyOverrideLaunchImage lowercaseString]] isEqualToString:@"true"])
+ {
+
+ }
+ else
+ {
+ // Use UILaunchImageFile if specified in plist. Otherwise, use Default.
+ imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
+ imageName = [imageName stringByDeletingPathExtension];
+ }
+
+ NSUInteger supportedOrientations = [orientationDelegate supportedInterfaceOrientations];
+
+ // 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);
+ // this means there are no mixed orientations in there
+ BOOL isOrientationLocked = !(supportsPortrait && supportsLandscape);
+
+ UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
+ // Add Asset Catalog specific prefixes
+ if ([imageName isEqualToString:@"LaunchImage"])
+ {
+ if(device.iPhone4 || device.iPhone5 || device.iPad) {
+ imageName = [imageName stringByAppendingString:@"-700"];
+ } else if(device.iPhone6) {
+ imageName = [imageName stringByAppendingString:@"-800"];
+ } else if(device.iPhone6Plus) {
+ imageName = [imageName stringByAppendingString:@"-800"];
+ if (deviceOrientation == UIDeviceOrientationPortrait || deviceOrientation == UIDeviceOrientationPortraitUpsideDown) {
+ imageName = [imageName stringByAppendingString:@"-Portrait"];
+ }
+ }
+ }
+
+ BOOL isLandscape = supportsLandscape &&
+ (deviceOrientation == UIDeviceOrientationLandscapeLeft || deviceOrientation == UIDeviceOrientationLandscapeRight);
+
+ if (device.iPhone4) { // does not support landscape
+ imageName = isLandscape ? nil : [imageName stringByAppendingString:@"480h"];
+ } else 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.iPhoneX) { // does not support landscape
+ imageName = isLandscape ? nil : [imageName stringByAppendingString:@"812h"];
+ } else if (device.iPhone6Plus) { // supports landscape
+ if (isOrientationLocked) {
+ imageName = [imageName stringByAppendingString:(supportsLandscape ? @"Landscape" : @"")];
+ } else {
+ switch (deviceOrientation) {
+ case UIInterfaceOrientationLandscapeLeft:
+ case UIInterfaceOrientationLandscapeRight:
+ imageName = [imageName stringByAppendingString:@"Landscape"];
+ break;
+ default:
+ break;
+ }
+ }
+ imageName = [imageName stringByAppendingString:@"736h"];
+
+ } else if (device.iPad) { // supports landscape
+ if (isOrientationLocked) {
+ imageName = [imageName stringByAppendingString:(supportsLandscape ? @"Landscape" : @"Portrait")];
+ } else {
+ switch (deviceOrientation) {
+ case UIInterfaceOrientationLandscapeLeft:
+ case UIInterfaceOrientationLandscapeRight:
+ imageName = [imageName stringByAppendingString:@"Landscape"];
+ break;
+
+ case UIInterfaceOrientationPortrait:
+ case UIInterfaceOrientationPortraitUpsideDown:
+ default:
+ imageName = [imageName stringByAppendingString:@"Portrait"];
+ break;
+ }
+ }
+ }
+// 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
\ No newline at end of file
+@end
diff --git a/www/PrivacyScreenPlugin.js b/www/PrivacyScreenPlugin.js
index ae80e7d..1c13da7 100644
--- a/www/PrivacyScreenPlugin.js
+++ b/www/PrivacyScreenPlugin.js
@@ -1,8 +1,25 @@
-//var exec = require('cordova/exec');
-
-/**
- * Not sure this will even have a JS API
- */
-//exports.activate = function(arg, success, error) {
- //exec(success, error, "PrivacyScreenPlugin", "activate", [arg]);
-//};
+function PrivacyScreen() {}
+
+//Default time to remove privacy screen is 2 seconds (+0.1s for fade animation)
+PrivacyScreen.prototype.setTimer = function(successCallback, errorCallback, timeInterval) {
+ cordova.exec(successCallback, errorCallback, "PrivacyScreenPlugin", "setTimer", [timeInterval]);
+};
+
+PrivacyScreen.prototype.hidePrivacyScreen = function(successCallback, errorCallback) {
+ cordova.exec(successCallback, errorCallback, "PrivacyScreenPlugin", "hidePrivacyScreen", []);
+};
+
+PrivacyScreen.prototype.showPrivacyScreen = function(successCallback, errorCallback) {
+ cordova.exec(successCallback, errorCallback, "PrivacyScreenPlugin", "showPrivacyScreen", []);
+};
+
+PrivacyScreen.install = function() {
+ if (!window.plugins) {
+ window.plugins = {};
+ }
+
+ window.plugins.privacyscreen = new PrivacyScreen();
+ return window.plugins.privacyscreen;
+};
+
+cordova.addConstructor(PrivacyScreen.install);
\ No newline at end of file