Skip to content

Commit e82044a

Browse files
committed
Merge branch 'release/3.2.2-33'
2 parents 540b1bc + c2ee8a4 commit e82044a

Some content is hidden

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

49 files changed

+812
-636
lines changed

MEGA.xcodeproj/project.pbxproj

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
4115044B1CEB07C700BF38E3 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 411504121CEB07C700BF38E3 /* [email protected] */; };
4747
411504941CEB183600BF38E3 /* SaveToCameraRollActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 411504931CEB183600BF38E3 /* SaveToCameraRollActivity.m */; };
4848
411C4C5E1BBEAFB3006FE451 /* CTAssetsPicker.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 411C4C5D1BBEAFB3006FE451 /* CTAssetsPicker.xcassets */; };
49+
411E712F1D461E1D00DD7EF8 /* MEGACollectionViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 411E712E1D461E1D00DD7EF8 /* MEGACollectionViewFlowLayout.m */; };
4950
4122C0E61B274E8C001CE833 /* LocalizationSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4122C0E51B274E8C001CE833 /* LocalizationSystem.m */; };
5051
412EB2661C6E52AA001EA6D6 /* MEGAAssetOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 412EB2651C6E52AA001EA6D6 /* MEGAAssetOperation.m */; };
5152
413199761BD7BD5D002CD6EA /* DateTools.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 413199661BD7BD5D002CD6EA /* DateTools.bundle */; };
@@ -274,6 +275,8 @@
274275
411504921CEB183600BF38E3 /* SaveToCameraRollActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaveToCameraRollActivity.h; sourceTree = "<group>"; };
275276
411504931CEB183600BF38E3 /* SaveToCameraRollActivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SaveToCameraRollActivity.m; sourceTree = "<group>"; };
276277
411C4C5D1BBEAFB3006FE451 /* CTAssetsPicker.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = CTAssetsPicker.xcassets; path = iMEGA/Vendor/CTAssetsPickerController/Resources/CTAssetsPicker.xcassets; sourceTree = SOURCE_ROOT; };
278+
411E712D1D461E1D00DD7EF8 /* MEGACollectionViewFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MEGACollectionViewFlowLayout.h; sourceTree = "<group>"; };
279+
411E712E1D461E1D00DD7EF8 /* MEGACollectionViewFlowLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MEGACollectionViewFlowLayout.m; sourceTree = "<group>"; };
277280
4122C0E41B274E8C001CE833 /* LocalizationSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LocalizationSystem.h; path = Vendor/AMLocalizedString/LocalizationSystem.h; sourceTree = "<group>"; };
278281
4122C0E51B274E8C001CE833 /* LocalizationSystem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LocalizationSystem.m; path = Vendor/AMLocalizedString/LocalizationSystem.m; sourceTree = "<group>"; };
279282
4122C0E71B27539F001CE833 /* MEGA-PrefixHeader.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MEGA-PrefixHeader.pch"; sourceTree = "<group>"; };
@@ -1021,6 +1024,8 @@
10211024
41AC33A71A926C27005118AF /* HeaderCollectionReusableView.m */,
10221025
412EB2641C6E52AA001EA6D6 /* MEGAAssetOperation.h */,
10231026
412EB2651C6E52AA001EA6D6 /* MEGAAssetOperation.m */,
1027+
411E712D1D461E1D00DD7EF8 /* MEGACollectionViewFlowLayout.h */,
1028+
411E712E1D461E1D00DD7EF8 /* MEGACollectionViewFlowLayout.m */,
10241029
);
10251030
path = "Camera uploads";
10261031
sourceTree = "<group>";
@@ -1450,7 +1455,7 @@
14501455
137361821A6664C300B740E8 /* Project object */ = {
14511456
isa = PBXProject;
14521457
attributes = {
1453-
LastUpgradeCheck = 0610;
1458+
LastUpgradeCheck = 0730;
14541459
ORGANIZATIONNAME = MEGA;
14551460
TargetAttributes = {
14561461
137361891A6664C300B740E8 = {
@@ -1478,36 +1483,23 @@
14781483
en,
14791484
Base,
14801485
es,
1481-
da,
14821486
de,
14831487
"es-ES",
14841488
fr,
14851489
ja,
14861490
pt,
14871491
"zh-Hans",
14881492
"zh-Hant",
1489-
af,
14901493
ar,
14911494
bg,
1492-
bs,
1493-
ca,
14941495
cs,
1495-
ee,
1496-
eu,
14971496
fa,
14981497
fi,
14991498
he,
1500-
hr,
15011499
hu,
15021500
id,
15031501
it,
1504-
ka,
15051502
ko,
1506-
lt,
1507-
lv,
1508-
mk,
1509-
ms,
1510-
nb,
15111503
nl,
15121504
pl,
15131505
ro,
@@ -1522,10 +1514,6 @@
15221514
uk,
15231515
"pt-br",
15241516
vi,
1525-
"es-MX",
1526-
"hi-IN",
1527-
"nl-NL",
1528-
"pt-PT",
15291517
);
15301518
mainGroup = 137361811A6664C300B740E8;
15311519
productRefGroup = 1373618B1A6664C300B740E8 /* Products */;
@@ -1722,6 +1710,7 @@
17221710
E8D5BF6C1BF3B28500955550 /* SharedItemsTableViewCell.m in Sources */,
17231711
E8F7917E1BC5754A00C58676 /* GetLinkActivity.m in Sources */,
17241712
41AA1A1C1AC081C600D32691 /* SecurityOptionsTableViewController.m in Sources */,
1713+
411E712F1D461E1D00DD7EF8 /* MEGACollectionViewFlowLayout.m in Sources */,
17251714
4131997B1BD7BD5D002CD6EA /* DTTimePeriodCollection.m in Sources */,
17261715
41AC33A81A926C27005118AF /* HeaderCollectionReusableView.m in Sources */,
17271716
E80620AB1CC8E7F400AA63A3 /* NSMutableAttributedString+MNZCategory.m in Sources */,
@@ -1840,6 +1829,7 @@
18401829
COPY_PHASE_STRIP = NO;
18411830
ENABLE_BITCODE = NO;
18421831
ENABLE_STRICT_OBJC_MSGSEND = YES;
1832+
ENABLE_TESTABILITY = YES;
18431833
GCC_C_LANGUAGE_STANDARD = gnu99;
18441834
GCC_DYNAMIC_NO_PIC = NO;
18451835
GCC_OPTIMIZATION_LEVEL = 0;
@@ -1934,6 +1924,7 @@
19341924
"$(inherited)",
19351925
"$(PROJECT_DIR)/iMEGA/Vendor/SDK/bindings/ios/build/Debug-iphoneos",
19361926
);
1927+
PRODUCT_BUNDLE_IDENTIFIER = mega.ios;
19371928
PRODUCT_NAME = MEGA;
19381929
PROVISIONING_PROFILE = "";
19391930
TARGETED_DEVICE_FAMILY = "1,2";
@@ -1973,6 +1964,7 @@
19731964
"$(inherited)",
19741965
"$(PROJECT_DIR)/iMEGA/Vendor/SDK/bindings/ios/build/Debug-iphoneos",
19751966
);
1967+
PRODUCT_BUNDLE_IDENTIFIER = mega.ios;
19761968
PRODUCT_NAME = MEGA;
19771969
PROVISIONING_PROFILE = "";
19781970
TARGETED_DEVICE_FAMILY = "1,2";

iMEGA/AppDelegate.m

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222

2323
#import <AVFoundation/AVFoundation.h>
24+
#import <Photos/Photos.h>
2425

2526
#import "LTHPasscodeViewController.h"
2627
#import "SSKeychain.h"
@@ -254,6 +255,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
254255
[[CameraUploads syncManager] setIsCameraUploadsEnabled:NO];
255256
}
256257

