extract dependencies, no change in behavior

pull/1/head
Michael Kirk 7 years ago
parent c680908646
commit 221ce513f1

@ -56,6 +56,11 @@ NS_ASSUME_NONNULL_BEGIN
return SSKEnvironment.shared.udManager;
}
- (OWSPreferences *)preferences
{
return Environment.shared.preferences;
}
#pragma mark - Table Contents
- (void)updateTableContents
@ -121,11 +126,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", @"")
isOn:[Environment.shared.preferences screenSecurityIsEnabled]
target:weakSelf
selector:@selector(didToggleScreenSecuritySwitch:)]];
[screenSecuritySection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_SCREEN_SECURITY", @"")
isOn:[self.preferences screenSecurityIsEnabled]
target:weakSelf
selector:@selector(didToggleScreenSecuritySwitch:)]];
[contents addSection:screenSecuritySection];
// Allow calls to connect directly vs. using TURN exclusively
@ -137,7 +141,7 @@ NS_ASSUME_NONNULL_BEGIN
[callingSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(
@"SETTINGS_CALLING_HIDES_IP_ADDRESS_PREFERENCE_TITLE",
@"Table cell label")
isOn:[Environment.shared.preferences doCallsHideIPAddress]
isOn:[self.preferences doCallsHideIPAddress]
target:weakSelf
selector:@selector(didToggleCallsHideIPAddressSwitch:)]];
[contents addSection:callingSection];
@ -148,7 +152,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(
@"SETTINGS_PRIVACY_CALLKIT_SYSTEM_CALL_LOG_PREFERENCE_TITLE",
@"Short table cell label")
isOn:[Environment.shared.preferences isSystemCallLogEnabled]
isOn:[self.preferences isSystemCallLogEnabled]
target:weakSelf
selector:@selector(didToggleEnableSystemCallLogSwitch:)]];
callKitSection.footerTitle = NSLocalizedString(
@ -160,14 +164,14 @@ NS_ASSUME_NONNULL_BEGIN
= NSLocalizedString(@"SETTINGS_SECTION_CALL_KIT_DESCRIPTION", @"Settings table section footer.");
[callKitSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_PRIVACY_CALLKIT_TITLE",
@"Short table cell label")
isOn:[Environment.shared.preferences isCallKitEnabled]
isOn:[self.preferences isCallKitEnabled]
target:weakSelf
selector:@selector(didToggleEnableCallKitSwitch:)]];
if (Environment.shared.preferences.isCallKitEnabled) {
if (self.preferences.isCallKitEnabled) {
[callKitSection
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_PRIVACY_CALLKIT_PRIVACY_TITLE",
@"Label for 'CallKit privacy' preference")
isOn:![Environment.shared.preferences isCallKitPrivacyEnabled]
isOn:![self.preferences isCallKitPrivacyEnabled]
target:weakSelf
selector:@selector(didToggleEnableCallKitPrivacySwitch:)]];
}
@ -259,7 +263,7 @@ NS_ASSUME_NONNULL_BEGIN
{
BOOL enabled = sender.isOn;
OWSLogInfo(@"toggled screen security: %@", enabled ? @"ON" : @"OFF");
[Environment.shared.preferences setScreenSecurity:enabled];
[self.preferences setScreenSecurity:enabled];
}
- (void)didToggleReadReceiptsSwitch:(UISwitch *)sender
@ -273,13 +277,13 @@ NS_ASSUME_NONNULL_BEGIN
{
BOOL enabled = sender.isOn;
OWSLogInfo(@"toggled callsHideIPAddress: %@", enabled ? @"ON" : @"OFF");
[Environment.shared.preferences setDoCallsHideIPAddress:enabled];
[self.preferences setDoCallsHideIPAddress:enabled];
}
- (void)didToggleEnableSystemCallLogSwitch:(UISwitch *)sender
{
OWSLogInfo(@"user toggled call kit preference: %@", (sender.isOn ? @"ON" : @"OFF"));
[Environment.shared.preferences setIsSystemCallLogEnabled:sender.isOn];
[self.preferences setIsSystemCallLogEnabled:sender.isOn];
// rebuild callUIAdapter since CallKit configuration changed.
[SignalApp.sharedApp.callService createCallUIAdapter];
@ -288,7 +292,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)didToggleEnableCallKitSwitch:(UISwitch *)sender
{
OWSLogInfo(@"user toggled call kit preference: %@", (sender.isOn ? @"ON" : @"OFF"));
[Environment.shared.preferences setIsCallKitEnabled:sender.isOn];
[self.preferences setIsCallKitEnabled:sender.isOn];
// rebuild callUIAdapter since CallKit vs not changed.
[SignalApp.sharedApp.callService createCallUIAdapter];
@ -300,7 +304,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)didToggleEnableCallKitPrivacySwitch:(UISwitch *)sender
{
OWSLogInfo(@"user toggled call kit privacy preference: %@", (sender.isOn ? @"ON" : @"OFF"));
[Environment.shared.preferences setIsCallKitPrivacyEnabled:!sender.isOn];
[self.preferences setIsCallKitPrivacyEnabled:!sender.isOn];
// rebuild callUIAdapter since CallKit configuration changed.
[SignalApp.sharedApp.callService createCallUIAdapter];

@ -16,8 +16,6 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
// MARK: Properties
let contactsManager: OWSContactsManager
let uiDatabaseConnection: YapDatabaseConnection
var bubbleView: UIView?
@ -41,7 +39,13 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
var conversationStyle: ConversationStyle
private var contactShareViewHelper: ContactShareViewHelper
private var contactShareViewHelper: ContactShareViewHelper!
// MARK: Dependencies
var contactsManager: OWSContactsManager {
return Environment.shared.contactsManager
}
// MARK: Initializers
@ -52,23 +56,21 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
@objc
required init(viewItem: ConversationViewItem, message: TSMessage, thread: TSThread, mode: MessageMetadataViewMode) {
self.contactsManager = Environment.shared.contactsManager
self.viewItem = viewItem
self.message = message
self.mode = mode
self.uiDatabaseConnection = OWSPrimaryStorage.shared().newDatabaseConnection()
self.contactShareViewHelper = ContactShareViewHelper(contactsManager: contactsManager)
self.conversationStyle = ConversationStyle(thread: thread)
super.init(nibName: nil, bundle: nil)
contactShareViewHelper.delegate = self
}
// MARK: View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.contactShareViewHelper = ContactShareViewHelper(contactsManager: contactsManager)
contactShareViewHelper.delegate = self
self.uiDatabaseConnection.beginLongLivedReadTransaction()
updateDBConnectionAndMessageToLatest()
@ -191,7 +193,6 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
}
var rows = [UIView]()
let contactsManager = Environment.shared.contactsManager!
// Content
rows += contentRows()
@ -291,7 +292,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
sentRow.addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(didLongPressSent)))
rows.append(sentRow)
if message as? TSIncomingMessage != nil {
if message is TSIncomingMessage {
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_RECEIVED_DATE_TIME",
comment: "Label for the 'received date & time' field of the 'message metadata' view."),
value: DateUtil.formatPastTimestampRelativeToNow(message.timestampForSorting())))

Loading…
Cancel
Save