From 4d8c764789a716e5215f360584032214c3076109 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 25 May 2018 17:17:15 -0400 Subject: [PATCH] Migrate to Swift 4. --- Signal/src/AppDelegate.m | 4 ++-- Signal/src/Jobs/MessageFetcherJob.swift | 6 +++--- .../src/Jobs/MultiDeviceProfileKeyUpdateJob.swift | 2 +- Signal/src/Jobs/SessionResetJob.swift | 2 +- Signal/src/Jobs/SyncPushTokensJob.swift | 3 ++- .../src/Models/CompareSafetyNumbersActivity.swift | 9 +++++---- .../CropScaleImageViewController.swift | 4 ++-- .../DebugUI/DebugUIFileBrowser.swift | 14 +++++++------- Signal/src/ViewControllers/InviteFlow.swift | 4 ++++ .../MediaGalleryViewController.swift | 2 ++ .../ViewControllers/MediaPageViewController.swift | 1 + .../Utils/MessageRecipientStatusUtils.swift | 9 ++++++--- Signal/src/call/CallService.swift | 2 ++ Signal/src/call/OutboundCallInitiator.swift | 8 ++++---- Signal/src/call/SignalCall.swift | 3 +++ .../src/call/Speakerbox/CallKitCallManager.swift | 2 ++ Signal/src/call/WebRTCCallMessageHandler.swift | 4 ++-- .../ExperienceUpgradeFinder.swift | 6 +++--- Signal/src/views/AttachmentPointerView.swift | 1 + .../views/DirectionalPanGestureRecognizer.swift | 2 +- Signal/src/views/GroupTableViewCell.swift | 1 + Signal/src/views/QuotedReplyPreview.swift | 2 ++ SignalMessaging/attachments/OWSVideoPlayer.swift | 7 ++++++- SignalMessaging/attachments/VideoPlayerView.swift | 1 + SignalMessaging/utils/DisplayableText.swift | 2 ++ .../utils/OWSMessagesBubbleImageFactory.swift | 6 ++++++ SignalMessaging/views/CommonStrings.swift | 1 + 27 files changed, 73 insertions(+), 35 deletions(-) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 6a6cbe549..890a13395 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -912,7 +912,7 @@ static NSTimeInterval launchStartedAt; - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification - completionHandler:(void (^)(void))completionHandler + completionHandler:(void (^)())completionHandler { OWSAssertIsOnMainThread(); @@ -939,7 +939,7 @@ static NSTimeInterval launchStartedAt; handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification withResponseInfo:(NSDictionary *)responseInfo - completionHandler:(void (^)(void))completionHandler + completionHandler:(void (^)())completionHandler { OWSAssertIsOnMainThread(); diff --git a/Signal/src/Jobs/MessageFetcherJob.swift b/Signal/src/Jobs/MessageFetcherJob.swift index a58f56a2f..cea2f8573 100644 --- a/Signal/src/Jobs/MessageFetcherJob.swift +++ b/Signal/src/Jobs/MessageFetcherJob.swift @@ -7,7 +7,7 @@ import PromiseKit import SignalServiceKit @objc(OWSMessageFetcherJob) -class MessageFetcherJob: NSObject { +public class MessageFetcherJob: NSObject { private var timer: Timer? @@ -16,7 +16,7 @@ class MessageFetcherJob: NSObject { private let messageReceiver: OWSMessageReceiver private let signalService: OWSSignalService - init(messageReceiver: OWSMessageReceiver, networkManager: TSNetworkManager, signalService: OWSSignalService) { + @objc public init(messageReceiver: OWSMessageReceiver, networkManager: TSNetworkManager, signalService: OWSSignalService) { self.messageReceiver = messageReceiver self.networkManager = networkManager self.signalService = signalService @@ -58,7 +58,7 @@ class MessageFetcherJob: NSObject { return promise } - @objc func run() -> AnyPromise { + @objc public func run() -> AnyPromise { return AnyPromise(run()) } diff --git a/Signal/src/Jobs/MultiDeviceProfileKeyUpdateJob.swift b/Signal/src/Jobs/MultiDeviceProfileKeyUpdateJob.swift index 996ea5543..00fbde15d 100644 --- a/Signal/src/Jobs/MultiDeviceProfileKeyUpdateJob.swift +++ b/Signal/src/Jobs/MultiDeviceProfileKeyUpdateJob.swift @@ -29,7 +29,7 @@ import SignalMessaging self.profileManager = profileManager } - class func run(profileKey: OWSAES256Key, identityManager: OWSIdentityManager, messageSender: MessageSender, profileManager: OWSProfileManager) { + @objc public class func run(profileKey: OWSAES256Key, identityManager: OWSIdentityManager, messageSender: MessageSender, profileManager: OWSProfileManager) { return self.init(profileKey: profileKey, identityManager: identityManager, messageSender: messageSender, profileManager: profileManager).run() } diff --git a/Signal/src/Jobs/SessionResetJob.swift b/Signal/src/Jobs/SessionResetJob.swift index f07fee705..f37b9a5b7 100644 --- a/Signal/src/Jobs/SessionResetJob.swift +++ b/Signal/src/Jobs/SessionResetJob.swift @@ -64,7 +64,7 @@ public class SessionResetJob: NSObject { } } - class func run(contactThread: TSContactThread, messageSender: MessageSender, primaryStorage: OWSPrimaryStorage) { + @objc public class func run(contactThread: TSContactThread, messageSender: MessageSender, primaryStorage: OWSPrimaryStorage) { let job = self.init(recipientId: contactThread.contactIdentifier(), thread: contactThread, messageSender: messageSender, diff --git a/Signal/src/Jobs/SyncPushTokensJob.swift b/Signal/src/Jobs/SyncPushTokensJob.swift index 1817f09ed..d1d396bee 100644 --- a/Signal/src/Jobs/SyncPushTokensJob.swift +++ b/Signal/src/Jobs/SyncPushTokensJob.swift @@ -18,8 +18,9 @@ class SyncPushTokensJob: NSObject { return PushRegistrationManager.shared } - var uploadOnlyIfStale = true + @objc var uploadOnlyIfStale = true + @objc required init(accountManager: AccountManager, preferences: OWSPreferences) { self.accountManager = accountManager self.preferences = preferences diff --git a/Signal/src/Models/CompareSafetyNumbersActivity.swift b/Signal/src/Models/CompareSafetyNumbersActivity.swift index 48eb88b59..d510bd5c9 100644 --- a/Signal/src/Models/CompareSafetyNumbersActivity.swift +++ b/Signal/src/Models/CompareSafetyNumbersActivity.swift @@ -1,5 +1,5 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // import Foundation @@ -20,6 +20,7 @@ class CompareSafetyNumbersActivity: UIActivity { var mySafetyNumbers: String? let delegate: CompareSafetyNumbersActivityDelegate + @objc required init(delegate: CompareSafetyNumbersActivityDelegate) { self.delegate = delegate super.init() @@ -48,7 +49,7 @@ class CompareSafetyNumbersActivity: UIActivity { } override func canPerform(withActivityItems activityItems: [Any]) -> Bool { - return stringsFrom(activityItems:activityItems).count > 0 + return stringsFrom(activityItems: activityItems).count > 0 } override func prepare(withActivityItems activityItems: [Any]) { @@ -73,7 +74,7 @@ class CompareSafetyNumbersActivity: UIActivity { if pasteboardSafetyNumbers == mySafetyNumbers { Logger.info("\(TAG) successfully matched safety numbers. local numbers: \(String(describing: mySafetyNumbers)) pasteboard:\(pasteboardSafetyNumbers)") - delegate.compareSafetyNumbersActivitySucceeded(activity:self) + delegate.compareSafetyNumbersActivitySucceeded(activity: self) } else { Logger.warn("\(TAG) local numbers: \(String(describing: mySafetyNumbers)) didn't match pasteboard:\(pasteboardSafetyNumbers)") let error = OWSErrorWithCodeDescription(OWSErrorCode.privacyVerificationFailure, @@ -91,7 +92,7 @@ class CompareSafetyNumbersActivity: UIActivity { var numericOnly: String? if let regex = try? NSRegularExpression(pattern: "\\D", options: .caseInsensitive) { - numericOnly = regex.stringByReplacingMatches(in: string!, options: .withTransparentBounds, range: NSMakeRange(0, string!.count), withTemplate: "") + numericOnly = regex.stringByReplacingMatches(in: string!, options: .withTransparentBounds, range: NSRange(location: 0, length: string!.count), withTemplate: "") } return numericOnly diff --git a/Signal/src/ViewControllers/CropScaleImageViewController.swift b/Signal/src/ViewControllers/CropScaleImageViewController.swift index beb3bc924..5fea8f2d0 100644 --- a/Signal/src/ViewControllers/CropScaleImageViewController.swift +++ b/Signal/src/ViewControllers/CropScaleImageViewController.swift @@ -52,7 +52,7 @@ class OWSLayerView: UIView { // region b) the rectangle at which the src image should be rendered // given a dst view or output context that will yield the // appropriate cropping. -class CropScaleImageViewController: OWSViewController { +@objc class CropScaleImageViewController: OWSViewController { let TAG = "[CropScaleImageViewController]" @@ -107,7 +107,7 @@ class CropScaleImageViewController: OWSViewController { fatalError("\(#function) is unimplemented.") } - required init(srcImage: UIImage, successCompletion : @escaping (UIImage) -> Void) { + @objc required init(srcImage: UIImage, successCompletion : @escaping (UIImage) -> Void) { // normalized() can be slightly expensive but in practice this is fine. self.srcImage = srcImage.normalized() self.successCompletion = successCompletion diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIFileBrowser.swift b/Signal/src/ViewControllers/DebugUI/DebugUIFileBrowser.swift index 5a12c2e38..d9f8602ec 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIFileBrowser.swift +++ b/Signal/src/ViewControllers/DebugUI/DebugUIFileBrowser.swift @@ -2,7 +2,7 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -class DebugUIFileBrowser: OWSTableViewController { +@objc class DebugUIFileBrowser: OWSTableViewController { // MARK: Dependencies var fileManager: FileManager { @@ -12,7 +12,7 @@ class DebugUIFileBrowser: OWSTableViewController { // MARK: Overrides let fileURL: URL - init(fileURL: URL) { + @objc init(fileURL: URL) { self.fileURL = fileURL super.init(nibName: nil, bundle: nil) @@ -125,7 +125,7 @@ class DebugUIFileBrowser: OWSTableViewController { preferredStyle: .alert) alert.addAction(OWSAlerts.cancelAction) - alert.addAction(UIAlertAction(title:"Rename \(strongSelf.fileURL.lastPathComponent)", style:.default) { _ in + alert.addAction(UIAlertAction(title: "Rename \(strongSelf.fileURL.lastPathComponent)", style: .default) { _ in guard let textField = alert.textFields?.first else { owsFail("missing text field") return @@ -170,7 +170,7 @@ class DebugUIFileBrowser: OWSTableViewController { preferredStyle: .alert) alert.addAction(OWSAlerts.cancelAction) - alert.addAction(UIAlertAction(title:"Moving \(filename)", style:.default) { _ in + alert.addAction(UIAlertAction(title: "Moving \(filename)", style: .default) { _ in guard let textField = alert.textFields?.first else { owsFail("missing text field") return @@ -259,7 +259,7 @@ class DebugUIFileBrowser: OWSTableViewController { let protections: [FileProtectionType] = [.none, .complete, .completeUnlessOpen, .completeUntilFirstUserAuthentication] protections.forEach { (protection: FileProtectionType) in - actionSheet.addAction(UIAlertAction(title: "\(protection.rawValue.replacingOccurrences(of:"NSFile", with: ""))", style: .default) { (_: UIAlertAction) in + actionSheet.addAction(UIAlertAction(title: "\(protection.rawValue.replacingOccurrences(of: "NSFile", with: ""))", style: .default) { (_: UIAlertAction) in Logger.debug("\(strongSelf.logTag) chose protection: \(protection) for file: \(fileURL)") let fileAttributes: [FileAttributeKey: Any] = [.protectionKey: protection] do { @@ -288,7 +288,7 @@ class DebugUIFileBrowser: OWSTableViewController { preferredStyle: .alert) alert.addAction(OWSAlerts.cancelAction) - alert.addAction(UIAlertAction(title:"Create", style:.default) { _ in + alert.addAction(UIAlertAction(title: "Create", style: .default) { _ in guard let textField = alert.textFields?.first else { owsFail("missing text field") return @@ -326,7 +326,7 @@ class DebugUIFileBrowser: OWSTableViewController { preferredStyle: .alert) alert.addAction(OWSAlerts.cancelAction) - alert.addAction(UIAlertAction(title:"Create", style:.default) { _ in + alert.addAction(UIAlertAction(title: "Create", style: .default) { _ in guard let textField = alert.textFields?.first else { owsFail("missing text field") return diff --git a/Signal/src/ViewControllers/InviteFlow.swift b/Signal/src/ViewControllers/InviteFlow.swift index 1517d91ea..e5940c5e0 100644 --- a/Signal/src/ViewControllers/InviteFlow.swift +++ b/Signal/src/ViewControllers/InviteFlow.swift @@ -19,12 +19,15 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos let installUrl = "https://signal.org/install/" let homepageUrl = "https://signal.org" + @objc let actionSheetController: UIAlertController + @objc let presentingViewController: UIViewController let contactsManager: OWSContactsManager var channel: Channel? + @objc required init(presentingViewController: UIViewController, contactsManager: OWSContactsManager) { self.presentingViewController = presentingViewController self.contactsManager = contactsManager @@ -165,6 +168,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos } } + @objc public func sendSMSTo(phoneNumbers: [String]) { if #available(iOS 10.0, *) { // iOS10 message compose view doesn't respect some system appearence attributes. diff --git a/Signal/src/ViewControllers/MediaGalleryViewController.swift b/Signal/src/ViewControllers/MediaGalleryViewController.swift index 71741244e..f7147f1a5 100644 --- a/Signal/src/ViewControllers/MediaGalleryViewController.swift +++ b/Signal/src/ViewControllers/MediaGalleryViewController.swift @@ -203,6 +203,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc Logger.debug("\(logTag) deinit") } + @objc init(thread: TSThread, uiDatabaseConnection: YapDatabaseConnection, options: MediaGalleryOption = []) { self.thread = thread assert(uiDatabaseConnection.isInLongLivedReadTransaction()) @@ -397,6 +398,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc // e.g. the conversation settings view controller var fromNavController: OWSNavigationController? + @objc func pushTileView(fromNavController: OWSNavigationController) { var mostRecentItem: MediaGalleryItem? self.uiDatabaseConnection.read { transaction in diff --git a/Signal/src/ViewControllers/MediaPageViewController.swift b/Signal/src/ViewControllers/MediaPageViewController.swift index 37542fc05..7c9b89fc9 100644 --- a/Signal/src/ViewControllers/MediaPageViewController.swift +++ b/Signal/src/ViewControllers/MediaPageViewController.swift @@ -13,6 +13,7 @@ public class GalleryItemBox: NSObject { self.value = value } + @objc public var attachmentStream: TSAttachmentStream { return value.attachmentStream } diff --git a/Signal/src/ViewControllers/Utils/MessageRecipientStatusUtils.swift b/Signal/src/ViewControllers/Utils/MessageRecipientStatusUtils.swift index 4d2bc2cd4..89dda1772 100644 --- a/Signal/src/ViewControllers/Utils/MessageRecipientStatusUtils.swift +++ b/Signal/src/ViewControllers/Utils/MessageRecipientStatusUtils.swift @@ -6,7 +6,7 @@ import Foundation import SignalServiceKit import SignalMessaging -@objc enum MessageReceiptStatus: Int { +@objc public enum MessageReceiptStatus: Int { case uploading case sending case sent @@ -25,7 +25,8 @@ public class MessageRecipientStatusUtils: NSObject { } // This method is per-recipient. - class func recipientStatus(outgoingMessage: TSOutgoingMessage, + @objc + public class func recipientStatus(outgoingMessage: TSOutgoingMessage, recipientState: TSOutgoingMessageRecipientState, referenceView: UIView) -> MessageReceiptStatus { let (messageReceiptStatus, _, _) = recipientStatusAndStatusMessage(outgoingMessage: outgoingMessage, @@ -143,6 +144,7 @@ public class MessageRecipientStatusUtils: NSObject { } // This method is per-message. + @objc public class func receiptMessage(outgoingMessage: TSOutgoingMessage, referenceView: UIView) -> String { let (_, message ) = receiptStatusAndMessage(outgoingMessage: outgoingMessage, @@ -151,7 +153,8 @@ public class MessageRecipientStatusUtils: NSObject { } // This method is per-message. - class func recipientStatus(outgoingMessage: TSOutgoingMessage, referenceView: UIView) -> MessageReceiptStatus { + @objc + public class func recipientStatus(outgoingMessage: TSOutgoingMessage, referenceView: UIView) -> MessageReceiptStatus { let (status, _ ) = receiptStatusAndMessage(outgoingMessage: outgoingMessage, referenceView: referenceView) return status diff --git a/Signal/src/call/CallService.swift b/Signal/src/call/CallService.swift index d4fc6cdf2..24604c805 100644 --- a/Signal/src/call/CallService.swift +++ b/Signal/src/call/CallService.swift @@ -259,6 +259,7 @@ private class SignalCallData: NSObject { } } + @objc var call: SignalCall? { get { SwiftAssertIsOnMainThread(#function) @@ -1251,6 +1252,7 @@ private class SignalCallData: NSObject { } } + @objc func handleCallKitStartVideo() { SwiftAssertIsOnMainThread(#function) diff --git a/Signal/src/call/OutboundCallInitiator.swift b/Signal/src/call/OutboundCallInitiator.swift index c081b4e0f..c5b200574 100644 --- a/Signal/src/call/OutboundCallInitiator.swift +++ b/Signal/src/call/OutboundCallInitiator.swift @@ -9,13 +9,13 @@ import SignalMessaging /** * Creates an outbound call via WebRTC. */ -@objc class OutboundCallInitiator: NSObject { +@objc public class OutboundCallInitiator: NSObject { let TAG = "[OutboundCallInitiator]" let contactsManager: OWSContactsManager let contactsUpdater: ContactsUpdater - init(contactsManager: OWSContactsManager, contactsUpdater: ContactsUpdater) { + @objc public init(contactsManager: OWSContactsManager, contactsUpdater: ContactsUpdater) { self.contactsManager = contactsManager self.contactsUpdater = contactsUpdater @@ -27,7 +27,7 @@ import SignalMessaging /** * |handle| is a user formatted phone number, e.g. from a system contacts entry */ - public func initiateCall(handle: String) -> Bool { + @objc public func initiateCall(handle: String) -> Bool { Logger.info("\(TAG) in \(#function) with handle: \(handle)") guard let recipientId = PhoneNumber(fromE164: handle)?.toE164() else { @@ -41,7 +41,7 @@ import SignalMessaging /** * |recipientId| is a e164 formatted phone number. */ - public func initiateCall(recipientId: String, + @objc public func initiateCall(recipientId: String, isVideo: Bool) -> Bool { // Rather than an init-assigned dependency property, we access `callUIAdapter` via Environment // because it can change after app launch due to user settings diff --git a/Signal/src/call/SignalCall.swift b/Signal/src/call/SignalCall.swift index d38bd1dff..6be0689d0 100644 --- a/Signal/src/call/SignalCall.swift +++ b/Signal/src/call/SignalCall.swift @@ -42,6 +42,8 @@ protocol CallObserver: class { let TAG = "[SignalCall]" var observers = [Weak]() + + @objc let remotePhoneNumber: String var isTerminated: Bool { @@ -59,6 +61,7 @@ protocol CallObserver: class { let direction: CallDirection // Distinguishes between calls locally, e.g. in CallKit + @objc let localId: UUID let thread: TSContactThread diff --git a/Signal/src/call/Speakerbox/CallKitCallManager.swift b/Signal/src/call/Speakerbox/CallKitCallManager.swift index fae886411..fac21ffc3 100644 --- a/Signal/src/call/Speakerbox/CallKitCallManager.swift +++ b/Signal/src/call/Speakerbox/CallKitCallManager.swift @@ -19,6 +19,8 @@ final class CallKitCallManager: NSObject { let callController = CXCallController() let showNamesOnCallScreen: Bool + + @objc static let kAnonymousCallHandlePrefix = "Signal:" required init(showNamesOnCallScreen: Bool) { diff --git a/Signal/src/call/WebRTCCallMessageHandler.swift b/Signal/src/call/WebRTCCallMessageHandler.swift index ef6a39d6a..8a358143f 100644 --- a/Signal/src/call/WebRTCCallMessageHandler.swift +++ b/Signal/src/call/WebRTCCallMessageHandler.swift @@ -7,7 +7,7 @@ import SignalServiceKit import SignalMessaging @objc(OWSWebRTCCallMessageHandler) -class WebRTCCallMessageHandler: NSObject, OWSCallMessageHandler { +public class WebRTCCallMessageHandler: NSObject, OWSCallMessageHandler { // MARK - Properties @@ -21,7 +21,7 @@ class WebRTCCallMessageHandler: NSObject, OWSCallMessageHandler { // MARK: Initializers - required init(accountManager: AccountManager, callService: CallService, messageSender: MessageSender) { + @objc public required init(accountManager: AccountManager, callService: CallService, messageSender: MessageSender) { self.accountManager = accountManager self.callService = callService self.messageSender = messageSender diff --git a/Signal/src/environment/ExperienceUpgrades/ExperienceUpgradeFinder.swift b/Signal/src/environment/ExperienceUpgrades/ExperienceUpgradeFinder.swift index 7653b79f9..d6e8fcbb9 100644 --- a/Signal/src/environment/ExperienceUpgrades/ExperienceUpgradeFinder.swift +++ b/Signal/src/environment/ExperienceUpgrades/ExperienceUpgradeFinder.swift @@ -13,7 +13,7 @@ enum ExperienceUpgradeId: String { introducingCustomNotificationAudio = "005" } -class ExperienceUpgradeFinder: NSObject { +@objc public class ExperienceUpgradeFinder: NSObject { // MARK - Singleton class @@ -79,11 +79,11 @@ class ExperienceUpgradeFinder: NSObject { // MARK: - Instance Methods - public func allUnseen(transaction: YapDatabaseReadTransaction) -> [ExperienceUpgrade] { + @objc public func allUnseen(transaction: YapDatabaseReadTransaction) -> [ExperienceUpgrade] { return allExperienceUpgrades.filter { ExperienceUpgrade.fetch(uniqueId: $0.uniqueId!, transaction: transaction) == nil } } - public func markAllAsSeen(transaction: YapDatabaseReadWriteTransaction) { + @objc public func markAllAsSeen(transaction: YapDatabaseReadWriteTransaction) { Logger.info("\(logTag) marking experience upgrades as seen") allExperienceUpgrades.forEach { $0.save(with: transaction) } } diff --git a/Signal/src/views/AttachmentPointerView.swift b/Signal/src/views/AttachmentPointerView.swift index 749db5980..03b369356 100644 --- a/Signal/src/views/AttachmentPointerView.swift +++ b/Signal/src/views/AttachmentPointerView.swift @@ -24,6 +24,7 @@ class AttachmentPointerView: UIView { } } + @objc required init(attachmentPointer: TSAttachmentPointer, isIncoming: Bool) { self.isIncoming = isIncoming self.attachmentPointer = attachmentPointer diff --git a/Signal/src/views/DirectionalPanGestureRecognizer.swift b/Signal/src/views/DirectionalPanGestureRecognizer.swift index 926158c51..9690a6a6a 100644 --- a/Signal/src/views/DirectionalPanGestureRecognizer.swift +++ b/Signal/src/views/DirectionalPanGestureRecognizer.swift @@ -14,7 +14,7 @@ class PanDirectionGestureRecognizer: UIPanGestureRecognizer { let direction: PanDirection - init(direction: PanDirection, target: AnyObject, action: Selector) { + @objc init(direction: PanDirection, target: AnyObject, action: Selector) { self.direction = direction super.init(target: target, action: action) diff --git a/Signal/src/views/GroupTableViewCell.swift b/Signal/src/views/GroupTableViewCell.swift index 81d4f706e..861baa300 100644 --- a/Signal/src/views/GroupTableViewCell.swift +++ b/Signal/src/views/GroupTableViewCell.swift @@ -51,6 +51,7 @@ import SignalServiceKit fatalError("init(coder:) has not been implemented") } + @objc public func configure(thread: TSGroupThread, contactsManager: OWSContactsManager) { if let groupName = thread.groupModel.groupName, !groupName.isEmpty { self.nameLabel.text = groupName diff --git a/Signal/src/views/QuotedReplyPreview.swift b/Signal/src/views/QuotedReplyPreview.swift index e7eab2b9d..7bd1db314 100644 --- a/Signal/src/views/QuotedReplyPreview.swift +++ b/Signal/src/views/QuotedReplyPreview.swift @@ -11,12 +11,14 @@ protocol QuotedReplyPreviewDelegate: class { @objc class QuotedReplyPreview: UIView { + @objc public weak var delegate: QuotedReplyPreviewDelegate? private let quotedReply: OWSQuotedReplyModel private var quotedMessageView: OWSQuotedMessageView? private var heightConstraint: NSLayoutConstraint! + @objc required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/SignalMessaging/attachments/OWSVideoPlayer.swift b/SignalMessaging/attachments/OWSVideoPlayer.swift index 16a41f0f9..48664dc82 100644 --- a/SignalMessaging/attachments/OWSVideoPlayer.swift +++ b/SignalMessaging/attachments/OWSVideoPlayer.swift @@ -13,12 +13,14 @@ protocol OWSVideoPlayerDelegate: class { @objc public class OWSVideoPlayer: NSObject { + @objc let avPlayer: AVPlayer let audioActivity: AudioActivity + @objc weak var delegate: OWSVideoPlayerDelegate? - init(url: URL) { + @objc init(url: URL) { self.avPlayer = AVPlayer(url: url) self.audioActivity = AudioActivity(audioDescription: "[OWSVideoPlayer] url:\(url)") @@ -32,11 +34,13 @@ public class OWSVideoPlayer: NSObject { // MARK: Playback Controls + @objc public func pause() { avPlayer.pause() OWSAudioSession.shared.endAudioActivity(self.audioActivity) } + @objc public func play() { OWSAudioSession.shared.startPlaybackAudioActivity(self.audioActivity) @@ -53,6 +57,7 @@ public class OWSVideoPlayer: NSObject { avPlayer.play() } + @objc public func stop() { avPlayer.pause() avPlayer.seek(to: kCMTimeZero) diff --git a/SignalMessaging/attachments/VideoPlayerView.swift b/SignalMessaging/attachments/VideoPlayerView.swift index 594eb5504..044c8ebc8 100644 --- a/SignalMessaging/attachments/VideoPlayerView.swift +++ b/SignalMessaging/attachments/VideoPlayerView.swift @@ -75,6 +75,7 @@ public class PlayerProgressBar: UIView { private let kPreferredTimeScale: CMTimeScale = 100 + @objc public var player: AVPlayer? { didSet { guard let item = player?.currentItem else { diff --git a/SignalMessaging/utils/DisplayableText.swift b/SignalMessaging/utils/DisplayableText.swift index 265322126..c4a422b5a 100644 --- a/SignalMessaging/utils/DisplayableText.swift +++ b/SignalMessaging/utils/DisplayableText.swift @@ -157,10 +157,12 @@ extension String { @objc public let isTextTruncated: Bool @objc public let jumbomojiCount: UInt + @objc static let kMaxJumbomojiCount: UInt = 5 // This value is a bit arbitrary since we don't need to be 100% correct about // rendering "Jumbomoji". It allows us to place an upper bound on worst-case // performacne. + @objc static let kMaxCharactersPerEmojiCount: UInt = 10 // MARK: Initializers diff --git a/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift b/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift index 27f8daea0..ef923b9bd 100644 --- a/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift +++ b/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift @@ -20,26 +20,31 @@ public class OWSMessagesBubbleImageFactory: NSObject { return UIView().isRTL() }() + @objc public lazy var incoming: JSQMessagesBubbleImage = { let color = OWSMessagesBubbleImageFactory.bubbleColorIncoming return self.incoming(color: color) }() + @objc public lazy var outgoing: JSQMessagesBubbleImage = { let color = OWSMessagesBubbleImageFactory.bubbleColorOutgoingSent return self.outgoing(color: color) }() + @objc public lazy var currentlyOutgoing: JSQMessagesBubbleImage = { let color = OWSMessagesBubbleImageFactory.bubbleColorOutgoingSending return self.outgoing(color: color) }() + @objc public lazy var outgoingFailed: JSQMessagesBubbleImage = { let color = OWSMessagesBubbleImageFactory.bubbleColorOutgoingUnsent return self.outgoing(color: color) }() + @objc public func bubble(message: TSMessage) -> JSQMessagesBubbleImage { if message is TSIncomingMessage { return self.incoming @@ -70,6 +75,7 @@ public class OWSMessagesBubbleImageFactory: NSObject { @objc public static let bubbleColorOutgoingSent = UIColor.ows_materialBlue + @objc public func bubbleColor(message: TSMessage) -> UIColor { if message is TSIncomingMessage { return OWSMessagesBubbleImageFactory.bubbleColorIncoming diff --git a/SignalMessaging/views/CommonStrings.swift b/SignalMessaging/views/CommonStrings.swift index 98434b398..af4e0d778 100644 --- a/SignalMessaging/views/CommonStrings.swift +++ b/SignalMessaging/views/CommonStrings.swift @@ -60,6 +60,7 @@ import Foundation } @objc public class MediaStrings: NSObject { + @objc static public let allMedia = NSLocalizedString("MEDIA_DETAIL_VIEW_ALL_MEDIA_BUTTON", comment: "nav bar button item") }