CCSettings.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. //
  2. // CCSettings.m
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 24/11/14.
  6. // Copyright (c) 2017 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 "CCSettings.h"
  24. #import "AppDelegate.h"
  25. #import "CCMain.h"
  26. #import "OCCapabilities.h"
  27. #import "CCSynchronize.h"
  28. #import "CCAdvanced.h"
  29. #import "CCManageAccount.h"
  30. #import "NCManageEndToEndEncryption.h"
  31. #import "NCBridgeSwift.h"
  32. #import "TOPasscodeSettingsViewController.h"
  33. #import "TOPasscodeViewController.h"
  34. #define alertViewEsci 1
  35. #define alertViewAzzeraCache 2
  36. @interface CCSettings () <TOPasscodeSettingsViewControllerDelegate, TOPasscodeViewControllerDelegate>
  37. {
  38. AppDelegate *appDelegate;
  39. }
  40. @end
  41. @implementation CCSettings
  42. - (void)initializeForm
  43. {
  44. XLFormDescriptor *form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_settings_", nil)];
  45. XLFormSectionDescriptor *section;
  46. XLFormRowDescriptor *row;
  47. NSInteger versionServer = [[NCManageDatabase sharedInstance] getServerVersionWithAccount:appDelegate.activeAccount];
  48. form.rowNavigationOptions = XLFormRowNavigationOptionNone;
  49. // Section AUTO UPLOAD OF CAMERA IMAGES ----------------------------
  50. section = [XLFormSectionDescriptor formSection];
  51. [form addFormSection:section];
  52. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUpload" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_settings_autoupload_", nil)];
  53. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  54. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  55. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  56. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"autoUpload"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  57. row.action.viewControllerClass = [CCManageAutoUpload class];
  58. [section addFormRow:row];
  59. // Section FOLDERS FAVORITES OFFLINE ------------------------------------
  60. section = [XLFormSectionDescriptor formSection];
  61. [form addFormSection:section];
  62. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"favoriteoffline" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_favorite_offline_", nil)];
  63. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  64. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"favorite"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  65. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  66. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  67. [section addFormRow:row];
  68. // Section : LOCK --------------------------------------------------------------
  69. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_lock_", nil)];
  70. [form addFormSection:section];
  71. // Lock active YES/NO
  72. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"bloccopasscode" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_lock_not_active_", nil)];
  73. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  74. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settingsPasscodeNO"] multiplier:2 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  75. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  76. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  77. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  78. //[row.cellConfig setObject:@(UITableViewCellAccessoryDisclosureIndicator) forKey:@"accessoryType"];
  79. row.action.formSelector = @selector(passcode:);
  80. [section addFormRow:row];
  81. // Lock no screen
  82. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"onlylockdir" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_lock_protection_no_screen_", nil)];
  83. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  84. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  85. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  86. [section addFormRow:row];
  87. // Section : Screen --------------------------------------------------------------
  88. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_screen_", nil)];
  89. [form addFormSection:section];
  90. // Dark Mode
  91. if (@available(iOS 13.0, *)) {
  92. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"darkModeDetect" rowType:XLFormRowDescriptorTypeBooleanSwitch title:[NSString stringWithFormat:@"%@ (beta)", NSLocalizedString(@"_dark_mode_detect_", nil)]];
  93. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  94. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"darkModeDetect"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  95. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  96. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  97. if ([CCUtility getDarkModeDetect]) row.value = @1;
  98. else row.value = @0;
  99. [section addFormRow:row];
  100. } else {
  101. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"darkMode" rowType:XLFormRowDescriptorTypeBooleanSwitch title:[NSString stringWithFormat:@"%@ (beta)", NSLocalizedString(@"_dark_mode_", nil)]];
  102. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  103. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"themeLightDark"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  104. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  105. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  106. if ([CCUtility getDarkMode]) row.value = @1;
  107. else row.value = @0;
  108. [section addFormRow:row];
  109. }
  110. // Section : E2EEncryption From Nextcloud 19 --------------------------------------------------------------
  111. if (versionServer >= k_nextcloud_version_19_0) {
  112. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_title_", nil)];
  113. [form addFormSection:section];
  114. // EndToEnd Encryption
  115. NSString *title = [NSString stringWithFormat:@"%@ (%@)",NSLocalizedString(@"_e2e_settings_", nil), NSLocalizedString(@"_experimental_", nil)];
  116. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"e2eEncryption" rowType:XLFormRowDescriptorTypeButton title:title];
  117. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  118. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  119. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  120. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"lock"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  121. row.action.viewControllerClass = [NCManageEndToEndEncryption class];
  122. [section addFormRow:row];
  123. }
  124. // Section Advanced -------------------------------------------------
  125. section = [XLFormSectionDescriptor formSection];
  126. [form addFormSection:section];
  127. // Advanced
  128. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"advanced" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_advanced_", nil)];
  129. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  130. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  131. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  132. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settings"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  133. row.action.viewControllerClass = [CCAdvanced class];
  134. [section addFormRow:row];
  135. // Section : INFORMATION ------------------------------------------------
  136. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_information_", nil)];
  137. [form addFormSection:section];
  138. // Acknowledgements
  139. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttonLeftAligned" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_acknowledgements_", nil)];
  140. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  141. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  142. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  143. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  144. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"acknowledgements"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  145. row.action.formBlock = ^(XLFormRowDescriptor * sender){
  146. [self performSegueWithIdentifier:@"AcknowledgementsSegue" sender:sender];
  147. [self deselectFormRow:sender];
  148. };
  149. [section addFormRow:row];
  150. self.tableView.showsVerticalScrollIndicator = NO;
  151. self.form = form;
  152. }
  153. - (void)viewDidLoad
  154. {
  155. [super viewDidLoad];
  156. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  157. // changeTheming
  158. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:k_notificationCenter_changeTheming object:nil];
  159. [self changeTheming];
  160. }
  161. - (void)changeTheming
  162. {
  163. [appDelegate changeTheming:self tableView:self.tableView collectionView:nil form:true];
  164. [self initializeForm];
  165. [self reloadForm];
  166. }
  167. #pragma --------------------------------------------------------------------------------------------
  168. #pragma mark === Chiamate dal Form ===
  169. #pragma --------------------------------------------------------------------------------------------
  170. - (void)reloadForm
  171. {
  172. self.form.delegate = nil;
  173. // ------------------------------------------------------------------
  174. XLFormRowDescriptor *rowBloccoPasscode = [self.form formRowWithTag:@"bloccopasscode"];
  175. XLFormRowDescriptor *rowSimplyPasscode = [self.form formRowWithTag:@"simplypasscode"];
  176. XLFormRowDescriptor *rowOnlyLockDir = [self.form formRowWithTag:@"onlylockdir"];
  177. XLFormRowDescriptor *rowFavoriteOffline = [self.form formRowWithTag:@"favoriteoffline"];
  178. XLFormRowDescriptor *rowDarkModeDetect = [self.form formRowWithTag:@"darkModeDetect"];
  179. XLFormRowDescriptor *rowDarkMode = [self.form formRowWithTag:@"darkMode"];
  180. // ------------------------------------------------------------------
  181. if ([[CCUtility getBlockCode] length]) {
  182. rowBloccoPasscode.title = NSLocalizedString(@"_lock_active_", nil);
  183. [rowBloccoPasscode.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settingsPasscodeYES"] multiplier:2 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  184. } else {
  185. rowBloccoPasscode.title = NSLocalizedString(@"_lock_not_active_", nil);
  186. [rowBloccoPasscode.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settingsPasscodeNO"] multiplier:2 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  187. }
  188. if ([CCUtility getSimplyBlockCode]) [rowSimplyPasscode setValue:@1]; else [rowSimplyPasscode setValue:@0];
  189. if ([CCUtility getOnlyLockDir]) [rowOnlyLockDir setValue:@1]; else [rowOnlyLockDir setValue:@0];
  190. if ([CCUtility getFavoriteOffline]) [rowFavoriteOffline setValue:@1]; else [rowFavoriteOffline setValue:@0];
  191. if ([CCUtility getDarkModeDetect]) [rowDarkModeDetect setValue:@1]; else [rowDarkModeDetect setValue:@0];
  192. if ([CCUtility getDarkMode]) [rowDarkMode setValue:@1]; else [rowDarkMode setValue:@0];
  193. // -----------------------------------------------------------------
  194. [self.tableView reloadData];
  195. self.form.delegate = self;
  196. }
  197. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  198. {
  199. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  200. if ([rowDescriptor.tag isEqualToString:@"onlylockdir"]) {
  201. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  202. [CCUtility setOnlyLockDir:true];
  203. } else {
  204. [CCUtility setOnlyLockDir:false];
  205. }
  206. }
  207. if ([rowDescriptor.tag isEqualToString:@"favoriteoffline"]) {
  208. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  209. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_continue_request_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  210. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  211. [CCUtility setFavoriteOffline:true];
  212. [self synchronizeFavorites];
  213. }]];
  214. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  215. [self reloadForm];
  216. }]];
  217. alertController.popoverPresentationController.sourceView = self.view;
  218. NSIndexPath *indexPath = [self.form indexPathOfFormRow:rowDescriptor];
  219. CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
  220. alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
  221. [self presentViewController:alertController animated:YES completion:nil];
  222. } else {
  223. [CCUtility setFavoriteOffline:false];
  224. }
  225. }
  226. if ([rowDescriptor.tag isEqualToString:@"darkMode"]) {
  227. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  228. [CCUtility setDarkMode:true];
  229. } else {
  230. [CCUtility setDarkMode:false];
  231. }
  232. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_changeTheming object:nil];
  233. }
  234. if ([rowDescriptor.tag isEqualToString:@"darkModeDetect"]) {
  235. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  236. [CCUtility setDarkModeDetect:true];
  237. // detect Dark Mode
  238. if (@available(iOS 12.0, *)) {
  239. appDelegate.preferredUserInterfaceStyle = self.traitCollection.userInterfaceStyle;
  240. if (appDelegate.preferredUserInterfaceStyle == UIUserInterfaceStyleDark) {
  241. [CCUtility setDarkMode:YES];
  242. } else {
  243. [CCUtility setDarkMode:NO];
  244. }
  245. }
  246. } else {
  247. [CCUtility setDarkModeDetect:false];
  248. [CCUtility setDarkMode:false];
  249. }
  250. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_changeTheming object:nil];
  251. }
  252. }
  253. #pragma mark - Passcode -
  254. - (void)didPerformBiometricValidationRequestInPasscodeViewController:(TOPasscodeViewController *)passcodeViewController
  255. {
  256. [[LAContext new] evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"Nextcloud" reply:^(BOOL success, NSError * _Nullable error) {
  257. if (success) {
  258. dispatch_async(dispatch_get_main_queue(), ^{
  259. [CCUtility setBlockCode:@""];
  260. [passcodeViewController dismissViewControllerAnimated:YES completion:nil];
  261. [self reloadForm];
  262. });
  263. }
  264. }];
  265. }
  266. - (void)passcodeSettingsViewController:(TOPasscodeSettingsViewController *)passcodeSettingsViewController didChangeToNewPasscode:(NSString *)passcode ofType:(TOPasscodeType)type
  267. {
  268. [CCUtility setBlockCode:passcode];
  269. [passcodeSettingsViewController dismissViewControllerAnimated:YES completion:nil];
  270. [self reloadForm];
  271. }
  272. - (void)didTapCancelInPasscodeViewController:(TOPasscodeViewController *)passcodeViewController
  273. {
  274. [passcodeViewController dismissViewControllerAnimated:YES completion:nil];
  275. }
  276. - (BOOL)passcodeViewController:(TOPasscodeViewController *)passcodeViewController isCorrectCode:(NSString *)code
  277. {
  278. if ([code isEqualToString:[CCUtility getBlockCode]]) {
  279. [CCUtility setBlockCode:@""];
  280. [self reloadForm];
  281. return YES;
  282. }
  283. return NO;
  284. }
  285. - (void)passcode:(XLFormRowDescriptor *)sender
  286. {
  287. LAContext *laContext = [LAContext new];
  288. NSError *error;
  289. [self deselectFormRow:sender];
  290. if ([[CCUtility getBlockCode] length] == 0) {
  291. TOPasscodeSettingsViewController *settingsController = [[TOPasscodeSettingsViewController alloc] init];
  292. if (@available(iOS 13.0, *)) {
  293. if ([[UITraitCollection currentTraitCollection] userInterfaceStyle] == UIUserInterfaceStyleDark) {
  294. settingsController.style = TOPasscodeSettingsViewStyleDark;
  295. }
  296. }
  297. settingsController.requireCurrentPasscode = NO;
  298. settingsController.passcodeType = TOPasscodeTypeSixDigits;
  299. settingsController.delegate = self;
  300. [self presentViewController:settingsController animated:YES completion:nil];
  301. } else {
  302. TOPasscodeViewController *passcodeViewController = [[TOPasscodeViewController alloc] initWithStyle:TOPasscodeViewStyleTranslucentLight passcodeType:TOPasscodeTypeSixDigits];
  303. if (@available(iOS 13.0, *)) {
  304. if ([[UITraitCollection currentTraitCollection] userInterfaceStyle] == UIUserInterfaceStyleDark) {
  305. passcodeViewController.style = TOPasscodeViewStyleTranslucentDark;
  306. }
  307. }
  308. passcodeViewController.allowCancel = true;
  309. passcodeViewController.delegate = self;
  310. passcodeViewController.keypadButtonShowLettering = false;
  311. if ([laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
  312. if (error == NULL) {
  313. if (laContext.biometryType == LABiometryTypeFaceID) {
  314. passcodeViewController.biometryType = TOPasscodeBiometryTypeFaceID;
  315. passcodeViewController.allowBiometricValidation = true;
  316. passcodeViewController.automaticallyPromptForBiometricValidation = true;
  317. } else if (laContext.biometryType == LABiometryTypeTouchID) {
  318. passcodeViewController.biometryType = TOPasscodeBiometryTypeTouchID;
  319. passcodeViewController.allowBiometricValidation = true;
  320. passcodeViewController.automaticallyPromptForBiometricValidation = true;
  321. } else {
  322. NSLog(@"No Biometric support");
  323. }
  324. }
  325. }
  326. [self presentViewController:passcodeViewController animated:YES completion:nil];
  327. }
  328. }
  329. - (void)synchronizeFavorites
  330. {
  331. NSArray *metadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND favorite == true", appDelegate.activeAccount] sorted:nil ascending:NO];
  332. for (tableMetadata *metadata in metadatas) {
  333. if (metadata.directory) {
  334. NSString *serverUrl = [CCUtility stringAppendServerUrl:metadata.serverUrl addFileName:metadata.fileName];
  335. NSString *serverUrlBeginWith = serverUrl;
  336. if (![serverUrl hasSuffix:@"/"])
  337. serverUrlBeginWith = [serverUrl stringByAppendingString:@"/"];
  338. NSArray *directories = [[NCManageDatabase sharedInstance] getTablesDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND (serverUrl == %@ OR serverUrl BEGINSWITH %@)", appDelegate.activeAccount, serverUrl, serverUrlBeginWith] sorted:@"serverUrl" ascending:true];
  339. for (tableDirectory *directory in directories)
  340. [[NCManageDatabase sharedInstance] clearDateReadWithServerUrl:directory.serverUrl account:appDelegate.activeAccount];
  341. }
  342. }
  343. [appDelegate.activeFavorites listingFavorites];
  344. }
  345. #pragma --------------------------------------------------------------------------------------------
  346. #pragma mark === Table View ===
  347. #pragma --------------------------------------------------------------------------------------------
  348. - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
  349. {
  350. NSString *sectionName;
  351. switch (section)
  352. {
  353. case 1: {
  354. sectionName = NSLocalizedString(@"_favorite_offline_footer_", nil);
  355. }
  356. break;
  357. case 2: {
  358. sectionName = NSLocalizedString(@"_lock_protection_no_screen_footer_", nil);
  359. }
  360. break;
  361. case 5: {
  362. tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:appDelegate.activeAccount];
  363. NSString *versionServer = capabilities.versionString;
  364. NSString *versionApp = [NSString stringWithFormat:@"%@.%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
  365. NSString *versionNextcloud = [NSString stringWithFormat:[NCBrandOptions sharedInstance].textCopyrightNextcloudServer, versionServer];
  366. NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions sharedInstance].textCopyrightNextcloudiOS, versionApp];
  367. NSString *nameSlogan = [NSString stringWithFormat:@"%@ - %@", capabilities.themingName, capabilities.themingSlogan];
  368. sectionName = [NSString stringWithFormat:@"%@\n\n%@\n%@", versionNextcloudiOS, versionNextcloud, nameSlogan];
  369. }
  370. break;
  371. }
  372. return sectionName;
  373. }
  374. @end