Merge branch 'charlesmchen/linkPreviewsPreference'
This commit is contained in:
commit
186e4e14d2
2
Pods
2
Pods
@ -1 +1 @@
|
||||
Subproject commit 8b2c886d38cb286341dad31a83ba59a25c30879f
|
||||
Subproject commit 6438a8ea501bb83f12c4224fd87dd9491319fc3e
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PrivacySettingsTableViewController.h"
|
||||
@ -309,6 +309,17 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
|
||||
}]];
|
||||
[contents addSection:unidentifiedDeliveryLearnMoreSection];
|
||||
|
||||
OWSTableSection *linkPreviewsSection = [OWSTableSection new];
|
||||
[linkPreviewsSection
|
||||
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_LINK_PREVIEWS",
|
||||
@"Setting for enabling & disabling link previews.")
|
||||
isOn:SSKPreferences.areLinkPreviewsEnabled
|
||||
target:weakSelf
|
||||
selector:@selector(didToggleLinkPreviewsEnabled:)]];
|
||||
linkPreviewsSection.headerTitle
|
||||
= NSLocalizedString(@"SETTINGS_LINK_PREVIEWS", @"Setting for enabling & disabling link previews.");
|
||||
[contents addSection:linkPreviewsSection];
|
||||
|
||||
self.contents = contents;
|
||||
}
|
||||
|
||||
@ -417,6 +428,12 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
|
||||
[self.preferences setShouldShowUnidentifiedDeliveryIndicators:sender.isOn];
|
||||
}
|
||||
|
||||
- (void)didToggleLinkPreviewsEnabled:(UISwitch *)sender
|
||||
{
|
||||
OWSLogInfo(@"toggled to: %@", (sender.isOn ? @"ON" : @"OFF"));
|
||||
[SSKPreferences setAreLinkPreviewsEnabledWithValue:sender.isOn];
|
||||
}
|
||||
|
||||
- (void)show2FASettings
|
||||
{
|
||||
OWSLogInfo(@"");
|
||||
|
||||
@ -2090,6 +2090,9 @@
|
||||
/* table cell label */
|
||||
"SETTINGS_LEGAL_TERMS_CELL" = "Terms & Privacy Policy";
|
||||
|
||||
/* Setting for enabling & disabling link previews. */
|
||||
"SETTINGS_LINK_PREVIEWS" = "Link Previews";
|
||||
|
||||
/* Title for settings activity */
|
||||
"SETTINGS_NAV_BAR_TITLE" = "Settings";
|
||||
|
||||
|
||||
@ -101,6 +101,9 @@ public class OWSLinkPreview: MTLModel {
|
||||
guard OWSLinkPreview.featureEnabled else {
|
||||
throw LinkPreviewError.noPreview
|
||||
}
|
||||
guard SSKPreferences.areLinkPreviewsEnabled() else {
|
||||
throw LinkPreviewError.noPreview
|
||||
}
|
||||
guard let previewProto = dataMessage.preview.first else {
|
||||
throw LinkPreviewError.noPreview
|
||||
}
|
||||
@ -162,6 +165,9 @@ public class OWSLinkPreview: MTLModel {
|
||||
guard OWSLinkPreview.featureEnabled else {
|
||||
throw LinkPreviewError.noPreview
|
||||
}
|
||||
guard SSKPreferences.areLinkPreviewsEnabled() else {
|
||||
throw LinkPreviewError.noPreview
|
||||
}
|
||||
let imageAttachmentId = OWSLinkPreview.saveAttachmentIfPossible(inputFilePath: info.imageFilePath,
|
||||
transaction: transaction)
|
||||
|
||||
@ -361,6 +367,9 @@ public class OWSLinkPreview: MTLModel {
|
||||
guard OWSLinkPreview.featureEnabled else {
|
||||
return nil
|
||||
}
|
||||
guard SSKPreferences.areLinkPreviewsEnabled() else {
|
||||
return nil
|
||||
}
|
||||
guard let body = body else {
|
||||
return nil
|
||||
}
|
||||
@ -407,6 +416,10 @@ public class OWSLinkPreview: MTLModel {
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
guard SSKPreferences.areLinkPreviewsEnabled() else {
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
guard let previewUrl = previewUrl else {
|
||||
completion(nil)
|
||||
return
|
||||
|
||||
28
SignalServiceKit/src/Util/SSKPreferences.swift
Normal file
28
SignalServiceKit/src/Util/SSKPreferences.swift
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc
|
||||
public class SSKPreferences: NSObject {
|
||||
// Never instantiate this class.
|
||||
private override init() {}
|
||||
|
||||
private static let collection = "SSKPreferences"
|
||||
private static let areLinkPreviewsEnabledKey = "areLinkPreviewsEnabled"
|
||||
|
||||
@objc
|
||||
public class func areLinkPreviewsEnabled() -> Bool {
|
||||
return OWSPrimaryStorage.dbReadConnection().bool(forKey: areLinkPreviewsEnabledKey,
|
||||
inCollection: collection,
|
||||
defaultValue: true)
|
||||
}
|
||||
|
||||
@objc
|
||||
public class func setAreLinkPreviewsEnabled(value: Bool) {
|
||||
return OWSPrimaryStorage.dbReadWriteConnection().setBool(value,
|
||||
forKey: areLinkPreviewsEnabledKey,
|
||||
inCollection: collection)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user