diff --git a/Signal/Images.xcassets/audio_pause_black_large.imageset/Contents.json b/Signal/Images.xcassets/audio_pause_black_large.imageset/Contents.json new file mode 100644 index 000000000..2fcfe511e --- /dev/null +++ b/Signal/Images.xcassets/audio_pause_black_large.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "audio_pause_black_large@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "audio_pause_black_large@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "audio_pause_black_large@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@1x.png b/Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@1x.png new file mode 100644 index 000000000..205f2e2dc Binary files /dev/null and b/Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@1x.png differ diff --git a/Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@2x.png b/Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@2x.png new file mode 100644 index 000000000..6b572c517 Binary files /dev/null and b/Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@2x.png differ diff --git a/Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@3x.png b/Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@3x.png new file mode 100644 index 000000000..efab70ca9 Binary files /dev/null and b/Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@3x.png differ diff --git a/Signal/Images.xcassets/audio_play_black_large.imageset/Contents.json b/Signal/Images.xcassets/audio_play_black_large.imageset/Contents.json new file mode 100644 index 000000000..a80e9d2b5 --- /dev/null +++ b/Signal/Images.xcassets/audio_play_black_large.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "audio_play_black_large@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "audio_play_black_large@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "audio_play_black_large@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@1x.png b/Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@1x.png new file mode 100644 index 000000000..1ecc55cd8 Binary files /dev/null and b/Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@1x.png differ diff --git a/Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@2x.png b/Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@2x.png new file mode 100644 index 000000000..fe07c9af9 Binary files /dev/null and b/Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@2x.png differ diff --git a/Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@3x.png b/Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@3x.png new file mode 100644 index 000000000..afdc88632 Binary files /dev/null and b/Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@3x.png differ diff --git a/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m b/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m index a9d3a07a2..b23a57e9d 100644 --- a/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m +++ b/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m @@ -94,25 +94,13 @@ NS_ASSUME_NONNULL_BEGIN [self updateAudioBottomLabel]; } -- (NSString *)formatTime:(long)timeSeconds -{ - long seconds = timeSeconds % 60; - long minutes = (timeSeconds / 60) % 60; - long hours = timeSeconds / 3600; - - if (hours > 0) { - return [NSString stringWithFormat:@"%ld:%02ld:%02ld", hours, minutes, seconds]; - } else { - return [NSString stringWithFormat:@"%ld:%02ld", minutes, seconds]; - } -} - - (void)updateAudioBottomLabel { if (self.isAudioPlaying && self.audioProgressSeconds > 0 && self.audioDurationSeconds > 0) { - self.audioBottomLabel.text = [NSString stringWithFormat:@"%@ / %@", - [self formatTime:(long)round(self.audioProgressSeconds)], - [self formatTime:(long)round(self.audioDurationSeconds)]]; + self.audioBottomLabel.text = + [NSString stringWithFormat:@"%@ / %@", + [ViewControllerUtils formatDurationSeconds:(long)round(self.audioProgressSeconds)], + [ViewControllerUtils formatDurationSeconds:(long)round(self.audioDurationSeconds)]]; } else { NSError *error; unsigned long long fileSize = diff --git a/Signal/src/ViewControllers/AttachmentApprovalViewController.swift b/Signal/src/ViewControllers/AttachmentApprovalViewController.swift index 2bde6ea43..c619df0af 100644 --- a/Signal/src/ViewControllers/AttachmentApprovalViewController.swift +++ b/Signal/src/ViewControllers/AttachmentApprovalViewController.swift @@ -18,9 +18,12 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay var videoPlayer: MPMoviePlayerController? var audioPlayer: OWSAudioAttachmentPlayer? + var audioStatusLabel: UILabel? var audioPlayButton: UIButton? var isAudioPlayingFlag = false var isAudioPaused = false + var audioProgressSeconds: CGFloat = 0 + var audioDurationSeconds: CGFloat = 0 // MARK: Initializers @@ -155,6 +158,11 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay let fileSizeLabel = createFileSizeLabel() subviews.append(fileSizeLabel) + let audioStatusLabel = createAudioStatusLabel() + self.audioStatusLabel = audioStatusLabel + updateAudioStatusLabel() + subviews.append(audioStatusLabel) + let stackView = wrapViewsInVerticalStack(subviews:subviews) attachmentPreviewView.addSubview(stackView) fileNameLabel?.autoPinWidthToSuperview(withMargin: 32) @@ -303,8 +311,8 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay let label = UILabel() let fileSize = attachment.data.count label.text = String(format:NSLocalizedString("ATTACHMENT_APPROVAL_FILE_SIZE_FORMAT", - comment: "Format string for file size label in call interstitial view. Embeds: {{file size as 'N mb' or 'N kb'}}."), - ViewControllerUtils.formatFileSize(UInt(fileSize))) + comment: "Format string for file size label in call interstitial view. Embeds: {{file size as 'N mb' or 'N kb'}}."), + ViewControllerUtils.formatFileSize(UInt(fileSize))) label.textColor = UIColor.ows_materialBlue() label.font = labelFont() @@ -313,6 +321,15 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay return label } + private func createAudioStatusLabel() -> UILabel { + let label = UILabel() + label.textColor = UIColor.ows_materialBlue() + label.font = labelFont() + label.textAlignment = .center + + return label + } + private func createButtonRow(attachmentPreviewView: UIView) { let buttonTopMargin = ScaleFromIPhone5To7Plus(30, 40) let buttonBottomMargin = ScaleFromIPhone5To7Plus(25, 40) @@ -400,6 +417,8 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay public func setIsAudioPlaying(_ isAudioPlaying: Bool) { isAudioPlayingFlag = isAudioPlaying + + updateAudioStatusLabel() } public func isPaused() -> Bool { @@ -411,18 +430,38 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay } public func setAudioProgress(_ progress: CGFloat, duration: CGFloat) { - // Ignore + audioProgressSeconds = progress + audioDurationSeconds = duration + + updateAudioStatusLabel() + } + + private func updateAudioStatusLabel() { + guard let audioStatusLabel = self.audioStatusLabel else { + assertionFailure("Missing audio status label") + return + } + + if isAudioPlayingFlag && audioProgressSeconds > 0 && audioDurationSeconds > 0 { + audioStatusLabel.text = String(format:"%@ / %@", + ViewControllerUtils.formatDurationSeconds(Int(round(self.audioProgressSeconds))), + ViewControllerUtils.formatDurationSeconds(Int(round(self.audioDurationSeconds)))) + } else { + audioStatusLabel.text = " " + } } public func setAudioIconToPlay() { - let image = UIImage(named:"audio_play_white_large") + let image = UIImage(named:"audio_play_black_large")?.withRenderingMode(.alwaysTemplate) assert(image != nil) audioPlayButton?.setImage(image, for:.normal) + audioPlayButton?.imageView?.tintColor = UIColor.ows_materialBlue() } public func setAudioIconToPause() { - let image = UIImage(named:"audio_pause_white_large") + let image = UIImage(named:"audio_pause_black_large")?.withRenderingMode(.alwaysTemplate) assert(image != nil) audioPlayButton?.setImage(image, for:.normal) + audioPlayButton?.imageView?.tintColor = UIColor.ows_materialBlue() } } diff --git a/Signal/src/ViewControllers/ViewControllerUtils.h b/Signal/src/ViewControllers/ViewControllerUtils.h index 8e478fb6a..64ac8e175 100644 --- a/Signal/src/ViewControllers/ViewControllerUtils.h +++ b/Signal/src/ViewControllers/ViewControllerUtils.h @@ -20,6 +20,8 @@ + (NSString *)formatFileSize:(unsigned long)fileSize; ++ (NSString *)formatDurationSeconds:(long)timeSeconds; + #pragma mark - Alerts + (UIAlertController *)showAlertWithTitle:(NSString *)title message:(NSString *)message; diff --git a/Signal/src/ViewControllers/ViewControllerUtils.m b/Signal/src/ViewControllers/ViewControllerUtils.m index aaebb97f3..d082d9b29 100644 --- a/Signal/src/ViewControllers/ViewControllerUtils.m +++ b/Signal/src/ViewControllers/ViewControllerUtils.m @@ -102,6 +102,19 @@ NS_ASSUME_NONNULL_BEGIN } } ++ (NSString *)formatDurationSeconds:(long)timeSeconds +{ + long seconds = timeSeconds % 60; + long minutes = (timeSeconds / 60) % 60; + long hours = timeSeconds / 3600; + + if (hours > 0) { + return [NSString stringWithFormat:@"%ld:%02ld:%02ld", hours, minutes, seconds]; + } else { + return [NSString stringWithFormat:@"%ld:%02ld", minutes, seconds]; + } +} + #pragma mark - Alerts + (UIAlertController *)showAlertWithTitle:(NSString *)title message:(NSString *)message