Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
element-hq/element-ios/issues/4090 - Add custom reply text to voice m…
Browse files Browse the repository at this point in the history
…essages, add duration and samples to sendVoiceMessage.
  • Loading branch information
stefanceriu committed Jul 13, 2021
1 parent 71d89e1 commit 9ca446d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ Changes to be released in next version
🙌 Improvements
* MXKAttachment: Add support for all voice message types (vector-im/element-ios/issues/4094).
* MXKRoomViewController, MXKRoomDataSource & MXKRoomInputToolbarView: Add methods to send videos as `AVAsset` objects (vector-im/element-ios/issues/4483).
* MXKSendReplyEventStringLocalizations: Added senderSentAVoiceMessage property

🐛 Bugfix
*

⚠️ API Changes
*
* MXRoomDataSource: Added duration and sample parameters on the sendVoiceMessage method (vector-im/element-ios/issues/4090)

🗣 Translations
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
"message_reply_to_sender_sent_an_image" = "sent an image.";
"message_reply_to_sender_sent_a_video" = "sent a video.";
"message_reply_to_sender_sent_an_audio_file" = "sent an audio file.";
"message_reply_to_sender_sent_a_voice_message" = "sent a voice message.";
"message_reply_to_sender_sent_a_file" = "sent a file.";
"message_reply_to_message_to_reply_to_prefix" = "In reply to";

Expand Down
12 changes: 5 additions & 7 deletions MatrixKit/Models/Room/MXKAttachment.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,13 @@ - (instancetype)initWithEvent:(MXEvent*)event andMediaManager:(MXMediaManager*)m
{
_type = MXKAttachmentTypeImage;
}
else if (event.isVoiceMessage)
{
_type = MXKAttachmentTypeVoiceMessage;
}
else if ([msgtype isEqualToString:kMXMessageTypeAudio])
{
if (eventContent[kMXMessageTypeVoiceMessage] ||
eventContent[kMXMessageTypeVoiceMessageMSC2516] ||
eventContent[kMXMessageTypeVoiceMessageMSC3245]) {
_type = MXKAttachmentTypeVoiceMessage;
} else {
_type = MXKAttachmentTypeAudio;
}
_type = MXKAttachmentTypeAudio;
}
else if ([msgtype isEqualToString:kMXMessageTypeVideo])
{
Expand Down
4 changes: 4 additions & 0 deletions MatrixKit/Models/Room/MXKRoomDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,16 @@ extern NSString *const kMXKRoomDataSourceTimelineErrorErrorKey;
@param audioFileLocalURL the local filesystem path of the audio file to send.
@param mimeType (optional) the mime type of the file. Defaults to `audio/ogg`
@param duration the length of the voice message in milliseconds
@param samples an array of floating point values normalized to [0, 1], boxed within NSNumbers
@param success A block object called when the operation succeeds. It returns
the event id of the event generated on the homeserver
@param failure A block object called when the operation fails.
*/
- (void)sendVoiceMessage:(NSURL *)audioFileLocalURL
mimeType:mimeType
duration:(NSTimeInterval)duration
samples:(NSArray<NSNumber *> *)samples
success:(void (^)(NSString *))success
failure:(void (^)(NSError *))failure;

Expand Down
9 changes: 7 additions & 2 deletions MatrixKit/Models/Room/MXKRoomDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -1885,11 +1885,16 @@ - (void)sendAudioFile:(NSURL *)audioFileLocalURL mimeType:mimeType success:(void
}
}

- (void)sendVoiceMessage:(NSURL *)audioFileLocalURL mimeType:mimeType success:(void (^)(NSString *))success failure:(void (^)(NSError *))failure
- (void)sendVoiceMessage:(NSURL *)audioFileLocalURL
mimeType:mimeType
duration:(NSTimeInterval)duration
samples:(NSArray<NSNumber *> *)samples
success:(void (^)(NSString *))success
failure:(void (^)(NSError *))failure
{
__block MXEvent *localEchoEvent = nil;

[_room sendVoiceMessage:audioFileLocalURL mimeType:mimeType localEcho:&localEchoEvent success:success failure:failure keepActualFilename:YES];
[_room sendVoiceMessage:audioFileLocalURL mimeType:mimeType duration:duration samples:samples localEcho:&localEchoEvent success:success failure:failure keepActualFilename:YES];

if (localEchoEvent)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@property (copy, readonly, nonnull) NSString *senderSentAnImage;
@property (copy, readonly, nonnull) NSString *senderSentAVideo;
@property (copy, readonly, nonnull) NSString *senderSentAnAudioFile;
@property (copy, readonly, nonnull) NSString *senderSentAVoiceMessage;
@property (copy, readonly, nonnull) NSString *senderSentAFile;
@property (copy, readonly, nonnull) NSString *messageToReplyToPrefix;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ - (instancetype)init
_senderSentAnImage = [NSBundle mxk_localizedStringForKey:@"message_reply_to_sender_sent_an_image"];
_senderSentAVideo = [NSBundle mxk_localizedStringForKey:@"message_reply_to_sender_sent_a_video"];
_senderSentAnAudioFile = [NSBundle mxk_localizedStringForKey:@"message_reply_to_sender_sent_an_audio_file"];
_senderSentAVoiceMessage = [NSBundle mxk_localizedStringForKey:@"message_reply_to_sender_sent_a_voice_message"];
_senderSentAFile = [NSBundle mxk_localizedStringForKey:@"message_reply_to_sender_sent_a_file"];
_messageToReplyToPrefix = [NSBundle mxk_localizedStringForKey:@"message_reply_to_message_to_reply_to_prefix"];
}
Expand Down

0 comments on commit 9ca446d

Please sign in to comment.