Merge branch 'mkirk/share-audio'

This commit is contained in:
Michael Kirk 2017-12-12 13:04:20 -05:00
commit 481427bf90
2 changed files with 37 additions and 20 deletions

View file

@ -121,11 +121,11 @@ public class AttachmentApprovalViewController: OWSViewController {
containerView.autoMatch(.width, to: .width, of: self.view)
containerView.addSubview(mediaMessageView)
mediaMessageView.autoCenterInSuperview()
mediaMessageView.setCompressionResistanceHigh()
mediaMessageView.autoPinEdgesToSuperviewEdges()
if attachment.isImage || attachment.isVideo {
// Add top and bottom gradients to ensure toolbar controls are legible
// when placed over media with a clashing color
// when placed over image/video preview which may be a clashing color.
let topGradient = GradientView(from: backgroundColor, to: UIColor.clear)
self.view.addSubview(topGradient)
topGradient.autoPinWidthToSuperview()
@ -137,6 +137,7 @@ public class AttachmentApprovalViewController: OWSViewController {
bottomGradient.autoPinWidthToSuperview()
bottomGradient.autoPinEdge(toSuperviewEdge: .bottom)
bottomGradient.autoSetDimension(.height, toSize: ScaleFromIPhone5(100))
}
// Hide the play button embedded in the MediaView and replace it with our own.
// This allows us to zoom in on the media view without zooming in on the button
@ -235,7 +236,12 @@ public class AttachmentApprovalViewController: OWSViewController {
extension AttachmentApprovalViewController: UIScrollViewDelegate {
public func viewForZooming(in scrollView: UIScrollView) -> UIView? {
if attachment.isImage || attachment.isVideo {
return mediaMessageView
} else {
// don't zoom for audio or generic attachments.
return nil
}
}
fileprivate func updateMinZoomScaleForSize(_ size: CGSize) {

View file

@ -292,8 +292,10 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
private func createHeroViewSize() -> CGFloat {
switch mode {
case .large, .attachmentApproval:
case .large:
return ScaleFromIPhone5To7Plus(175, 225)
case .attachmentApproval:
return ScaleFromIPhone5(100)
case .small:
return ScaleFromIPhone5To7Plus(80, 80)
}
@ -327,6 +329,15 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
}
}
private var controlTintColor: UIColor {
switch mode {
case .small, .large:
return UIColor.ows_materialBlue()
case .attachmentApproval:
return UIColor.white
}
}
private func formattedFileExtension() -> String? {
guard let fileExtension = attachment.fileExtension else {
return nil
@ -357,7 +368,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
let label = UILabel()
label.text = filename
label.textColor = UIColor.ows_materialBlue()
label.textColor = controlTintColor
label.font = labelFont()
label.textAlignment = .center
label.lineBreakMode = .byTruncatingMiddle
@ -371,7 +382,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
comment: "Format string for file size label in call interstitial view. Embeds: {{file size as 'N mb' or 'N kb'}}."),
OWSFormat.formatFileSize(UInt(fileSize)))
label.textColor = UIColor.ows_materialBlue()
label.textColor = controlTintColor
label.font = labelFont()
label.textAlignment = .center
@ -412,14 +423,14 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
let image = UIImage(named: "audio_play_black_large")?.withRenderingMode(.alwaysTemplate)
assert(image != nil)
audioPlayButton?.setImage(image, for: .normal)
audioPlayButton?.imageView?.tintColor = UIColor.ows_materialBlue()
audioPlayButton?.imageView?.tintColor = controlTintColor
}
private func setAudioIconToPause() {
let image = UIImage(named: "audio_pause_black_large")?.withRenderingMode(.alwaysTemplate)
assert(image != nil)
audioPlayButton?.setImage(image, for: .normal)
audioPlayButton?.imageView?.tintColor = UIColor.ows_materialBlue()
audioPlayButton?.imageView?.tintColor = controlTintColor
}
// MARK: - Full Screen Image