浏览代码

review Settings

Marino Faggiana 8 年之前
父节点
当前提交
9200256eea

+ 6 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -519,6 +519,7 @@
 		F7A3217A1E9E3EAF0069AD1B /* CCTransfersCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A321771E9E3EAF0069AD1B /* CCTransfersCell.m */; };
 		F7A3217B1E9E3EAF0069AD1B /* CCTransfersCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7A321781E9E3EAF0069AD1B /* CCTransfersCell.xib */; };
 		F7A3218C1E9E42B30069AD1B /* CCMenuAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A3218B1E9E42B30069AD1B /* CCMenuAccount.m */; };
+		F7A321AD1E9E6AD50069AD1B /* CCAdvanced.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A321AC1E9E6AD50069AD1B /* CCAdvanced.m */; };
 		F7B1FBC41E72E3D1001781FE /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7B1FBB11E72E3D1001781FE /* Media.xcassets */; };
 		F7B1FBC61E72E3D1001781FE /* SwiftModalWebVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B1FBBF1E72E3D1001781FE /* SwiftModalWebVC.swift */; };
 		F7B1FBC71E72E3D1001781FE /* SwiftWebVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B1FBC01E72E3D1001781FE /* SwiftWebVC.swift */; };
@@ -1477,6 +1478,8 @@
 		F7A321781E9E3EAF0069AD1B /* CCTransfersCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CCTransfersCell.xib; sourceTree = "<group>"; };
 		F7A3218A1E9E42B30069AD1B /* CCMenuAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMenuAccount.h; sourceTree = "<group>"; };
 		F7A3218B1E9E42B30069AD1B /* CCMenuAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCMenuAccount.m; sourceTree = "<group>"; };
+		F7A321AB1E9E6AD50069AD1B /* CCAdvanced.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAdvanced.h; sourceTree = "<group>"; };
+		F7A321AC1E9E6AD50069AD1B /* CCAdvanced.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCAdvanced.m; sourceTree = "<group>"; };
 		F7A54C341C6267B500E2C8BF /* CCExifGeo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCExifGeo.h; sourceTree = "<group>"; };
 		F7A54C351C6267B500E2C8BF /* CCExifGeo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCExifGeo.m; sourceTree = "<group>"; };
 		F7A582D61A24DAB500E903D7 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AppDelegate.m; sourceTree = "<group>"; };
@@ -3001,6 +3004,8 @@
 				F7FEB6CF1BECADC100E7C415 /* CCManageHelp.m */,
 				F7AB79EF1BB1A3AD00A82F32 /* CCManageOptimizations.h */,
 				F7AB79F01BB1A3AD00A82F32 /* CCManageOptimizations.m */,
+				F7A321AB1E9E6AD50069AD1B /* CCAdvanced.h */,
+				F7A321AC1E9E6AD50069AD1B /* CCAdvanced.m */,
 				F7ACE4301BAC0268006C0017 /* CCSettings.h */,
 				F7ACE4311BAC0268006C0017 /* CCSettings.m */,
 			);
@@ -4196,6 +4201,7 @@
 				F77B0E3A1D118A16002130FE /* RNCryptorEngine.m in Sources */,
 				F77B0E3C1D118A16002130FE /* CCCartaIdentita.m in Sources */,
 				F7659A6C1DC0B760004860C4 /* PSTGridLayoutItem.m in Sources */,
+				F7A321AD1E9E6AD50069AD1B /* CCAdvanced.m in Sources */,
 				F7F06EA31DBFACC600099AE9 /* CTAssetCollectionViewController.m in Sources */,
 				F77B0E411D118A16002130FE /* CCSplit.m in Sources */,
 				F77B0E421D118A16002130FE /* ReaderMainPagebar.m in Sources */,

+ 33 - 0
iOSClient/Settings/CCAdvanced.h

