diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m
index e47e60961..66605e2c4 100644
--- a/Signal/src/AppDelegate.m
+++ b/Signal/src/AppDelegate.m
@@ -28,7 +28,8 @@
@interface AppDelegate ()
-@property (nonatomic, strong) MMDrawerController *drawerController;
+@property (nonatomic, retain) UIWindow *blankWindow;
+@property (nonatomic, strong) MMDrawerController *drawerController;
@property (nonatomic, strong) NotificationTracker *notificationTracker;
@end
@@ -51,11 +52,9 @@
// Migrate from custom preferences to NSUserDefaults
[VersionMigrations migrationFrom1Dot0Dot2toLarger];
}
-
}
}
-
/**
* Protects the preference and logs file with disk encryption and prevents them to leak to iCloud.
*/
@@ -116,6 +115,9 @@
[self protectPreferenceFiles];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+
+ [self prepareScreenshotProtection];
+
self.notificationTracker = [NotificationTracker notificationTracker];
CategorizingLogger* logger = [CategorizingLogger categorizingLogger];
@@ -186,6 +188,7 @@
-(void) applicationDidBecomeActive:(UIApplication *)application {
[[AppAudioManager sharedInstance] awake];
application.applicationIconBadgeNumber = 0;
+ [self removeScreenProtection];
if ([Environment isRegistered]) {
[[PushManager sharedManager] verifyPushActivated];
@@ -193,4 +196,41 @@
}
}
+- (void)applicationWillResignActive:(UIApplication *)application{
+ [self protectScreen];
+}
+
+- (void)prepareScreenshotProtection{
+ self.blankWindow = ({
+ UIWindow *window = [[UIWindow alloc] initWithFrame:self.window.bounds];
+ window.hidden = YES;
+ window.opaque = YES;
+ window.userInteractionEnabled = NO;
+ window.windowLevel = CGFLOAT_MAX;
+ window;
+ });
+}
+
+- (void)protectScreen{
+ if ([[Environment preferences] screenSecurityIsEnabled]) {
+ self.blankWindow.rootViewController = [[UIViewController alloc] init];
+ 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.opaque = YES;
+ [self.blankWindow.rootViewController.view addSubview:imageView];
+ self.blankWindow.hidden = NO;
+ }
+}
+
+- (void)removeScreenProtection{
+ if ([[Environment preferences] screenSecurityIsEnabled]) {
+ self.blankWindow.rootViewController = nil;
+ self.blankWindow.hidden = YES;
+ }
+}
+
@end
diff --git a/Signal/src/environment/PreferencesUtil.h b/Signal/src/environment/PreferencesUtil.h
index a65ca8332..300dc1773 100644
--- a/Signal/src/environment/PreferencesUtil.h
+++ b/Signal/src/environment/PreferencesUtil.h
@@ -28,6 +28,9 @@
-(BOOL)loggingIsEnabled;
-(void)setLoggingEnabled:(BOOL)flag;
+-(BOOL)screenSecurityIsEnabled;
+-(void)setScreenSecurity:(BOOL)flag;
+
-(NSString*)lastRanVersion;
-(NSString*)setAndGetCurrentVersion;
diff --git a/Signal/src/environment/PreferencesUtil.m b/Signal/src/environment/PreferencesUtil.m
index a32f666e7..235a09fd4 100644
--- a/Signal/src/environment/PreferencesUtil.m
+++ b/Signal/src/environment/PreferencesUtil.m
@@ -21,6 +21,7 @@
#define AUTOCORRECT_ENABLED_KEY @"Autocorrect Enabled Key"
#define HISTORY_LOG_ENABLED_KEY @"History Log Enabled Key"
#define PUSH_REVOKED_KEY @"Push Revoked Key"
+#define SCREEN_SECURITY_KEY @"Screen Security Key"
#define DEBUG_IS_ENABLED_KEY @"Debugging Log Enabled Key"
#define kSignalVersionKey @"SignalUpdateVersionKey"
@@ -107,6 +108,19 @@
}
}
+-(BOOL)screenSecurityIsEnabled{
+ NSNumber *preference = [self tryGetValueForKey:SCREEN_SECURITY_KEY];
+ if (preference) {
+ return [preference boolValue];
+ } else{
+ return NO;
+ }
+}
+
+-(void)setScreenSecurity:(BOOL)flag{
+ [self setValueForKey:SCREEN_SECURITY_KEY toValue:[NSNumber numberWithBool:flag]];
+}
+
-(void) setFreshInstallTutorialsEnabled:(BOOL)enabled {
[self setValueForKey:FRESH_INSTALL_TUTORIALS_ENABLED_KEY toValue:[NSNumber numberWithBool:enabled]];
}
@@ -144,5 +158,4 @@
return lastVersion;
}
-
@end
diff --git a/Signal/src/view controllers/SettingsViewController.h b/Signal/src/view controllers/SettingsViewController.h
index 896c1a8e6..304bc522e 100644
--- a/Signal/src/view controllers/SettingsViewController.h
+++ b/Signal/src/view controllers/SettingsViewController.h
@@ -27,11 +27,13 @@
@property (nonatomic, strong) IBOutlet UITableViewCell *disableHistoryCell;
@property (nonatomic, strong) IBOutlet UITableViewCell *clearHistoryLogCell;
@property (nonatomic, strong) IBOutlet UITableViewCell *disableLogsCell;
+@property (nonatomic, strong) IBOutlet UITableViewCell *enableScreenSecurityCell;
@property (nonatomic, strong) IBOutlet UIButton *hideContactImagesButton;
@property (nonatomic, strong) IBOutlet UIButton *disableAutocorrectButton;
@property (nonatomic, strong) IBOutlet UIButton *disableHistoryButton;
@property (nonatomic, strong) IBOutlet UIButton *disableDebugLogsButton;
+@property (nonatomic, strong) IBOutlet UIButton *enableScreenSecurityButton;
@property (nonatomic, strong) IBOutlet UITableViewCell *sendDebugLog;
@@ -46,6 +48,8 @@
- (IBAction)disableLogTapped:(id)sender;
+- (IBAction)enableScreenSecurityTapped:(id)sender;
+
- (IBAction)menuButtonTapped;
@end
diff --git a/Signal/src/view controllers/SettingsViewController.m b/Signal/src/view controllers/SettingsViewController.m
index bc94acebe..f79935302 100644
--- a/Signal/src/view controllers/SettingsViewController.m
+++ b/Signal/src/view controllers/SettingsViewController.m
@@ -97,6 +97,7 @@ static NSString *const CHECKBOX_EMPTY_IMAGE_NAME = @"checkbox_empty";
- (void)configureCheckboxPreferences {
NSArray *buttons = @[_hideContactImagesButton,
+ _enableScreenSecurityButton,
_disableAutocorrectButton,
_disableHistoryButton,
_disableDebugLogsButton];
@@ -108,11 +109,12 @@ static NSString *const CHECKBOX_EMPTY_IMAGE_NAME = @"checkbox_empty";
[button setImage:[UIImage imageNamed:CHECKBOX_CHECKMARK_IMAGE_NAME]
forState:UIControlStateSelected];
}
- PropertyListPreferences *prefs = [Environment preferences];
- _hideContactImagesButton.selected = ![prefs getContactImagesEnabled];
- _disableAutocorrectButton.selected = ![prefs getAutocorrectEnabled];
- _disableHistoryButton.selected = ![prefs getHistoryLogEnabled];
- _disableLogsCell.selected = ![prefs loggingIsEnabled];
+ PropertyListPreferences *prefs = [Environment preferences];
+ _hideContactImagesButton.selected = ![prefs getContactImagesEnabled];
+ _enableScreenSecurityButton.selected = [prefs screenSecurityIsEnabled];
+ _disableAutocorrectButton.selected = ![prefs getAutocorrectEnabled];
+ _disableHistoryButton.selected = ![prefs getHistoryLogEnabled];
+ _disableLogsCell.selected = ![prefs loggingIsEnabled];
}
- (void)configureAllCells {
@@ -134,8 +136,9 @@ static NSString *const CHECKBOX_EMPTY_IMAGE_NAME = @"checkbox_empty";
- (NSArray *)privacyAndSecurityCells {
return @[_hideContactImagesCell,
- _disableAutocorrectCell,
_disableHistoryCell,
+ _disableAutocorrectCell,
+ _enableScreenSecurityCell,
_clearHistoryLogCell];
}
@@ -217,6 +220,11 @@ static NSString *const CHECKBOX_EMPTY_IMAGE_NAME = @"checkbox_empty";
[[Environment preferences] setHistoryLogEnabled:!_disableHistoryButton.selected];
}
+- (IBAction)enableScreenSecurityTapped:(id)sender{
+ _enableScreenSecurityButton.selected = !_enableScreenSecurityButton.selected;
+ [[Environment preferences] setScreenSecurity:_enableScreenSecurityButton.selected];
+}
+
- (IBAction)disableLogTapped:(id)sender{
_disableDebugLogsButton.selected = !_disableDebugLogsButton.selected;
diff --git a/Signal/src/view controllers/xibs/SettingsViewController.xib b/Signal/src/view controllers/xibs/SettingsViewController.xib
index daa92994b..07fa8d031 100644
--- a/Signal/src/view controllers/xibs/SettingsViewController.xib
+++ b/Signal/src/view controllers/xibs/SettingsViewController.xib
@@ -14,6 +14,8 @@
+
+
@@ -442,6 +444,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Signal/test/network/tcp/tls/NetworkStreamTest.m b/Signal/test/network/tcp/tls/NetworkStreamTest.m
index ce2dc7d6a..1dee57682 100644
--- a/Signal/test/network/tcp/tls/NetworkStreamTest.m
+++ b/Signal/test/network/tcp/tls/NetworkStreamTest.m
@@ -112,8 +112,8 @@
instance.secCertificateRef = cert;
SecureEndPoint* e = [SecureEndPoint secureEndPointForHost:[HostNameEndPoint hostNameEndPointWithHostName:TEST_SERVER_HOST andPort:TEST_SERVER_PORT]
- identifiedByCertificate:[Certificate certificateFromResourcePath:TEST_SERVER_INCORRECT_CERT_PATH
- ofType:TEST_SERVER_INCORRECT_CERT_TYPE]];
+ identifiedByCertificate:instance];
+
NetworkStream* s = [NetworkStream networkStreamToEndPoint:e];
__block bool terminated = false;
diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings
index 31e85d61b..fc3095b3f 100644
--- a/Signal/translations/en.lproj/Localizable.strings
+++ b/Signal/translations/en.lproj/Localizable.strings
@@ -121,6 +121,7 @@
"SETTINGS_RINGTONE" = "Ringtone";
"SETTINGS_DEBUGGING" = "Debugging";
"SETTINGS_DISABLE_LOGS" = "Disable debugging logs";
+"SETTINGS_SCREEN_SECURITY" = "Enable Screen Security";
"SETTINGS_SENDLOG" = "Submit Debug Log";
"SETTINGS_SENDLOGS_WAITING" = "Sending log file\n Please wait...";
"SETTINGS_SENDLOG_ALERT_BODY" = "Bugs can be reported by email or by copying the log in a GitHub Issue (advanced).";