diff --git a/Signal/src/Loki/Components/VoiceMessageView2.swift b/Signal/src/Loki/Components/VoiceMessageView2.swift index 61f429185..d0edd56b3 100644 --- a/Signal/src/Loki/Components/VoiceMessageView2.swift +++ b/Signal/src/Loki/Components/VoiceMessageView2.swift @@ -3,6 +3,7 @@ import Accelerate @objc(LKVoiceMessageView2) final class VoiceMessageView2 : UIView { private let voiceMessage: TSAttachment + private let isOutgoing: Bool private var isAnimating = false private var volumeSamples: [Float] = [] { didSet { updateShapeLayers() } } private var progress: CGFloat = 0 @@ -30,7 +31,7 @@ final class VoiceMessageView2 : UIView { private lazy var foregroundShapeLayer: CAShapeLayer = { let result = CAShapeLayer() - result.fillColor = isLightMode ? UIColor.white.cgColor : Colors.accent.cgColor + result.fillColor = (isLightMode && isOutgoing) ? UIColor.white.cgColor : Colors.accent.cgColor return result }() @@ -41,9 +42,10 @@ final class VoiceMessageView2 : UIView { @objc public static let contentHeight: CGFloat = 32 // MARK: Initialization - @objc(initWithVoiceMessage:) - init(voiceMessage: TSAttachment) { + @objc(initWithVoiceMessage:isOutgoing:) + init(voiceMessage: TSAttachment, isOutgoing: Bool) { self.voiceMessage = voiceMessage + self.isOutgoing = isOutgoing super.init(frame: CGRect.zero) initialize() } diff --git a/Signal/src/Loki/Utilities/AudioUtilities.swift b/Signal/src/Loki/Utilities/AudioUtilities.swift index 8a0316882..35ee29aa6 100644 --- a/Signal/src/Loki/Utilities/AudioUtilities.swift +++ b/Signal/src/Loki/Utilities/AudioUtilities.swift @@ -39,9 +39,9 @@ enum AudioUtilities { return Promise(error: Error.noAudioTrack) } let (promise, seal) = Promise.pending() - asset.loadValuesAsynchronously(forKeys: [ "duration" ]) { + asset.loadValuesAsynchronously(forKeys: [ #keyPath(AVAsset.duration) ]) { var nsError: NSError? - let status = asset.statusOfValue(forKey: "duration", error: &nsError) + let status = asset.statusOfValue(forKey: #keyPath(AVAsset.duration), error: &nsError) switch status { case .loaded: guard let formatDescriptions = track.formatDescriptions as? [CMAudioFormatDescription], diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index b34f0b99a..99a105433 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -839,8 +839,9 @@ NS_ASSUME_NONNULL_BEGIN OWSAssertDebug(attachment); OWSAssertDebug([attachment isAudio]); - LKVoiceMessageView2 *voiceMessageView = [[LKVoiceMessageView2 alloc] initWithVoiceMessage:attachment]; - voiceMessageView.duration = (int)self.viewItem.audioDurationSeconds; + LKVoiceMessageView2 *voiceMessageView = [[LKVoiceMessageView2 alloc] initWithVoiceMessage:attachment isOutgoing:self.isOutgoing]; + [voiceMessageView setDuration:(int)self.viewItem.audioDurationSeconds]; + [voiceMessageView updateForProgress:self.viewItem.audioProgressSeconds / self.viewItem.audioDurationSeconds]; self.viewItem.lastAudioMessageView = voiceMessageView;