@@ -0,0 +1,33 @@
+//
+//  CCAdvanced.h
+//  Crypto Cloud Technology Nextcloud
+//
+//  Created by Marino Faggiana on 12/04/17.
+//  Copyright (c) 2014 TWS. All rights reserved.
+//
+//  Author Marino Faggiana <m.faggiana@twsweb.it>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+#import <MessageUI/MFMailComposeViewController.h>
+#import "XLFormViewController.h"
+#import "XLForm.h"
+#import "CCHud.h"
+
+@interface CCAdvanced : XLFormViewController <MFMailComposeViewControllerDelegate>
+
+@property (nonatomic, strong) CCHud *hud;
+
+@end

+ 483 - 0
iOSClient/Settings/CCAdvanced.m

@@ -0,0 +1,483 @@
+//
+//  CCManageHelp.m
+//  Crypto Cloud Technology Nextcloud
+//
+//  Created by Marino Faggiana on 06/11/15.
+//  Copyright (c) 2014 TWS. All rights reserved.
+//
+//  Author Marino Faggiana <m.faggiana@twsweb.it>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+#import "CCAdvanced.h"
+#import "CCUtility.h"
+#import "AppDelegate.h"
+
+@interface CCAdvanced ()
+
+@end
+
+@implementation CCAdvanced
+
+-(id)init
+{
+    XLFormDescriptor *form ;
+    XLFormSectionDescriptor *section;
+    XLFormRowDescriptor *row;
+    
+    form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_advanced_", nil)];
+
+    // Section ACTIVITY -------------------------------------------------
+    
+    section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_activity_", nil)];
+    [form addFormSection:section];
+    
+    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"activityVerboseHigh" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_help_activity_verbose_", nil)];
+    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
+    [row.cellConfig setObject:[UIImage imageNamed:image_settingsActivityHigh] forKey:@"imageView.image"];
+    if ([CCUtility getActivityVerboseHigh]) row.value = @"1";
+    else row.value = @"0";
+    [section addFormRow:row];
+    
+    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sendMailActivity" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_help_activity_mail_", nil)];
+    [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
+    [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
+    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
+    [row.cellConfig setObject:[UIImage imageNamed:image_settingsSendActivity] forKey:@"imageView.image"];
+    row.action.formSelector = @selector(sendMail:);
+    [section addFormRow:row];
+
+    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"clearActivityLog" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_help_activity_clear_", nil)];
+    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
+    [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
+    [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
+    [row.cellConfig setObject:[UIImage imageNamed:image_settingsClearActivity] forKey:@"imageView.image"];
+    row.action.formSelector = @selector(clearActivity:);
+    [section addFormRow:row];
+    
+    // Section CLEAR CACHE -------------------------------------------------
+    
+    section = [XLFormSectionDescriptor formSection];
+    [form addFormSection:section];
+    
+    // Clear cache
+    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"azzeracache" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_cache_no_size_", nil)];
+    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
+    [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
+    [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
+    [row.cellConfig setObject:[UIImage imageNamed:image_settingsClearCache] forKey:@"imageView.image"];
+    row.action.formSelector = @selector(clearCache:);
+    [section addFormRow:row];
+
+    // Section EXIT --------------------------------------------------------
+    
+    section = [XLFormSectionDescriptor formSection];
+    [form addFormSection:section];
+    
+    // Exit
+    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"esci" rowType:XLFormRowDescriptorTypeButton title:[CCUtility localizableBrand:@"_exit_" table:nil]];
+    [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
+    [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
+    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
+    [row.cellConfig setObject:[UIImage imageNamed:image_settingsExit] forKey:@"imageView.image"];
+    row.action.formSelector = @selector(exitNextcloud:);
+    [section addFormRow:row];
+
+    return [super initWithForm:form];
+}
+
+// Apparirà
+- (void)viewWillAppear:(BOOL)animated
+{
+    [super viewWillAppear:animated];
+    
+    // Color
+    [CCAspect aspectNavigationControllerBar:self.navigationController.navigationBar encrypted:NO online:[app.reachability isReachable] hidden:NO];
+    [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
+    
+    [self recalculateSize];
+}
+
+- (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
+{
+    [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
+    
+    if ([rowDescriptor.tag isEqualToString:@"activityVerboseHigh"]) {
+        
+        if ([[rowDescriptor.value valueData] boolValue] == YES) {
+            [CCUtility setActivityVerboseHigh:true];
+        } else {
+            [CCUtility setActivityVerboseHigh:false];
+        }
+        
+        // Clear Date read Activity for force reload datasource
+        app.activeActivity.storeDateFirstActivity = nil;
+    }
+}
+
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark === Mail ===
+#pragma --------------------------------------------------------------------------------------------
+
+- (void) mailComposeController:(MFMailComposeViewController *)vc didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
+{
+    switch (result)
+    {
+        case MFMailComposeResultCancelled:
+            [app messageNotification:@"_info_" description:@"_mail_deleted_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
+            break;
+        case MFMailComposeResultSaved:
+            [app messageNotification:@"_info_" description:@"_mail_saved_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
+            break;
+        case MFMailComposeResultSent:
+            [app messageNotification:@"_info_" description:@"_mail_sent_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeSuccess];
+            break;
+        case MFMailComposeResultFailed: {
+            NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"_mail_failure_", nil), [error localizedDescription]];
+            [app messageNotification:@"_error_" description:msg visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
+        }
+            break;
+        default:
+            break;
+    }
+    
+    // Close the Mail Interface
+    [self dismissViewControllerAnimated:YES completion:NULL];
+}
+
+- (void)sendMail:(XLFormRowDescriptor *)sender
+{
+    [self deselectFormRow:sender];
+    
+    // Email Subject
+    NSString *emailTitle = NSLocalizedString(@"_information_req_", nil);
+    // Email Content
+    NSString *messageBody;
+    // File Attachment
+    NSString *fileAttachment = @"";
+    // Email Recipents
+    NSArray *toRecipents;
+    
+    NSArray *activities = [CCCoreData getAllTableActivityWithPredicate:[NSPredicate predicateWithFormat:@"((account == %@) || (account == ''))", app.activeAccount]];
+    
+    if ([activities count] == 0) {
+        
+        [app messageNotification:@"_info_" description:@"No activity found" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo];
+        return;
+    }
+    
+    for (TableActivity *activity in activities) {
+        
+        NSString *date, *type, *actionFile, *note;
+        
+        date = [[NSDateFormatter localizedStringFromDate:activity.date dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterMediumStyle] stringByPaddingToLength:22 withString:@" " startingAtIndex:0];
+        
+        if ([activity.type isEqual: k_activityTypeInfo])    type = @"Info   ";
+        if ([activity.type isEqual: k_activityTypeSuccess]) type = @"Success";
+        if ([activity.type isEqual: k_activityTypeFailure]) type = @"Failure";
+        
+        actionFile = [[NSString stringWithFormat:@"%@ %@", activity.action, activity.file] stringByPaddingToLength:100 withString:@" " startingAtIndex:0];
+        
+        if (activity.idActivity == 0) note = [NSString stringWithFormat:@"%@ Selector: %@", activity.note, activity.selector];
+        else note = activity.note;
+        note = [note stringByPaddingToLength:200 withString:@" " startingAtIndex:0];
+        
+        fileAttachment = [fileAttachment stringByAppendingString:[NSString stringWithFormat:@"| %@ | %@ | %@ | %@ |\n", date, type, actionFile, note]];
+    }
+    
+    messageBody = [NSString stringWithFormat:@"\n\n\n%@ Version %@ (%@)", k_brand,[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
+    
+    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+    NSString *documentsDirectory = [paths objectAtIndex:0];
+    NSError *error;
+    
+    if ([fileAttachment writeToFile:[documentsDirectory stringByAppendingPathComponent:@"activity.txt"] atomically:YES encoding:NSUTF8StringEncoding error:&error]) {
+        
+        toRecipents = [NSArray arrayWithObject:k_mailMe];
+        
+        MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
+        mc.mailComposeDelegate = self;
+        [mc setSubject:emailTitle];
+        [mc setMessageBody:messageBody isHTML:NO];
+        [mc setToRecipients:toRecipents];
+        
+        NSData *noteData = [NSData dataWithContentsOfFile:[documentsDirectory stringByAppendingPathComponent:@"activity.txt"]];
+        [mc addAttachmentData:noteData mimeType:@"text/plain" fileName:@"activity.txt"];
+        
+        // Present mail view controller on screen
+        [self presentViewController:mc animated:YES completion:NULL];
+        
+    } else {
+        
+        [app messageNotification:@"_error_" description:@"Impossible create file body" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError];
+    }
+}
+
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark === Clear Activity ===
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)clearActivity:(XLFormRowDescriptor *)sender
+{
+    [self deselectFormRow:sender];
+    
+    [CCCoreData flushTableActivityAccount:app.activeAccount];
+    
+    [app.activeActivity reloadDatasource];
+}
+
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark === Clear Cache ===
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)clearCache:(XLFormRowDescriptor *)sender
+{
+    [self deselectFormRow:sender];
+    
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_cache_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
+    
+    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
+        
+        [self.hud visibleHudTitle:NSLocalizedString(@"_remove_cache_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
+        
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+            
+            [app cancelAllOperations];
+            [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
+            
+            [[NSURLCache sharedURLCache] setMemoryCapacity:0];
+            [[NSURLCache sharedURLCache] setDiskCapacity:0];
+            
+            [CCCoreData flushTableAutomaticUploadAccount:app.activeAccount selector:nil];
+            [CCCoreData flushTableDirectoryAccount:app.activeAccount];
+            [CCCoreData flushTableLocalFileAccount:app.activeAccount];
+            [CCCoreData flushTableMetadataAccount:app.activeAccount];
+            [CCCoreData flushTableActivityAccount:app.activeAccount];
+            
+            [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl];
+            
+            [self emptyLocalDirectory];
+            
+            NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
+            for (NSString *file in tmpDirectory)
+                [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
+            
+            [self recalculateSize];
+            
+            // Inizialized home
+            [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
+            
+            [self.hud hideHud];
+        });
+        
+    }]];
+
+    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+    }]];
+    
+    //if iPhone
+    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
+        
+        [self presentViewController:alertController animated:YES completion:nil];
+    }
+    //if iPad
+    else {
+        
+        // Change Rect to position Popover
+        UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:alertController];
+        [popup presentPopoverFromRect:[self.tableView rectForRowAtIndexPath:[self.form indexPathOfFormRow:sender]] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
+    }
+}
+
+- (void)recalculateSize
+{
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        
+        self.form.delegate = nil;
+        
+        XLFormRowDescriptor *rowAzzeraCache = [self.form formRowWithTag:@"azzeracache"];
+        
+        NSString *size = [CCUtility transformedSize:[[self getUserDirectorySize] longValue]];
+        rowAzzeraCache.title = [NSString stringWithFormat:NSLocalizedString(@"_clear_cache_", nil), size];
+        //rowAzzeraCache.title = NSLocalizedString(@"_clear_cache_no_size_", nil);
+        
+        [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
+        
+        self.form.delegate = self;
+    });
+}
+
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark == Exit Nextcloud ==
+#pragma --------------------------------------------------------------------------------------------
+
+
+- (void)exitNextcloud:(XLFormRowDescriptor *)sender
+{
+    [self deselectFormRow:sender];
+    
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:[CCUtility localizableBrand:@"_want_exit_" table:nil] preferredStyle:UIAlertControllerStyleActionSheet];
+    
+    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
+        
+        [self.hud visibleIndeterminateHud];
+        
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+            
+            [app cancelAllOperations];
+            [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
+            
+            [[NSURLCache sharedURLCache] setMemoryCapacity:0];
+            [[NSURLCache sharedURLCache] setDiskCapacity:0];
+            
+            [[CCNetworking sharedNetworking] invalidateAndCancelAllSession];
+            
+            [CCCoreData flushAllDatabase];
+            
+            [CCUtility deleteAllChainStore];
+            
+            [self emptyDocumentsDirectory];
+            
+            [self emptyLibraryDirectory];
+            
+            [self emptyGroupApplicationSupport];
+            
+            NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
+            for (NSString *file in tmpDirectory)
+                [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
+            
+            [self.hud hideHud];
+            
+            exit(0);
+        });
+    }]];
+    
+    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+    }]];
+    
+    //if iPhone
+    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
+        
+        [self presentViewController:alertController animated:YES completion:nil];
+    }
+    //if iPad
+    else {
+        
+        // Change Rect to position Popover
+        UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:alertController];
+        [popup presentPopoverFromRect:[self.tableView rectForRowAtIndexPath:[self.form indexPathOfFormRow:sender]] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
+    }
+}
+
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark == Utility ==
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)emptyGroupApplicationSupport
+{
+    NSString *file;
+    NSURL *dirGroup = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:k_capabilitiesGroups];
+    NSString *dirIniziale = [[dirGroup URLByAppendingPathComponent:appApplicationSupport] path];
+    
+    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
+    
+    while (file = [enumerator nextObject])
+        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
+}
+
+- (void)emptyLibraryDirectory
+{
+    NSString *file;
+    NSString *dirIniziale;
+    
+    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
+    dirIniziale = [paths objectAtIndex:0];
+    
+    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
+    
+    while (file = [enumerator nextObject])
+        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
+}
+
+- (void)emptyDocumentsDirectory
+{
+    NSString *file;
+    NSString *dirIniziale;
+    
+    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+    dirIniziale = [paths objectAtIndex:0];
+    
+    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
+    
+    while (file = [enumerator nextObject])
+        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
+}
+
+- (void)emptyUserDirectoryUser:(NSString *)user url:(NSString *)url
+{
+    NSString *file;
+    NSString *dirIniziale;
+    
+    dirIniziale = [CCUtility getDirectoryActiveUser:user activeUrl:url];
+    
+    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
+    
+    while (file = [enumerator nextObject]) {
+        
+        NSString *ext = [[file pathExtension] lowercaseString];
+        
+        // Do not remove ICO
+        if ([ext isEqualToString:@"ico"])
+            continue;
+        
+        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
+    }
+}
+
+- (void)emptyLocalDirectory
+{
+    NSString *file;
+    NSString *dirIniziale;
+    
+    dirIniziale = [CCUtility getDirectoryLocal];
+    
+    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
+    
+    while (file = [enumerator nextObject])
+        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
+}
+
+- (NSNumber *)getUserDirectorySize
+{
+    NSString *directoryUser = [CCUtility getDirectoryActiveUser:app.activeUser activeUrl:app.activeUrl];
+    NSURL *directoryURL = [NSURL fileURLWithPath:directoryUser];
+    unsigned long long count = 0;
+    NSNumber *value = nil;
+    
+    if (! directoryURL) return 0;
+    
+    // Get dimension Document
+    for (NSURL *url in [[NSFileManager defaultManager] enumeratorAtURL:directoryURL includingPropertiesForKeys:@[NSURLFileSizeKey] options:0 errorHandler:NULL]) {
+        if ([url getResourceValue:&value forKey:NSURLFileSizeKey error:nil]) {
+            count += [value longLongValue];
+        } else {
+            return nil;
+        }
+    }
+    
+    return @(count);
+}
+
+@end

