CCAdvanced.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. //
  2. // CCManageHelp.m
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 06/11/15.
  6. // Copyright (c) 2015 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import "CCAdvanced.h"
  24. #import "CCUtility.h"
  25. #import "NCBridgeSwift.h"
  26. @interface CCAdvanced ()
  27. {
  28. AppDelegate *appDelegate;
  29. XLFormSectionDescriptor *sectionSize;
  30. }
  31. @end
  32. @implementation CCAdvanced
  33. - (void)initializeForm
  34. {
  35. XLFormDescriptor *form = [XLFormDescriptor formDescriptor];
  36. XLFormSectionDescriptor *section;
  37. XLFormRowDescriptor *row;
  38. // Section HIDDEN FILES -------------------------------------------------
  39. section = [XLFormSectionDescriptor formSection];
  40. [form addFormSection:section];
  41. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"showHiddenFiles" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_show_hidden_files_", nil)];
  42. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  43. if ([[[NCKeychain alloc] init] showHiddenFiles]) row.value = @"1";
  44. else row.value = @"0";
  45. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  46. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  47. [section addFormRow:row];
  48. // Format Compatibility + Live Photo + Delete asset
  49. section = [XLFormSectionDescriptor formSection];
  50. [form addFormSection:section];
  51. section.footerTitle = [NSString stringWithFormat:@"%@\n%@\n%@", NSLocalizedString(@"_format_compatibility_footer_", nil), NSLocalizedString(@"_upload_mov_livephoto_footer_", nil), NSLocalizedString(@"_remove_photo_CameraRoll_desc_", nil)];
  52. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"formatCompatibility" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_format_compatibility_", nil)];
  53. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  54. if ([[[NCKeychain alloc] init] formatCompatibility]) row.value = @"1";
  55. else row.value = @"0";
  56. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  57. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  58. [section addFormRow:row];
  59. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"livePhoto" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_upload_mov_livephoto_", nil)];
  60. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  61. if ([[[NCKeychain alloc] init] livePhoto]) row.value = @"1";
  62. else row.value = @"0";
  63. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  64. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  65. [section addFormRow:row];
  66. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removePhotoCameraRoll" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_remove_photo_CameraRoll_", nil)];
  67. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  68. if ([[[NCKeychain alloc] init] removePhotoCameraRoll]) row.value = @"1";
  69. else row.value = @0;
  70. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  71. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  72. [section addFormRow:row];
  73. // Section : Files App --------------------------------------------------------------
  74. if (![NCBrandOptions shared].disable_openin_file) {
  75. section = [XLFormSectionDescriptor formSection];
  76. [form addFormSection:section];
  77. section.footerTitle = NSLocalizedString(@"_disable_files_app_footer_", nil);
  78. // Disable Files App
  79. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"disablefilesapp" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_disable_files_app_", nil)];
  80. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  81. if ([[NCKeychain alloc] init].disableFilesApp) row.value = @"1";
  82. else row.value = @"0";
  83. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  84. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  85. [section addFormRow:row];
  86. }
  87. // Section : Privacy --------------------------------------------------------------
  88. if (!NCBrandOptions.shared.disable_crash_service) {
  89. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_privacy_", nil)];
  90. [form addFormSection:section];
  91. section.footerTitle = NSLocalizedString(@"_privacy_footer_", nil);
  92. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"crashservice" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_crashservice_title_", nil)];
  93. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  94. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  95. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  96. [row.cellConfig setObject:[[UIImage imageNamed:@"crashservice"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
  97. if ([[[NCKeychain alloc] init] disableCrashservice]) row.value = @"1";
  98. else row.value = @"0";
  99. [section addFormRow:row];
  100. }
  101. // Section DIAGNOSTICS -------------------------------------------------
  102. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_diagnostics_", nil)];
  103. [form addFormSection:section];
  104. if ([[NSFileManager defaultManager] fileExistsAtPath:NextcloudKit.shared.nkCommonInstance.filenamePathLog] && NCBrandOptions.shared.disable_log == false) {
  105. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"log" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_view_log_", nil)];
  106. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  107. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  108. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  109. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  110. [row.cellConfig setObject:[[UIImage imageNamed:@"log"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
  111. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  112. [self deselectFormRow:sender];
  113. NCViewerQuickLook *viewerQuickLook = [[NCViewerQuickLook alloc] initWith:[NSURL fileURLWithPath:NextcloudKit.shared.nkCommonInstance.filenamePathLog] isEditingEnabled:false metadata:nil];
  114. [self presentViewController:viewerQuickLook animated:YES completion:nil];
  115. };
  116. [section addFormRow:row];
  117. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"clearlog" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_log_", nil)];
  118. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  119. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  120. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  121. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  122. [row.cellConfig setObject:[[UIImage imageNamed:@"clear"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
  123. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  124. [self deselectFormRow:sender];
  125. [[[NextcloudKit shared] nkCommonInstance] clearFileLog];
  126. NSInteger logLevel = [[NCKeychain alloc] init].logLevel;
  127. BOOL isSimulatorOrTestFlight = [[[NCUtility alloc] init] isSimulatorOrTestFlight];
  128. NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, [[[NCUtility alloc] init] getVersionAppWithBuild:true]];
  129. if (isSimulatorOrTestFlight) {
  130. [[[NextcloudKit shared] nkCommonInstance] writeLog:[NSString stringWithFormat:@"[INFO] Clear log with level %lu %@ (Simulator / TestFlight)", (unsigned long)logLevel, versionNextcloudiOS]];
  131. } else {
  132. [[[NextcloudKit shared] nkCommonInstance] writeLog:[NSString stringWithFormat:@"[INFO] Clear log with level %lu %@", (unsigned long)logLevel, versionNextcloudiOS]];
  133. }
  134. };
  135. [section addFormRow:row];
  136. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"logLevel" rowType:XLFormRowDescriptorTypeSlider title:NSLocalizedString(@"_level_log_", nil)];
  137. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  138. [row.cellConfig setObject:@(NSTextAlignmentCenter) forKey:@"textLabel.textAlignment"];
  139. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  140. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  141. NSInteger logLevel = [[NCKeychain alloc] init].logLevel;
  142. row.value = @(logLevel);
  143. [row.cellConfigAtConfigure setObject:@(2) forKey:@"slider.maximumValue"];
  144. [row.cellConfigAtConfigure setObject:@(0) forKey:@"slider.minimumValue"];
  145. [row.cellConfigAtConfigure setObject:@(2) forKey:@"steps"];
  146. [section addFormRow:row];
  147. }
  148. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"capabilities" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_capabilities_", nil)];
  149. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  150. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  151. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  152. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  153. [row.cellConfig setObject:[[UIImage imageNamed:@"capabilities"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
  154. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  155. [self deselectFormRow:sender];
  156. UIViewController *vc = [[NCHostingCapabilitiesView alloc] makeShipDetailsUI];
  157. [self.navigationController pushViewController:vc animated:YES];
  158. };
  159. [section addFormRow:row];
  160. // Section : Delete files / Clear cache --------------------------------------------------------------
  161. sectionSize = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_delete_files_desc_", nil)];
  162. [form addFormSection:sectionSize];
  163. sectionSize.footerTitle = NSLocalizedString(@"_clear_cache_footer_", nil);
  164. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deleteoldfiles" rowType:XLFormRowDescriptorTypeSelectorPush title:NSLocalizedString(@"_delete_old_files_", nil)];
  165. switch ([[NCKeychain alloc] init].cleanUpDay) {
  166. case 0:
  167. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:NSLocalizedString(@"_never_", nil)];
  168. break;
  169. case 365:
  170. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(365) displayText:NSLocalizedString(@"_1_year_", nil)];
  171. break;
  172. case 180:
  173. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(180) displayText:NSLocalizedString(@"_6_months_", nil)];
  174. break;
  175. case 90:
  176. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(90) displayText:NSLocalizedString(@"_3_months_", nil)];
  177. break;
  178. case 30:
  179. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(30) displayText:NSLocalizedString(@"_1_month_", nil)];
  180. break;
  181. case 7:
  182. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(7) displayText:NSLocalizedString(@"_1_week_", nil)];
  183. break;
  184. case 1:
  185. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:NSLocalizedString(@"_1_day_", nil)];
  186. break;
  187. default:
  188. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:NSLocalizedString(@"_never_", nil)];
  189. break;
  190. }
  191. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  192. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  193. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  194. row.selectorTitle = NSLocalizedString(@"_delete_old_files_", nil);
  195. row.selectorOptions = @[[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:NSLocalizedString(@"_never_", nil)],
  196. [XLFormOptionsObject formOptionsObjectWithValue:@(365) displayText:NSLocalizedString(@"_1_year_", nil)],
  197. [XLFormOptionsObject formOptionsObjectWithValue:@(180) displayText:NSLocalizedString(@"_6_months_", nil)],
  198. [XLFormOptionsObject formOptionsObjectWithValue:@(90) displayText:NSLocalizedString(@"_3_months_", nil)],
  199. [XLFormOptionsObject formOptionsObjectWithValue:@(30) displayText:NSLocalizedString(@"_1_month_", nil)],
  200. [XLFormOptionsObject formOptionsObjectWithValue:@(7) displayText:NSLocalizedString(@"_1_week_", nil)],
  201. ];
  202. [sectionSize addFormRow:row];
  203. // Clear cache
  204. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"azzeracache" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_cache_", nil)];
  205. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  206. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  207. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  208. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  209. [row.cellConfig setObject:[[UIImage imageNamed:@"trash"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
  210. row.action.formSelector = @selector(clearCacheRequest:);
  211. [sectionSize addFormRow:row];
  212. // Section EXIT --------------------------------------------------------
  213. section = [XLFormSectionDescriptor formSection];
  214. [form addFormSection:section];
  215. section.footerTitle = NSLocalizedString(@"_exit_footer_", nil);
  216. // Exit
  217. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"esci" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_exit_", nil)];
  218. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  219. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  220. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  221. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  222. [row.cellConfig setObject:[[UIImage imageNamed:@"xmark"] imageWithColor:[UIColor redColor] size:25] forKey:@"imageView.image"];
  223. row.action.formSelector = @selector(exitNextcloud:);
  224. [section addFormRow:row];
  225. self.tableView.showsVerticalScrollIndicator = NO;
  226. self.form = form;
  227. }
  228. // MARK: - View Life Cycle
  229. - (void)viewDidLoad
  230. {
  231. [super viewDidLoad];
  232. self.title = NSLocalizedString(@"_advanced_", nil);
  233. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  234. self.view.backgroundColor = UIColor.systemGroupedBackgroundColor;
  235. self.tableView.backgroundColor = UIColor.systemGroupedBackgroundColor;
  236. [self initializeForm];
  237. [self calculateSize];
  238. }
  239. - (void)viewWillAppear:(BOOL)animated
  240. {
  241. [super viewWillAppear:animated];
  242. appDelegate.activeViewController = self;
  243. }
  244. #pragma mark -
  245. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  246. {
  247. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  248. if ([rowDescriptor.tag isEqualToString:@"showHiddenFiles"]) {
  249. [[NCKeychain alloc] init].showHiddenFiles = [[rowDescriptor.value valueData] boolValue];
  250. }
  251. if ([rowDescriptor.tag isEqualToString:@"formatCompatibility"]) {
  252. [[NCKeychain alloc] init].formatCompatibility = [[rowDescriptor.value valueData] boolValue];
  253. }
  254. if ([rowDescriptor.tag isEqualToString:@"livePhoto"]) {
  255. [[NCKeychain alloc] init].livePhoto = [[rowDescriptor.value valueData] boolValue];
  256. }
  257. if ([rowDescriptor.tag isEqualToString:@"removePhotoCameraRoll"]) {
  258. [[NCKeychain alloc] init].removePhotoCameraRoll = [[rowDescriptor.value valueData] boolValue];
  259. }
  260. if ([rowDescriptor.tag isEqualToString:@"disablefilesapp"]) {
  261. [[NCKeychain alloc] init].disableFilesApp = [[rowDescriptor.value valueData] boolValue];
  262. }
  263. if ([rowDescriptor.tag isEqualToString:@"crashservice"]) {
  264. [[NCKeychain alloc] init].disableCrashservice = [[rowDescriptor.value valueData] boolValue];
  265. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_crashservice_title_", nil) message:NSLocalizedString(@"_crashservice_alert_", nil) preferredStyle:UIAlertControllerStyleAlert];
  266. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  267. exit(0);
  268. }];
  269. [alertController addAction:okAction];
  270. [self presentViewController:alertController animated:YES completion:nil];
  271. }
  272. if ([rowDescriptor.tag isEqualToString:@"logLevel"]) {
  273. NSInteger levelLog = [[rowDescriptor.value valueData] intValue];
  274. [[NCKeychain alloc] init].logLevel = levelLog;
  275. [[[NextcloudKit shared] nkCommonInstance] setLevelLog:levelLog];
  276. }
  277. if ([rowDescriptor.tag isEqualToString:@"deleteoldfiles"]) {
  278. NSInteger days = [[rowDescriptor.value valueData] intValue];
  279. [[NCKeychain alloc] init].cleanUpDay = days;
  280. }
  281. }
  282. #pragma mark - Clear Cache
  283. - (void)clearCache:(NSString *)account
  284. {
  285. [[NCNetworking shared] cancelAllTask];
  286. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  287. NCUtilityFileSystem *ufs = [[NCUtilityFileSystem alloc] init];
  288. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  289. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  290. [[NCManageDatabase shared] clearDatabaseWithAccount:account removeAccount:false];
  291. [ufs removeGroupDirectoryProviderStorage];
  292. [ufs removeGroupLibraryDirectory];
  293. [ufs removeDocumentsDirectory];
  294. [ufs removeTemporaryDirectory];
  295. [ufs createDirectoryStandard];
  296. [[NCAutoUpload shared] alignPhotoLibraryWithViewController:self];
  297. [[NCImageCache shared] clearMediaCache];
  298. [[NCActivityIndicator shared] stop];
  299. [self calculateSize];
  300. });
  301. }
  302. - (void)clearCacheRequest:(XLFormRowDescriptor *)sender
  303. {
  304. [self deselectFormRow:sender];
  305. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_cache_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  306. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_yes_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  307. [[NCActivityIndicator shared] startActivityWithBackgroundView:nil style: UIActivityIndicatorViewStyleLarge blurEffect:true];
  308. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  309. [self clearCache:appDelegate.account];
  310. });
  311. }]];
  312. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  313. }]];
  314. alertController.popoverPresentationController.sourceView = self.view;
  315. NSIndexPath *indexPath = [self.form indexPathOfFormRow:sender];
  316. CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
  317. alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
  318. [self presentViewController:alertController animated:YES completion:nil];
  319. }
  320. - (void)calculateSize
  321. {
  322. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  323. NCUtilityFileSystem *ufs = [[NCUtilityFileSystem alloc] init];
  324. NSString *directory = [ufs directoryProviderStorage];
  325. int64_t totalSize = [ufs getDirectorySizeWithDirectory:directory];
  326. sectionSize.footerTitle = [NSString stringWithFormat:@"%@. (%@ %@)", NSLocalizedString(@"_clear_cache_footer_", nil), NSLocalizedString(@"_used_space_", nil), [ufs transformedSize:totalSize]];
  327. dispatch_async(dispatch_get_main_queue(), ^{
  328. [self.tableView reloadData];
  329. });
  330. });
  331. }
  332. #pragma mark - Exit Nextcloud
  333. - (void)exitNextcloud:(XLFormRowDescriptor *)sender
  334. {
  335. [self deselectFormRow:sender];
  336. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_exit_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  337. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  338. [appDelegate resetApplication];
  339. }]];
  340. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  341. }]];
  342. alertController.popoverPresentationController.sourceView = self.view;
  343. NSIndexPath *indexPath = [self.form indexPathOfFormRow:sender];
  344. CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
  345. alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
  346. [self presentViewController:alertController animated:YES completion:nil];
  347. }
  348. #pragma mark -
  349. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  350. if (indexPath.section == 4 && indexPath.row == 2) {
  351. return 80;
  352. } else {
  353. return NCGlobal.shared.heightCellSettings;
  354. }
  355. }
  356. @end