Skip to content

Commit c9678b6

Browse files
committed
Merge branch 'release/3.7'
2 parents 9f73c5c + 7739a27 commit c9678b6

File tree

112 files changed

+3689
-694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+3689
-694
lines changed

CREDITS.md

+11
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ Copyright (c) 2014 Georg Kitz
5858
The MIT License (MIT)
5959

6060
https://github.com/gekitz/GKContactImage/blob/master/LICENSE
61+
--------------------------------------------------------------------
62+
63+
#### JSQMessagesViewController
64+
https://github.com/jessesquires/JSQMessagesViewController
65+
66+
Copyright (c) 2013-present Jesse Squires
67+
68+
###### License:
69+
The MIT License (MIT)
70+
71+
https://github.com/jessesquires/JSQMessagesViewController/blob/develop/LICENSE
6172

6273
--------------------------------------------------------------------
6374

MEGA.entitlements

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<dict>
55
<key>aps-environment</key>
66
<string>development</string>
7+
<key>com.apple.developer.default-data-protection</key>
8+
<string>NSFileProtectionComplete</string>
79
<key>com.apple.developer.icloud-container-identifiers</key>
810
<array>
911
<string>iCloud.$(CFBundleIdentifier)</string>

MEGA.xcodeproj/project.pbxproj

+598-35
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
#import "MEGABaseRequestDelegate.h"
3+
4+
@interface MEGAGetPreviewRequestDelegate : MEGABaseRequestDelegate
5+
6+
- (instancetype)initWithCompletion:(void (^)(MEGARequest *request))completion;
7+
8+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
#import "MEGAGetPreviewRequestDelegate.h"
3+
4+
@interface MEGAGetPreviewRequestDelegate ()
5+
6+
@property (nonatomic, copy) void (^completion)(MEGARequest *request);
7+
8+
@end
9+
10+
@implementation MEGAGetPreviewRequestDelegate
11+
12+
- (instancetype)initWithCompletion:(void (^)(MEGARequest *request))completion {
13+
self = [super init];
14+
if(self) {
15+
_completion = completion;
16+
}
17+
return self;
18+
}
19+
20+
#pragma mark - MEGARequestDelegate
21+
22+
- (void)onRequestStart:(MEGASdk *)api request:(MEGARequest *)request {
23+
[super onRequestStart:api request:request];
24+
}
25+
26+
- (void)onRequestFinish:(MEGASdk *)api request:(MEGARequest *)request error:(MEGAError *)error {
27+
[super onRequestFinish:api request:request error:error];
28+
29+
if (error.type != MEGAErrorTypeApiOk) {
30+
return;
31+
}
32+
if (self.completion) {
33+
self.completion(request);
34+
}
35+
}
36+
37+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
#import "MEGABaseRequestDelegate.h"
3+
4+
@interface MEGAGetThumbnailRequestDelegate : MEGABaseRequestDelegate
5+
6+
- (instancetype)initWithCompletion:(void (^)(MEGARequest *request))completion;
7+
8+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
3+
#import "MEGAGetThumbnailRequestDelegate.h"
4+
5+
@interface MEGAGetThumbnailRequestDelegate ()
6+
7+
@property (nonatomic, copy) void (^completion)(MEGARequest *request);
8+
9+
@end
10+
11+
@implementation MEGAGetThumbnailRequestDelegate
12+
13+
- (instancetype)initWithCompletion:(void (^)(MEGARequest *request))completion {
14+
self = [super init];
15+
if(self) {
16+
_completion = completion;
17+
}
18+
return self;
19+
}
20+
21+
#pragma mark - MEGARequestDelegate
22+
23+
- (void)onRequestStart:(MEGASdk *)api request:(MEGARequest *)request {
24+
[super onRequestStart:api request:request];
25+
}
26+
27+
- (void)onRequestFinish:(MEGASdk *)api request:(MEGARequest *)request error:(MEGAError *)error {
28+
[super onRequestFinish:api request:request error:error];
29+
30+
if (error.type != MEGAErrorTypeApiOk) {
31+
return;
32+
}
33+
if (self.completion) {
34+
self.completion(request);
35+
}
36+
}
37+
38+
@end

