NCSettings.m 24 KB

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