Screen security feature. Closes #31

pull/1/head
Frederic Jacobs 11 years ago
parent f5bbf9d480
commit 619b53cb0b

@ -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

@ -28,6 +28,9 @@
-(BOOL)loggingIsEnabled;
-(void)setLoggingEnabled:(BOOL)flag;
-(BOOL)screenSecurityIsEnabled;
-(void)setScreenSecurity:(BOOL)flag;
-(NSString*)lastRanVersion;
-(NSString*)setAndGetCurrentVersion;

@ -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

@ -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

@ -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;

@ -14,6 +14,8 @@
<outlet property="disableHistoryButton" destination="trw-DG-amf" id="97O-Y4-iu3"/>
<outlet property="disableHistoryCell" destination="5Wr-Th-YJI" id="fQY-Qd-xv0"/>
<outlet property="disableLogsCell" destination="Zs4-3i-4Dm" id="eeD-Br-M2J"/>
<outlet property="enableScreenSecurityButton" destination="Lv5-XS-B3n" id="XlL-nk-Hbh"/>
<outlet property="enableScreenSecurityCell" destination="9qY-qg-UWw" id="RPW-Fn-NdF"/>
<outlet property="hideContactImagesButton" destination="kv5-cc-It9" id="Ftz-lp-Eqd"/>
<outlet property="hideContactImagesCell" destination="1Sy-9w-LqE" id="Rvh-96-REp"/>
<outlet property="phoneNumberLabel" destination="G77-lz-XM0" id="adE-bu-2Kn"/>
@ -442,6 +444,56 @@
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="SettingsTableViewCell" id="9qY-qg-UWw">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="9qY-qg-UWw" id="Sh2-R0-QWn">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Enable Screen Security" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uVg-2E-0e2" customClass="HelveticaNeueLTStdMedLabel">
<rect key="frame" x="20" y="0.0" width="223" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="Ajf-ml-YgK"/>
<constraint firstAttribute="width" constant="223" id="dLp-oG-7LG"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizationKey" value="SETTINGS_SCREEN_SECURITY"/>
</userDefinedRuntimeAttributes>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iml-Q7-4vG" userLabel="Seperator View">
<rect key="frame" x="15" y="42" width="290" height="1"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.7843137255" green="0.7843137255" blue="0.7843137255" alpha="1" colorSpace="calibratedRGB"/>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Lv5-XS-B3n">
<rect key="frame" x="265" y="2" width="40" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" image="checkbox_empty.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="enableScreenSecurityTapped:" destination="-1" eventType="touchUpInside" id="72r-h1-KkU"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="iml-Q7-4vG" firstAttribute="leading" secondItem="Sh2-R0-QWn" secondAttribute="leading" constant="15" id="2f5-sg-LO5"/>
<constraint firstItem="iml-Q7-4vG" firstAttribute="top" secondItem="Sh2-R0-QWn" secondAttribute="top" constant="42" id="BwK-BP-uRz"/>
<constraint firstItem="uVg-2E-0e2" firstAttribute="bottom" secondItem="iml-Q7-4vG" secondAttribute="bottom" constant="1" id="EEe-s7-X3t"/>
<constraint firstItem="Lv5-XS-B3n" firstAttribute="top" secondItem="Sh2-R0-QWn" secondAttribute="top" constant="2" id="Io9-sI-ubP"/>
<constraint firstItem="Lv5-XS-B3n" firstAttribute="leading" secondItem="uVg-2E-0e2" secondAttribute="trailing" constant="22" id="MyM-rR-ZRq"/>
<constraint firstItem="uVg-2E-0e2" firstAttribute="top" secondItem="Sh2-R0-QWn" secondAttribute="top" id="PLq-lf-BQ3"/>
<constraint firstItem="iml-Q7-4vG" firstAttribute="trailing" secondItem="Lv5-XS-B3n" secondAttribute="trailing" id="T83-en-yfE"/>
<constraint firstItem="uVg-2E-0e2" firstAttribute="leading" secondItem="Sh2-R0-QWn" secondAttribute="leading" constant="20" symbolic="YES" id="fiZ-5C-Nqu"/>
<constraint firstItem="iml-Q7-4vG" firstAttribute="top" secondItem="Lv5-XS-B3n" secondAttribute="bottom" id="hfU-ah-Tbb"/>
<constraint firstItem="iml-Q7-4vG" firstAttribute="centerX" secondItem="Sh2-R0-QWn" secondAttribute="centerX" id="zYo-ei-1Yu"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</objects>
<resources>
<image name="checkbox_empty.png" width="19" height="19"/>

@ -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;

@ -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).";

Loading…
Cancel
Save