From 871dca41388331ae498c2713b4bc1ab43b702c5a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 22 Mar 2018 16:16:48 -0400 Subject: [PATCH] Refine 'Screen Lock'. --- .../PrivacySettingsTableViewController.m | 12 ++++-------- Signal/src/util/OWSScreenLock.swift | 13 +++++-------- Signal/src/util/OWSScreenLockUI.m | 5 ++--- Signal/translations/en.lproj/Localizable.strings | 2 +- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m index 00b3f119f..bbc694e27 100644 --- a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m @@ -111,14 +111,10 @@ NS_ASSUME_NONNULL_BEGIN OWSTableSection *screenSecuritySection = [OWSTableSection new]; screenSecuritySection.headerTitle = NSLocalizedString(@"SETTINGS_SECURITY_TITLE", @"Section header"); screenSecuritySection.footerTitle = NSLocalizedString(@"SETTINGS_SCREEN_SECURITY_DETAIL", nil); - [screenSecuritySection - addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_SCREEN_SECURITY", @"") - // If 'Screen Lock' is enabled, 'Screen Protection' is auto-enabled. - isOn:([Environment.preferences screenSecurityIsEnabled] - || OWSScreenLock.sharedManager.isScreenLockEnabled) - isEnabled:!OWSScreenLock.sharedManager.isScreenLockEnabled - target:weakSelf - selector:@selector(didToggleScreenSecuritySwitch:)]]; + [screenSecuritySection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_SCREEN_SECURITY", @"") + isOn:[Environment.preferences screenSecurityIsEnabled] + target:weakSelf + selector:@selector(didToggleScreenSecuritySwitch:)]]; [contents addSection:screenSecuritySection]; OWSTableSection *removeMetadataSection = [OWSTableSection new]; diff --git a/Signal/src/util/OWSScreenLock.swift b/Signal/src/util/OWSScreenLock.swift index a2317a696..fffe6de24 100644 --- a/Signal/src/util/OWSScreenLock.swift +++ b/Signal/src/util/OWSScreenLock.swift @@ -10,18 +10,16 @@ import LocalAuthentication public enum OWSScreenLockOutcome { case success case cancel -// case userCancel -// case otherCancel case failure(error:String) -// case permanentFailure(error:String) } + @objc public let screenLockTimeoutDefault = 15 * kMinuteInterval @objc public let screenLockTimeouts = [ - 5 * kSecondInterval, - 15 * kSecondInterval, - 30 * kSecondInterval, 1 * kMinuteInterval, 5 * kMinuteInterval, + 15 * kMinuteInterval, + 30 * kMinuteInterval, + 1 * kHourInterval, 0 ] @@ -78,8 +76,7 @@ import LocalAuthentication return 0 } - let defaultTimeout = screenLockTimeouts[0] - return self.dbConnection.double(forKey: OWSScreenLock_Key_ScreenLockTimeoutSeconds, inCollection: OWSScreenLock_Collection, defaultValue: defaultTimeout) + return self.dbConnection.double(forKey: OWSScreenLock_Key_ScreenLockTimeoutSeconds, inCollection: OWSScreenLock_Collection, defaultValue: screenLockTimeoutDefault) } @objc public func setScreenLockTimeout(_ value: TimeInterval) { diff --git a/Signal/src/util/OWSScreenLockUI.m b/Signal/src/util/OWSScreenLockUI.m index 85049f93b..d0e26d611 100644 --- a/Signal/src/util/OWSScreenLockUI.m +++ b/Signal/src/util/OWSScreenLockUI.m @@ -147,9 +147,8 @@ NS_ASSUME_NONNULL_BEGIN // Show 'Screen Protection' if: // // * App is inactive and... - // * Either 'Screen Protection' or 'Screen Lock' is enabled. - BOOL shouldHaveScreenProtection = (self.appIsInactive - && (Environment.preferences.screenSecurityIsEnabled || OWSScreenLock.sharedManager.isScreenLockEnabled)); + // * 'Screen Protection' is enabled. + BOOL shouldHaveScreenProtection = (self.appIsInactive && Environment.preferences.screenSecurityIsEnabled); BOOL shouldShowBlockWindow = shouldHaveScreenProtection || shouldHaveScreenLock; DDLogVerbose(@"%@, shouldHaveScreenProtection: %d, shouldHaveScreenLock: %d, shouldShowBlockWindow: %d", diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 72d3657cf..e62085a68 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1538,7 +1538,7 @@ "SCAN_QR_CODE_VIEW_TITLE" = "Scan QR Code"; /* Indicates a delay of zero seconds, and that 'screen lock activity' will timeout immediately. */ -"SCREEN_LOCK_ACTIVITY_TIMEOUT_NONE" = "None"; +"SCREEN_LOCK_ACTIVITY_TIMEOUT_NONE" = "Instant"; /* Title for alert indicating that screen lock could not be disabled. */ "SCREEN_LOCK_DISABLE_FAILED" = "Screen Lock Could Not Be Disabled";