+ 0 - 1
iOSClient/Settings/CCSettings.h

@@ -37,7 +37,6 @@
 
 @property (strong, nonatomic) NSDate *lockUntilDate;
 
-@property (nonatomic, strong) CCHud *hud;
 
 - (void)reloadForm;
 

+ 7 - 290
iOSClient/Settings/CCSettings.m

@@ -26,6 +26,7 @@
 #import "CCMain.h"
 #import "OCCapabilities.h"
 #import "CCSynchronize.h"
+#import "CCAdvanced.h"
 
 #define alertViewEsci 1
 #define alertViewAzzeraCache 2
@@ -210,6 +211,7 @@
 
     section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_information_", nil)];
     [form addFormSection:section];
+    
     NSString *versionApp = [NSString stringWithFormat:@"%@.%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
     section.footerTitle = [NSString stringWithFormat:k_textCopyright, versionApp];
     
@@ -241,57 +243,18 @@
     row.action.formSelector = @selector(sendMail:);
     [section addFormRow:row];
    
-    // Section CLEAR CACHE -------------------------------------------------
-    
-    section = [XLFormSectionDescriptor formSection];
-    [form addFormSection:section];
-    
-    // Clear cache
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"azzeracache" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_cache_no_size_", nil)];
-    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
-    [row.cellConfig setObject:COLOR_BRAND forKey:@"textLabel.textColor"];
-    [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
-    [row.cellConfig setObject:[UIImage imageNamed:image_settingsClearCache] forKey:@"imageView.image"];
-    row.action.formSelector = @selector(azzeraCache:);
-    [section addFormRow:row];
-
-    // Section EXIT --------------------------------------------------------
+    // Section Advanced -------------------------------------------------
     
     section = [XLFormSectionDescriptor formSection];
     [form addFormSection:section];
     
-    // Exit
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"esci" rowType:XLFormRowDescriptorTypeButton title:[CCUtility localizableBrand:@"_exit_" table:nil]];
-    [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
-    [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
-    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
-    [row.cellConfig setObject:[UIImage imageNamed:image_settingsExit] forKey:@"imageView.image"];
-    row.action.formSelector = @selector(esci:);
-    [section addFormRow:row];
-    
-#ifdef DEBUG
-    /*
-    // Section : debug
-    
-    section = [XLFormSectionDescriptor formSectionWithTitle:@"Debug"];
-    [form addFormSection:section];
-    
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"adminRemoveVersion" rowType:XLFormRowDescriptorTypeButton title:@"Remove Version"];
-    [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
+    // Advanced
+    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"advanced" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_advanced_", nil)];
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
-    [row.cellConfig setObject:[UIImage imageNamed:image_settingsAdmin] forKey:@"imageView.image"];
-    row.action.formSelector = @selector(adminRemoveVersion:);
+    [row.cellConfig setObject:[UIImage imageNamed:image_settingsHelp] forKey:@"imageView.image"];
+    row.action.viewControllerClass = [CCAdvanced class];
     [section addFormRow:row];
     
-    row = [XLFormRowDescriptor formRowDescriptorWithTag:@"quickActionPhotos" rowType:XLFormRowDescriptorTypeButton title:@"Quick Action Photos"];
-    [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
-    [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
-    [row.cellConfig setObject:[UIImage imageNamed:image_settingsAdmin] forKey:@"imageView.image"];
-    row.action.formSelector = @selector(quickActionPhotos:);
-    [section addFormRow:row];
-    */
-#endif
-
     self.form = form;
 }
 
@@ -299,7 +262,6 @@
 {
     [super viewDidLoad];
     
-    self.hud = [[CCHud alloc] initWithView:[[[UIApplication sharedApplication] delegate] window]];
     self.title = NSLocalizedString(@"_settings_", nil);
     
     // Color
@@ -317,7 +279,6 @@
     [CCAspect aspectTabBar:self.tabBarController.tabBar hidden:NO];
     
     [self reloadForm];
-    [self recalculateSize];    
 }
 
 // E' apparsa
@@ -355,30 +316,6 @@
     return nil;
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark === Admin ===
-#pragma --------------------------------------------------------------------------------------------
-
-/*
-- (void)adminRemoveVersion:(XLFormRowDescriptor *)sender
-{
-    [self deselectFormRow:sender];
-    
-    [CCUtility adminRemoveVersion];
-    
-    exit(0);
-}
-
-- (void)quickActionPhotos:(XLFormRowDescriptor *)sender
-{
-    NSString *bundleId = [NSBundle mainBundle].bundleIdentifier;
-    
-     UIApplicationShortcutItem *shortcutPhotos = [[UIApplicationShortcutItem alloc] initWithType:[NSString stringWithFormat:@"%@.photos", bundleId] localizedTitle:@"" localizedSubtitle:nil icon:nil userInfo:nil];
-    
-    [app handleShortCutItem:shortcutPhotos];
-}
-*/
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark === Chiamate dal Form ===
 #pragma --------------------------------------------------------------------------------------------
@@ -459,24 +396,6 @@
     self.form.delegate = self;
 }
 
-- (void)recalculateSize
-{
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
-        self.form.delegate = nil;
-
-        XLFormRowDescriptor *rowAzzeraCache = [self.form formRowWithTag:@"azzeracache"];
-
-        NSString *size = [CCUtility transformedSize:[[self getUserDirectorySize] longValue]];
-        rowAzzeraCache.title = [NSString stringWithFormat:NSLocalizedString(@"_clear_cache_", nil), size];
-        //rowAzzeraCache.title = NSLocalizedString(@"_clear_cache_no_size_", nil);
-        
-        [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
-
-        self.form.delegate = self;
-    });
-}
-
 - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
 {
     [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
@@ -652,32 +571,6 @@
     
 }
 
-- (void)esci:(XLFormRowDescriptor *)sender
-{
-    [self deselectFormRow:sender];
-    UIAlertView * alertView =[[UIAlertView alloc ] initWithTitle:[CCUtility localizableBrand:@"_exit_" table:nil]
-                                                         message:[CCUtility localizableBrand:@"_want_exit_" table:nil]
-                                                        delegate:self
-                                               cancelButtonTitle:NSLocalizedString(@"_cancel_", nil)
-                                               otherButtonTitles: nil];
-    alertView.tag = alertViewEsci;
-    [alertView addButtonWithTitle:NSLocalizedString(@"_proceed_", nil)];
-    [alertView show];
-}
-
-- (void)azzeraCache:(XLFormRowDescriptor *)sender
-{
-    [self deselectFormRow:sender];
-    UIAlertView * alertView =[[UIAlertView alloc ] initWithTitle:NSLocalizedString(@"_delete_cache_",nil)
-                                                         message:NSLocalizedString(@"_want_delete_cache_", nil)
-                                                        delegate:self
-                                               cancelButtonTitle:NSLocalizedString(@"_cancel_", nil)
-                                               otherButtonTitles: nil];
-    alertView.tag = alertViewAzzeraCache;
-    [alertView addButtonWithTitle:NSLocalizedString(@"_proceed_", nil)];
-    [alertView show];
-}
-
 - (void)quota:(XLFormRowDescriptor *)sender
 {
     [self deselectFormRow:sender];
@@ -762,84 +655,6 @@
     [CCUtility sendMailEncryptPass:[CCUtility getEmail] validateEmail:NO form:self];
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark === AlertView ===
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
-{
-    // Remove ALL
-    if (buttonIndex == 1 && alertView.tag == alertViewEsci)
-    {
-        [self.hud visibleIndeterminateHud];
-        
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
-
-            [app cancelAllOperations];
-            [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
-        
-            [[NSURLCache sharedURLCache] setMemoryCapacity:0];
-            [[NSURLCache sharedURLCache] setDiskCapacity:0];
-            
-            [[CCNetworking sharedNetworking] invalidateAndCancelAllSession];
-        
-            [CCCoreData flushAllDatabase];
-        
-            [CCUtility deleteAllChainStore];
-            
-            [self emptyDocumentsDirectory];
-        
-            [self emptyLibraryDirectory];
-        
-            [self emptyGroupApplicationSupport];
-            
-            NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
-            for (NSString *file in tmpDirectory)
-                [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
-            
-            [self.hud hideHud];
-            
-            exit(0);
-        });
-    }
-    
-    // Clear Cache
-    if (buttonIndex == 1 && alertView.tag == alertViewAzzeraCache)
-    {
-        [self.hud visibleHudTitle:NSLocalizedString(@"_remove_cache_", nil) mode:MBProgressHUDModeIndeterminate color:nil];
-        
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.01 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
-            
-            [app cancelAllOperations];
-            [[CCNetworking sharedNetworking] settingSessionsDownload:YES upload:YES taskStatus:k_taskStatusCancel activeAccount:app.activeAccount activeUser:app.activeUser activeUrl:app.activeUrl];
-
-            [[NSURLCache sharedURLCache] setMemoryCapacity:0];
-            [[NSURLCache sharedURLCache] setDiskCapacity:0];
-            
-            [CCCoreData flushTableAutomaticUploadAccount:app.activeAccount selector:nil];
-            [CCCoreData flushTableDirectoryAccount:app.activeAccount];
-            [CCCoreData flushTableLocalFileAccount:app.activeAccount];
-            [CCCoreData flushTableMetadataAccount:app.activeAccount];
-            [CCCoreData flushTableActivityAccount:app.activeAccount];
-            
-            [self emptyUserDirectoryUser:app.activeUser url:app.activeUrl];
-        
-            [self emptyLocalDirectory];
-            
-            NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
-            for (NSString *file in tmpDirectory) 
-                [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
-                
-            [self recalculateSize];
-                
-            // Inizialized home
-            [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
-                                
-            [self.hud hideHud];
-        });
-    }
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark === BKPasscodeViewController ===
 #pragma --------------------------------------------------------------------------------------------
@@ -957,103 +772,5 @@
     [self dismissViewControllerAnimated:YES completion:nil];
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark == Utility ==
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)emptyGroupApplicationSupport
-{
-    NSString *file;
-    NSURL *dirGroup = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:k_capabilitiesGroups];
-    NSString *dirIniziale = [[dirGroup URLByAppendingPathComponent:appApplicationSupport] path];
-    
-    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
-    
-    while (file = [enumerator nextObject])
-        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
-}
-
-- (void)emptyLibraryDirectory
-{
-    NSString *file;
-    NSString *dirIniziale;
-    
-    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
-    dirIniziale = [paths objectAtIndex:0];
-    
-    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
-    
-    while (file = [enumerator nextObject])
-        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
-}
-
-- (void)emptyDocumentsDirectory
-{
-    NSString *file;
-    NSString *dirIniziale;
-    
-    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-    dirIniziale = [paths objectAtIndex:0];
-    
-    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
-    
-    while (file = [enumerator nextObject])
-        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
-}
-
-- (void)emptyUserDirectoryUser:(NSString *)user url:(NSString *)url
-{
-    NSString *file;
-    NSString *dirIniziale;
-    
-    dirIniziale = [CCUtility getDirectoryActiveUser:user activeUrl:url];
-    
-    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
-    
-    while (file = [enumerator nextObject]) {
-        
-        NSString *ext = [[file pathExtension] lowercaseString];
-        
-        // Do not remove ICO
-        if ([ext isEqualToString:@"ico"])
-            continue;
-        
-        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
-    }
-}
-
-- (void)emptyLocalDirectory
-{
-    NSString *file;
-    NSString *dirIniziale;
-    
-    dirIniziale = [CCUtility getDirectoryLocal];
-    
-    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:dirIniziale];
-    
-    while (file = [enumerator nextObject])
-        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@", dirIniziale, file] error:nil];
-}
-
-- (NSNumber *)getUserDirectorySize
-{
-    NSString *directoryUser = [CCUtility getDirectoryActiveUser:app.activeUser activeUrl:app.activeUrl];
-    NSURL *directoryURL = [NSURL fileURLWithPath:directoryUser];
-    unsigned long long count = 0;
-    NSNumber *value = nil;
-    
-    if (! directoryURL) return 0;
-    
-    // Get dimension Document
-    for (NSURL *url in [[NSFileManager defaultManager] enumeratorAtURL:directoryURL includingPropertiesForKeys:@[NSURLFileSizeKey] options:0 errorHandler:NULL]) {
-        if ([url getResourceValue:&value forKey:NSURLFileSizeKey error:nil]) {
-            count += [value longLongValue];
-        } else {
-            return nil;
-        }
-    }
-    
-    return @(count);
-}
 
 @end

+ 0 - 1
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -190,7 +190,6 @@
 
 "_help_tutorial_"               = "Tutorial";
 "_help_intro_"                  = "Introduction _brand_";
-"_help_activity_section_"       = "Activity";
 "_help_activity_verbose_"       = "Detailed Activity feed";
 "_help_activity_mail_"          = "Send activity by mail";
 "_help_activity_clear_"         = "Clear activity";