CCAdvanced.m 22 KB

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