NCSettings.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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 "CCAdvanced.h"
  25. #import "CCManageAccount.h"
  26. #import "CCManageAutoUpload.h"
  27. #import "NCManageEndToEndEncryption.h"
  28. #import "NCBridgeSwift.h"
  29. #import "NSNotificationCenter+MainThread.h"
  30. #import <LocalAuthentication/LocalAuthentication.h>
  31. #import <TOPasscodeViewController/TOPasscodeViewController.h>
  32. #define alertViewEsci 1
  33. #define alertViewAzzeraCache 2
  34. @interface NCSettings () <TOPasscodeSettingsViewControllerDelegate, TOPasscodeViewControllerDelegate>
  35. {
  36. AppDelegate *appDelegate;
  37. TOPasscodeViewController *passcodeViewController;
  38. TOPasscodeSettingsViewController *passcodeSettingsViewController;
  39. }
  40. @end
  41. @implementation NCSettings
  42. - (void)initializeForm
  43. {
  44. XLFormDescriptor *form = [XLFormDescriptor formDescriptor];
  45. XLFormSectionDescriptor *section;
  46. XLFormRowDescriptor *row;
  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"] = UIColor.secondarySystemGroupedBackgroundColor;
  53. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  54. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  55. [row.cellConfig setObject:[[UIImage imageNamed:@"autoUpload"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  56. row.action.viewControllerClass = [CCManageAutoUpload class];
  57. [section addFormRow:row];
  58. // Section : PRIVACY --------------------------------------------------------------
  59. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_privacy_", nil)];
  60. [form addFormSection:section];
  61. // Lock active YES/NO
  62. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"bloccopasscode" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_lock_not_active_", nil)];
  63. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  64. [row.cellConfig setObject:[[UIImage imageNamed:@"lock_open"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  65. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  66. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  67. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  68. //[row.cellConfig setObject:@(UITableViewCellAccessoryDisclosureIndicator) forKey:@"accessoryType"];
  69. row.action.formSelector = @selector(passcode:);
  70. [section addFormRow:row];
  71. // Enable Touch ID
  72. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"enableTouchDaceID" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_enable_touch_face_id_", nil)];
  73. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  74. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  75. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  76. [section addFormRow:row];
  77. // Lock no screen
  78. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"notPasscodeAtStart" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_lock_protection_no_screen_", nil)];
  79. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  80. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  81. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  82. [section addFormRow:row];
  83. // Privacy screen
  84. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"privacyScreen" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_privacy_screen_", nil)];
  85. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  86. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  87. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  88. [section addFormRow:row];
  89. // Section : CALDAV CARDAV --------------------------------------------------------------
  90. if (!NCBrandOptions.shared.disable_mobileconfig) {
  91. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_calendar_contacts_", nil)];
  92. [form addFormSection:section];
  93. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"caldavcardav" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_mobile_config_", nil)];
  94. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  95. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  96. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  97. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  98. [row.cellConfig setObject:[[UIImage imageNamed:@"caldavcardav"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  99. row.action.formSelector = @selector(CalDAVCardDAV:);
  100. [section addFormRow:row];
  101. }
  102. // Section : E2EEncryption --------------------------------------------------------------
  103. BOOL isE2EEEnabled = [[NCManageDatabase shared] getCapabilitiesServerBoolWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesE2EEEnabled exists:false];
  104. NSString *versionE2EE = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesE2EEApiVersion];
  105. if (isE2EEEnabled == YES && [versionE2EE isEqual:[[NCGlobal shared] e2eeVersion]]) {
  106. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_title_", nil)];
  107. [form addFormSection:section];
  108. // EndToEnd Encryption
  109. NSString *title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"_e2e_settings_", nil)];
  110. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"e2eEncryption" rowType:XLFormRowDescriptorTypeButton title:title];
  111. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  112. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  113. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  114. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  115. [row.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  116. //row.action.formSelector = @selector(manageE2EE:);
  117. row.action.viewControllerClass = [NCManageEndToEndEncryption class];
  118. [section addFormRow:row];
  119. }
  120. // Section Advanced -------------------------------------------------
  121. section = [XLFormSectionDescriptor formSection];
  122. [form addFormSection:section];
  123. // Advanced
  124. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"advanced" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_advanced_", nil)];
  125. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  126. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  127. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  128. [row.cellConfig setObject:[[UIImage imageNamed:@"gear"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  129. row.action.viewControllerClass = [CCAdvanced class];
  130. [section addFormRow:row];
  131. // Section : INFORMATION ------------------------------------------------
  132. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_information_", nil)];
  133. [form addFormSection:section];
  134. // Acknowledgements
  135. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttonLeftAligned" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_acknowledgements_", nil)];
  136. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  137. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  138. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  139. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  140. [row.cellConfig setObject:[[UIImage imageNamed:@"acknowledgements"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  141. row.action.formBlock = ^(XLFormRowDescriptor * sender){
  142. [self performSegueWithIdentifier:@"AcknowledgementsSegue" sender:sender];
  143. [self deselectFormRow:sender];
  144. };
  145. [section addFormRow:row];
  146. if (!NCBrandOptions.shared.disable_crash_service) {
  147. // Privacy and Legal Policy
  148. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"privacy" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_privacy_legal_", nil)];
  149. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  150. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  151. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  152. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  153. [row.cellConfig setObject:[[UIImage imageNamed:@"shield.checkerboard"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  154. row.action.formSelector = @selector(privacy:);
  155. [section addFormRow:row];
  156. // Source code
  157. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sourcecode" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_source_code_", nil)];
  158. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  159. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  160. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  161. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  162. [row.cellConfig setObject:[[UIImage imageNamed:@"gitHub"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  163. row.action.formSelector = @selector(sourceCode:);
  164. [section addFormRow:row];
  165. }
  166. self.tableView.showsVerticalScrollIndicator = NO;
  167. self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 35, 0);
  168. self.form = form;
  169. }
  170. // MARK: - View Life Cycle
  171. - (void)viewDidLoad
  172. {
  173. [super viewDidLoad];
  174. self.title = NSLocalizedString(@"_settings_", nil);
  175. self.view.backgroundColor = UIColor.systemGroupedBackgroundColor;
  176. self.tableView.backgroundColor = UIColor.systemGroupedBackgroundColor;
  177. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  178. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:NCGlobal.shared.notificationCenterApplicationDidEnterBackground object:nil];
  179. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(initialize) name:NCGlobal.shared.notificationCenterInitialize object:nil];
  180. [self initializeForm];
  181. [self reloadForm];
  182. }
  183. - (void)viewWillAppear:(BOOL)animated
  184. {
  185. [super viewWillAppear:animated];
  186. appDelegate.activeViewController = self;
  187. }
  188. #pragma mark - NotificationCenter
  189. - (void)initialize
  190. {
  191. [self initializeForm];
  192. [self reloadForm];
  193. }
  194. - (void)applicationDidEnterBackground
  195. {
  196. if (passcodeViewController.view.window != nil) {
  197. [passcodeViewController dismissViewControllerAnimated:true completion:nil];
  198. }
  199. if (passcodeSettingsViewController.view.window != nil) {
  200. [passcodeSettingsViewController dismissViewControllerAnimated:true completion:nil];
  201. }
  202. [[self navigationController] popToRootViewControllerAnimated:false];
  203. }
  204. #pragma mark -
  205. - (void)reloadForm
  206. {
  207. self.form.delegate = nil;
  208. // ------------------------------------------------------------------
  209. XLFormRowDescriptor *rowBloccoPasscode = [self.form formRowWithTag:@"bloccopasscode"];
  210. XLFormRowDescriptor *rowNotPasscodeAtStart = [self.form formRowWithTag:@"notPasscodeAtStart"];
  211. XLFormRowDescriptor *rowEnableTouchDaceID = [self.form formRowWithTag:@"enableTouchDaceID"];
  212. XLFormRowDescriptor *rowPrivacyScreen = [self.form formRowWithTag:@"privacyScreen"];
  213. // ------------------------------------------------------------------
  214. if ([[CCUtility getPasscode] length]) {
  215. rowBloccoPasscode.title = NSLocalizedString(@"_lock_active_", nil);
  216. [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  217. } else {
  218. rowBloccoPasscode.title = NSLocalizedString(@"_lock_not_active_", nil);
  219. [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock_open"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  220. }
  221. if ([CCUtility getEnableTouchFaceID]) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0];
  222. if ([CCUtility getNotPasscodeAtStart]) [rowNotPasscodeAtStart setValue:@1]; else [rowNotPasscodeAtStart setValue:@0];
  223. if ([CCUtility getPrivacyScreenEnabled]) [rowPrivacyScreen setValue:@1]; else [rowPrivacyScreen setValue:@0];
  224. // -----------------------------------------------------------------
  225. [self.tableView reloadData];
  226. self.form.delegate = self;
  227. }
  228. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  229. {
  230. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  231. if ([rowDescriptor.tag isEqualToString:@"notPasscodeAtStart"]) {
  232. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  233. [CCUtility setNotPasscodeAtStart:true];
  234. } else {
  235. [CCUtility setNotPasscodeAtStart:false];
  236. }
  237. }
  238. if ([rowDescriptor.tag isEqualToString:@"enableTouchDaceID"]) {
  239. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  240. [CCUtility setEnableTouchFaceID:true];
  241. } else {
  242. [CCUtility setEnableTouchFaceID:false];
  243. }
  244. }
  245. if ([rowDescriptor.tag isEqualToString:@"privacyScreen"]) {
  246. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  247. [CCUtility setPrivacyScreenEnabled:true];
  248. } else {
  249. [CCUtility setPrivacyScreenEnabled:false];
  250. }
  251. }
  252. }
  253. #pragma mark -
  254. - (void)manageE2EE:(XLFormRowDescriptor *)sender
  255. {
  256. [self deselectFormRow:sender];
  257. UIViewController *vc = [[NCManageE2EEInterface alloc] makeShipDetailsUIWithAccount:appDelegate.account];
  258. [self.navigationController pushViewController:vc animated:YES];
  259. }
  260. - (void)privacy:(XLFormRowDescriptor *)sender
  261. {
  262. [self deselectFormRow:sender];
  263. NCBrowserWeb* browserWebVC = [[UIStoryboard storyboardWithName:@"NCBrowserWeb" bundle:nil] instantiateInitialViewController];
  264. browserWebVC.urlBase = NCBrandOptions.shared.privacy;
  265. browserWebVC.isHiddenButtonExit = false;
  266. browserWebVC.titleBrowser = NSLocalizedString(@"_privacy_", nil);
  267. [self presentViewController:browserWebVC animated:YES completion:nil];
  268. }
  269. - (void)sourceCode:(XLFormRowDescriptor *)sender
  270. {
  271. [self deselectFormRow:sender];
  272. NCBrowserWeb* browserWebVC = [[UIStoryboard storyboardWithName:@"NCBrowserWeb" bundle:nil] instantiateInitialViewController];
  273. browserWebVC.urlBase = NCBrandOptions.shared.sourceCode;
  274. browserWebVC.isHiddenButtonExit = false;
  275. browserWebVC.titleBrowser = NSLocalizedString(@"_source_code_", nil);
  276. [self presentViewController:browserWebVC animated:YES completion:nil];
  277. }
  278. - (void)CalDAVCardDAV:(XLFormRowDescriptor *)sender
  279. {
  280. [self deselectFormRow:sender];
  281. NSString *url = [appDelegate.urlBase stringByAppendingString:NCBrandOptions.shared.mobileconfig];
  282. NCConfigServer *configServer = [NCConfigServer new];
  283. [configServer startServiceWithUrl:[NSURL URLWithString: url]];
  284. }
  285. #pragma mark - Passcode
  286. - (void)didPerformBiometricValidationRequestInPasscodeViewController:(TOPasscodeViewController *)passcodeViewController
  287. {
  288. [[LAContext new] evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:[[NCBrandOptions shared] brand] reply:^(BOOL success, NSError * _Nullable error) {
  289. if (success) {
  290. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  291. [CCUtility setPasscode:@""];
  292. [passcodeViewController dismissViewControllerAnimated:YES completion:nil];
  293. [self reloadForm];
  294. });
  295. }
  296. }];
  297. }
  298. - (void)passcodeSettingsViewController:(TOPasscodeSettingsViewController *)passcodeSettingsViewController didChangeToNewPasscode:(NSString *)passcode ofType:(TOPasscodeType)type
  299. {
  300. [CCUtility setPasscode:passcode];
  301. [passcodeSettingsViewController dismissViewControllerAnimated:YES completion:nil];
  302. [self reloadForm];
  303. }
  304. - (void)didTapCancelInPasscodeViewController:(TOPasscodeViewController *)passcodeViewController
  305. {
  306. [passcodeViewController dismissViewControllerAnimated:YES completion:nil];
  307. }
  308. - (BOOL)passcodeViewController:(TOPasscodeViewController *)passcodeViewController isCorrectCode:(NSString *)code
  309. {
  310. if ([code isEqualToString:[CCUtility getPasscode]]) {
  311. [CCUtility setPasscode:@""];
  312. [self reloadForm];
  313. return YES;
  314. }
  315. return NO;
  316. }
  317. - (void)passcode:(XLFormRowDescriptor *)sender
  318. {
  319. LAContext *laContext = [LAContext new];
  320. NSError *error;
  321. [self deselectFormRow:sender];
  322. if ([[CCUtility getPasscode] length] == 0) {
  323. passcodeSettingsViewController = [[TOPasscodeSettingsViewController alloc] init];
  324. passcodeSettingsViewController.hideOptionsButton = YES;
  325. passcodeSettingsViewController.requireCurrentPasscode = NO;
  326. passcodeSettingsViewController.passcodeType = TOPasscodeTypeSixDigits;
  327. passcodeSettingsViewController.delegate = self;
  328. [self presentViewController:passcodeSettingsViewController animated:YES completion:nil];
  329. } else {
  330. passcodeViewController = [[TOPasscodeViewController alloc] initPasscodeType:TOPasscodeTypeSixDigits allowCancel:true];
  331. passcodeViewController.delegate = self;
  332. passcodeViewController.keypadButtonShowLettering = false;
  333. if (CCUtility.getEnableTouchFaceID && [laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
  334. if (error == NULL) {
  335. if (laContext.biometryType == LABiometryTypeFaceID) {
  336. passcodeViewController.biometryType = TOPasscodeBiometryTypeFaceID;
  337. passcodeViewController.allowBiometricValidation = true;
  338. passcodeViewController.automaticallyPromptForBiometricValidation = true;
  339. } else if (laContext.biometryType == LABiometryTypeTouchID) {
  340. passcodeViewController.biometryType = TOPasscodeBiometryTypeTouchID;
  341. passcodeViewController.allowBiometricValidation = true;
  342. passcodeViewController.automaticallyPromptForBiometricValidation = true;
  343. } else {
  344. NSLog(@"No Biometric support");
  345. }
  346. }
  347. }
  348. [self presentViewController:passcodeViewController animated:YES completion:nil];
  349. }
  350. }
  351. #pragma mark -
  352. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  353. return NCGlobal.shared.heightCellSettings;
  354. }
  355. - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
  356. {
  357. NSString *sectionName;
  358. NSInteger numSections = [tableView numberOfSections] - 1;
  359. if (section == 1) {
  360. sectionName = NSLocalizedString(@"_lock_protection_no_screen_footer_", nil);
  361. } else if (section == 2 && !NCBrandOptions.shared.disable_mobileconfig) {
  362. sectionName = NSLocalizedString(@"_calendar_contacts_footer_", nil);
  363. } else if (section == numSections) {
  364. NSString *versionServer = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesVersionString];
  365. NSString *themingName = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingName];
  366. NSString *themingSlogan = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingSlogan];
  367. NSString *versionNextcloud = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudServer, versionServer];
  368. NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, [[NCUtility shared] getVersionAppWithBuild:true]];
  369. NSString *nameSlogan = [NSString stringWithFormat:@"%@ - %@", themingName, themingSlogan];
  370. sectionName = [NSString stringWithFormat:@"\n%@\n\n%@\n%@", versionNextcloudiOS, versionNextcloud, nameSlogan];
  371. }
  372. return sectionName;
  373. }
  374. @end