NCSettings.m 22 KB

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