NCSettings.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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 "AppDelegate.h"
  25. #import "CCAdvanced.h"
  26. #import "CCManageAccount.h"
  27. #import "NCManageEndToEndEncryption.h"
  28. #import "NCBridgeSwift.h"
  29. #import <TOPasscodeViewController/TOPasscodeViewController.h>
  30. #define alertViewEsci 1
  31. #define alertViewAzzeraCache 2
  32. @interface NCSettings () <TOPasscodeSettingsViewControllerDelegate, TOPasscodeViewControllerDelegate>
  33. {
  34. AppDelegate *appDelegate;
  35. TOPasscodeViewController *passcodeViewController;
  36. TOPasscodeSettingsViewController *passcodeSettingsViewController;
  37. }
  38. @end
  39. @implementation NCSettings
  40. - (void)initializeForm
  41. {
  42. XLFormDescriptor *form = [XLFormDescriptor formDescriptor];
  43. XLFormSectionDescriptor *section;
  44. XLFormRowDescriptor *row;
  45. //NSInteger serverVersionMajor = [[NCManageDatabase shared] getCapabilitiesServerIntWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesVersionMajor];
  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"] = NCBrandColor.shared.backgroundCell;
  52. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  53. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  54. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"autoUpload"] width:50 height:50 color:NCBrandColor.shared.icon] forKey:@"imageView.image"];
  55. row.action.viewControllerClass = [CCManageAutoUpload class];
  56. [section addFormRow:row];
  57. // Section FOLDERS FAVORITES OFFLINE ------------------------------------
  58. section = [XLFormSectionDescriptor formSection];
  59. [form addFormSection:section];
  60. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"favoriteoffline" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_favorite_offline_", nil)];
  61. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  62. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"favorite"] width:50 height:50 color:NCBrandColor.shared.icon] forKey:@"imageView.image"];
  63. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  64. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  65. [section addFormRow:row];
  66. // Section : LOCK --------------------------------------------------------------
  67. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_lock_", nil)];
  68. [form addFormSection:section];
  69. // Lock active YES/NO
  70. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"bloccopasscode" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_lock_not_active_", nil)];
  71. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  72. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settingsPasscodeNO"] multiplier:2 color:NCBrandColor.shared.icon] forKey:@"imageView.image"];
  73. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  74. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  75. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  76. //[row.cellConfig setObject:@(UITableViewCellAccessoryDisclosureIndicator) forKey:@"accessoryType"];
  77. row.action.formSelector = @selector(passcode:);
  78. [section addFormRow:row];
  79. // Enable Touch ID
  80. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"enableTouchDaceID" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_enable_touch_face_id_", nil)];
  81. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  82. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  83. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  84. [section addFormRow:row];
  85. // Lock no screen
  86. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"notPasscodeAtStart" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_lock_protection_no_screen_", nil)];
  87. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  88. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  89. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  90. [section addFormRow:row];
  91. // Section : Screen --------------------------------------------------------------
  92. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_screen_", nil)];
  93. [form addFormSection:section];
  94. // Dark Mode
  95. if (@available(iOS 13.0, *)) {
  96. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"darkModeDetect" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_dark_mode_detect_", nil)];
  97. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  98. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"darkModeDetect"] width:50 height:50 color:NCBrandColor.shared.icon] forKey:@"imageView.image"];
  99. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  100. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  101. if ([CCUtility getDarkModeDetect]) row.value = @1;
  102. else row.value = @0;
  103. [section addFormRow:row];
  104. } else {
  105. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"darkMode" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_dark_mode_", nil)];
  106. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  107. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"themeLightDark"] width:50 height:50 color:NCBrandColor.shared.icon] forKey:@"imageView.image"];
  108. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  109. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  110. if ([CCUtility getDarkMode]) row.value = @1;
  111. else row.value = @0;
  112. [section addFormRow:row];
  113. }
  114. // Section : E2EEncryption --------------------------------------------------------------
  115. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_title_", nil)];
  116. [form addFormSection:section];
  117. // EndToEnd Encryption
  118. NSString *title = [NSString stringWithFormat:@"%@ (%@)",NSLocalizedString(@"_e2e_settings_", nil), NSLocalizedString(@"_experimental_", nil)];
  119. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"e2eEncryption" rowType:XLFormRowDescriptorTypeButton title:title];
  120. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  121. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  122. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  123. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"lock"] width:50 height:50 color:NCBrandColor.shared.icon] forKey:@"imageView.image"];
  124. row.action.viewControllerClass = [NCManageEndToEndEncryption class];
  125. [section addFormRow:row];
  126. // Section Advanced -------------------------------------------------
  127. section = [XLFormSectionDescriptor formSection];
  128. [form addFormSection:section];
  129. // Advanced
  130. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"advanced" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_advanced_", nil)];
  131. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  132. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  133. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  134. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settings"] width:50 height:50 color:NCBrandColor.shared.icon] forKey:@"imageView.image"];
  135. row.action.viewControllerClass = [CCAdvanced class];
  136. [section addFormRow:row];
  137. // Section : INFORMATION ------------------------------------------------
  138. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_information_", nil)];
  139. [form addFormSection:section];
  140. // Acknowledgements
  141. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttonLeftAligned" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_acknowledgements_", nil)];
  142. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.shared.backgroundCell;
  143. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  144. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  145. [row.cellConfig setObject:NCBrandColor.shared.textView forKey:@"textLabel.textColor"];
  146. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"acknowledgements"] width:50 height:50 color:NCBrandColor.shared.icon] forKey:@"imageView.image"];
  147. row.action.formBlock = ^(XLFormRowDescriptor * sender){
  148. [self performSegueWithIdentifier:@"AcknowledgementsSegue" sender:sender];
  149. [self deselectFormRow:sender];
  150. };
  151. [section addFormRow:row];
  152. self.tableView.showsVerticalScrollIndicator = NO;
  153. self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 35, 0);
  154. self.form = form;
  155. }
  156. - (void)viewDidLoad
  157. {
  158. [super viewDidLoad];
  159. self.title = NSLocalizedString(@"_settings_", nil);
  160. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  161. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:k_notificationCenter_changeTheming object:nil];
  162. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:k_notificationCenter_applicationDidEnterBackground object:nil];
  163. [self changeTheming];
  164. }
  165. - (void)changeTheming
  166. {
  167. self.view.backgroundColor = NCBrandColor.shared.backgroundForm;
  168. self.tableView.backgroundColor = NCBrandColor.shared.backgroundForm;
  169. [self.tableView reloadData];
  170. [self initializeForm];
  171. [self reloadForm];
  172. }
  173. - (void)applicationDidEnterBackground
  174. {
  175. if (passcodeViewController.view.window != nil) {
  176. [passcodeViewController dismissViewControllerAnimated:true completion:nil];
  177. }
  178. if (passcodeSettingsViewController.view.window != nil) {
  179. [passcodeSettingsViewController dismissViewControllerAnimated:true completion:nil];
  180. }
  181. }
  182. #pragma --------------------------------------------------------------------------------------------
  183. #pragma mark === Chiamate dal Form ===
  184. #pragma --------------------------------------------------------------------------------------------
  185. - (void)reloadForm
  186. {
  187. self.form.delegate = nil;
  188. // ------------------------------------------------------------------
  189. XLFormRowDescriptor *rowBloccoPasscode = [self.form formRowWithTag:@"bloccopasscode"];
  190. XLFormRowDescriptor *rowNotPasscodeAtStart = [self.form formRowWithTag:@"notPasscodeAtStart"];
  191. XLFormRowDescriptor *rowEnableTouchDaceID = [self.form formRowWithTag:@"enableTouchDaceID"];
  192. XLFormRowDescriptor *rowFavoriteOffline = [self.form formRowWithTag:@"favoriteoffline"];
  193. XLFormRowDescriptor *rowDarkModeDetect = [self.form formRowWithTag:@"darkModeDetect"];
  194. XLFormRowDescriptor *rowDarkMode = [self.form formRowWithTag:@"darkMode"];
  195. // ------------------------------------------------------------------
  196. if ([[CCUtility getPasscode] length]) {
  197. rowBloccoPasscode.title = NSLocalizedString(@"_lock_active_", nil);
  198. [rowBloccoPasscode.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settingsPasscodeYES"] multiplier:2 color:NCBrandColor.shared.icon] forKey:@"imageView.image"];
  199. } else {
  200. rowBloccoPasscode.title = NSLocalizedString(@"_lock_not_active_", nil);
  201. [rowBloccoPasscode.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settingsPasscodeNO"] multiplier:2 color:NCBrandColor.shared.icon] forKey:@"imageView.image"];
  202. }
  203. if ([CCUtility getEnableTouchFaceID]) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0];
  204. if ([CCUtility getNotPasscodeAtStart]) [rowNotPasscodeAtStart setValue:@1]; else [rowNotPasscodeAtStart setValue:@0];
  205. if ([CCUtility getFavoriteOffline]) [rowFavoriteOffline setValue:@1]; else [rowFavoriteOffline setValue:@0];
  206. if ([CCUtility getDarkModeDetect]) [rowDarkModeDetect setValue:@1]; else [rowDarkModeDetect setValue:@0];
  207. if ([CCUtility getDarkMode]) [rowDarkMode setValue:@1]; else [rowDarkMode setValue:@0];
  208. // -----------------------------------------------------------------
  209. [self.tableView reloadData];
  210. self.form.delegate = self;
  211. }
  212. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  213. {
  214. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  215. if ([rowDescriptor.tag isEqualToString:@"notPasscodeAtStart"]) {
  216. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  217. [CCUtility setNotPasscodeAtStart:true];
  218. } else {
  219. [CCUtility setNotPasscodeAtStart:false];
  220. }
  221. }
  222. if ([rowDescriptor.tag isEqualToString:@"enableTouchDaceID"]) {
  223. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  224. [CCUtility setEnableTouchFaceID:true];
  225. } else {
  226. [CCUtility setEnableTouchFaceID:false];
  227. }
  228. }
  229. if ([rowDescriptor.tag isEqualToString:@"favoriteoffline"]) {
  230. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  231. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_continue_request_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  232. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  233. [CCUtility setFavoriteOffline:true];
  234. [[NCManageDatabase shared] removeAllDirectoriesSynchronizedWithAccount:appDelegate.account];
  235. [[NCNetworking shared] listingFavoritescompletionWithSelector:(selectorDownloadAllFile) completion:^(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 shared] 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 shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesVersionString];
  371. NSString *themingName = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingName];
  372. NSString *themingSlogan = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingSlogan];
  373. NSString *versionApp = [NSString stringWithFormat:@"%@.%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
  374. NSString *versionNextcloud = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudServer, versionServer];
  375. NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].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