CCAdvanced.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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. }
  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.cellSettings;
  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.textView forKey:@"textLabel.textColor"];
  48. [section addFormRow:row];
  49. // Format Compatibility + Live Photo
  50. section = [XLFormSectionDescriptor formSection];
  51. [form addFormSection:section];
  52. section.footerTitle = [NSString stringWithFormat:@"%@\n%@", NSLocalizedString(@"_format_compatibility_footer_", nil), NSLocalizedString(@"_upload_mov_livephoto_footer_", nil)];
  53. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"formatCompatibility" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_format_compatibility_", nil)];
  54. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  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.textView 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.cellSettings;
  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.textView forKey:@"textLabel.textColor"];
  66. [section addFormRow:row];
  67. // Disable Local Cache After Upload
  68. section = [XLFormSectionDescriptor formSection];
  69. [form addFormSection:section];
  70. section.footerTitle = NSLocalizedString(@"_disableLocalCacheAfterUpload_footer_", nil);
  71. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"disableLocalCacheAfterUpload" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_disableLocalCacheAfterUpload_", nil)];
  72. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  73. if ([CCUtility getDisableLocalCacheAfterUpload]) row.value = @"1";
  74. else row.value = @"0";
  75. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  76. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  77. [section addFormRow:row];
  78. // Automatic download image
  79. section = [XLFormSectionDescriptor formSection];
  80. [form addFormSection:section];
  81. section.footerTitle = NSLocalizedString(@"_automatic_Download_Image_footer_", nil);
  82. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"automaticDownloadImage" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_automatic_Download_Image_", nil)];
  83. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  84. if ([CCUtility getAutomaticDownloadImage]) row.value = @"1";
  85. else row.value = @"0";
  86. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  87. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  88. [section addFormRow:row];
  89. // Section : Files App --------------------------------------------------------------
  90. if (![NCBrandOptions shared].disable_openin_file) {
  91. section = [XLFormSectionDescriptor formSection];
  92. [form addFormSection:section];
  93. section.footerTitle = NSLocalizedString(@"_disable_files_app_footer_", nil);
  94. // Disable Files App
  95. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"disablefilesapp" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_disable_files_app_", nil)];
  96. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  97. if ([CCUtility getDisableFilesApp]) row.value = @"1";
  98. else row.value = @"0";
  99. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  100. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  101. [section addFormRow:row];
  102. }
  103. // Section : Chunk --------------------------------------------------------------
  104. section = [XLFormSectionDescriptor formSection];
  105. [form addFormSection:section];
  106. section.footerTitle = NSLocalizedString(@"_chunk_footer_title_", nil);
  107. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"chunk" rowType:XLFormRowDescriptorTypeStepCounter title:NSLocalizedString(@"_chunk_size_mb_", nil)];
  108. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  109. row.value = [NSString stringWithFormat:@"%ld", CCUtility.getChunkSize];
  110. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  111. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  112. [row.cellConfigAtConfigure setObject:@YES forKey:@"stepControl.wraps"];
  113. [row.cellConfigAtConfigure setObject:@1 forKey:@"stepControl.stepValue"];
  114. [row.cellConfigAtConfigure setObject:@0 forKey:@"stepControl.minimumValue"];
  115. [row.cellConfigAtConfigure setObject:@100 forKey:@"stepControl.maximumValue"];
  116. [section addFormRow:row];
  117. // Section : Privacy --------------------------------------------------------------
  118. if (!NCBrandOptions.shared.disable_crash_service) {
  119. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_privacy_", nil)];
  120. [form addFormSection:section];
  121. section.footerTitle = NSLocalizedString(@"_privacy_footer_", nil);
  122. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"crashservice" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_crashservice_title_", nil)];
  123. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  124. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  125. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  126. [row.cellConfig setObject:[[UIImage imageNamed:@"crashservice"] imageWithColor:NCBrandColor.shared.icon size:25] forKey:@"imageView.image"];
  127. if ([CCUtility getDisableCrashservice]) row.value = @"1";
  128. else row.value = @"0";
  129. [section addFormRow:row];
  130. }
  131. // Section DIAGNOSTICS -------------------------------------------------
  132. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_diagnostics_", nil)];
  133. [form addFormSection:section];
  134. if ([[NSFileManager defaultManager] fileExistsAtPath:NCCommunicationCommon.shared.filenamePathLog]) {
  135. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"log" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_view_log_", nil)];
  136. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  137. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  138. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  139. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  140. [row.cellConfig setObject:[[UIImage imageNamed:@"log"] imageWithColor:NCBrandColor.shared.icon size:25] forKey:@"imageView.image"];
  141. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  142. [self deselectFormRow:sender];
  143. NCViewerQuickLook *viewerQuickLook = [NCViewerQuickLook new];
  144. [viewerQuickLook quickLookWithUrl:[NSURL fileURLWithPath:NCCommunicationCommon.shared.filenamePathLog]];
  145. };
  146. [section addFormRow:row];
  147. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"clearlog" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_log_", nil)];
  148. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  149. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  150. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  151. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  152. [row.cellConfig setObject:[[UIImage imageNamed:@"clear"] imageWithColor:NCBrandColor.shared.icon size:25] forKey:@"imageView.image"];
  153. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  154. [self deselectFormRow:sender];
  155. [[NCCommunicationCommon shared] clearFileLog];
  156. NSInteger logLevel = [CCUtility getLogLevel];
  157. BOOL isSimulatorOrTestFlight = [[NCUtility shared] isSimulatorOrTestFlight];
  158. NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp];
  159. if (isSimulatorOrTestFlight) {
  160. [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Clear log with level %lu %@ (Simulator / TestFlight)", (unsigned long)logLevel, versionNextcloudiOS]];
  161. } else {
  162. [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Clear log with level %lu %@", (unsigned long)logLevel, versionNextcloudiOS]];
  163. }
  164. };
  165. [section addFormRow:row];
  166. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"logLevel" rowType:XLFormRowDescriptorTypeSlider title:NSLocalizedString(@"_level_log_", nil)];
  167. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  168. [row.cellConfig setObject:@(NSTextAlignmentCenter) forKey:@"textLabel.textAlignment"];
  169. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  170. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  171. NSInteger logLevel = [CCUtility getLogLevel];
  172. row.value = @(logLevel);
  173. [row.cellConfigAtConfigure setObject:@(2) forKey:@"slider.maximumValue"];
  174. [row.cellConfigAtConfigure setObject:@(0) forKey:@"slider.minimumValue"];
  175. [row.cellConfigAtConfigure setObject:@(2) forKey:@"steps"];
  176. [section addFormRow:row];
  177. }
  178. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"capabilities" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_capabilities_", nil)];
  179. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  180. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  181. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  182. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  183. [row.cellConfig setObject:[[UIImage imageNamed:@"capabilities"] imageWithColor:NCBrandColor.shared.icon size:25] forKey:@"imageView.image"];
  184. row.action.formBlock = ^(XLFormRowDescriptor * sender) {
  185. [self deselectFormRow:sender];
  186. NCCapabilitiesViewController *capabilities = [[UIStoryboard storyboardWithName:@"NCCapabilitiesViewController" bundle:nil] instantiateInitialViewController];
  187. [self presentViewController:capabilities animated:YES completion:nil];
  188. };
  189. [section addFormRow:row];
  190. // Section CLEAR CACHE -------------------------------------------------
  191. section = [XLFormSectionDescriptor formSection];
  192. [form addFormSection:section];
  193. section.footerTitle = NSLocalizedString(@"_clear_cache_footer_", nil);
  194. // Clear cache
  195. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"azzeracache" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_clear_cache_", nil)];
  196. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  197. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  198. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  199. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  200. [row.cellConfig setObject:[[UIImage imageNamed:@"trash"] imageWithColor:NCBrandColor.shared.icon size:25] forKey:@"imageView.image"];
  201. row.action.formSelector = @selector(clearCacheRequest:);
  202. [section addFormRow:row];
  203. // Section EXIT --------------------------------------------------------
  204. section = [XLFormSectionDescriptor formSection];
  205. [form addFormSection:section];
  206. section.footerTitle = NSLocalizedString(@"_exit_footer_", nil);
  207. // Exit
  208. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"esci" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_exit_", nil)];
  209. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.cellSettings;
  210. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  211. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  212. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  213. [row.cellConfig setObject:[[UIImage imageNamed:@"exit"] imageWithColor:[UIColor redColor] size:25] forKey:@"imageView.image"];
  214. row.action.formSelector = @selector(exitNextcloud:);
  215. [section addFormRow:row];
  216. self.tableView.showsVerticalScrollIndicator = NO;
  217. self.form = form;
  218. }
  219. - (void)viewDidLoad
  220. {
  221. [super viewDidLoad];
  222. self.title = NSLocalizedString(@"_advanced_", nil);
  223. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  224. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:NCGlobal.shared.notificationCenterChangeTheming object:nil];
  225. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(initializeMain) name:NCGlobal.shared.notificationCenterInitializeMain object:nil];
  226. [self changeTheming];
  227. }
  228. - (void)viewWillAppear:(BOOL)animated
  229. {
  230. [super viewWillAppear:animated];
  231. appDelegate.activeViewController = self;
  232. [self initializeForm];
  233. [self.tableView reloadData];
  234. }
  235. #pragma mark - NotificationCenter
  236. - (void)changeTheming
  237. {
  238. self.view.backgroundColor = NCBrandColor.shared.backgroundSettings;
  239. self.tableView.backgroundColor = NCBrandColor.shared.backgroundSettings;
  240. [self initializeForm];
  241. [self.tableView reloadData];
  242. }
  243. - (void)initializeMain
  244. {
  245. [self initializeForm];
  246. [self.tableView reloadData];
  247. }
  248. #pragma mark -
  249. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  250. {
  251. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  252. if ([rowDescriptor.tag isEqualToString:@"showHiddenFiles"]) {
  253. [CCUtility setShowHiddenFiles:[[rowDescriptor.value valueData] boolValue]];
  254. }
  255. if ([rowDescriptor.tag isEqualToString:@"formatCompatibility"]) {
  256. [CCUtility setFormatCompatibility:[[rowDescriptor.value valueData] boolValue]];
  257. }
  258. if ([rowDescriptor.tag isEqualToString:@"livePhoto"]) {
  259. [CCUtility setLivePhoto:[[rowDescriptor.value valueData] boolValue]];
  260. }
  261. if ([rowDescriptor.tag isEqualToString:@"disableLocalCacheAfterUpload"]) {
  262. [CCUtility setDisableLocalCacheAfterUpload:[[rowDescriptor.value valueData] boolValue]];
  263. }
  264. if ([rowDescriptor.tag isEqualToString:@"automaticDownloadImage"]) {
  265. [CCUtility setAutomaticDownloadImage:[[rowDescriptor.value valueData] boolValue]];
  266. }
  267. if ([rowDescriptor.tag isEqualToString:@"disablefilesapp"]) {
  268. [CCUtility setDisableFilesApp:[[rowDescriptor.value valueData] boolValue]];
  269. }
  270. if ([rowDescriptor.tag isEqualToString:@"crashservice"]) {
  271. [CCUtility setDisableCrashservice:[[rowDescriptor.value valueData] boolValue]];
  272. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_crashservice_title_", nil) message:NSLocalizedString(@"_crashservice_alert_", nil) preferredStyle:UIAlertControllerStyleAlert];
  273. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  274. exit(0);
  275. }];
  276. [alertController addAction:okAction];
  277. [self presentViewController:alertController animated:YES completion:nil];
  278. }
  279. if ([rowDescriptor.tag isEqualToString:@"logLevel"]) {
  280. NSInteger levelLog = [[rowDescriptor.value valueData] intValue];
  281. [CCUtility setLogLevel:levelLog];
  282. [[NCCommunicationCommon shared] setLevelLog:levelLog];
  283. }
  284. if ([rowDescriptor.tag isEqualToString:@"chunk"]) {
  285. NSInteger chunkSize = [[rowDescriptor.value valueData] intValue];
  286. [CCUtility setChunkSize:chunkSize];
  287. }
  288. }
  289. #pragma --------------------------------------------------------------------------------------------
  290. #pragma mark === Clear Cache ===
  291. #pragma --------------------------------------------------------------------------------------------
  292. - (void)clearCache
  293. {
  294. [[NCNetworking shared] cancelAllTransferWithAccount:appDelegate.account completion:^{ }];
  295. [[NCOperationQueue shared] cancelAllQueue];
  296. [[NCNetworking shared] cancelAllTask];
  297. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  298. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  299. [KTVHTTPCache cacheDeleteAllCaches];
  300. [[NCManageDatabase shared] clearDatabaseWithAccount:appDelegate.account removeAccount:false];
  301. [CCUtility removeGroupDirectoryProviderStorage];
  302. [CCUtility removeGroupLibraryDirectory];
  303. [CCUtility removeDocumentsDirectory];
  304. [CCUtility removeTemporaryDirectory];
  305. [CCUtility createDirectoryStandard];
  306. [[NCAutoUpload shared] alignPhotoLibraryWithViewController:self];
  307. // Inizialized home
  308. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:NCGlobal.shared.notificationCenterInitializeMain object:nil userInfo:nil];
  309. // Clear Media
  310. [appDelegate.activeMedia reloadDataSource];
  311. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  312. [[NCUtility shared] stopActivityIndicator];
  313. });
  314. }
  315. - (void)clearCacheRequest:(XLFormRowDescriptor *)sender
  316. {
  317. [self deselectFormRow:sender];
  318. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_cache_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  319. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_yes_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  320. [[NCUtility shared] startActivityIndicatorWithBackgroundView:nil blurEffect:true bottom:0 style: UIActivityIndicatorViewStyleWhiteLarge];
  321. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  322. [self clearCache];
  323. });
  324. }]];
  325. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  326. }]];
  327. alertController.popoverPresentationController.sourceView = self.view;
  328. NSIndexPath *indexPath = [self.form indexPathOfFormRow:sender];
  329. CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
  330. alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
  331. [self presentViewController:alertController animated:YES completion:nil];
  332. }
  333. #pragma --------------------------------------------------------------------------------------------
  334. #pragma mark == Exit Nextcloud ==
  335. #pragma --------------------------------------------------------------------------------------------
  336. - (void)exitNextcloud:(XLFormRowDescriptor *)sender
  337. {
  338. [self deselectFormRow:sender];
  339. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_exit_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  340. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  341. [[NSURLCache sharedURLCache] setMemoryCapacity:0];
  342. [[NSURLCache sharedURLCache] setDiskCapacity:0];
  343. [KTVHTTPCache cacheDeleteAllCaches];
  344. [CCUtility removeGroupDirectoryProviderStorage];
  345. [CCUtility removeGroupApplicationSupport];
  346. [CCUtility removeDocumentsDirectory];
  347. [CCUtility removeTemporaryDirectory];
  348. [CCUtility deleteAllChainStore];
  349. [[NCManageDatabase shared] removeDB];
  350. exit(0);
  351. }]];
  352. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  353. }]];
  354. alertController.popoverPresentationController.sourceView = self.view;
  355. NSIndexPath *indexPath = [self.form indexPathOfFormRow:sender];
  356. CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
  357. alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
  358. [self presentViewController:alertController animated:YES completion:nil];
  359. }
  360. @end