CCAdvanced.m 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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 "NSNotificationCenter+MainThread.h"
  26. #import "NCBridgeSwift.h"
  27. @interface CCAdvanced ()
  28. {
  29. AppDelegate *appDelegate;
  30. XLFormSectionDescriptor *sectionSize;
  31. }
  32. @end
  33. @implementation CCAdvanced
  34. - (void)initializeForm
  35. {
  36. XLFormDescriptor *form = [XLFormDescriptor formDescriptor];
  37. XLFormSectionDescriptor *section;
  38. XLFormRowDescriptor *row;
  39. // Section HIDDEN FILES -------------------------------------------------
  40. section = [XLFormSectionDescriptor formSection];
  41. [form addFormSection:section];
  42. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"showHiddenFiles" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_show_hidden_files_", nil)];
  43. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  44. if ([CCUtility getShowHiddenFiles]) row.value = @"1";
  45. else row.value = @"0";
  46. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  47. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  48. [section addFormRow:row];
  49. // Format Compatibility + Live Photo + Delete asset
  50. section = [XLFormSectionDescriptor formSection];
  51. [form addFormSection:section];
  52. section.footerTitle = [NSString stringWithFormat:@"%@\n%@\n%@", NSLocalizedString(@"_format_compatibility_footer_", nil), NSLocalizedString(@"_upload_mov_livephoto_footer_", nil), NSLocalizedString(@"_remove_photo_CameraRoll_desc_", nil)];
  53. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"formatCompatibility" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_format_compatibility_", nil)];
  54. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  55. if ([CCUtility getFormatCompatibility]) row.value = @"1";
  56. else row.value = @"0";
  57. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  58. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  59. [section addFormRow:row];
  60. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"livePhoto" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_upload_mov_livephoto_", nil)];
  61. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  62. if ([CCUtility getLivePhoto]) row.value = @"1";
  63. else row.value = @"0";
  64. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  65. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  66. [section addFormRow:row];
  67. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"removePhotoCameraRoll" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_remove_photo_CameraRoll_", nil)];
  68. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  69. if ([CCUtility getRemovePhotoCameraRoll]) row.value = @"1";
  70. else row.value = @0;
  71. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  72. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  73. [section addFormRow:row];
  74. // Disable Local Cache After Upload
  75. section = [XLFormSectionDescriptor formSection];
  76. [form addFormSection:section];
  77. section.footerTitle = NSLocalizedString(@"_disableLocalCacheAfterUpload_footer_", nil);
  78. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"disableLocalCacheAfterUpload" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_disableLocalCacheAfterUpload_", nil)];
  79. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  80. if ([CCUtility getDisableLocalCacheAfterUpload]) row.value = @"1";
  81. else row.value = @"0";
  82. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  83. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  84. [section addFormRow:row];
  85. // Section : Files App --------------------------------------------------------------
  86. if (![NCBrandOptions shared].disable_openin_file) {
  87. section = [XLFormSectionDescriptor formSection];
  88. [form addFormSection:section];
  89. section.footerTitle = NSLocalizedString(@"_disable_files_app_footer_", nil);
  90. // Disable Files App
  91. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"disablefilesapp" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_disable_files_app_", nil)];
  92. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  93. if ([CCUtility getDisableFilesApp]) row.value = @"1";
  94. else row.value = @"0";
  95. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  96. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  97. [section addFormRow:row];
  98. }
  99. // Section : Chunk --------------------------------------------------------------
  100. section = [XLFormSectionDescriptor formSection];
  101. [form addFormSection:section];
  102. section.footerTitle = NSLocalizedString(@"_chunk_footer_title_", nil);
  103. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"chunk" rowType:XLFormRowDescriptorTypeStepCounter title:NSLocalizedString(@"_chunk_size_mb_", nil)];
  104. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  105. row.value = [NSString stringWithFormat:@"%ld", CCUtility.getChunkSize];
  106. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  107. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  108. [row.cellConfigAtConfigure setObject:@YES forKey:@"stepControl.wraps"];
  109. [row.cellConfigAtConfigure setObject:@1 forKey:@"stepControl.stepValue"];
  110. [row.cellConfigAtConfigure setObject:@0 forKey:@"stepControl.minimumValue"];
  111. [row.cellConfigAtConfigure setObject:@100 forKey:@"stepControl.maximumValue"];
  112. [section addFormRow:row];
  113. // Section : Privacy --------------------------------------------------------------
  114. if (!NCBrandOptions.shared.disable_crash_service) {
  115. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_privacy_", nil)];
  116. [form addFormSection:section];
  117. section.footerTitle = NSLocalizedString(@"_privacy_footer_", nil);
  118. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"crashservice" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_crashservice_title_", nil)];
  119. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  120. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  121. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  122. [row.cellConfig setObject:[[UIImage imageNamed:@"crashservice"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  123. if ([CCUtility getDisableCrashservice]) row.value = @"1";
  124. else row.value = @"0";
  125. [section addFormRow:row];
  126. }
  127. // Section DIAGNOSTICS -------------------------------------------------
  128. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_diagnostics_", nil)];
  129. [form addFormSection:section];
  130. if ([[NSFileManager defaultManager] fileExistsAtPath:NCCommunicationCommon.shared.filenamePathLog] && NCBrandOptions.shared.disable_log == false) {
  131. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"log" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_view_log_", nil)];
  132. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  133. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  134. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  135. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  136. [row.cellConfig setObject:[[UIImage imageNamed:@"log"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  137. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  138. [self deselectFormRow:sender];
  139. NCViewerQuickLook *viewerQuickLook = [[NCViewerQuickLook alloc] initWith:[NSURL fileURLWithPath:NCCommunicationCommon.shared.filenamePathLog] isEditingEnabled:false metadata:nil];
  140. [self presentViewController:viewerQuickLook animated:YES completion:nil];
  141. };
  142. [section addFormRow:row];
  143. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"clearlog" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_log_", nil)];
  144. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  145. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  146. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  147. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  148. [row.cellConfig setObject:[[UIImage imageNamed:@"clear"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  149. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  150. [self deselectFormRow:sender];
  151. [[NCCommunicationCommon shared] clearFileLog];
  152. NSInteger logLevel = [CCUtility getLogLevel];
  153. BOOL isSimulatorOrTestFlight = [[NCUtility shared] isSimulatorOrTestFlight];
  154. NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp];
  155. if (isSimulatorOrTestFlight) {
  156. [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Clear log with level %lu %@ (Simulator / TestFlight)", (unsigned long)logLevel, versionNextcloudiOS]];
  157. } else {
  158. [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Clear log with level %lu %@", (unsigned long)logLevel, versionNextcloudiOS]];
  159. }
  160. };
  161. [section addFormRow:row];
  162. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"logLevel" rowType:XLFormRowDescriptorTypeSlider title:NSLocalizedString(@"_level_log_", nil)];
  163. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  164. [row.cellConfig setObject:@(NSTextAlignmentCenter) forKey:@"textLabel.textAlignment"];
  165. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  166. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  167. NSInteger logLevel = [CCUtility getLogLevel];
  168. row.value = @(logLevel);
  169. [row.cellConfigAtConfigure setObject:@(2) forKey:@"slider.maximumValue"];
  170. [row.cellConfigAtConfigure setObject:@(0) forKey:@"slider.minimumValue"];
  171. [row.cellConfigAtConfigure setObject:@(2) forKey:@"steps"];
  172. [section addFormRow:row];
  173. }
  174. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"capabilities" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_capabilities_", nil)];
  175. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  176. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  177. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  178. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  179. [row.cellConfig setObject:[[UIImage imageNamed:@"capabilities"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  180. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  181. [self deselectFormRow:sender];
  182. NCCapabilitiesViewController *capabilities = [[UIStoryboard storyboardWithName:@"NCCapabilitiesViewController" bundle:nil] instantiateInitialViewController];
  183. [self presentViewController:capabilities animated:YES completion:nil];
  184. };
  185. [section addFormRow:row];
  186. // Section : Delete files / Clear cache --------------------------------------------------------------
  187. sectionSize = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_delete_files_desc_", nil)];
  188. [form addFormSection:sectionSize];
  189. sectionSize.footerTitle = NSLocalizedString(@"_clear_cache_footer_", nil);
  190. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"deleteoldfiles" rowType:XLFormRowDescriptorTypeSelectorPush title:NSLocalizedString(@"_delete_old_files_", nil)];
  191. switch (CCUtility.getCleanUpDay) {
  192. case 0:
  193. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:NSLocalizedString(@"_never_", nil)];
  194. break;
  195. case 365:
  196. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(365) displayText:NSLocalizedString(@"_1_year_", nil)];
  197. break;
  198. case 180:
  199. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(180) displayText:NSLocalizedString(@"_6_months_", nil)];
  200. break;
  201. case 90:
  202. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(90) displayText:NSLocalizedString(@"_3_months_", nil)];
  203. break;
  204. case 30:
  205. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(30) displayText:NSLocalizedString(@"_1_month_", nil)];
  206. break;
  207. case 7:
  208. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(7) displayText:NSLocalizedString(@"_1_week_", nil)];
  209. break;
  210. case 1:
  211. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:NSLocalizedString(@"_1_day_", nil)];
  212. break;
  213. default:
  214. row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:NSLocalizedString(@"_never_", nil)];
  215. break;
  216. }
  217. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  218. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  219. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  220. row.selectorTitle = NSLocalizedString(@"_delete_old_files_", nil);
  221. row.selectorOptions = @[[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:NSLocalizedString(@"_never_", nil)],
  222. [XLFormOptionsObject formOptionsObjectWithValue:@(365) displayText:NSLocalizedString(@"_1_year_", nil)],
  223. [XLFormOptionsObject formOptionsObjectWithValue:@(180) displayText:NSLocalizedString(@"_6_months_", nil)],
  224. [XLFormOptionsObject formOptionsObjectWithValue:@(90) displayText:NSLocalizedString(@"_3_months_", nil)],
  225. [XLFormOptionsObject formOptionsObjectWithValue:@(30) displayText:NSLocalizedString(@"_1_month_", nil)],
  226. [XLFormOptionsObject formOptionsObjectWithValue:@(7) displayText:NSLocalizedString(@"_1_week_", nil)],
  227. //[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:NSLocalizedString(@"_1_day_", nil)],
  228. ];
  229. [sectionSize addFormRow:row];
  230. // Clear cache
  231. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"azzeracache" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_cache_", nil)];
  232. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  233. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  234. [row.cellConfig setObject:NCBrandColor.shared.label forKey:@"textLabel.textColor"];
  235. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  236. [row.cellConfig setObject:[[UIImage imageNamed:@"trash"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  237. row.action.formSelector = @selector(clearCacheRequest:);
  238. [sectionSize addFormRow:row];
  239. // Section EXIT --------------------------------------------------------
  240. section = [XLFormSectionDescriptor formSection];
  241. [form addFormSection:section];
  242. section.footerTitle = NSLocalizedString(@"_exit_footer_", nil);
  243. // Exit
  244. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"esci" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_exit_", nil)];
  245. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.secondarySystemGroupedBackground;
  246. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  247. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  248. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  249. [row.cellConfig setObject:[[UIImage imageNamed:@"xmark"] imageWithColor:[UIColor redColor] size:25] forKey:@"imageView.image"];
  250. row.action.formSelector = @selector(exitNextcloud:);
  251. [section addFormRow:row];
  252. self.tableView.showsVerticalScrollIndicator = NO;
  253. self.form = form;
  254. }
  255. // MARK: - View Life Cycle
  256. - (void)viewDidLoad
  257. {
  258. [super viewDidLoad];
  259. self.title = NSLocalizedString(@"_advanced_", nil);
  260. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  261. self.view.backgroundColor = NCBrandColor.shared.systemGroupedBackground;
  262. self.tableView.backgroundColor = NCBrandColor.shared.systemGroupedBackground;
  263. [self initializeForm];
  264. [self calculateSize];
  265. }
  266. - (void)viewWillAppear:(BOOL)animated
  267. {
  268. [super viewWillAppear:animated];
  269. appDelegate.activeViewController = self;
  270. }
  271. #pragma mark -
  272. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  273. {
  274. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  275. if ([rowDescriptor.tag isEqualToString:@"showHiddenFiles"]) {
  276. [CCUtility setShowHiddenFiles:[[rowDescriptor.value valueData] boolValue]];
  277. }
  278. if ([rowDescriptor.tag isEqualToString:@"formatCompatibility"]) {
  279. [CCUtility setFormatCompatibility:[[rowDescriptor.value valueData] boolValue]];
  280. }
  281. if ([rowDescriptor.tag isEqualToString:@"livePhoto"]) {
  282. [CCUtility setLivePhoto:[[rowDescriptor.value valueData] boolValue]];
  283. }
  284. if ([rowDescriptor.tag isEqualToString:@"removePhotoCameraRoll"]) {
  285. [CCUtility setRemovePhotoCameraRoll:[[rowDescriptor.value valueData] boolValue]];
  286. }
  287. if ([rowDescriptor.tag isEqualToString:@"disableLocalCacheAfterUpload"]) {
  288. [CCUtility setDisableLocalCacheAfterUpload:[[rowDescriptor.value valueData] boolValue]];
  289. }
  290. if ([rowDescriptor.tag isEqualToString:@"disablefilesapp"]) {
  291. [CCUtility setDisableFilesApp:[[rowDescriptor.value valueData] boolValue]];
  292. }
  293. if ([rowDescriptor.tag isEqualToString:@"crashservice"]) {
  294. [CCUtility setDisableCrashservice:[[rowDescriptor.value valueData] boolValue]];
  295. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_crashservice_title_", nil) message:NSLocalizedString(@"_crashservice_alert_", nil) preferredStyle:UIAlertControllerStyleAlert];
  296. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  297. exit(0);
  298. }];
  299. [alertController addAction:okAction];
  300. [self presentViewController:alertController animated:YES completion:nil];
  301. }
  302. if ([rowDescriptor.tag isEqualToString:@"logLevel"]) {
  303. NSInteger levelLog = [[rowDescriptor.value valueData] intValue];
  304. [CCUtility setLogLevel:levelLog];
  305. [[NCCommunicationCommon shared] setLevelLog:levelLog];
  306. }
  307. if ([rowDescriptor.tag isEqualToString:@"chunk"]) {
  308. NSInteger chunkSize = [[rowDescriptor.value valueData] intValue];
  309. [CCUtility setChunkSize:chunkSize];
  310. }
  311. if ([rowDescriptor.tag isEqualToString:@"deleteoldfiles"]) {
  312. NSInteger days = [[rowDescriptor.value valueData] intValue];
  313. [CCUtility setCleanUpDay:days];
  314. }
  315. }
  316. #pragma mark - Clear Cache
  317. - (void)clearCache
  318. {
  319. [[NCNetworking shared] cancelAllTransferWithAccount:appDelegate.account completion:^{ }];
  320. [[NCOperationQueue shared] cancelAllQueue];
  321. [[NCNetworking shared] cancelAllTask];
  322. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  323. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  324. [[NCManageDatabase shared] clearDatabaseWithAccount:appDelegate.account removeAccount:false];
  325. [CCUtility removeGroupDirectoryProviderStorage];
  326. [CCUtility removeGroupLibraryDirectory];
  327. [CCUtility removeDocumentsDirectory];
  328. [CCUtility removeTemporaryDirectory];
  329. [[NCKTVHTTPCache shared] deleteAllCache];
  330. [CCUtility createDirectoryStandard];
  331. [[NCAutoUpload shared] alignPhotoLibraryWithViewController:self];
  332. // Inizialized home
  333. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterInitialize object:nil userInfo:nil];
  334. // Clear Media
  335. [appDelegate.activeMedia reloadDataSourceWithCompletion:^(NSArray *metadatas) { }];
  336. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  337. [[NCUtility shared] stopActivityIndicator];
  338. [self calculateSize];
  339. });
  340. }
  341. - (void)clearCacheRequest:(XLFormRowDescriptor *)sender
  342. {
  343. [self deselectFormRow:sender];
  344. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_cache_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  345. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_yes_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  346. [[NCUtility shared] startActivityIndicatorWithBackgroundView:nil blurEffect:true bottom:0 style: UIActivityIndicatorViewStyleWhiteLarge];
  347. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  348. [self clearCache];
  349. });
  350. }]];
  351. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  352. }]];
  353. alertController.popoverPresentationController.sourceView = self.view;
  354. NSIndexPath *indexPath = [self.form indexPathOfFormRow:sender];
  355. CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
  356. alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
  357. [self presentViewController:alertController animated:YES completion:nil];
  358. }
  359. - (void)calculateSize
  360. {
  361. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  362. NSString *directory = CCUtility.getDirectoryProviderStorage;
  363. int64_t totalSize = [[NCUtilityFileSystem shared] getDirectorySizeWithDirectory:directory];
  364. sectionSize.footerTitle = [NSString stringWithFormat:@"%@. (%@ %@)", NSLocalizedString(@"_clear_cache_footer_", nil), NSLocalizedString(@"_used_space_", nil), [CCUtility transformedSize:totalSize]];
  365. dispatch_async(dispatch_get_main_queue(), ^{
  366. [self.tableView reloadData];
  367. });
  368. });
  369. }
  370. #pragma mark - Exit Nextcloud
  371. - (void)exitNextcloud:(XLFormRowDescriptor *)sender
  372. {
  373. [self deselectFormRow:sender];
  374. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_exit_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  375. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  376. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  377. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  378. [CCUtility removeGroupDirectoryProviderStorage];
  379. [CCUtility removeGroupApplicationSupport];
  380. [CCUtility removeDocumentsDirectory];
  381. [CCUtility removeTemporaryDirectory];
  382. [CCUtility deleteAllChainStore];
  383. [[NCManageDatabase shared] removeDB];
  384. exit(0);
  385. }]];
  386. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  387. }]];
  388. alertController.popoverPresentationController.sourceView = self.view;
  389. NSIndexPath *indexPath = [self.form indexPathOfFormRow:sender];
  390. CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
  391. alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
  392. [self presentViewController:alertController animated:YES completion:nil];
  393. }
  394. #pragma mark -
  395. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  396. if (indexPath.section == 7 && indexPath.row == 2) {
  397. return 80;
  398. } else {
  399. return NCGlobal.shared.heightCellSettings;
  400. }
  401. }
  402. @end