258+
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 9.0) {
259+
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"IsSavePhotoToGalleryEnabled"];
260+
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"IsSaveVideoToGalleryEnabled"];
261+
[[NSUserDefaults standardUserDefaults] synchronize];
262+
}
263+
257264
return YES;
258265
}
259266

@@ -822,15 +829,6 @@ - (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error co
822829
}
823830
}
824831

825-
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
826-
if (!error) {
827-
NSString *imagePath = CFBridgingRelease(contextInfo);
828-
[[NSFileManager defaultManager] removeItemAtPath:imagePath error:nil];
829-
} else {
830-
MEGALogError(@"Save image to Camera roll: %@ (Domain: %@ - Code:%ld)", error.localizedDescription, error.domain, error.code);
831-
}
832-
}
833-
834832
#pragma mark - Battery changed
835833

836834
- (void)batteryChanged:(NSNotification *)notification {
@@ -1455,10 +1453,18 @@ - (void)onTransferFinish:(MEGASdk *)api transfer:(MEGATransfer *)transfer error:
14551453
}
14561454

14571455
if (isImage([transfer fileName].pathExtension) && [[NSUserDefaults standardUserDefaults] boolForKey:@"IsSavePhotoToGalleryEnabled"]) {
1458-
UIImage *image = [UIImage imageWithContentsOfFile:transfer.path];
1459-
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void){
1460-
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), (void*)CFBridgingRetain(transfer.path));
1461-
});
1456+
NSURL *imageURL = [NSURL fileURLWithPath:transfer.path];
1457+
1458+
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
1459+
PHAssetCreationRequest *assetCreationRequest = [PHAssetCreationRequest creationRequestForAsset];
1460+
[assetCreationRequest addResourceWithType:PHAssetResourceTypePhoto fileURL:imageURL options:nil];
1461+
1462+
} completionHandler:^(BOOL success, NSError * _Nullable nserror) {
1463+
[[NSFileManager defaultManager] removeItemAtPath:transfer.path error:nil];
1464+
if (nserror) {
1465+
MEGALogError(@"Add asset to camera roll: %@ (Domain: %@ - Code:%ld)", nserror.localizedDescription, nserror.domain, nserror.code);
1466+
}
1467+
}];
14621468
}
14631469
return;
14641470
}

