code cleanup
- refactor screen protection code for clarity - remove unused settings cell class - remove unused preferences // FREEBIE
This commit is contained in:
parent
006c4ba958
commit
58548c68cc
|
@ -452,7 +452,6 @@
|
|||
FCAC963C19FEF9280046DFC5 /* SignalsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAC963B19FEF9280046DFC5 /* SignalsViewController.m */; };
|
||||
FCAC964019FEF99A0046DFC5 /* InboxTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAC963E19FEF99A0046DFC5 /* InboxTableViewCell.m */; };
|
||||
FCAC965119FF0A6E0046DFC5 /* MessagesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAC965019FF0A6E0046DFC5 /* MessagesViewController.m */; settings = {COMPILER_FLAGS = "-Wno-receiver-is-weak"; }; };
|
||||
FCB11D8A1A1284BB002F93FB /* SettingsTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = FCB11D891A1284BB002F93FB /* SettingsTableViewCell.m */; };
|
||||
FCB11D8C1A129A76002F93FB /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FCB11D8B1A129A76002F93FB /* CoreMedia.framework */; };
|
||||
FCB11D931A12A4AA002F93FB /* FullImageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCB11D921A12A4AA002F93FB /* FullImageViewController.m */; };
|
||||
FCC81A981A44558300DFEC7D /* UIDevice+TSHardwareVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = FCC81A971A44558300DFEC7D /* UIDevice+TSHardwareVersion.m */; };
|
||||
|
@ -1034,8 +1033,6 @@
|
|||
FCAC963E19FEF99A0046DFC5 /* InboxTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InboxTableViewCell.m; path = "../view controllers/InboxTableViewCell.m"; sourceTree = "<group>"; };
|
||||
FCAC964F19FF0A6E0046DFC5 /* MessagesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessagesViewController.h; sourceTree = "<group>"; };
|
||||
FCAC965019FF0A6E0046DFC5 /* MessagesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessagesViewController.m; sourceTree = "<group>"; };
|
||||
FCB11D881A1284BB002F93FB /* SettingsTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SettingsTableViewCell.h; path = "../view controllers/SettingsTableViewCell.h"; sourceTree = "<group>"; };
|
||||
FCB11D891A1284BB002F93FB /* SettingsTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SettingsTableViewCell.m; path = "../view controllers/SettingsTableViewCell.m"; sourceTree = "<group>"; };
|
||||
FCB11D8B1A129A76002F93FB /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
|
||||
FCB11D911A12A4AA002F93FB /* FullImageViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullImageViewController.h; sourceTree = "<group>"; };
|
||||
FCB11D921A12A4AA002F93FB /* FullImageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FullImageViewController.m; sourceTree = "<group>"; };
|
||||
|
@ -1699,8 +1696,6 @@
|
|||
A5509ECC1A69B1D600ABA4BC /* CountryCodeTableViewCell.m */,
|
||||
FCAC963D19FEF99A0046DFC5 /* InboxTableViewCell.h */,
|
||||
FCAC963E19FEF99A0046DFC5 /* InboxTableViewCell.m */,
|
||||
FCB11D881A1284BB002F93FB /* SettingsTableViewCell.h */,
|
||||
FCB11D891A1284BB002F93FB /* SettingsTableViewCell.m */,
|
||||
76EB052E18170B33006006FC /* ContactTableViewCell.h */,
|
||||
76EB052F18170B33006006FC /* ContactTableViewCell.m */,
|
||||
76EB053818170B33006006FC /* xibs */,
|
||||
|
@ -2760,7 +2755,6 @@
|
|||
B68EF9BA1C0B1EBD009C3DCD /* FLAnimatedImage.m in Sources */,
|
||||
B68112EA1A4D9EC400BA82FF /* UIImage+normalizeImage.m in Sources */,
|
||||
B609597C1C2C0FC6004E8797 /* iRate.m in Sources */,
|
||||
FCB11D8A1A1284BB002F93FB /* SettingsTableViewCell.m in Sources */,
|
||||
76EB05C818170B33006006FC /* HelloPacket.m in Sources */,
|
||||
BFB074C719A5611000F2947C /* FutureUtil.m in Sources */,
|
||||
FCD274E21A5AFD8000202277 /* PrivacySettingsTableViewController.m in Sources */,
|
||||
|
|
|
@ -23,7 +23,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@property (nonatomic, retain) UIWindow *blankWindow;
|
||||
@property (nonatomic, retain) UIWindow *screenProtectionWindow;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -93,7 +93,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
[self application:application didReceiveRemoteNotification:remoteNotif];
|
||||
}
|
||||
|
||||
[self prepareScreenshotProtection];
|
||||
[self prepareScreenProtection];
|
||||
|
||||
if ([TSAccountManager isRegistered]) {
|
||||
if (application.applicationState == UIApplicationStateInactive) {
|
||||
|
@ -229,31 +229,32 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
|||
}
|
||||
}
|
||||
|
||||
- (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.backgroundColor = UIColor.ows_materialBlueColor;
|
||||
/**
|
||||
* Screen protection obscures the app screen shown in the app switcher.
|
||||
*/
|
||||
- (void)prepareScreenProtection
|
||||
{
|
||||
UIWindow *window = [[UIWindow alloc] initWithFrame:self.window.bounds];
|
||||
window.hidden = YES;
|
||||
window.opaque = YES;
|
||||
window.userInteractionEnabled = NO;
|
||||
window.windowLevel = CGFLOAT_MAX;
|
||||
window.backgroundColor = UIColor.ows_materialBlueColor;
|
||||
window.rootViewController =
|
||||
[[UIStoryboard storyboardWithName:@"Launch Screen" bundle:nil] instantiateInitialViewController];
|
||||
|
||||
UIViewController *vc = [[UIStoryboard storyboardWithName:@"Launch Screen" bundle:nil] instantiateInitialViewController];
|
||||
|
||||
window.rootViewController = vc;
|
||||
window;
|
||||
});
|
||||
self.screenProtectionWindow = window;
|
||||
}
|
||||
|
||||
- (void)protectScreen {
|
||||
if (Environment.preferences.screenSecurityIsEnabled) {
|
||||
self.blankWindow.hidden = NO;
|
||||
self.screenProtectionWindow.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)removeScreenProtection {
|
||||
if (Environment.preferences.screenSecurityIsEnabled) {
|
||||
self.blankWindow.hidden = YES;
|
||||
self.screenProtectionWindow.hidden = YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import "PropertyListPreferences.h"
|
||||
#import "Zid.h"
|
||||
|
||||
typedef NS_ENUM(NSUInteger, NotificationType) {
|
||||
NotificationNoNameNoPreview,
|
||||
|
@ -45,10 +43,8 @@ typedef NS_ENUM(NSUInteger, TSImageQuality) {
|
|||
- (void)setHasRegisteredVOIPPush:(BOOL)enabled;
|
||||
|
||||
- (TSImageQuality)imageUploadQuality;
|
||||
- (void)setImageUploadQuality:(TSImageQuality)quality;
|
||||
|
||||
- (NSString *)lastRanVersion;
|
||||
- (NSString *)setAndGetCurrentVersion;
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -2,23 +2,12 @@
|
|||
#import "PreferencesUtil.h"
|
||||
|
||||
#define CALL_STREAM_DES_BUFFER_LEVEL_KEY @"CallStreamDesiredBufferLevel"
|
||||
|
||||
|
||||
#define DEFAULT_CALL_STREAM_DES_BUFFER_LEVEL 0.5
|
||||
|
||||
#define SETTINGS_EXPANDED_ROW_PREF_DICT_KEY @"Settings Expanded Row Pref Dict Key"
|
||||
|
||||
#define FRESH_INSTALL_TUTORIALS_ENABLED_KEY @"Fresh Install Tutorials Enabled Key"
|
||||
#define CONTACT_IMAGES_ENABLED_KEY @"Contact Images Enabled Key"
|
||||
#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 NOTIFICATION_PREVIEW_TYPE_KEY @"Notification Preview Type Key"
|
||||
#define IMAGE_UPLOAD_QUALITY_KEY @"Image Upload Quality Key"
|
||||
#define HAS_SENT_A_MESSAGE_KEY @"User has sent a message"
|
||||
#define HAS_ARCHIVED_A_MESSAGE_KEY @"User archived a message"
|
||||
#define HAS_SENT_A_MESSAGE_KEY @"User has sent a message" // TODO remove?
|
||||
#define HAS_ARCHIVED_A_MESSAGE_KEY @"User archived a message" // TODO remove?
|
||||
#define kSignalVersionKey @"SignalUpdateVersionKey"
|
||||
#define PLAY_SOUND_IN_FOREGROUND_KEY @"NotificationSoundInForeground"
|
||||
#define HAS_REGISTERED_VOIP_PUSH @"VOIPPushEnabled"
|
||||
|
@ -31,44 +20,12 @@
|
|||
return DEFAULT_CALL_STREAM_DES_BUFFER_LEVEL;
|
||||
return [v doubleValue];
|
||||
}
|
||||
|
||||
- (void)setCachedDesiredBufferDepth:(double)value {
|
||||
ows_require(value >= 0);
|
||||
[self setValueForKey:CALL_STREAM_DES_BUFFER_LEVEL_KEY toValue:@(value)];
|
||||
}
|
||||
|
||||
- (BOOL)getFreshInstallTutorialsEnabled {
|
||||
NSNumber *preference = [self tryGetValueForKey:FRESH_INSTALL_TUTORIALS_ENABLED_KEY];
|
||||
if (preference) {
|
||||
return [preference boolValue];
|
||||
} else {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
- (BOOL)getContactImagesEnabled {
|
||||
NSNumber *preference = [self tryGetValueForKey:CONTACT_IMAGES_ENABLED_KEY];
|
||||
if (preference) {
|
||||
return [preference boolValue];
|
||||
} else {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
- (BOOL)getAutocorrectEnabled {
|
||||
NSNumber *preference = [self tryGetValueForKey:AUTOCORRECT_ENABLED_KEY];
|
||||
if (preference) {
|
||||
return [preference boolValue];
|
||||
} else {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
- (BOOL)getHistoryLogEnabled {
|
||||
NSNumber *preference = [self tryGetValueForKey:HISTORY_LOG_ENABLED_KEY];
|
||||
if (preference) {
|
||||
return [preference boolValue];
|
||||
} else {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)loggingIsEnabled {
|
||||
NSNumber *preference = [self tryGetValueForKey:DEBUG_IS_ENABLED_KEY];
|
||||
if (preference) {
|
||||
|
@ -119,39 +76,15 @@
|
|||
return TSImageQualityMedium;
|
||||
}
|
||||
|
||||
- (void)setImageUploadQuality:(TSImageQuality)quality {
|
||||
[self setValueForKey:IMAGE_UPLOAD_QUALITY_KEY toValue:@(quality)];
|
||||
}
|
||||
|
||||
- (void)setScreenSecurity:(BOOL)flag {
|
||||
- (void)setScreenSecurity:(BOOL)flag
|
||||
{
|
||||
[self setValueForKey:SCREEN_SECURITY_KEY toValue:@(flag)];
|
||||
}
|
||||
|
||||
- (void)setFreshInstallTutorialsEnabled:(BOOL)enabled {
|
||||
[self setValueForKey:FRESH_INSTALL_TUTORIALS_ENABLED_KEY toValue:@(enabled)];
|
||||
}
|
||||
|
||||
- (void)setHasRegisteredVOIPPush:(BOOL)enabled {
|
||||
[self setValueForKey:HAS_REGISTERED_VOIP_PUSH toValue:@(enabled)];
|
||||
}
|
||||
|
||||
- (void)setContactImagesEnabled:(BOOL)enabled {
|
||||
[self setValueForKey:CONTACT_IMAGES_ENABLED_KEY toValue:@(enabled)];
|
||||
}
|
||||
- (void)setAutocorrectEnabled:(BOOL)enabled {
|
||||
[self setValueForKey:AUTOCORRECT_ENABLED_KEY toValue:@(enabled)];
|
||||
}
|
||||
- (void)setHistoryLogEnabled:(BOOL)enabled {
|
||||
[self setValueForKey:HISTORY_LOG_ENABLED_KEY toValue:@(enabled)];
|
||||
}
|
||||
|
||||
- (BOOL)encounteredRevokedPushPermission {
|
||||
return [[self tryGetValueForKey:PUSH_REVOKED_KEY] boolValue];
|
||||
}
|
||||
- (void)setRevokedPushPermission:(BOOL)revoked {
|
||||
[self setValueForKey:PUSH_REVOKED_KEY toValue:@(revoked)];
|
||||
}
|
||||
|
||||
- (void)setLoggingEnabled:(BOOL)flag {
|
||||
[self setValueForKey:DEBUG_IS_ENABLED_KEY toValue:@(flag)];
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface PropertyListPreferences : NSObject
|
||||
|
||||
- (id)tryGetValueForKey:(NSString *)key;
|
||||
- (void)setValueForKey:(NSString *)key toValue:(id)value;
|
||||
- (id)adjustAndTryGetNewValueForKey:(NSString *)key afterAdjuster:(id (^)(id oldValue))adjuster;
|
||||
- (void)clear;
|
||||
|
||||
@end
|
||||
|
|
|
@ -18,20 +18,12 @@
|
|||
ows_require(key != nil);
|
||||
return [TSStorageManager.sharedManager objectForKey:key inCollection:SignalDatabaseCollection];
|
||||
}
|
||||
|
||||
- (void)setValueForKey:(NSString *)key toValue:(id)value {
|
||||
ows_require(key != nil);
|
||||
|
||||
[TSStorageManager.sharedManager setObject:value forKey:key inCollection:SignalDatabaseCollection];
|
||||
}
|
||||
- (id)adjustAndTryGetNewValueForKey:(NSString *)key afterAdjuster:(id (^)(id))adjuster {
|
||||
ows_require(key != nil);
|
||||
ows_require(adjuster != nil);
|
||||
@synchronized(self) {
|
||||
id oldValue = [self tryGetValueForKey:key];
|
||||
id newValue = adjuster(oldValue);
|
||||
[self setValueForKey:key toValue:newValue];
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
//
|
||||
// SettingsTableViewCell.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Dylan Bourgeois on 11/11/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface SettingsTableViewCell : UITableViewCell
|
||||
|
||||
- (void)updateImageQualityLabel;
|
||||
|
||||
// Optionals
|
||||
@property (nonatomic, strong) IBOutlet UISwitch *toggle;
|
||||
@property (nonatomic, strong) IBOutlet UILabel *detailLabel;
|
||||
|
||||
@end
|
|
@ -1,65 +0,0 @@
|
|||
//
|
||||
// SettingsTableViewCell.m
|
||||
// Signal
|
||||
//
|
||||
// Created by Dylan Bourgeois on 11/11/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SettingsTableViewCell.h"
|
||||
|
||||
#import "Environment.h"
|
||||
#import "PreferencesUtil.h"
|
||||
|
||||
@implementation SettingsTableViewCell
|
||||
|
||||
- (void)awakeFromNib {
|
||||
if (self.toggle) {
|
||||
[self.toggle setOn:[Environment.preferences screenSecurityIsEnabled]];
|
||||
[self.toggle addTarget:self action:@selector(toggleSetting:) forControlEvents:UIControlEventValueChanged];
|
||||
}
|
||||
|
||||
if ([self.reuseIdentifier isEqualToString:@"imageUploadQuality"]) {
|
||||
[self updateImageQualityLabel];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
[super setSelected:selected animated:animated];
|
||||
}
|
||||
|
||||
#pragma mark - UISwitch
|
||||
|
||||
- (void)toggleSetting:(id)sender {
|
||||
if ([self.reuseIdentifier isEqualToString:@"enableScreenSecurity"]) {
|
||||
[Environment.preferences setScreenSecurity:self.toggle.isOn];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Detail Label
|
||||
|
||||
- (void)updateImageQualityLabel {
|
||||
/* this is currently unused, thus unlocalized. code should probably be excised as this will never be part of design
|
||||
*/
|
||||
switch ([Environment.preferences imageUploadQuality]) {
|
||||
case TSImageQualityUncropped:
|
||||
self.detailLabel.text = @"Full";
|
||||
break;
|
||||
case TSImageQualityHigh:
|
||||
self.detailLabel.text = @"High";
|
||||
break;
|
||||
case TSImageQualityMedium:
|
||||
self.detailLabel.text = @"Medium";
|
||||
break;
|
||||
case TSImageQualityLow:
|
||||
self.detailLabel.text = @"Low";
|
||||
break;
|
||||
default:
|
||||
DDLogWarn(@"Unknown Image Quality setting : %lu <%s>",
|
||||
(unsigned long)[Environment.preferences imageUploadQuality],
|
||||
__PRETTY_FUNCTION__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -491,11 +491,13 @@ static NSString *const kShowSignupFlowSegue = @"showSignupFlow";
|
|||
firstLine = NSLocalizedString(@"EMPTY_INBOX_FIRST_TITLE", @"");
|
||||
secondLine = NSLocalizedString(@"EMPTY_INBOX_FIRST_TEXT", @"");
|
||||
} else {
|
||||
// FIXME This looks wrong. Shouldn't we be showing inbox_title/text here?
|
||||
firstLine = NSLocalizedString(@"EMPTY_ARCHIVE_FIRST_TITLE", @"");
|
||||
secondLine = NSLocalizedString(@"EMPTY_ARCHIVE_FIRST_TEXT", @"");
|
||||
}
|
||||
} else {
|
||||
if ([Environment.preferences getHasArchivedAMessage]) {
|
||||
// FIXME This looks wrong. Shouldn't we be showing first_archive_title/text here?
|
||||
firstLine = NSLocalizedString(@"EMPTY_INBOX_TITLE", @"");
|
||||
secondLine = NSLocalizedString(@"EMPTY_INBOX_TEXT", @"");
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue