Skip to content

Commit

Permalink
Merge branch 'release/4.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
jnavarrom committed Jan 18, 2019
2 parents f3f2971 + 58a53ab commit be8d39b
Show file tree
Hide file tree
Showing 121 changed files with 2,870 additions and 1,399 deletions.
110 changes: 90 additions & 20 deletions MEGA.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions iMEGA/API/Requests/MEGALoginRequestDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#import "SAMKeychain.h"
#import "SVProgressHUD.h"

#import "LaunchViewController.h"
#import "DevicePermissionsHelper.h"
#import "InitialLaunchViewController.h"
#import "Helper.h"
#import "MEGAStore.h"
#import "NSString+MNZCategory.h"
Expand Down Expand Up @@ -128,8 +129,15 @@ - (void)onRequestFinish:(MEGASdk *)api request:(MEGARequest *)request error:(MEG
[SAMKeychain setPassword:session forService:@"MEGA" account:@"sessionV3"];
[[MEGAStore shareInstance] configureMEGAStore];

LaunchViewController *launchVC = [[UIStoryboard storyboardWithName:@"Launch" bundle:nil] instantiateViewControllerWithIdentifier:@"LaunchViewControllerID"];
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
LaunchViewController *launchVC;
if (DevicePermissionsHelper.shouldSetupPermissions) {
launchVC = [[UIStoryboard storyboardWithName:@"Launch" bundle:nil] instantiateViewControllerWithIdentifier:@"InitialLaunchViewControllerID"];
} else {
launchVC = [[UIStoryboard storyboardWithName:@"Launch" bundle:nil] instantiateViewControllerWithIdentifier:@"LaunchViewControllerID"];
}

launchVC.delegate = (id<LaunchViewControllerDelegate>)UIApplication.sharedApplication.delegate;
UIWindow *window = UIApplication.sharedApplication.delegate.window;
[UIView transitionWithView:window duration:0.5 options:(UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowAnimatedContent) animations:^{
[window setRootViewController:launchVC];
} completion:nil];
Expand Down
314 changes: 169 additions & 145 deletions iMEGA/AppDelegate.m

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions iMEGA/Camera uploads/CameraUploads.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ - (void)setIsCameraUploadsEnabled:(BOOL)isCameraUploadsEnabled {
self.isOnlyWhenChargingEnabled = NO;
self.shouldCameraUploadsBeDelayed = NO;

[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:_isCameraUploadsEnabled] forKey:kIsCameraUploadsEnabled];
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:self.isUploadVideosEnabled] forKey:kIsUploadVideosEnabled];
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:self.isUseCellularConnectionEnabled] forKey:kIsUseCellularConnectionEnabled];
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:self.isOnlyWhenChargingEnabled] forKey:kIsOnlyWhenChargingEnabled];
[NSUserDefaults.standardUserDefaults setObject:@(self.isCameraUploadsEnabled) forKey:kIsCameraUploadsEnabled];
[NSUserDefaults.standardUserDefaults setObject:@(self.isUploadVideosEnabled) forKey:kIsUploadVideosEnabled];
[NSUserDefaults.standardUserDefaults setObject:@(self.isUseCellularConnectionEnabled) forKey:kIsUseCellularConnectionEnabled];
[NSUserDefaults.standardUserDefaults setObject:@(self.isOnlyWhenChargingEnabled) forKey:kIsOnlyWhenChargingEnabled];

[[NSUserDefaults standardUserDefaults] synchronize];

Expand Down
90 changes: 19 additions & 71 deletions iMEGA/Camera uploads/CameraUploadsPopUpViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#import "SVProgressHUD.h"

#import "DevicePermissionsHelper.h"
#import "MEGAReachabilityManager.h"
#import "UIDevice+MNZCategory.h"

Expand All @@ -14,12 +15,6 @@
@interface CameraUploadsPopUpViewController ()

@property (weak, nonatomic) IBOutlet UILabel *topLabel;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@property (weak, nonatomic) IBOutlet UILabel *uploadVideosLabel;
@property (weak, nonatomic) IBOutlet UISwitch *uploadVideosSwitch;
@property (weak, nonatomic) IBOutlet UILabel *useCellularConnectionLabel;
@property (weak, nonatomic) IBOutlet UISwitch *useCellularConnectionSwitch;

@property (weak, nonatomic) IBOutlet UIButton *skipButton;
@property (weak, nonatomic) IBOutlet UIButton *enableButton;
Expand All @@ -30,29 +25,13 @@ @implementation CameraUploadsPopUpViewController

#pragma mark - Lifecycle

- (void)viewDidLoad {
[super viewDidLoad];

if (![MEGAReachabilityManager hasCellularConnection]) {
[_useCellularConnectionLabel setHidden:YES];
[_useCellularConnectionSwitch setHidden:YES];
}
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

self.navigationItem.title = AMLocalizedString(@"enableCameraUploadsButton", @"Button title that enables the functionality 'Camera Uploads', which uploads all the photos in your device to MEGA");
self.topLabel.text = AMLocalizedString(@"automaticallyBackupYourPhotos", @"Text shown to explain what means 'Enable Camera Uploads'.");

self.navigationItem.title = AMLocalizedString(@"cameraUploadsLabel", @"Title of one of the Settings sections where you can set up the 'Camera Uploads' options");
self.imageView.image = [UIImage imageNamed:@"cameraUploadsPopUp"];

[_uploadVideosLabel setText:AMLocalizedString(@"uploadVideosLabel", @"Upload videos")];
self.useCellularConnectionLabel.text = AMLocalizedString(@"useMobileData", @"Title next to a switch button (On-Off) to allow using mobile data (Roaming) for a feature.");

[_skipButton setTitle:AMLocalizedString(@"skipButton", @"Skip") forState:UIControlStateNormal];

[self.enableButton setTitle:AMLocalizedString(@"enable", @"Text button shown when the chat is disabled and if tapped the chat will be enabled") forState:UIControlStateNormal];
[self.skipButton setTitle:AMLocalizedString(@"notNow", nil) forState:UIControlStateNormal];
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
Expand All @@ -61,58 +40,27 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations {

#pragma mark - IBActions

- (IBAction)uploadVideosValueChanged:(UISwitch *)sender {
[CameraUploads syncManager].isUploadVideosEnabled = ![CameraUploads syncManager].isUploadVideosEnabled;
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[CameraUploads syncManager].isUploadVideosEnabled] forKey:kIsUploadVideosEnabled];
}

- (IBAction)useCellularConnectionValueChanged:(UISwitch *)sender {
[CameraUploads syncManager].isUseCellularConnectionEnabled = ![CameraUploads syncManager].isUseCellularConnectionEnabled;
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[CameraUploads syncManager].isUseCellularConnectionEnabled] forKey:kIsUseCellularConnectionEnabled];
}

- (IBAction)skipTouchUpInside:(UIButton *)sender {
[NSUserDefaults.standardUserDefaults setObject:@0 forKey:kIsCameraUploadsEnabled];
[self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)enableTouchUpInside:(UIButton *)sender {
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
switch (status) {
case PHAuthorizationStatusNotDetermined:
break;

case PHAuthorizationStatusAuthorized: {
MEGALogInfo(@"Enable Camera Uploads");
[[CameraUploads syncManager] setIsCameraUploadsEnabled:YES];
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:[CameraUploads syncManager].isCameraUploadsEnabled] forKey:kIsCameraUploadsEnabled];

[self dismissViewControllerAnimated:YES completion:^{
[SVProgressHUD showImage:[UIImage imageNamed:@"hudCameraUploads"] status:AMLocalizedString(@"cameraUploadsEnabled", nil)];
}];
break;
}

case PHAuthorizationStatusRestricted:
break;

case PHAuthorizationStatusDenied:{
[self dismissViewControllerAnimated:YES completion:nil];
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController *permissionsAlertController = [UIAlertController alertControllerWithTitle:AMLocalizedString(@"attention", @"Alert title to attract attention") message:AMLocalizedString(@"photoLibraryPermissions", @"Alert message to explain that the MEGA app needs permission to access your device photos") preferredStyle:UIAlertControllerStyleAlert];

[permissionsAlertController addAction:[UIAlertAction actionWithTitle:AMLocalizedString(@"cancel", @"Button title to cancel something") style:UIAlertActionStyleCancel handler:nil]];

[permissionsAlertController addAction:[UIAlertAction actionWithTitle:AMLocalizedString(@"ok", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}]];

[self presentViewController:permissionsAlertController animated:YES completion:nil];

});
break;
}
default:
break;
[DevicePermissionsHelper photosPermissionWithCompletionHandler:^(BOOL granted) {
[NSUserDefaults.standardUserDefaults setObject:@(granted) forKey:kIsCameraUploadsEnabled];
if (granted) {
MEGALogInfo(@"Enable Camera Uploads");
CameraUploads.syncManager.isCameraUploadsEnabled = YES;
CameraUploads.syncManager.isUploadVideosEnabled = YES;
[NSUserDefaults.standardUserDefaults setObject:@1 forKey:kIsUploadVideosEnabled];

[self dismissViewControllerAnimated:YES completion:^{
[SVProgressHUD showImage:[UIImage imageNamed:@"hudCameraUploads"] status:AMLocalizedString(@"cameraUploadsEnabled", nil)];
}];
} else {
[self dismissViewControllerAnimated:YES completion:^{
[DevicePermissionsHelper alertPhotosPermission];
}];
}
}];
}
Expand Down
Loading

0 comments on commit be8d39b

Please sign in to comment.