CCSettings.m 24 KB

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