CCAdvanced.m 27 KB

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