mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 00:52:43 +02:00
Merge branch 'develop' into steve/4734_nav_room_stack
# Conflicts: # Riot/Modules/Room/RoomViewController.m
This commit is contained in:
@@ -126,6 +126,8 @@
|
||||
|
||||
#import "TypingUserInfo.h"
|
||||
|
||||
#import "MXSDKOptions.h"
|
||||
|
||||
#import "Riot-Swift.h"
|
||||
|
||||
NSNotificationName const RoomCallTileTappedNotification = @"RoomCallTileTappedNotification";
|
||||
@@ -206,6 +208,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
// Observe kThemeServiceDidChangeThemeNotification to handle user interface theme change.
|
||||
id kThemeServiceDidChangeThemeNotificationObserver;
|
||||
|
||||
// Observe URL preview updates to refresh cells.
|
||||
id URLPreviewDidUpdateNotificationObserver;
|
||||
|
||||
// Listener for `m.room.tombstone` event type
|
||||
id tombstoneEventNotificationsListener;
|
||||
|
||||
@@ -444,6 +449,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
}];
|
||||
[self userInterfaceThemeDidChange];
|
||||
|
||||
// Observe URL preview updates.
|
||||
[self registerURLPreviewNotifications];
|
||||
|
||||
[self setupActions];
|
||||
}
|
||||
|
||||
@@ -1367,6 +1375,11 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:mxEventDidDecryptNotificationObserver];
|
||||
mxEventDidDecryptNotificationObserver = nil;
|
||||
}
|
||||
if (URLPreviewDidUpdateNotificationObserver)
|
||||
{
|
||||
[NSNotificationCenter.defaultCenter removeObserver:URLPreviewDidUpdateNotificationObserver];
|
||||
URLPreviewDidUpdateNotificationObserver = nil;
|
||||
}
|
||||
|
||||
[self removeCallNotificationsListeners];
|
||||
[self removeWidgetNotificationsListeners];
|
||||
@@ -1518,6 +1531,47 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
return myPower >= requiredPower;
|
||||
}
|
||||
|
||||
- (void)registerURLPreviewNotifications
|
||||
{
|
||||
URLPreviewDidUpdateNotificationObserver = [NSNotificationCenter.defaultCenter addObserverForName:URLPreviewDidUpdateNotification object:nil queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification * _Nonnull notification) {
|
||||
|
||||
// Ensure this is the correct room
|
||||
if (![(NSString*)notification.userInfo[@"roomId"] isEqualToString:self.roomDataSource.roomId])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the indexPath for the updated cell.
|
||||
NSString *updatedEventId = notification.userInfo[@"eventId"];
|
||||
NSInteger updatedEventIndex = [self.roomDataSource indexOfCellDataWithEventId:updatedEventId];
|
||||
NSIndexPath *updatedIndexPath = [NSIndexPath indexPathForRow:updatedEventIndex inSection:0];
|
||||
|
||||
// Store the content size and offset before reloading the cell
|
||||
CGFloat originalContentSize = self.bubblesTableView.contentSize.height;
|
||||
CGPoint contentOffset = self.bubblesTableView.contentOffset;
|
||||
|
||||
// Only update the content offset if the cell is visible or above the current visible cells.
|
||||
BOOL shouldUpdateContentOffset = NO;
|
||||
NSIndexPath *lastVisibleIndexPath = [self.bubblesTableView indexPathsForVisibleRows].lastObject;
|
||||
if (lastVisibleIndexPath && updatedIndexPath.row < lastVisibleIndexPath.row)
|
||||
{
|
||||
shouldUpdateContentOffset = YES;
|
||||
}
|
||||
|
||||
// Note: Despite passing in the index path, this reloads the whole table.
|
||||
[self dataSource:self.roomDataSource didCellChange:updatedIndexPath];
|
||||
|
||||
// Update the content offset to include any changes to the scroll view's height.
|
||||
if (shouldUpdateContentOffset)
|
||||
{
|
||||
CGFloat delta = self.bubblesTableView.contentSize.height - originalContentSize;
|
||||
contentOffset.y += delta;
|
||||
|
||||
self.bubblesTableView.contentOffset = contentOffset;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)refreshRoomTitle
|
||||
{
|
||||
NSMutableArray *rightBarButtonItems = nil;
|
||||
@@ -2014,6 +2068,46 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
self.documentPickerPresenter = documentPickerPresenter;
|
||||
}
|
||||
|
||||
/**
|
||||
Send a video asset via the room input toolbar prompting the user for the conversion preset to use
|
||||
if the `showMediaCompressionPrompt` setting has been enabled.
|
||||
@param videoAsset The video asset to send
|
||||
@param isPhotoLibraryAsset Whether the asset was picked from the user's photo library.
|
||||
*/
|
||||
- (void)sendVideoAsset:(AVAsset *)videoAsset isPhotoLibraryAsset:(BOOL)isPhotoLibraryAsset
|
||||
{
|
||||
RoomInputToolbarView *roomInputToolbarView = [self inputToolbarViewAsRoomInputToolbarView];
|
||||
if (!roomInputToolbarView)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (RiotSettings.shared.showMediaCompressionPrompt)
|
||||
{
|
||||
// Show the video conversion prompt for the user to select what size video they would like to send.
|
||||
UIAlertController *compressionPrompt = [MXKTools videoConversionPromptForVideoAsset:videoAsset
|
||||
withCompletion:^(NSString *presetName) {
|
||||
// When the preset name is missing, the user cancelled.
|
||||
if (!presetName)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the chosen preset and send the video (conversion takes place in the SDK).
|
||||
[MXSDKOptions sharedInstance].videoConversionPresetName = presetName;
|
||||
[roomInputToolbarView sendSelectedVideoAsset:videoAsset isPhotoLibraryAsset:isPhotoLibraryAsset];
|
||||
}];
|
||||
|
||||
[self presentViewController:compressionPrompt animated:YES completion:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise default to 1080p and send the video.
|
||||
[MXSDKOptions sharedInstance].videoConversionPresetName = AVAssetExportPreset1920x1080;
|
||||
[roomInputToolbarView sendSelectedVideoAsset:videoAsset isPhotoLibraryAsset:isPhotoLibraryAsset];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showRoomWithId:(NSString*)roomId
|
||||
{
|
||||
if (self.delegate)
|
||||
@@ -2512,11 +2606,16 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
}
|
||||
else if (bubbleData.attachment.type == MXKAttachmentTypeVoiceMessage)
|
||||
{
|
||||
if (bubbleData.isPaginationFirstBubble) {
|
||||
if (bubbleData.isPaginationFirstBubble)
|
||||
{
|
||||
cellViewClass = VoiceMessageWithPaginationTitleBubbleCell.class;
|
||||
} else if (bubbleData.shouldHideSenderInformation) {
|
||||
}
|
||||
else if (bubbleData.shouldHideSenderInformation)
|
||||
{
|
||||
cellViewClass = VoiceMessageWithoutSenderInfoBubbleCell.class;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cellViewClass = VoiceMessageBubbleCell.class;
|
||||
}
|
||||
}
|
||||
@@ -6187,7 +6286,10 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
RoomInputToolbarView *roomInputToolbarView = [self inputToolbarViewAsRoomInputToolbarView];
|
||||
if (roomInputToolbarView)
|
||||
{
|
||||
[roomInputToolbarView sendSelectedImage:imageData withMimeType:uti.mimeType andCompressionMode:BuildSettings.roomInputToolbarCompressionMode isPhotoLibraryAsset:NO];
|
||||
[roomInputToolbarView sendSelectedImage:imageData
|
||||
withMimeType:uti.mimeType
|
||||
andCompressionMode:MediaCompressionHelper.defaultCompressionMode
|
||||
isPhotoLibraryAsset:NO];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6196,12 +6298,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
[cameraPresenter dismissWithAnimated:YES completion:nil];
|
||||
self.cameraPresenter = nil;
|
||||
|
||||
RoomInputToolbarView *roomInputToolbarView = [self inputToolbarViewAsRoomInputToolbarView];
|
||||
if (roomInputToolbarView)
|
||||
{
|
||||
AVURLAsset *selectedVideo = [AVURLAsset assetWithURL:url];
|
||||
[roomInputToolbarView sendSelectedVideoAsset:selectedVideo isPhotoLibraryAsset:NO];
|
||||
}
|
||||
AVURLAsset *selectedVideo = [AVURLAsset assetWithURL:url];
|
||||
[self sendVideoAsset:selectedVideo isPhotoLibraryAsset:NO];
|
||||
}
|
||||
|
||||
#pragma mark - MediaPickerCoordinatorBridgePresenterDelegate
|
||||
@@ -6220,7 +6318,10 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
RoomInputToolbarView *roomInputToolbarView = [self inputToolbarViewAsRoomInputToolbarView];
|
||||
if (roomInputToolbarView)
|
||||
{
|
||||
[roomInputToolbarView sendSelectedImage:imageData withMimeType:uti.mimeType andCompressionMode:BuildSettings.roomInputToolbarCompressionMode isPhotoLibraryAsset:YES];
|
||||
[roomInputToolbarView sendSelectedImage:imageData
|
||||
withMimeType:uti.mimeType
|
||||
andCompressionMode:MediaCompressionHelper.defaultCompressionMode
|
||||
isPhotoLibraryAsset:YES];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6229,11 +6330,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
[coordinatorBridgePresenter dismissWithAnimated:YES completion:nil];
|
||||
self.mediaPickerPresenter = nil;
|
||||
|
||||
RoomInputToolbarView *roomInputToolbarView = [self inputToolbarViewAsRoomInputToolbarView];
|
||||
if (roomInputToolbarView)
|
||||
{
|
||||
[roomInputToolbarView sendSelectedVideoAsset:videoAsset isPhotoLibraryAsset:YES];
|
||||
}
|
||||
[self sendVideoAsset:videoAsset isPhotoLibraryAsset:YES];
|
||||
}
|
||||
|
||||
- (void)mediaPickerCoordinatorBridgePresenter:(MediaPickerCoordinatorBridgePresenter *)coordinatorBridgePresenter didSelectAssets:(NSArray<PHAsset *> *)assets
|
||||
@@ -6244,7 +6341,10 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
||||
RoomInputToolbarView *roomInputToolbarView = [self inputToolbarViewAsRoomInputToolbarView];
|
||||
if (roomInputToolbarView)
|
||||
{
|
||||
[roomInputToolbarView sendSelectedAssets:assets withCompressionMode:BuildSettings.roomInputToolbarCompressionMode];
|
||||
// Set a 1080p video conversion preset as compression mode only has an effect on the images.
|
||||
[MXSDKOptions sharedInstance].videoConversionPresetName = AVAssetExportPreset1920x1080;
|
||||
|
||||
[roomInputToolbarView sendSelectedAssets:assets withCompressionMode:MediaCompressionHelper.defaultCompressionMode];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user