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

Support iOS #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
32 changes: 32 additions & 0 deletions src/ios/PrivacyScreenPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Copyright (c) 2014 Tommy-Carlos Williams. All rights reserved.
* MIT Licensed
*/
#import "AppDelegate.h"
#import "MainViewController.h"
#import "PrivacyScreenPlugin.h"

static UIImageView *imageView;
Expand All @@ -17,6 +19,9 @@ - (void)pluginInitialize

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillResignActive:)
name:UIApplicationWillResignActiveNotification object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidFinishLaunching:)
name:UIApplicationDidFinishLaunchingNotification object:nil];
}

- (void)onAppDidBecomeActive:(UIApplication *)application
Expand Down Expand Up @@ -152,4 +157,31 @@ - (NSString*)getImageName:(UIInterfaceOrientation)currentOrientation delegate:(i
return imageName;
}

- (void)onAppDidFinishLaunching:(NSNotification *)notification {
[self makeSecure];
}

- (void) makeSecure {
UIWindow *window = [[[[UIApplication sharedApplication] delegate] window] rootViewController].view.window;

UITextField *field = [[UITextField alloc] init];

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, field.frame.size.width, field.frame.size.height)];

UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"whiteImage"]];
image.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);

field.secureTextEntry = YES;

[window addSubview:field];
[view addSubview:image];

[window.layer.superlayer addSublayer:field.layer];
[[field.layer.sublayers lastObject] addSublayer:window.layer];

field.leftView = view;
field.leftViewMode = UITextFieldViewModeAlways;
}


@end