CCSettings.m 24 KB

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