mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-18 07:28:28 +02:00
RoomInputToolbarView: Add separate actions for camera and media library.
This commit is contained in:
@@ -24,12 +24,6 @@
|
||||
|
||||
#import "UINavigationController+Riot.h"
|
||||
|
||||
#import <MediaPlayer/MediaPlayer.h>
|
||||
|
||||
#import <Photos/Photos.h>
|
||||
|
||||
#import <MobileCoreServices/MobileCoreServices.h>
|
||||
|
||||
#import "WidgetManager.h"
|
||||
#import "IntegrationManagerViewController.h"
|
||||
|
||||
@@ -39,8 +33,6 @@
|
||||
UIAlertController *actionSheet;
|
||||
}
|
||||
|
||||
@property(nonatomic, weak) MediaPickerViewController *mediaPicker;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RoomInputToolbarView
|
||||
@@ -322,6 +314,21 @@
|
||||
actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
[actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"Take photo or video", @"Vector", nil)
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
|
||||
if (weakSelf)
|
||||
{
|
||||
typeof(self) self = weakSelf;
|
||||
self->actionSheet = nil;
|
||||
|
||||
[self.delegate roomInputToolbarViewDidTapCamera:self];
|
||||
}
|
||||
}]];
|
||||
|
||||
|
||||
[actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"room_action_send_photo_or_video", @"Vector", nil)
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * action) {
|
||||
@@ -331,7 +338,7 @@
|
||||
typeof(self) self = weakSelf;
|
||||
self->actionSheet = nil;
|
||||
|
||||
[self showMediaPicker];
|
||||
[self.delegate roomInputToolbarViewDidTapMediaLibrary:self];
|
||||
}
|
||||
|
||||
}]];
|
||||
@@ -375,8 +382,8 @@
|
||||
|
||||
}]];
|
||||
|
||||
[actionSheet popoverPresentationController].sourceView = self.voiceCallButton;
|
||||
[actionSheet popoverPresentationController].sourceRect = self.voiceCallButton.bounds;
|
||||
[actionSheet popoverPresentationController].sourceView = self.attachMediaButton;
|
||||
[actionSheet popoverPresentationController].sourceRect = self.attachMediaButton.bounds;
|
||||
[self.window.rootViewController presentViewController:actionSheet animated:YES completion:nil];
|
||||
}
|
||||
else
|
||||
@@ -448,34 +455,8 @@
|
||||
[super onTouchUpInside:button];
|
||||
}
|
||||
|
||||
- (void)showMediaPicker
|
||||
{
|
||||
// MediaPickerViewController is based on the Photos framework. So it is available only for iOS 8 and later.
|
||||
Class PHAsset_class = NSClassFromString(@"PHAsset");
|
||||
if (PHAsset_class)
|
||||
{
|
||||
MediaPickerViewController * mediaPicker = [MediaPickerViewController mediaPickerViewController];
|
||||
mediaPicker.mediaTypes = @[(NSString *)kUTTypeImage, (NSString *)kUTTypeMovie];
|
||||
mediaPicker.delegate = self;
|
||||
UINavigationController *navigationController = [UINavigationController new];
|
||||
[navigationController pushViewController:mediaPicker animated:NO];
|
||||
|
||||
self.mediaPicker = mediaPicker;
|
||||
|
||||
[self.delegate roomInputToolbarView:self presentViewController:navigationController];
|
||||
}
|
||||
else
|
||||
{
|
||||
// We use UIImagePickerController by default for iOS < 8
|
||||
self.leftInputToolbarButton = self.attachMediaButton;
|
||||
[super onTouchUpInside:self.leftInputToolbarButton];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)destroy
|
||||
{
|
||||
[self dismissMediaPicker];
|
||||
|
||||
if (actionSheet)
|
||||
{
|
||||
[actionSheet dismissViewControllerAnimated:NO completion:nil];
|
||||
@@ -485,40 +466,6 @@
|
||||
[super destroy];
|
||||
}
|
||||
|
||||
#pragma mark - MediaPickerViewController Delegate
|
||||
|
||||
- (void)mediaPickerController:(MediaPickerViewController *)mediaPickerController didSelectImage:(NSData*)imageData withMimeType:(NSString *)mimetype isPhotoLibraryAsset:(BOOL)isPhotoLibraryAsset
|
||||
{
|
||||
[self dismissMediaPicker];
|
||||
|
||||
[self sendSelectedImage:imageData withMimeType:mimetype andCompressionMode:MXKRoomInputToolbarCompressionModePrompt isPhotoLibraryAsset:isPhotoLibraryAsset];
|
||||
}
|
||||
|
||||
- (void)mediaPickerController:(MediaPickerViewController *)mediaPickerController didSelectVideo:(NSURL*)videoURL
|
||||
{
|
||||
[self dismissMediaPicker];
|
||||
|
||||
BOOL isPhotoLibraryAsset = ![videoURL.path hasPrefix:NSTemporaryDirectory()];
|
||||
[self sendSelectedVideo:videoURL isPhotoLibraryAsset:isPhotoLibraryAsset];
|
||||
}
|
||||
|
||||
- (void)mediaPickerController:(MediaPickerViewController *)mediaPickerController didSelectAssets:(NSArray<PHAsset*>*)assets
|
||||
{
|
||||
[self dismissMediaPicker];
|
||||
|
||||
[self sendSelectedAssets:assets withCompressionMode:MXKRoomInputToolbarCompressionModePrompt];
|
||||
}
|
||||
|
||||
#pragma mark - Media picker handling
|
||||
|
||||
- (void)dismissMediaPicker
|
||||
{
|
||||
if (self.mediaPicker)
|
||||
{
|
||||
[self.mediaPicker withdrawViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Clipboard - Handle image/data paste from general pasteboard
|
||||
|
||||
- (void)paste:(id)sender
|
||||
|
||||
Reference in New Issue
Block a user