Try to deduce attachment MIME type from the file extension if possible.
// FREEBIE
This commit is contained in:
parent
18498eeda7
commit
0137e01aff
4
Podfile
4
Podfile
|
@ -5,8 +5,8 @@ target 'Signal' do
|
|||
pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git'
|
||||
pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git'
|
||||
#pod 'AxolotlKit', path: '../SignalProtocolKit'
|
||||
pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
|
||||
#pod 'SignalServiceKit', path: '../SignalServiceKit'
|
||||
#pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
|
||||
pod 'SignalServiceKit', path: '../SignalServiceKit'
|
||||
pod 'OpenSSL'
|
||||
pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'mkirk/position-edit-menu'
|
||||
#pod 'JSQMessagesViewController' path: '../JSQMessagesViewController'
|
||||
|
|
|
@ -114,7 +114,7 @@ DEPENDENCIES:
|
|||
- JSQMessagesViewController (from `https://github.com/WhisperSystems/JSQMessagesViewController.git`, branch `mkirk/position-edit-menu`)
|
||||
- OpenSSL
|
||||
- PureLayout
|
||||
- SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`)
|
||||
- SignalServiceKit (from `../SignalServiceKit`)
|
||||
- SocketRocket (from `https://github.com/facebook/SocketRocket.git`)
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
|
@ -124,7 +124,7 @@ EXTERNAL SOURCES:
|
|||
:branch: mkirk/position-edit-menu
|
||||
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git
|
||||
SignalServiceKit:
|
||||
:git: https://github.com/WhisperSystems/SignalServiceKit.git
|
||||
:path: ../SignalServiceKit
|
||||
SocketRocket:
|
||||
:git: https://github.com/facebook/SocketRocket.git
|
||||
|
||||
|
@ -135,9 +135,6 @@ CHECKOUT OPTIONS:
|
|||
JSQMessagesViewController:
|
||||
:commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308
|
||||
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git
|
||||
SignalServiceKit:
|
||||
:commit: 955c4d8a0281ea5a53da751044ba818032bb72d1
|
||||
:git: https://github.com/WhisperSystems/SignalServiceKit.git
|
||||
SocketRocket:
|
||||
:commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf
|
||||
:git: https://github.com/facebook/SocketRocket.git
|
||||
|
@ -164,6 +161,6 @@ SPEC CHECKSUMS:
|
|||
UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d
|
||||
YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f
|
||||
|
||||
PODFILE CHECKSUM: 549de6756fe8eab98647be8561b3988361f62e85
|
||||
PODFILE CHECKSUM: 74ea2172e28ade89124e817d3eae14753f1e9bbf
|
||||
|
||||
COCOAPODS: 1.2.1
|
||||
|
|
|
@ -316,23 +316,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
if (action == @selector(copy:)) {
|
||||
NSString *utiType = [MIMETypeUtil utiTypeForMIMEType:_contentType];
|
||||
if (!utiType) {
|
||||
if ([_contentType isEqualToString:@"audio/amr"]) {
|
||||
utiType = @"org.3gpp.adaptive-multi-rate-audio";
|
||||
} else if ([_contentType isEqualToString:@"audio/mp3"] ||
|
||||
[_contentType isEqualToString:@"audio/x-mpeg"] || [_contentType isEqualToString:@"audio/mpeg"] ||
|
||||
[_contentType isEqualToString:@"audio/mpeg3"] || [_contentType isEqualToString:@"audio/x-mp3"] ||
|
||||
[_contentType isEqualToString:@"audio/x-mpeg3"]) {
|
||||
utiType = (NSString *)kUTTypeMP3;
|
||||
} else if ([_contentType isEqualToString:@"audio/aac"] ||
|
||||
[_contentType isEqualToString:@"audio/x-m4a"]) {
|
||||
utiType = (NSString *)kUTTypeMPEG4Audio;
|
||||
} else if ([_contentType isEqualToString:@"audio/aiff"] ||
|
||||
[_contentType isEqualToString:@"audio/x-aiff"]) {
|
||||
utiType = (NSString *)kUTTypeAudioInterchangeFileFormat;
|
||||
} else {
|
||||
OWSAssert(0);
|
||||
utiType = (NSString *)kUTTypeAudio;
|
||||
}
|
||||
OWSAssert(0);
|
||||
utiType = (NSString *)kUTTypeAudio;
|
||||
}
|
||||
|
||||
NSData *data = [NSData dataWithContentsOfURL:self.fileURL];
|
||||
|
|
|
@ -325,6 +325,10 @@ typedef enum : NSUInteger {
|
|||
|
||||
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
|
||||
{
|
||||
if (self.rightBarButtonItem != self.voiceMemoButton) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// We want to be permissive about the voice message gesture, so we accept
|
||||
// gesture that begin within N points of the
|
||||
CGFloat kVoiceMemoGestureTolerancePoints = 10;
|
||||
|
@ -3158,7 +3162,7 @@ typedef enum : NSUInteger {
|
|||
self.audioRecorder = nil;
|
||||
|
||||
NSString *filename = [NSLocalizedString(@"VOICE_MESSAGE_FILE_NAME", @"Filename for voice messages.")
|
||||
stringByAppendingPathExtension:[MIMETypeUtil fileExtensionForUTIType:(NSString *)kUTTypeMPEG4Audio]];
|
||||
stringByAppendingPathExtension:@".m4a"];
|
||||
|
||||
SignalAttachment *attachment =
|
||||
[SignalAttachment attachmentWithData:audioData dataUTI:(NSString *)kUTTypeMPEG4Audio filename:filename];
|
||||
|
|
|
@ -168,6 +168,18 @@ class SignalAttachment: NSObject {
|
|||
// Returns the MIME type for this attachment or nil if no MIME type
|
||||
// can be identified.
|
||||
var mimeType: String {
|
||||
if let filename = filename {
|
||||
let fileExtension = (filename as NSString).pathExtension
|
||||
if fileExtension.characters.count > 0 {
|
||||
if let mimeType = MIMETypeUtil.mimeType(forFileExtension:fileExtension) {
|
||||
// UTI types are an imperfect means of representing file type;
|
||||
// file extensions are also imperfect but far more reliable and
|
||||
// comprehensive so we always prefer to try to deduce MIME type
|
||||
// from the file extension.
|
||||
return mimeType
|
||||
}
|
||||
}
|
||||
}
|
||||
if dataUTI == SignalAttachment.kOversizeTextAttachmentUTI {
|
||||
return OWSMimeTypeOversizeTextMessage
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue