diff --git a/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift b/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift index 361859e09..0c5e5877e 100644 --- a/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift +++ b/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift @@ -283,11 +283,6 @@ extension OWSSound { owsFailDebug("filename was unexpectedly nil") return UNNotificationSound.default } - return UNNotificationSound(named: convertToUNNotificationSoundName(filename)) + return UNNotificationSound(named: UNNotificationSoundName(rawValue: filename)) } } - -// Helper function inserted by Swift 4.2 migrator. -private func convertToUNNotificationSoundName(_ input: String) -> UNNotificationSoundName { - return UNNotificationSoundName(rawValue: input) -} diff --git a/Signal/src/ViewControllers/Call/CallViewController.swift b/Signal/src/ViewControllers/Call/CallViewController.swift index 779ba56f3..7d5837a9c 100644 --- a/Signal/src/ViewControllers/Call/CallViewController.swift +++ b/Signal/src/ViewControllers/Call/CallViewController.swift @@ -124,7 +124,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver, } // Don't use receiver when video is enabled. Only bluetooth or speaker - return convertFromAVAudioSessionPort(portDescription.portType) != convertFromAVAudioSessionPort(AVAudioSession.Port.builtInMic) + return portDescription.portType != AVAudioSession.Port.builtInMic } } return Set(appropriateForVideo) @@ -1225,8 +1225,3 @@ extension CallViewController: CallVideoHintViewDelegate { updateRemoteVideoLayout() } } - -// Helper function inserted by Swift 4.2 migrator. -private func convertFromAVAudioSessionPort(_ input: AVAudioSession.Port) -> String { - return input.rawValue -} diff --git a/Signal/src/ViewControllers/MediaPageViewController.swift b/Signal/src/ViewControllers/MediaPageViewController.swift index 5ff4fd936..68f1abf2d 100644 --- a/Signal/src/ViewControllers/MediaPageViewController.swift +++ b/Signal/src/ViewControllers/MediaPageViewController.swift @@ -75,9 +75,10 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou let kSpacingBetweenItems: CGFloat = 20 + let options: [UIPageViewController.OptionsKey: Any] = [.interPageSpacing: kSpacingBetweenItems] super.init(transitionStyle: .scroll, navigationOrientation: .horizontal, - options: convertToOptionalUIPageViewControllerOptionsKeyDictionary([convertFromUIPageViewControllerOptionsKey(UIPageViewController.OptionsKey.interPageSpacing): kSpacingBetweenItems])) + options: options) self.dataSource = self self.delegate = self @@ -829,14 +830,3 @@ extension MediaPageViewController: CaptionContainerViewDelegate { captionContainerView.isHidden = true } } - -// Helper function inserted by Swift 4.2 migrator. -private func convertToOptionalUIPageViewControllerOptionsKeyDictionary(_ input: [String: Any]?) -> [UIPageViewController.OptionsKey: Any]? { - guard let input = input else { return nil } - return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIPageViewController.OptionsKey(rawValue: key), value)}) -} - -// Helper function inserted by Swift 4.2 migrator. -private func convertFromUIPageViewControllerOptionsKey(_ input: UIPageViewController.OptionsKey) -> String { - return input.rawValue -} diff --git a/Signal/src/views/MarqueeLabel.swift b/Signal/src/views/MarqueeLabel.swift index 26b31a9d7..c505510bf 100644 --- a/Signal/src/views/MarqueeLabel.swift +++ b/Signal/src/views/MarqueeLabel.swift @@ -1089,20 +1089,19 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate { } private func timingFunctionForAnimationCurve(_ curve: UIView.AnimationCurve) -> CAMediaTimingFunction { - let timingFunction: String? - + let timingFunction: CAMediaTimingFunctionName switch curve { case .easeIn: - timingFunction = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn) + timingFunction = .easeIn case .easeInOut: - timingFunction = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeInEaseOut) + timingFunction = .easeInEaseOut case .easeOut: - timingFunction = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeOut) + timingFunction = .easeOut default: - timingFunction = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.linear) + timingFunction = .linear } - return CAMediaTimingFunction(name: convertToCAMediaTimingFunctionName(timingFunction!)) + return CAMediaTimingFunction(name: timingFunction) } private func transactionDurationType(_ labelType: MarqueeType, interval: CGFloat, delay: CGFloat) -> TimeInterval { @@ -1840,13 +1839,3 @@ fileprivate extension CAMediaTimingFunction { return pointArray } } - -// Helper function inserted by Swift 4.2 migrator. -private func convertFromCAMediaTimingFunctionName(_ input: CAMediaTimingFunctionName) -> String { - return input.rawValue -} - -// Helper function inserted by Swift 4.2 migrator. -private func convertToCAMediaTimingFunctionName(_ input: String) -> CAMediaTimingFunctionName { - return CAMediaTimingFunctionName(rawValue: input) -} diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift index d9c6fbb02..9480f2ecf 100644 --- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift @@ -65,9 +65,11 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC self.mode = mode let attachmentItems = attachments.map { SignalAttachmentItem(attachment: $0 )} self.attachmentItemCollection = AttachmentItemCollection(attachmentItems: attachmentItems) + + let options: [UIPageViewController.OptionsKey: Any] = [.interPageSpacing: kSpacingBetweenItems] super.init(transitionStyle: .scroll, navigationOrientation: .horizontal, - options: convertToOptionalUIPageViewControllerOptionsKeyDictionary([convertFromUIPageViewControllerOptionsKey(UIPageViewController.OptionsKey.interPageSpacing): kSpacingBetweenItems])) + options: options) self.dataSource = self self.delegate = self @@ -792,14 +794,3 @@ extension AttachmentApprovalViewController: AttachmentApprovalInputAccessoryView isEditingCaptions = false } } - -// Helper function inserted by Swift 4.2 migrator. -private func convertToOptionalUIPageViewControllerOptionsKeyDictionary(_ input: [String: Any]?) -> [UIPageViewController.OptionsKey: Any]? { - guard let input = input else { return nil } - return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIPageViewController.OptionsKey(rawValue: key), value)}) -} - -// Helper function inserted by Swift 4.2 migrator. -private func convertFromUIPageViewControllerOptionsKey(_ input: UIPageViewController.OptionsKey) -> String { - return input.rawValue -} diff --git a/SignalMessaging/environment/OWSAudioSession.swift b/SignalMessaging/environment/OWSAudioSession.swift index ae0e11c17..057ff15f5 100644 --- a/SignalMessaging/environment/OWSAudioSession.swift +++ b/SignalMessaging/environment/OWSAudioSession.swift @@ -106,19 +106,19 @@ public class OWSAudioSession: NSObject { // session handling. } else if aggregateBehaviors.contains(.playAndRecord) { assert(avAudioSession.recordPermission == .granted) - try avAudioSession.setCategory(AVAudioSession.Category(rawValue: convertFromAVAudioSessionCategory(AVAudioSession.Category.record))) + try avAudioSession.setCategory(.record) } else if aggregateBehaviors.contains(.audioMessagePlayback) { if self.device.proximityState { Logger.debug("proximityState: true") - try avAudioSession.setCategory(AVAudioSession.Category(rawValue: convertFromAVAudioSessionCategory(AVAudioSession.Category.playAndRecord))) + try avAudioSession.setCategory(.playAndRecord) try avAudioSession.overrideOutputAudioPort(.none) } else { Logger.debug("proximityState: false") - try avAudioSession.setCategory(AVAudioSession.Category(rawValue: convertFromAVAudioSessionCategory(AVAudioSession.Category.playback))) + try avAudioSession.setCategory(.playback) } } else if aggregateBehaviors.contains(.playback) { - try avAudioSession.setCategory(AVAudioSession.Category(rawValue: convertFromAVAudioSessionCategory(AVAudioSession.Category.playback))) + try avAudioSession.setCategory(.playback) } else { ensureAudioSessionActivationStateAfterDelay() } @@ -215,8 +215,3 @@ public class OWSAudioSession: NSObject { } } } - -// Helper function inserted by Swift 4.2 migrator. -private func convertFromAVAudioSessionCategory(_ input: AVAudioSession.Category) -> String { - return input.rawValue -}