iMEGA/Camera uploads/CameraUploads.m

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ - (void)setIsCameraUploadsEnabled:(BOOL)isCameraUploadsEnabled {
110110
_isCameraUploadsEnabled = isCameraUploadsEnabled;
111111

112112
if (isCameraUploadsEnabled) {
113+
MEGALogInfo(@"Camera Uploads enabled");
113114
self.lastUploadPhotoDate = [[NSUserDefaults standardUserDefaults] objectForKey:kLastUploadPhotoDate];
114115
self.lastUploadVideoDate = [[NSUserDefaults standardUserDefaults] objectForKey:kLastUploadVideoDate];
115116
if (![[NSUserDefaults standardUserDefaults] objectForKey:kCameraUploadsNodeHandle]){
@@ -154,6 +155,7 @@ - (void)setIsCameraUploadsEnabled:(BOOL)isCameraUploadsEnabled {
154155
[self getAssetsForUpload];
155156
}
156157
} else {
158+
MEGALogInfo(@"Camera Uploads disabled");
157159
[self resetOperationQueue];
158160

159161
_isCameraUploadsEnabled = NO;
@@ -177,6 +179,10 @@ - (void)getAssetsForUpload {
177179
return;
178180
}
179181

182+
if (![[NSFileManager defaultManager] fileExistsAtPath:NSTemporaryDirectory()]) {
183+
[[NSFileManager defaultManager] createDirectoryAtPath:NSTemporaryDirectory() withIntermediateDirectories:YES attributes:nil error:nil];
184+
}
185+
180186
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
181187
PHFetchResult *assetsFetchResult = nil;
182188

@@ -189,18 +195,16 @@ - (void)getAssetsForUpload {
189195
assetsFetchResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:fetchOptions];
190196
}
191197

198+
MEGALogInfo(@"Retrieved assets %ld", assetsFetchResult.count);
199+
192200
[assetsFetchResult enumerateObjectsUsingBlock:^(PHAsset *asset, NSUInteger index, BOOL *stop) {
193-
194-
NSDate *assetCreationTime = asset.creationDate;
195-
196-
if (asset.mediaType == PHAssetMediaTypeVideo && self.isUploadVideosEnabled && ([assetCreationTime timeIntervalSince1970] > [self.lastUploadVideoDate timeIntervalSince1970])) {
201+
if (asset.mediaType == PHAssetMediaTypeVideo && self.isUploadVideosEnabled && ([asset.creationDate timeIntervalSince1970] > [self.lastUploadVideoDate timeIntervalSince1970])) {
197202
MEGAAssetOperation *uploadAssetsOperation = [[MEGAAssetOperation alloc] initWithPHAsset:asset parentNode:cameraUploadsNode automatically:YES];
198203
[_assetsOperationQueue addOperation:uploadAssetsOperation];
199-
} else if (asset.mediaType == PHAssetMediaTypeImage && ([assetCreationTime timeIntervalSince1970] > [self.lastUploadPhotoDate timeIntervalSince1970])) {
204+
} else if (asset.mediaType == PHAssetMediaTypeImage && ([asset.creationDate timeIntervalSince1970] > [self.lastUploadPhotoDate timeIntervalSince1970])) {
200205
MEGAAssetOperation *uploadAssetsOperation = [[MEGAAssetOperation alloc] initWithPHAsset:asset parentNode:cameraUploadsNode automatically:YES];
201206
[_assetsOperationQueue addOperation:uploadAssetsOperation];
202-
}
203-
207+
}
204208
}];
205209
} else {
206210
__block NSInteger totalAssets = 0;

iMEGA/Camera uploads/HeaderCollectionReusableView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
@interface HeaderCollectionReusableView : UICollectionReusableView
2525

2626
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
27+
@property (weak, nonatomic) IBOutlet UILabel *itemsLabel;
2728

2829
@end

iMEGA/Camera uploads/MEGAAssetOperation.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ - (void)actionForNode:(MEGANode *)node fingerPrint:(NSString *)fingerprint fileP
463463
} else {
464464
MEGALogDebug(@"The asset exists in MEGA in the correct folder");
465465
[self completeOperation];
466+
if (![[[CameraUploads syncManager] assetsOperationQueue] operationCount]) {
467+
[[CameraUploads syncManager] setBadgeValue];
468+
}
466469
if ([[[CameraUploads syncManager] assetsOperationQueue] operationCount] == 1 && _automatically) {
467470
[[CameraUploads syncManager] resetOperationQueue];
468471
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
#import <UIKit/UIKit.h>
3+
4+
@interface MEGACollectionViewFlowLayout : UICollectionViewFlowLayout
5+
6+
@end
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
2+
#import "MEGACollectionViewFlowLayout.h"
3+
4+
@implementation MEGACollectionViewFlowLayout
5+
6+
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
7+
8+
NSMutableArray *answer = [[super layoutAttributesForElementsInRect:rect] mutableCopy];
9+
UICollectionView *const cv = self.collectionView;
10+
CGPoint const contentOffset = cv.contentOffset;
11+
12+
NSMutableIndexSet *missingSections = [NSMutableIndexSet indexSet];
13+
for (UICollectionViewLayoutAttributes *layoutAttributes in answer) {
14+
if (layoutAttributes.representedElementCategory == UICollectionElementCategoryCell) {
15+
[missingSections addIndex:layoutAttributes.indexPath.section];
16+
}
17+
}
18+
for (UICollectionViewLayoutAttributes *layoutAttributes in answer) {
19+
if ([layoutAttributes.representedElementKind isEqualToString:UICollectionElementKindSectionHeader]) {
20+
[missingSections removeIndex:layoutAttributes.indexPath.section];
21+
}
22+
}
23+
24+
[missingSections enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
25+
26+
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:idx];
27+
28+
UICollectionViewLayoutAttributes *layoutAttributes = [self layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionHeader atIndexPath:indexPath];
29+
30+
[answer addObject:layoutAttributes];
31+
32+
}];
33+
34+
for (UICollectionViewLayoutAttributes *layoutAttributes in answer) {
35+
36+
if ([layoutAttributes.representedElementKind isEqualToString:UICollectionElementKindSectionHeader]) {
37+
38+
NSInteger section = layoutAttributes.indexPath.section;
39+
NSInteger numberOfItemsInSection = [cv numberOfItemsInSection:section];
40+
41+
NSIndexPath *firstObjectIndexPath = [NSIndexPath indexPathForItem:0 inSection:section];
42+
NSIndexPath *lastObjectIndexPath = [NSIndexPath indexPathForItem:MAX(0, (numberOfItemsInSection - 1)) inSection:section];
43+
44+
BOOL cellsExist;
45+
UICollectionViewLayoutAttributes *firstObjectAttrs;
46+
UICollectionViewLayoutAttributes *lastObjectAttrs;
47+
48+
if (numberOfItemsInSection > 0) { // use cell data if items exist
49+
cellsExist = YES;
50+
firstObjectAttrs = [self layoutAttributesForItemAtIndexPath:firstObjectIndexPath];
51+
lastObjectAttrs = [self layoutAttributesForItemAtIndexPath:lastObjectIndexPath];
52+
} else { // else use the header and footer
53+
cellsExist = NO;
54+
firstObjectAttrs = [self layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionHeader
55+
atIndexPath:firstObjectIndexPath];
56+
lastObjectAttrs = [self layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionFooter
57+
atIndexPath:lastObjectIndexPath];
58+
59+
}
60+
61+
CGFloat topHeaderHeight = (cellsExist) ? CGRectGetHeight(layoutAttributes.frame) : 0;
62+
CGFloat bottomHeaderHeight = CGRectGetHeight(layoutAttributes.frame);
63+
CGRect frameWithEdgeInsets = UIEdgeInsetsInsetRect(layoutAttributes.frame,
64+
cv.contentInset);
65+
66+
CGPoint origin = frameWithEdgeInsets.origin;
67+
68+
origin.y = MIN(
69+
MAX(
70+
contentOffset.y + cv.contentInset.top,
71+
(CGRectGetMinY(firstObjectAttrs.frame) - topHeaderHeight)
72+
),
73+
(CGRectGetMaxY(lastObjectAttrs.frame) - bottomHeaderHeight)
74+
);
75+
76+
layoutAttributes.zIndex = 1024;
77+
layoutAttributes.frame = (CGRect){
78+
.origin = origin,
79+
.size = layoutAttributes.frame.size
80+
};
81+
82+
}
83+
84+
}
85+
86+
return answer;
87+
88+
}
89+
90+
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBound {
91+
return YES;
92+
}
93+
94+
95+
@end

0 commit comments

Comments
 (0)