NCSettings.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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. //NSInteger serverVersionMajor = [[NCManageDatabase shared] getCapabilitiesServerIntWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesVersionMajor];
  48. form.rowNavigationOptions = XLFormRowNavigationOptionNone;
  49. // Section AUTO UPLOAD OF CAMERA IMAGES ----------------------------
  50. section = [XLFormSectionDescriptor formSection];
  51. [form addFormSection:section];
  52. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUpload" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_settings_autoupload_", nil)];
  53. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  54. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  55. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  56. [row.cellConfig setObject:[[UIImage imageNamed:@"autoUpload"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  57. row.action.viewControllerClass = [CCManageAutoUpload class];
  58. [section addFormRow:row];
  59. // Section : PRIVACY --------------------------------------------------------------
  60. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_privacy_", nil)];
  61. [form addFormSection:section];
  62. // Lock active YES/NO
  63. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"bloccopasscode" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_lock_not_active_", nil)];
  64. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  65. [row.cellConfig setObject:[[UIImage imageNamed:@"lock_open"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  66. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  67. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  68. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  69. //[row.cellConfig setObject:@(UITableViewCellAccessoryDisclosureIndicator) forKey:@"accessoryType"];
  70. row.action.formSelector = @selector(passcode:);
  71. [section addFormRow:row];
  72. // Enable Touch ID
  73. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"enableTouchDaceID" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_enable_touch_face_id_", nil)];
  74. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  75. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  76. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  77. [section addFormRow:row];
  78. // Lock no screen
  79. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"notPasscodeAtStart" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_lock_protection_no_screen_", nil)];
  80. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  81. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  82. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  83. [section addFormRow:row];
  84. // Privacy screen
  85. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"privacyScreen" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_privacy_screen_", nil)];
  86. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  87. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  88. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  89. [section addFormRow:row];
  90. // Section : CARDAV --------------------------------------------------------------
  91. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_cardav_", nil)];
  92. [form addFormSection:section];
  93. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"cardav" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_cardav_", 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:@"shield.checkerboard"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  99. row.action.formSelector = @selector(CalDAVCardDAV:);
  100. [section addFormRow:row];
  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 && [versionE2EE isEqual:[[NCGlobal shared] e2eeVersion]]) {
  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:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  115. //row.action.formSelector = @selector(manageE2EE:);
  116. row.action.viewControllerClass = [NCManageEndToEndEncryption class];
  117. [section addFormRow:row];
  118. }
  119. // Section Advanced -------------------------------------------------
  120. section = [XLFormSectionDescriptor formSection];
  121. [form addFormSection:section];
  122. // Advanced
  123. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"advanced" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_advanced_", nil)];
  124. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  125. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  126. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  127. [row.cellConfig setObject:[[UIImage imageNamed:@"gear"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  128. row.action.viewControllerClass = [CCAdvanced class];
  129. [section addFormRow:row];
  130. // Section : INFORMATION ------------------------------------------------
  131. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_information_", nil)];
  132. [form addFormSection:section];
  133. // Acknowledgements
  134. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttonLeftAligned" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_acknowledgements_", nil)];
  135. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  136. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  137. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  138. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  139. [row.cellConfig setObject:[[UIImage imageNamed:@"acknowledgements"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  140. row.action.formBlock = ^(XLFormRowDescriptor * sender){
  141. [self performSegueWithIdentifier:@"AcknowledgementsSegue" sender:sender];
  142. [self deselectFormRow:sender];
  143. };
  144. [section addFormRow:row];
  145. if (!NCBrandOptions.shared.disable_crash_service) {
  146. // Privacy and Legal Policy
  147. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"privacy" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_privacy_legal_", nil)];
  148. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  149. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  150. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  151. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  152. [row.cellConfig setObject:[[UIImage imageNamed:@"shield.checkerboard"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  153. row.action.formSelector = @selector(privacy:);
  154. [section addFormRow:row];
  155. // Source code
  156. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"sourcecode" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_source_code_", nil)];
  157. row.cellConfigAtConfigure[@"backgroundColor"] = UIColor.secondarySystemGroupedBackgroundColor;
  158. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  159. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  160. [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
  161. [row.cellConfig setObject:[[UIImage imageNamed:@"gitHub"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  162. row.action.formSelector = @selector(sourceCode:);
  163. [section addFormRow:row];
  164. }
  165. self.tableView.showsVerticalScrollIndicator = NO;
  166. self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 35, 0);
  167. self.form = form;
  168. }
  169. // MARK: - View Life Cycle
  170. - (void)viewDidLoad
  171. {
  172. [super viewDidLoad];
  173. self.title = NSLocalizedString(@"_settings_", nil);
  174. self.view.backgroundColor = UIColor.systemGroupedBackgroundColor;
  175. self.tableView.backgroundColor = UIColor.systemGroupedBackgroundColor;
  176. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  177. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:NCGlobal.shared.notificationCenterApplicationDidEnterBackground object:nil];
  178. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(initialize) name:NCGlobal.shared.notificationCenterInitialize object:nil];
  179. [self initializeForm];
  180. [self reloadForm];
  181. }
  182. - (void)viewWillAppear:(BOOL)animated
  183. {
  184. [super viewWillAppear:animated];
  185. appDelegate.activeViewController = self;
  186. }
  187. #pragma mark - NotificationCenter
  188. - (void)initialize
  189. {
  190. [self initializeForm];
  191. [self reloadForm];
  192. }
  193. - (void)applicationDidEnterBackground
  194. {
  195. if (passcodeViewController.view.window != nil) {
  196. [passcodeViewController dismissViewControllerAnimated:true completion:nil];
  197. }
  198. if (passcodeSettingsViewController.view.window != nil) {
  199. [passcodeSettingsViewController dismissViewControllerAnimated:true completion:nil];
  200. }
  201. [[self navigationController] popToRootViewControllerAnimated:false];
  202. }
  203. #pragma mark -
  204. - (void)reloadForm
  205. {
  206. self.form.delegate = nil;
  207. // ------------------------------------------------------------------
  208. XLFormRowDescriptor *rowBloccoPasscode = [self.form formRowWithTag:@"bloccopasscode"];
  209. XLFormRowDescriptor *rowNotPasscodeAtStart = [self.form formRowWithTag:@"notPasscodeAtStart"];
  210. XLFormRowDescriptor *rowEnableTouchDaceID = [self.form formRowWithTag:@"enableTouchDaceID"];
  211. XLFormRowDescriptor *rowPrivacyScreen = [self.form formRowWithTag:@"privacyScreen"];
  212. // ------------------------------------------------------------------
  213. if ([[CCUtility getPasscode] length]) {
  214. rowBloccoPasscode.title = NSLocalizedString(@"_lock_active_", nil);
  215. [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  216. } else {
  217. rowBloccoPasscode.title = NSLocalizedString(@"_lock_not_active_", nil);
  218. [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock_open"] imageWithColor:NCBrandColor.shared.gray size:25] forKey:@"imageView.image"];
  219. }
  220. if ([CCUtility getEnableTouchFaceID]) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0];
  221. if ([CCUtility getNotPasscodeAtStart]) [rowNotPasscodeAtStart setValue:@1]; else [rowNotPasscodeAtStart setValue:@0];
  222. if ([CCUtility getPrivacyScreenEnabled]) [rowPrivacyScreen setValue:@1]; else [rowPrivacyScreen setValue:@0];
  223. // -----------------------------------------------------------------
  224. [self.tableView reloadData];
  225. self.form.delegate = self;
  226. }
  227. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  228. {
  229. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  230. if ([rowDescriptor.tag isEqualToString:@"notPasscodeAtStart"]) {
  231. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  232. [CCUtility setNotPasscodeAtStart:true];
  233. } else {
  234. [CCUtility setNotPasscodeAtStart:false];
  235. }
  236. }
  237. if ([rowDescriptor.tag isEqualToString:@"enableTouchDaceID"]) {
  238. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  239. [CCUtility setEnableTouchFaceID:true];
  240. } else {
  241. [CCUtility setEnableTouchFaceID:false];
  242. }
  243. }
  244. if ([rowDescriptor.tag isEqualToString:@"privacyScreen"]) {
  245. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  246. [CCUtility setPrivacyScreenEnabled:true];
  247. } else {
  248. [CCUtility setPrivacyScreenEnabled:false];
  249. }
  250. }
  251. }
  252. #pragma mark -
  253. - (void)manageE2EE:(XLFormRowDescriptor *)sender
  254. {
  255. [self deselectFormRow:sender];
  256. UIViewController *vc = [[NCManageE2EEInterface alloc] makeShipDetailsUIWithAccount:appDelegate.account];
  257. [self.navigationController pushViewController:vc animated:YES];
  258. }
  259. - (void)privacy:(XLFormRowDescriptor *)sender
  260. {
  261. [self deselectFormRow:sender];
  262. NCBrowserWeb* browserWebVC = [[UIStoryboard storyboardWithName:@"NCBrowserWeb" bundle:nil] instantiateInitialViewController];
  263. browserWebVC.urlBase = NCBrandOptions.shared.privacy;
  264. browserWebVC.isHiddenButtonExit = false;
  265. browserWebVC.titleBrowser = NSLocalizedString(@"_privacy_", nil);
  266. [self presentViewController:browserWebVC animated:YES completion:nil];
  267. }
  268. - (void)sourceCode:(XLFormRowDescriptor *)sender
  269. {
  270. [self deselectFormRow:sender];
  271. NCBrowserWeb* browserWebVC = [[UIStoryboard storyboardWithName:@"NCBrowserWeb" bundle:nil] instantiateInitialViewController];
  272. browserWebVC.urlBase = NCBrandOptions.shared.sourceCode;
  273. browserWebVC.isHiddenButtonExit = false;
  274. browserWebVC.titleBrowser = NSLocalizedString(@"_source_code_", nil);
  275. [self presentViewController:browserWebVC animated:YES completion:nil];
  276. }
  277. - (void)CalDAVCardDAV:(XLFormRowDescriptor *)sender
  278. {
  279. [self deselectFormRow:sender];
  280. NSString *url = [appDelegate.urlBase stringByAppendingString:@"/remote.php/dav/provisioning/apple-provisioning.mobileconfig"];
  281. [[NCConfigServer shared] 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 == numSections) {
  360. NSString *versionServer = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesVersionString];
  361. NSString *themingName = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingName];
  362. NSString *themingSlogan = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingSlogan];
  363. NSString *versionNextcloud = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudServer, versionServer];
  364. NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, [[NCUtility shared] getVersionAppWithBuild:true]];
  365. NSString *nameSlogan = [NSString stringWithFormat:@"%@ - %@", themingName, themingSlogan];
  366. sectionName = [NSString stringWithFormat:@"\n%@\n\n%@\n%@", versionNextcloudiOS, versionNextcloud, nameSlogan];
  367. }
  368. return sectionName;
  369. }
  370. @end