mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-30 08:12:40 +00:00
Merge pull request #405 from vector-im/373
Bug Fix Media Picker: move the camera roll at the top of the folders
This commit is contained in:
commit
4744b44d34
2 changed files with 36 additions and 6 deletions
|
@ -131,8 +131,6 @@ static void *RecordingContext = &RecordingContext;
|
||||||
|
|
||||||
[self setBackgroundRecordingID:UIBackgroundTaskInvalid];
|
[self setBackgroundRecordingID:UIBackgroundTaskInvalid];
|
||||||
|
|
||||||
userAlbumsQueue = dispatch_queue_create("media.picker.user.albums", DISPATCH_QUEUE_SERIAL);
|
|
||||||
|
|
||||||
// Observe UIApplicationWillEnterForegroundNotification to refresh captures collection when app leaves the background state.
|
// Observe UIApplicationWillEnterForegroundNotification to refresh captures collection when app leaves the background state.
|
||||||
UIApplicationWillEnterForegroundNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
|
UIApplicationWillEnterForegroundNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
|
||||||
|
|
||||||
|
@ -144,9 +142,11 @@ static void *RecordingContext = &RecordingContext;
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
cameraQueue = nil;
|
// Check whether destroy is required
|
||||||
userAlbumsQueue = nil;
|
if (captureSession)
|
||||||
userAlbums = nil;
|
{
|
||||||
|
[self destroy];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning
|
- (void)didReceiveMemoryWarning
|
||||||
|
@ -167,6 +167,11 @@ static void *RecordingContext = &RecordingContext;
|
||||||
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];
|
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!userAlbumsQueue)
|
||||||
|
{
|
||||||
|
userAlbumsQueue = dispatch_queue_create("media.picker.user.albums", DISPATCH_QUEUE_SERIAL);
|
||||||
|
}
|
||||||
|
|
||||||
[self reloadRecentCapturesCollection];
|
[self reloadRecentCapturesCollection];
|
||||||
[self reloadUserLibraryAlbums];
|
[self reloadUserLibraryAlbums];
|
||||||
|
|
||||||
|
@ -471,6 +476,7 @@ static void *RecordingContext = &RecordingContext;
|
||||||
PHFetchResult *albums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
|
PHFetchResult *albums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
|
||||||
|
|
||||||
NSMutableArray *updatedUserAlbums = [NSMutableArray array];
|
NSMutableArray *updatedUserAlbums = [NSMutableArray array];
|
||||||
|
__block PHAssetCollection *cameraRollAlbum, *videoAlbum;
|
||||||
|
|
||||||
// Set up fetch options.
|
// Set up fetch options.
|
||||||
PHFetchOptions *options = [[PHFetchOptions alloc] init];
|
PHFetchOptions *options = [[PHFetchOptions alloc] init];
|
||||||
|
@ -497,11 +503,32 @@ static void *RecordingContext = &RecordingContext;
|
||||||
|
|
||||||
if (assets.count)
|
if (assets.count)
|
||||||
{
|
{
|
||||||
[updatedUserAlbums addObject:collection];
|
if (collection.assetCollectionSubtype == PHAssetCollectionSubtypeSmartAlbumUserLibrary)
|
||||||
|
{
|
||||||
|
cameraRollAlbum = collection;
|
||||||
|
}
|
||||||
|
else if (collection.assetCollectionSubtype == PHAssetCollectionSubtypeSmartAlbumVideos)
|
||||||
|
{
|
||||||
|
videoAlbum = collection;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[updatedUserAlbums addObject:collection];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
// Move the camera roll at the top, followed by video and the rest by default
|
||||||
|
if (videoAlbum)
|
||||||
|
{
|
||||||
|
[updatedUserAlbums insertObject:videoAlbum atIndex:0];
|
||||||
|
}
|
||||||
|
if (cameraRollAlbum)
|
||||||
|
{
|
||||||
|
[updatedUserAlbums insertObject:cameraRollAlbum atIndex:0];
|
||||||
|
}
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
|
||||||
userAlbums = updatedUserAlbums;
|
userAlbums = updatedUserAlbums;
|
||||||
|
@ -765,6 +792,8 @@ static void *RecordingContext = &RecordingContext;
|
||||||
[self dismissImageValidationView];
|
[self dismissImageValidationView];
|
||||||
|
|
||||||
cameraQueue = nil;
|
cameraQueue = nil;
|
||||||
|
userAlbumsQueue = nil;
|
||||||
|
userAlbums = nil;
|
||||||
|
|
||||||
[super destroy];
|
[super destroy];
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,6 +260,7 @@
|
||||||
if (mediaPicker)
|
if (mediaPicker)
|
||||||
{
|
{
|
||||||
[mediaPicker withdrawViewControllerAnimated:YES completion:nil];
|
[mediaPicker withdrawViewControllerAnimated:YES completion:nil];
|
||||||
|
[mediaPicker destroy];
|
||||||
mediaPicker = nil;
|
mediaPicker = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue