Skip to content

Commit

Permalink
#4096 - Added voice message decoding, timeline cell and playback UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Jun 15, 2021
1 parent 46678d8 commit a7ad573
Show file tree
Hide file tree
Showing 23 changed files with 783 additions and 33 deletions.
1 change: 1 addition & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ abstract_target 'RiotPods' do
pod 'SwiftBase32', '~> 0.9.0'
pod 'SwiftJWT', '~> 3.6.200'
pod 'SideMenu', '~> 6.5'
pod 'DSWaveformImage', '~> 6.1.1'

pod 'FLEX', '~> 4.4.1', :configurations => ['Debug']

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "voice_message_pause_button.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "voice_message_play_button.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Riot/Generated/Images.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ internal enum Asset {
internal static let voiceCallHangonIcon = ImageAsset(name: "voice_call_hangon_icon")
internal static let voiceCallHangupIcon = ImageAsset(name: "voice_call_hangup_icon")
internal static let voiceMessageCancelGradient = ImageAsset(name: "voice_message_cancel_gradient")
internal static let voiceMessagePauseButton = ImageAsset(name: "voice_message_pause_button")
internal static let voiceMessagePlayButton = ImageAsset(name: "voice_message_play_button")
internal static let voiceMessageRecordButtonDefault = ImageAsset(name: "voice_message_record_button_default")
internal static let voiceMessageRecordButtonRecording = ImageAsset(name: "voice_message_record_button_recording")
internal static let voiceMessageRecordIcon = ImageAsset(name: "voice_message_record_icon")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ - (UIImage*)attachmentIcon: (MXKAttachmentType)type
case MXKAttachmentTypeAudio:
image = [UIImage imageNamed:@"file_music_icon"];
break;
case MXKAttachmentTypeVoiceMessage:
image = [UIImage imageNamed:@"file_music_icon"];
break;
case MXKAttachmentTypeVideo:
image = [UIImage imageNamed:@"file_video_icon"];
break;
Expand Down
3 changes: 3 additions & 0 deletions Riot/Modules/Room/CellData/RoomBubbleCellData.m
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,9 @@ - (NSString*)accessibilityLabelForAttachmentType:(MXKAttachmentType)attachmentTy
case MXKAttachmentTypeAudio:
accessibilityLabel = NSLocalizedStringFromTable(@"media_type_accessibility_audio", @"Vector", nil);
break;
case MXKAttachmentTypeVoiceMessage:
accessibilityLabel = NSLocalizedStringFromTable(@"media_type_accessibility_audio", @"Vector", nil);
break;
case MXKAttachmentTypeVideo:
accessibilityLabel = NSLocalizedStringFromTable(@"media_type_accessibility_video", @"Vector", nil);
break;
Expand Down
19 changes: 16 additions & 3 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ - (void)viewDidLoad

[self.bubblesTableView registerNib:RoomTypingBubbleCell.nib forCellReuseIdentifier:RoomTypingBubbleCell.defaultReuseIdentifier];

[self.bubblesTableView registerClass:VoiceMessageBubbleCell.class forCellReuseIdentifier:VoiceMessageBubbleCell.defaultReuseIdentifier];
[self.bubblesTableView registerClass:VoiceMessageWithoutSenderInfoBubbleCell.class forCellReuseIdentifier:VoiceMessageWithoutSenderInfoBubbleCell.defaultReuseIdentifier];
[self.bubblesTableView registerClass:VoiceMessageWithPaginationTitleBubbleCell.class forCellReuseIdentifier:VoiceMessageWithPaginationTitleBubbleCell.defaultReuseIdentifier];

[self vc_removeBackTitle];

[self setupRemoveJitsiWidgetRemoveView];
Expand Down Expand Up @@ -2367,6 +2371,15 @@ - (void)displayRoomPreview:(RoomPreviewData *)previewData
{
cellViewClass = RoomGroupCallStatusBubbleCell.class;
}
else if (bubbleData.attachment.type == MXKAttachmentTypeVoiceMessage) {
if (bubbleData.isPaginationFirstBubble) {
cellViewClass = VoiceMessageWithPaginationTitleBubbleCell.class;
} else if (bubbleData.shouldHideSenderInformation) {
cellViewClass = VoiceMessageWithoutSenderInfoBubbleCell.class;
} else {
cellViewClass = VoiceMessageBubbleCell.class;
}
}
else if (bubbleData.isIncoming)
{
if (bubbleData.isAttachmentWithThumbnail)
Expand Down Expand Up @@ -6163,7 +6176,7 @@ - (void)removeJitsiWidgetViewDidCompleteSliding:(RemoveJitsiWidgetView *)view

#pragma mark - VoiceMessageControllerDelegate

- (void)voiceMessageController:(VoiceMessageController *)voiceMessageController didRequestPermissionCheckWithCompletion:(void (^)(BOOL))completion
- (void)voiceMessageControllerDidRequestMicrophonePermission:(VoiceMessageController *)voiceMessageController
{
NSString *appDisplayName = [[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"];

Expand All @@ -6173,13 +6186,13 @@ - (void)voiceMessageController:(VoiceMessageController *)voiceMessageController
[MXKTools checkAccessForMediaType:AVMediaTypeAudio
manualChangeMessage: message
showPopUpInViewController:self completionHandler:^(BOOL granted) {
completion(granted);

}];
}

- (void)voiceMessageController:(VoiceMessageController *)voiceMessageController didRequestSendForFileAtURL:(NSURL *)url completion:(void (^)(BOOL))completion
{
[self.roomDataSource sendAudioFile:url mimeType:@"audio/mp4" success:^(NSString *eventId) {
[self.roomDataSource sendVoiceMessage:url mimeType:@"audio/m4a" success:^(NSString *eventId) {
MXLogDebug(@"Success with event id %@", eventId);
completion(YES);
} failure:^(NSError *error) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

class VoiceMessageBubbleCell: SizableBaseBubbleCell, BubbleCellReactionsDisplayable {

private var playbackView: VoiceMessagePlaybackView!

override func render(_ cellData: MXKCellData!) {
super.render(cellData)

guard let data = cellData as? RoomBubbleCellData else {
return
}

guard data.attachment.type == MXKAttachmentTypeVoiceMessage else {
fatalError("Invalid attachment type passed to a voice message cell.")
}

playbackView.attachment = data.attachment
}

override func setupViews() {
super.setupViews()

bubbleCellContentView?.showSenderInfo = true
bubbleCellContentView?.showPaginationTitle = false

guard let contentView = bubbleCellContentView?.innerContentView else {
return
}

playbackView = VoiceMessagePlaybackView.instanceFromNib()
bubbleCellContentView?.addSubview(playbackView)

contentView.vc_addSubViewMatchingParent(playbackView)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

class VoiceMessageWithPaginationTitleBubbleCell: VoiceMessageBubbleCell {
override func setupViews() {
super.setupViews()

bubbleCellContentView?.showPaginationTitle = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@
//

import Foundation

class VoiceMessageWithoutSenderInfoBubbleCell: VoiceMessageBubbleCell {
override func setupViews() {
super.setupViews()

bubbleCellContentView?.showSenderInfo = false
}
}
Loading

0 comments on commit a7ad573

Please sign in to comment.