General: Screenshot protection (closes #216)

This commit is contained in:
dtsbourg 2014-12-04 15:00:49 +01:00 committed by Frederic Jacobs
parent 67a1a41330
commit e70fd6391b
3 changed files with 17 additions and 12 deletions

View file

@ -87,8 +87,6 @@
[self performUpdateCheck];
[self prepareScreenshotProtection];
self.notificationTracker = [NotificationTracker notificationTracker];
CategorizingLogger* logger = [CategorizingLogger categorizingLogger];
@ -120,6 +118,8 @@
[self.window makeKeyAndVisible];
[self prepareScreenshotProtection];
[Environment.phoneManager.currentCallObservable watchLatestValue:^(CallState* latestCall) {
if (latestCall == nil){
return;
@ -245,6 +245,10 @@
}
}
- (void)applicationWillResignActive:(UIApplication *)application{
[self protectScreen];
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler{
if ([identifier isEqualToString:Signal_Call_Accept_Identifier]) {
[self.callPickUpFuture trySetResult:@YES];
@ -276,12 +280,9 @@
- (void)protectScreen{
if (Environment.preferences.screenSecurityIsEnabled) {
self.blankWindow.rootViewController = [UIViewController new];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.blankWindow.bounds];
if (self.blankWindow.bounds.size.height == 568) {
imageView.image = [UIImage imageNamed:@"Default-568h"];
} else {
imageView.image = [UIImage imageNamed:@"Default"];
}
imageView.backgroundColor = [UIColor whiteColor];
imageView.opaque = YES;
[self.blankWindow.rootViewController.view addSubview:imageView];
self.blankWindow.hidden = NO;

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="kts-vO-ui1">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="14C68k" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="kts-vO-ui1">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<capability name="Alignment constraints with different attributes" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
@ -2393,7 +2393,7 @@ Licensed under the GPLv3</string>
</tableViewSection>
<tableViewSection id="JqD-8c-dMF">
<cells>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" rowHeight="60" id="quP-Cu-8LE" customClass="SettingsTableViewCell">
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="enableScreenSecurity" rowHeight="60" id="quP-Cu-8LE" customClass="SettingsTableViewCell">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="quP-Cu-8LE" id="i03-Ww-QZz">
<autoresizingMask key="autoresizingMask"/>

View file

@ -8,11 +8,14 @@
#import "SettingsTableViewCell.h"
#import "Environment.h"
#import "PreferencesUtil.h"
@implementation SettingsTableViewCell
- (void)awakeFromNib {
// Initialization code
[self.toggle setOn:[Environment.preferences screenSecurityIsEnabled]];
[self.toggle addTarget:self action:@selector(toggleSetting:) forControlEvents:UIControlEventValueChanged];
}
@ -27,9 +30,10 @@
-(void)toggleSetting:(id)sender
{
if ([self.reuseIdentifier isEqualToString:@"hideContactImages"])
if ([self.reuseIdentifier isEqualToString:@"enableScreenSecurity"])
{
self.state.text = self.toggle.isOn ? @"Yes" : @"No";
[Environment.preferences setScreenSecurity:self.toggle.isOn];
}
}