CCSettings.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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.account 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 --------------------------------------------------------------
  116. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_title_", nil)];
  117. [form addFormSection:section];
  118. // EndToEnd Encryption
  119. NSString *title = [NSString stringWithFormat:@"%@ (%@)",NSLocalizedString(@"_e2e_settings_", nil), NSLocalizedString(@"_experimental_", nil)];
  120. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"e2eEncryption" rowType:XLFormRowDescriptorTypeButton title:title];
  121. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundCell;
  122. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  123. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  124. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"lock"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  125. row.action.viewControllerClass = [NCManageEndToEndEncryption class];
  126. [section addFormRow:row];
  127. // Section Advanced -------------------------------------------------
  128. section = [XLFormSectionDescriptor formSection];
  129. [form addFormSection:section];
  130. // Advanced
  131. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"advanced" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_advanced_", nil)];
  132. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundCell;
  133. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  134. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  135. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settings"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  136. row.action.viewControllerClass = [CCAdvanced class];
  137. [section addFormRow:row];
  138. // Section : INFORMATION ------------------------------------------------
  139. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_information_", nil)];
  140. [form addFormSection:section];
  141. // Acknowledgements
  142. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttonLeftAligned" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_acknowledgements_", nil)];
  143. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundCell;
  144. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  145. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  146. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  147. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"acknowledgements"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  148. row.action.formBlock = ^(XLFormRowDescriptor * sender){
  149. [self performSegueWithIdentifier:@"AcknowledgementsSegue" sender:sender];
  150. [self deselectFormRow:sender];
  151. };
  152. [section addFormRow:row];
  153. self.tableView.showsVerticalScrollIndicator = NO;
  154. self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 35, 0);
  155. self.form = form;
  156. }
  157. - (void)viewDidLoad
  158. {
  159. [super viewDidLoad];
  160. self.title = NSLocalizedString(@"_settings_", nil);
  161. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  162. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:k_notificationCenter_changeTheming object:nil];
  163. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:k_notificationCenter_applicationDidEnterBackground object:nil];
  164. [self changeTheming];
  165. }
  166. - (void)changeTheming
  167. {
  168. [appDelegate changeTheming:self tableView:self.tableView collectionView:nil form:true];
  169. [self initializeForm];
  170. [self reloadForm];
  171. }
  172. - (void)applicationDidEnterBackground
  173. {
  174. if (passcodeViewController.view.window != nil) {
  175. [passcodeViewController dismissViewControllerAnimated:true completion:nil];
  176. }
  177. if (passcodeSettingsViewController.view.window != nil) {
  178. [passcodeSettingsViewController dismissViewControllerAnimated:true completion:nil];
  179. }
  180. }
  181. #pragma --------------------------------------------------------------------------------------------
  182. #pragma mark === Chiamate dal Form ===
  183. #pragma --------------------------------------------------------------------------------------------
  184. - (void)reloadForm
  185. {
  186. self.form.delegate = nil;
  187. // ------------------------------------------------------------------
  188. XLFormRowDescriptor *rowBloccoPasscode = [self.form formRowWithTag:@"bloccopasscode"];
  189. XLFormRowDescriptor *rowNotPasscodeAtStart = [self.form formRowWithTag:@"notPasscodeAtStart"];
  190. XLFormRowDescriptor *rowEnableTouchDaceID = [self.form formRowWithTag:@"enableTouchDaceID"];
  191. XLFormRowDescriptor *rowFavoriteOffline = [self.form formRowWithTag:@"favoriteoffline"];
  192. XLFormRowDescriptor *rowDarkModeDetect = [self.form formRowWithTag:@"darkModeDetect"];
  193. XLFormRowDescriptor *rowDarkMode = [self.form formRowWithTag:@"darkMode"];
  194. // ------------------------------------------------------------------
  195. if ([[CCUtility getPasscode] length]) {
  196. rowBloccoPasscode.title = NSLocalizedString(@"_lock_active_", nil);
  197. [rowBloccoPasscode.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settingsPasscodeYES"] multiplier:2 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  198. } else {
  199. rowBloccoPasscode.title = NSLocalizedString(@"_lock_not_active_", nil);
  200. [rowBloccoPasscode.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"settingsPasscodeNO"] multiplier:2 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  201. }
  202. if ([CCUtility getEnableTouchFaceID]) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0];
  203. if ([CCUtility getNotPasscodeAtStart]) [rowNotPasscodeAtStart setValue:@1]; else [rowNotPasscodeAtStart setValue:@0];
  204. if ([CCUtility getFavoriteOffline]) [rowFavoriteOffline setValue:@1]; else [rowFavoriteOffline setValue:@0];
  205. if ([CCUtility getDarkModeDetect]) [rowDarkModeDetect setValue:@1]; else [rowDarkModeDetect setValue:@0];
  206. if ([CCUtility getDarkMode]) [rowDarkMode setValue:@1]; else [rowDarkMode setValue:@0];
  207. // -----------------------------------------------------------------
  208. [self.tableView reloadData];
  209. self.form.delegate = self;
  210. }
  211. - (void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  212. {
  213. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  214. if ([rowDescriptor.tag isEqualToString:@"notPasscodeAtStart"]) {
  215. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  216. [CCUtility setNotPasscodeAtStart:true];
  217. } else {
  218. [CCUtility setNotPasscodeAtStart:false];
  219. }
  220. }
  221. if ([rowDescriptor.tag isEqualToString:@"enableTouchDaceID"]) {
  222. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  223. [CCUtility setEnableTouchFaceID:true];
  224. } else {
  225. [CCUtility setEnableTouchFaceID:false];
  226. }
  227. }
  228. if ([rowDescriptor.tag isEqualToString:@"favoriteoffline"]) {
  229. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  230. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_continue_request_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
  231. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  232. [CCUtility setFavoriteOffline:true];
  233. [[NCNetworking shared] listingFavoritescompletionWithCompletion:^(NSString *account, NSArray *metadatas, NSInteger errorCode, NSString *errorDescription) { }];
  234. }]];
  235. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  236. [self reloadForm];
  237. }]];
  238. alertController.popoverPresentationController.sourceView = self.view;
  239. NSIndexPath *indexPath = [self.form indexPathOfFormRow:rowDescriptor];
  240. CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
  241. alertController.popoverPresentationController.sourceRect = CGRectOffset(cellRect, -self.tableView.contentOffset.x, -self.tableView.contentOffset.y);
  242. [self presentViewController:alertController animated:YES completion:nil];
  243. } else {
  244. [CCUtility setFavoriteOffline:false];
  245. }
  246. }
  247. if ([rowDescriptor.tag isEqualToString:@"darkMode"]) {
  248. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  249. [CCUtility setDarkMode:true];
  250. } else {
  251. [CCUtility setDarkMode:false];
  252. }
  253. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_changeTheming object:nil];
  254. }
  255. if ([rowDescriptor.tag isEqualToString:@"darkModeDetect"]) {
  256. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  257. [CCUtility setDarkModeDetect:true];
  258. // detect Dark Mode
  259. if (@available(iOS 12.0, *)) {
  260. appDelegate.preferredUserInterfaceStyle = self.traitCollection.userInterfaceStyle;
  261. if (appDelegate.preferredUserInterfaceStyle == UIUserInterfaceStyleDark) {
  262. [CCUtility setDarkMode:YES];
  263. } else {
  264. [CCUtility setDarkMode:NO];
  265. }
  266. }
  267. } else {
  268. [CCUtility setDarkModeDetect:false];
  269. [CCUtility setDarkMode:false];
  270. }
  271. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_changeTheming object:nil];
  272. }
  273. }
  274. #pragma mark - Passcode -
  275. - (void)didPerformBiometricValidationRequestInPasscodeViewController:(TOPasscodeViewController *)passcodeViewController
  276. {
  277. [[LAContext new] evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:[[NCBrandOptions sharedInstance] brand] reply:^(BOOL success, NSError * _Nullable error) {
  278. if (success) {
  279. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
  280. [CCUtility setPasscode:@""];
  281. [passcodeViewController dismissViewControllerAnimated:YES completion:nil];
  282. [self reloadForm];
  283. });
  284. }
  285. }];
  286. }
  287. - (void)passcodeSettingsViewController:(TOPasscodeSettingsViewController *)passcodeSettingsViewController didChangeToNewPasscode:(NSString *)passcode ofType:(TOPasscodeType)type
  288. {
  289. [CCUtility setPasscode:passcode];
  290. [passcodeSettingsViewController dismissViewControllerAnimated:YES completion:nil];
  291. [self reloadForm];
  292. }
  293. - (void)didTapCancelInPasscodeViewController:(TOPasscodeViewController *)passcodeViewController
  294. {
  295. [passcodeViewController dismissViewControllerAnimated:YES completion:nil];
  296. }
  297. - (BOOL)passcodeViewController:(TOPasscodeViewController *)passcodeViewController isCorrectCode:(NSString *)code
  298. {
  299. if ([code isEqualToString:[CCUtility getPasscode]]) {
  300. [CCUtility setPasscode:@""];
  301. [self reloadForm];
  302. return YES;
  303. }
  304. return NO;
  305. }
  306. - (void)passcode:(XLFormRowDescriptor *)sender
  307. {
  308. LAContext *laContext = [LAContext new];
  309. NSError *error;
  310. [self deselectFormRow:sender];
  311. if ([[CCUtility getPasscode] length] == 0) {
  312. passcodeSettingsViewController = [[TOPasscodeSettingsViewController alloc] init];
  313. if (@available(iOS 13.0, *)) {
  314. if ([[UITraitCollection currentTraitCollection] userInterfaceStyle] == UIUserInterfaceStyleDark) {
  315. passcodeSettingsViewController.style = TOPasscodeSettingsViewStyleDark;
  316. }
  317. }
  318. passcodeSettingsViewController.hideOptionsButton = YES;
  319. passcodeSettingsViewController.requireCurrentPasscode = NO;
  320. passcodeSettingsViewController.passcodeType = TOPasscodeTypeSixDigits;
  321. passcodeSettingsViewController.delegate = self;
  322. [self presentViewController:passcodeSettingsViewController animated:YES completion:nil];
  323. } else {
  324. passcodeViewController = [[TOPasscodeViewController alloc] initWithStyle:TOPasscodeViewStyleTranslucentLight passcodeType:TOPasscodeTypeSixDigits];
  325. if (@available(iOS 13.0, *)) {
  326. if ([[UITraitCollection currentTraitCollection] userInterfaceStyle] == UIUserInterfaceStyleDark) {
  327. passcodeViewController.style = TOPasscodeViewStyleTranslucentDark;
  328. }
  329. }
  330. passcodeViewController.allowCancel = true;
  331. passcodeViewController.delegate = self;
  332. passcodeViewController.keypadButtonShowLettering = false;
  333. if (CCUtility.getEnableTouchFaceID && [laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
  334. if (error == NULL) {
  335. if (laContext.biometryType == LABiometryTypeFaceID) {
  336. passcodeViewController.biometryType = TOPasscodeBiometryTypeFaceID;
  337. passcodeViewController.allowBiometricValidation = true;
  338. passcodeViewController.automaticallyPromptForBiometricValidation = true;
  339. } else if (laContext.biometryType == LABiometryTypeTouchID) {
  340. passcodeViewController.biometryType = TOPasscodeBiometryTypeTouchID;
  341. passcodeViewController.allowBiometricValidation = true;
  342. passcodeViewController.automaticallyPromptForBiometricValidation = true;
  343. } else {
  344. NSLog(@"No Biometric support");
  345. }
  346. }
  347. }
  348. [self presentViewController:passcodeViewController animated:YES completion:nil];
  349. }
  350. }
  351. #pragma --------------------------------------------------------------------------------------------
  352. #pragma mark === Table View ===
  353. #pragma --------------------------------------------------------------------------------------------
  354. - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
  355. {
  356. NSString *sectionName;
  357. switch (section)
  358. {
  359. case 1: {
  360. sectionName = NSLocalizedString(@"_favorite_offline_footer_", nil);
  361. }
  362. break;
  363. case 2: {
  364. sectionName = NSLocalizedString(@"_lock_protection_no_screen_footer_", nil);
  365. }
  366. break;
  367. case 5: {
  368. NSString *versionServer = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesVersionString];
  369. NSString *themingName = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingName];
  370. NSString *themingSlogan = [[NCManageDatabase sharedInstance] getCapabilitiesServerStringWithAccount:appDelegate.account elements:NCElementsJSON.shared.capabilitiesThemingSlogan];
  371. NSString *versionApp = [NSString stringWithFormat:@"%@.%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
  372. NSString *versionNextcloud = [NSString stringWithFormat:[NCBrandOptions sharedInstance].textCopyrightNextcloudServer, versionServer];
  373. NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions sharedInstance].textCopyrightNextcloudiOS, versionApp];
  374. NSString *nameSlogan = [NSString stringWithFormat:@"%@ - %@", themingName, themingSlogan];
  375. sectionName = [NSString stringWithFormat:@"%@\n\n%@\n%@", versionNextcloudiOS, versionNextcloud, nameSlogan];
  376. }
  377. break;
  378. }
  379. return sectionName;
  380. }
  381. @end