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];
|
||||
|
||||
userAlbumsQueue = dispatch_queue_create("media.picker.user.albums", DISPATCH_QUEUE_SERIAL);
|
||||
|
||||
// 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) {
|
||||
|
||||
|
@ -144,9 +142,11 @@ static void *RecordingContext = &RecordingContext;
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
cameraQueue = nil;
|
||||
userAlbumsQueue = nil;
|
||||
userAlbums = nil;
|
||||
// Check whether destroy is required
|
||||
if (captureSession)
|
||||
{
|
||||
[self destroy];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
|
@ -167,6 +167,11 @@ static void *RecordingContext = &RecordingContext;
|
|||
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];
|
||||
}
|
||||
|
||||
if (!userAlbumsQueue)
|
||||
{
|
||||
userAlbumsQueue = dispatch_queue_create("media.picker.user.albums", DISPATCH_QUEUE_SERIAL);
|
||||
}
|
||||
|
||||
[self reloadRecentCapturesCollection];
|
||||
[self reloadUserLibraryAlbums];
|
||||
|
||||
|
@ -471,6 +476,7 @@ static void *RecordingContext = &RecordingContext;
|
|||
PHFetchResult *albums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
|
||||
|
||||
NSMutableArray *updatedUserAlbums = [NSMutableArray array];
|
||||
__block PHAssetCollection *cameraRollAlbum, *videoAlbum;
|
||||
|
||||
// Set up fetch options.
|
||||
PHFetchOptions *options = [[PHFetchOptions alloc] init];
|
||||
|
@ -497,11 +503,32 @@ static void *RecordingContext = &RecordingContext;
|
|||
|
||||
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(), ^{
|
||||
|
||||
userAlbums = updatedUserAlbums;
|
||||
|
@ -765,6 +792,8 @@ static void *RecordingContext = &RecordingContext;
|
|||
[self dismissImageValidationView];
|
||||
|
||||
cameraQueue = nil;
|
||||
userAlbumsQueue = nil;
|
||||
userAlbums = nil;
|
||||
|
||||
[super destroy];
|
||||
}
|
||||
|
|
|
@ -260,6 +260,7 @@
|
|||
if (mediaPicker)
|
||||
{
|
||||
[mediaPicker withdrawViewControllerAnimated:YES completion:nil];
|
||||
[mediaPicker destroy];
|
||||
mediaPicker = nil;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue