inline enum converters

This commit is contained in:
Michael Kirk 2019-03-30 08:05:02 -06:00
parent a837cc0ab0
commit 57b1aaa3dc
6 changed files with 17 additions and 62 deletions

View File

@ -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)
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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)
}

View File

@ -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
}

View File

@ -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
}