iMEGA/API/Requests/MEGAInviteContactRequestDelegate.m

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ - (instancetype)initWithNumberOfRequests:(NSUInteger)numberOfRequests {
2626

2727
#pragma mark - MEGARequestDelegate
2828

29+
- (void)onRequestStart:(MEGASdk *)api request:(MEGARequest *)request {
30+
[super onRequestStart:api request:request];
31+
}
32+
2933
- (void)onRequestFinish:(MEGASdk *)api request:(MEGARequest *)request error:(MEGAError *)error {
3034
[super onRequestFinish:api request:request error:error];
3135

iMEGA/API/Requests/MEGARemoveContactRequestDelegate.m

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ - (instancetype)initWithNumberOfRequests:(NSUInteger)numberOfRequests completion
2828

2929
#pragma mark - MEGARequestDelegate
3030

31+
- (void)onRequestStart:(MEGASdk *)api request:(MEGARequest *)request {
32+
[super onRequestStart:api request:request];
33+
}
3134
- (void)onRequestFinish:(MEGASdk *)api request:(MEGARequest *)request error:(MEGAError *)error {
3235
[super onRequestFinish:api request:request error:error];
3336

iMEGA/API/Requests/MEGAShareRequestDelegate.m

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ - (instancetype)initToChangePermissionsWithNumberOfRequests:(NSUInteger)numberOf
4242

4343
#pragma mark - MEGARequestDelegate
4444

45+
- (void)onRequestStart:(MEGASdk *)api request:(MEGARequest *)request {
46+
[super onRequestStart:api request:request];
47+
}
48+
4549
- (void)onRequestFinish:(MEGASdk *)api request:(MEGARequest *)request error:(MEGAError *)error {
4650
[super onRequestFinish:api request:request error:error];
4751

iMEGA/AppDelegate.m

+15-13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import "MEGAReachabilityManager.h"
1818
#import "MEGAStore.h"
1919
#import "NSFileManager+MNZCategory.h"
20+
#import "NSString+MNZCategory.h"
2021
#import "UIImage+MNZCategory.h"
2122

2223
#import "BrowserViewController.h"
@@ -735,7 +736,7 @@ - (BOOL)isNewSignUpLink:(NSString *)afterSlashesString {
735736
}
736737

737738
- (BOOL)isBackupLink:(NSString *)afterSlashesString {
738-
if (afterSlashesString.length < 6) {
739+
if (afterSlashesString.length < 7) {
739740
return NO;
740741
}
741742

@@ -756,7 +757,7 @@ - (BOOL)isBackupLink:(NSString *)afterSlashesString {
756757
}
757758

758759
- (BOOL)isIncomingPendingContactsLink:(NSString *)afterSlashesString {
759-
if (afterSlashesString.length < 6) {
760+
if (afterSlashesString.length < 7) {
760761
return NO;
761762
}
762763

@@ -776,7 +777,7 @@ - (BOOL)isIncomingPendingContactsLink:(NSString *)afterSlashesString {
776777
}
777778

778779
- (BOOL)isChangeEmailLink:(NSString *)afterSlashesString {
779-
if (afterSlashesString.length < 6) {
780+
if (afterSlashesString.length < 7) {
780781
return NO;
781782
}
782783

@@ -795,7 +796,7 @@ - (BOOL)isChangeEmailLink:(NSString *)afterSlashesString {
795796
}
796797

797798
- (BOOL)isCancelAccountLink:(NSString *)afterSlashesString {
798-
if (afterSlashesString.length < 6) {
799+
if (afterSlashesString.length < 7) {
799800
return NO;
800801
}
801802

@@ -814,7 +815,7 @@ - (BOOL)isCancelAccountLink:(NSString *)afterSlashesString {
814815
}
815816

816817
- (BOOL)isRecoverLink:(NSString *)afterSlashesString {
817-
if (afterSlashesString.length < 7) {
818+
if (afterSlashesString.length < 8) {
818819
return NO;
819820
}
820821

@@ -829,7 +830,7 @@ - (BOOL)isRecoverLink:(NSString *)afterSlashesString {
829830
}
830831

831832
- (BOOL)isLoginRequiredLink:(NSString *)afterSlashesString {
832-
if (afterSlashesString.length < 13) {
833+
if (afterSlashesString.length < 14) {
833834
return NO;
834835
}
835836

@@ -1133,7 +1134,7 @@ - (void)renameAttributesAtPath:(NSString *)v2Path v3Path:(NSString *)v3Path {
11331134
NSString *attributePath = [v2Path stringByAppendingPathComponent:attributeFilename];
11341135

11351136
if ([base64Filename isEqualToString:@"AAAAAAAA"]) {
1136-
if (isImage(attributePath.pathExtension)) {
1137+
if (attributePath.mnz_isImagePathExtension) {
11371138
if ([[NSFileManager defaultManager] fileExistsAtPath:attributePath]) {
11381139
[[NSFileManager defaultManager] removeItemAtPath:attributePath error:nil];
11391140
}
@@ -1869,7 +1870,7 @@ - (void)onTransferFinish:(MEGASdk *)api transfer:(MEGATransfer *)transfer error:
18691870
}
18701871
}
18711872

1872-
if ([transfer type] == MEGATransferTypeUpload && isImage([transfer fileName].pathExtension)) {
1873+
if (transfer.type == MEGATransferTypeUpload && transfer.fileName.mnz_isImagePathExtension) {
18731874
NSString *thumbsDirectory = [Helper pathForSharedSandboxCacheDirectory:@"thumbnailsV3"];
18741875
NSString *previewsDirectory = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"previewsV3"];
18751876
if ([error type] == MEGAErrorTypeApiOk) {
@@ -1909,11 +1910,11 @@ - (void)onTransferFinish:(MEGASdk *)api transfer:(MEGATransfer *)transfer error:
19091910
// Don't add to the database files saved in others applications
19101911
if ([transfer.appData isEqualToString:@"SaveInPhotosApp"]) {
19111912

1912-
if (isVideo(node.name.pathExtension) && UIVideoAtPathIsCompatibleWithSavedPhotosAlbum([NSHomeDirectory() stringByAppendingPathComponent:transfer.path])) {
1913+
if (node.name.mnz_isVideoPathExtension && UIVideoAtPathIsCompatibleWithSavedPhotosAlbum([NSHomeDirectory() stringByAppendingPathComponent:transfer.path])) {
19131914
UISaveVideoAtPathToSavedPhotosAlbum([NSHomeDirectory() stringByAppendingPathComponent:transfer.path], self, @selector(video:didFinishSavingWithError:contextInfo:), nil);
19141915
}
19151916

1916-
if (isImage([transfer fileName].pathExtension)) {
1917+
if (transfer.fileName.mnz_isImagePathExtension) {
19171918
NSURL *imageURL = [NSURL fileURLWithPath:[NSHomeDirectory() stringByAppendingPathComponent:transfer.path]];
19181919

19191920
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
@@ -1930,7 +1931,8 @@ - (void)onTransferFinish:(MEGASdk *)api transfer:(MEGATransfer *)transfer error:
19301931
return;
19311932
}
19321933

1933-
MOOfflineNode *offlineNodeExist = [[MEGAStore shareInstance] fetchOfflineNodeWithFingerprint:[api fingerprintForNode:node]];
1934+
MOOfflineNode *offlineNodeExist = [[MEGAStore shareInstance] offlineNodeWithNode:node api:[MEGASdkManager sharedMEGASdk]];
1935+
19341936
if (!offlineNodeExist) {
19351937
MEGALogDebug(@"Transfer finish: insert node to DB: base64 handle: %@ - local path: %@", node.base64Handle, transfer.path);
19361938
NSRange replaceRange = [transfer.path rangeOfString:@"Documents/"];
@@ -1940,7 +1942,7 @@ - (void)onTransferFinish:(MEGASdk *)api transfer:(MEGATransfer *)transfer error:
19401942
}
19411943
}
19421944

1943-
if (isImage([transfer fileName].pathExtension)) {
1945+
if (transfer.fileName.mnz_isImagePathExtension) {
19441946
NSString *thumbnailFilePath = [Helper pathForNode:node inSharedSandboxCacheDirectory:@"thumbnailsV3"];
19451947
BOOL thumbnailExists = [[NSFileManager defaultManager] fileExistsAtPath:thumbnailFilePath];
19461948

@@ -1956,7 +1958,7 @@ - (void)onTransferFinish:(MEGASdk *)api transfer:(MEGATransfer *)transfer error:
19561958
}
19571959
}
19581960

1959-
if (isVideo(transfer.fileName.pathExtension) && ![node hasThumbnail]) {
1961+
if (transfer.fileName.mnz_isVideoPathExtension && !node.hasThumbnail) {
19601962
NSURL *videoURL = [NSURL fileURLWithPath:[NSHomeDirectory() stringByAppendingPathComponent:transfer.path]];
19611963
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURL options:nil];
19621964
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];

iMEGA/Camera uploads/MEGAAssetOperation.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,13 @@ - (void)actionForNode:(MEGANode *)node fingerPrint:(NSString *)fingerprint fileP
360360
if (![[NSFileManager defaultManager] moveItemAtPath:filePath toPath:newFilePath error:&error]) {
361361
MEGALogError(@"Move item at path failed with error: %@", error);
362362
}
363-
if (isImage(name.pathExtension)) {
363+
if (name.mnz_isImagePathExtension) {
364364
[[MEGASdkManager sharedMEGASdk] createThumbnail:newFilePath destinatioPath:[newFilePath stringByAppendingString:@"_thumbnail"]];
365365
[[MEGASdkManager sharedMEGASdk] createPreview:newFilePath destinatioPath:[newFilePath stringByAppendingString:@"_preview"]];
366366
}
367367
[[MEGASdkManager sharedMEGASdk] startUploadWithLocalPath:[newFilePath stringByReplacingOccurrencesOfString:[NSHomeDirectory() stringByAppendingString:@"/"] withString:@""] parent:_cameraUploadNode appData:appData isSourceTemporary:YES delegate:self];
368368
} else {
369-
if (isImage(name.pathExtension)) {
369+
if (name.pathExtension.mnz_isImagePathExtension) {
370370
[[MEGASdkManager sharedMEGASdk] createThumbnail:filePath destinatioPath:[filePath stringByAppendingString:@"_thumbnail"]];
371371
[[MEGASdkManager sharedMEGASdk] createPreview:filePath destinatioPath:[filePath stringByAppendingString:@"_preview"]];
372372
}

iMEGA/Camera uploads/MEGACollectionViewFlowLayout.m

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
@implementation MEGACollectionViewFlowLayout
55

6+
- (void)prepareLayout {
7+
if ([[UIDevice currentDevice] systemVersionGreaterThanOrEqualVersion:@"10.0"]) {
8+
self.collectionView.prefetchingEnabled = false;
9+
}
10+
}
11+
612
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
713

814
NSMutableArray *answer = [[super layoutAttributesForElementsInRect:rect] mutableCopy];

iMEGA/Camera uploads/PhotosViewController.m

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#import "MEGANavigationController.h"
99
#import "MEGAReachabilityManager.h"
1010
#import "MEGAStore.h"
11+
#import "NSString+MNZCategory.h"
1112

1213
#import "PhotoCollectionViewCell.h"
1314
#import "HeaderCollectionReusableView.h"
@@ -161,7 +162,7 @@ - (void)reloadUI {
161162
for (NSInteger i = 0; i < [self.nodeList.size integerValue]; i++) {
162163
MEGANode *node = [self.nodeList nodeAtIndex:i];
163164

164-
if (!isImage([node name].lowercaseString.pathExtension) && !isVideo([node name].lowercaseString.pathExtension)) {
165+
if (!node.name.mnz_isImagePathExtension && !node.name.mnz_isVideoPathExtension) {
165166
continue;
166167
}
167168

@@ -471,7 +472,7 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
471472

472473
for (NSInteger i = 0; i < [[self.nodeList size] integerValue]; i++) {
473474
MEGANode *n = [self.nodeList nodeAtIndex:i];
474-
if (isImage([n name].pathExtension)) {
475+
if (n.name.mnz_isImagePathExtension) {
475476
MWPhoto *preview = [[MWPhoto alloc] initWithNode:n];
476477
[self.previewsArray addObject:preview];
477478
}
@@ -489,7 +490,7 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
489490
NSInteger videosCount = 0;
490491
for (NSInteger i = 0; i < index + indexPath.row; i++) {
491492
MEGANode *n = [self.nodeList nodeAtIndex:i];
492-
if (!isImage([n name].pathExtension)) {
493+
if (!n.name.mnz_isImagePathExtension) {
493494
videosCount++;
494495
}
495496
}
@@ -500,7 +501,7 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
500501

501502

502503
if (![self.photosCollectionView allowsMultipleSelection]) {
503-
if (isImage([node name].pathExtension)) {
504+
if (node.name.mnz_isImagePathExtension) {
504505
MWPhotoBrowser *photoBrowser = [[MWPhotoBrowser alloc] initWithPhotos:self.previewsArray];
505506
photoBrowser.displayActionButton = YES;
506507
photoBrowser.displayNavArrows = YES;
@@ -516,7 +517,7 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
516517
[photoBrowser showPreviousPhotoAnimated:YES];
517518
[photoBrowser setCurrentPhotoIndex:index];
518519
} else {
519-
MOOfflineNode *offlineNodeExist = [[MEGAStore shareInstance] fetchOfflineNodeWithFingerprint:[[MEGASdkManager sharedMEGASdk] fingerprintForNode:node]];
520+
MOOfflineNode *offlineNodeExist = [[MEGAStore shareInstance] offlineNodeWithNode:node api:[MEGASdkManager sharedMEGASdk]];
520521

521522
if (offlineNodeExist) {
522523
NSURL *path = [NSURL fileURLWithPath:[[Helper pathForOffline] stringByAppendingString:offlineNodeExist.localPath]];
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
@interface MEGANode (MNZCategory)
3+
4+
- (void)mnz_openImageInNavigationController:(UINavigationController *)navigationController withNodes:(NSArray *)nodesArray folderLink:(BOOL)isFolderLink displayMode:(NSUInteger)displayMode;
5+
- (void)mnz_openImageInNavigationController:(UINavigationController *)navigationController withNodes:(NSArray *)nodesArray folderLink:(BOOL)isFolderLink displayMode:(NSUInteger)displayMode enableMoveToRubbishBin:(BOOL)enableMoveToRubbishBin;
6+
- (void)mnz_openNodeInNavigationController:(UINavigationController *)navigationController folderLink:(BOOL)isFolderLink;
7+
8+
@end

0 commit comments

Comments
 (0)