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