mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Respond to CR.
// FREEBIE
This commit is contained in:
parent
ae7934c117
commit
33415eaa0f
23
Signal/Images.xcassets/audio_pause_black_large.imageset/Contents.json
vendored
Normal file
23
Signal/Images.xcassets/audio_pause_black_large.imageset/Contents.json
vendored
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
BIN
Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@1x.png
vendored
Normal file
BIN
Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@1x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@2x.png
vendored
Normal file
BIN
Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
BIN
Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@3x.png
vendored
Normal file
BIN
Signal/Images.xcassets/audio_pause_black_large.imageset/audio_pause_black_large@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
23
Signal/Images.xcassets/audio_play_black_large.imageset/Contents.json
vendored
Normal file
23
Signal/Images.xcassets/audio_play_black_large.imageset/Contents.json
vendored
Normal file
|
@ -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"
|
||||
}
|
||||
}
|
BIN
Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@1x.png
vendored
Normal file
BIN
Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@1x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 4 KiB |
BIN
Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@2x.png
vendored
Normal file
BIN
Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.9 KiB |
BIN
Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@3x.png
vendored
Normal file
BIN
Signal/Images.xcassets/audio_play_black_large.imageset/audio_play_black_large@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -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 =
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
+ (NSString *)formatFileSize:(unsigned long)fileSize;
|
||||
|
||||
+ (NSString *)formatDurationSeconds:(long)timeSeconds;
|
||||
|
||||
#pragma mark - Alerts
|
||||
|
||||
+ (UIAlertController *)showAlertWithTitle:(NSString *)title message:(NSString *)message;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue