CCManageAutoUpload.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. //
  2. // CCManageAutoUpload.m
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 01/09/15.
  6. // Copyright (c) 2017 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 "CCManageAutoUpload.h"
  24. #import "NCAutoUpload.h"
  25. #import "AppDelegate.h"
  26. #import "NCBridgeSwift.h"
  27. @interface CCManageAutoUpload () <NCSelectDelegate>
  28. {
  29. AppDelegate *appDelegate;
  30. }
  31. @end
  32. @implementation CCManageAutoUpload
  33. - (void)initializeForm
  34. {
  35. XLFormDescriptor *form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_settings_autoupload_", nil)];
  36. XLFormSectionDescriptor *section;
  37. XLFormRowDescriptor *row;
  38. tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
  39. // Auto Upload
  40. section = [XLFormSectionDescriptor formSection];
  41. [form addFormSection:section];
  42. section.footerTitle = NSLocalizedString(@"_autoupload_description_", nil);
  43. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUpload" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_autoupload_", nil)];
  44. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  45. if (tableAccount.autoUpload) row.value = @1;
  46. else row.value = @0;
  47. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  48. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  49. [section addFormRow:row];
  50. // Auto Upload Directory
  51. section = [XLFormSectionDescriptor formSection];
  52. [form addFormSection:section];
  53. // Lock active YES/NO
  54. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadDirectory" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_autoupload_select_folder_", nil)];
  55. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  56. row.cellConfigAtConfigure[@"switchControl.onTintColor"] = NCBrandColor.sharedInstance.brand;
  57. row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  58. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"folderAutomaticUpload"] width:50 height:50 color:NCBrandColor.sharedInstance.icon] forKey:@"imageView.image"];
  59. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  60. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  61. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  62. //[row.cellConfig setObject:@(UITableViewCellAccessoryDisclosureIndicator) forKey:@"accessoryType"];
  63. row.action.formSelector = @selector(selectAutomaticUploadFolder);
  64. [section addFormRow:row];
  65. // Auto Upload Photo
  66. section = [XLFormSectionDescriptor formSection];
  67. [form addFormSection:section];
  68. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadImage" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_autoupload_photos_", nil)];
  69. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  70. row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  71. if (tableAccount.autoUploadImage) row.value = @1;
  72. else row.value = @0;
  73. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  74. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  75. [section addFormRow:row];
  76. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadWWAnPhoto" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_wifi_only_", nil)];
  77. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  78. row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  79. if (tableAccount.autoUploadWWAnPhoto) row.value = @1;
  80. else row.value = @0;
  81. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  82. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  83. [section addFormRow:row];
  84. // Auto Upload Video
  85. section = [XLFormSectionDescriptor formSection];
  86. [form addFormSection:section];
  87. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadVideo" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_autoupload_videos_", nil)];
  88. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  89. row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  90. if (tableAccount.autoUploadVideo) row.value = @1;
  91. else row.value = @0;
  92. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  93. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  94. [section addFormRow:row];
  95. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadWWAnVideo" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_wifi_only_", nil)];
  96. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  97. row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  98. if (tableAccount.autoUploadWWAnVideo) row.value = @1;
  99. else row.value = @0;
  100. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  101. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  102. [section addFormRow:row];
  103. // Auto Upload Background
  104. section = [XLFormSectionDescriptor formSection];
  105. [form addFormSection:section];
  106. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadBackground" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_autoupload_background_", nil)];
  107. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  108. row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  109. if (tableAccount.autoUploadBackground) row.value = @1;
  110. else row.value = @0;
  111. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  112. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  113. [section addFormRow:row];
  114. // Auto Upload Full
  115. section = [XLFormSectionDescriptor formSection];
  116. [form addFormSection:section];
  117. NSString *title = NSLocalizedString(@"_autoupload_fullphotos_", nil);
  118. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadFull" rowType:XLFormRowDescriptorTypeBooleanSwitch title:title];
  119. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  120. row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  121. row.value = 0;
  122. if (tableAccount.autoUploadFull) row.value = @1;
  123. else row.value = @0;
  124. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  125. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  126. [section addFormRow:row];
  127. // Auto Upload create subfolder
  128. section = [XLFormSectionDescriptor formSection];
  129. [form addFormSection:section];
  130. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadCreateSubfolder" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_autoupload_create_subfolder_", nil)];
  131. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  132. row.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  133. if (tableAccount.autoUploadCreateSubfolder) row.value = @1;
  134. else row.value = @0;
  135. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  136. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  137. [section addFormRow:row];
  138. // Auto Upload file name
  139. section = [XLFormSectionDescriptor formSection];
  140. [form addFormSection:section];
  141. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"autoUploadFileName" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_autoupload_filenamemask_", nil)];
  142. row.cellConfigAtConfigure[@"backgroundColor"] = NCBrandColor.sharedInstance.backgroundView;
  143. row.cellConfigAtConfigure[@"switchControl.onTintColor"] = NCBrandColor.sharedInstance.brand;
  144. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
  145. [row.cellConfig setObject:NCBrandColor.sharedInstance.textView forKey:@"textLabel.textColor"];
  146. row.action.viewControllerClass = [NCManageAutoUploadFileName class];
  147. [section addFormRow:row];
  148. // end
  149. section = [XLFormSectionDescriptor formSection];
  150. [form addFormSection:section];
  151. self.tableView.showsVerticalScrollIndicator = NO;
  152. self.form = form;
  153. }
  154. - (void)viewDidLoad
  155. {
  156. [super viewDidLoad];
  157. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  158. // changeTheming
  159. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
  160. [self changeTheming];
  161. }
  162. - (void)viewWillAppear:(BOOL)animated
  163. {
  164. [super viewWillAppear:animated];
  165. // Request permission for camera roll access
  166. [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
  167. switch (status) {
  168. case PHAuthorizationStatusRestricted:
  169. NSLog(@"[LOG] user can't grant access to camera roll");
  170. break;
  171. case PHAuthorizationStatusDenied:
  172. NSLog(@"[LOG] user denied access to camera roll");
  173. break;
  174. default:
  175. break;
  176. }
  177. }];
  178. }
  179. - (void)changeTheming
  180. {
  181. [appDelegate changeTheming:self tableView:self.tableView collectionView:nil form:true];
  182. [self initializeForm];
  183. [self reloadForm];
  184. }
  185. -(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  186. {
  187. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  188. tableAccount *account = [[NCManageDatabase sharedInstance] getAccountActive];
  189. if ([rowDescriptor.tag isEqualToString:@"autoUpload"]) {
  190. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  191. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUpload" state:YES];
  192. // Default
  193. [[NCManageDatabase sharedInstance] setAccountAutoUploadFileName:nil];
  194. [[NCManageDatabase sharedInstance] setAccountAutoUploadDirectory:nil activeUrl:appDelegate.activeUrl];
  195. // verifichiamo che almeno uno dei servizi (foto video) siano attivi, in caso contrario attiviamo le foto
  196. if (account.autoUploadImage == NO && account.autoUploadVideo == NO) {
  197. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadImage" state:YES];
  198. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadVideo" state:YES];
  199. }
  200. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
  201. [[NCAutoUpload sharedInstance] alignPhotoLibrary];
  202. });
  203. } else {
  204. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUpload" state:NO];
  205. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadFull" state:NO];
  206. // remove
  207. [[NCManageDatabase sharedInstance] clearMetadatasUploadWithAccount:appDelegate.activeAccount];
  208. }
  209. [self reloadForm];
  210. }
  211. if ([rowDescriptor.tag isEqualToString:@"autoUploadBackground"]) {
  212. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  213. BOOL isLocationIsEnabled = NO;
  214. [[NCAutoUpload sharedInstance] checkIfLocationIsEnabled];
  215. if(isLocationIsEnabled == YES) {
  216. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_autoupload_background_title_", nil) message:NSLocalizedString(@"_autoupload_background_msg_", nil) preferredStyle:UIAlertControllerStyleAlert];
  217. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  218. [alertController addAction:okAction];
  219. [self presentViewController:alertController animated:YES completion:nil];
  220. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadBackground" state:YES];
  221. } else {
  222. [self reloadForm];
  223. }
  224. } else {
  225. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadBackground" state:NO];
  226. [[CCManageLocation sharedInstance] stopSignificantChangeUpdates];
  227. }
  228. }
  229. if ([rowDescriptor.tag isEqualToString:@"autoUploadFull"]) {
  230. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  231. [[NCAutoUpload sharedInstance] setupAutoUploadFull];
  232. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadFull" state:YES];
  233. } else {
  234. [[NCManageDatabase sharedInstance] clearMetadatasUploadWithAccount:appDelegate.activeAccount];
  235. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadFull" state:NO];
  236. }
  237. }
  238. if ([rowDescriptor.tag isEqualToString:@"autoUploadImage"]) {
  239. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadImage" state:[[rowDescriptor.value valueData] boolValue]];
  240. if ([[rowDescriptor.value valueData] boolValue] == YES) {
  241. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
  242. [[NCAutoUpload sharedInstance] alignPhotoLibrary];
  243. });
  244. }
  245. }
  246. if ([rowDescriptor.tag isEqualToString:@"autoUploadWWAnPhoto"]) {
  247. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadWWAnPhoto" state:[[rowDescriptor.value valueData] boolValue]];
  248. }
  249. if ([rowDescriptor.tag isEqualToString:@"autoUploadVideo"]) {
  250. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadVideo" state:[[rowDescriptor.value valueData] boolValue]];
  251. if ([[rowDescriptor.value valueData] boolValue] == YES){
  252. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
  253. [[NCAutoUpload sharedInstance] alignPhotoLibrary];
  254. });
  255. }
  256. }
  257. if ([rowDescriptor.tag isEqualToString:@"autoUploadWWAnVideo"]) {
  258. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadWWAnVideo" state:[[rowDescriptor.value valueData] boolValue]];
  259. }
  260. if ([rowDescriptor.tag isEqualToString:@"autoUploadCreateSubfolder"]) {
  261. [[NCManageDatabase sharedInstance] setAccountAutoUploadProperty:@"autoUploadCreateSubfolder" state:[[rowDescriptor.value valueData] boolValue]];
  262. }
  263. }
  264. - (void)done:(XLFormRowDescriptor *)sender
  265. {
  266. [self dismissViewControllerAnimated:YES completion:nil];
  267. }
  268. - (void)reloadForm
  269. {
  270. self.form.delegate = nil;
  271. XLFormRowDescriptor *rowAutoUpload = [self.form formRowWithTag:@"autoUpload"];
  272. XLFormRowDescriptor *rowAutoUploadImage = [self.form formRowWithTag:@"autoUploadImage"];
  273. XLFormRowDescriptor *rowAutoUploadWWAnPhoto = [self.form formRowWithTag:@"autoUploadWWAnPhoto"];
  274. XLFormRowDescriptor *rowAutoUploadVideo = [self.form formRowWithTag:@"autoUploadVideo"];
  275. XLFormRowDescriptor *rowAutoUploadWWAnVideo = [self.form formRowWithTag:@"autoUploadWWAnVideo"];
  276. XLFormRowDescriptor *rowAutoUploadBackground = [self.form formRowWithTag:@"autoUploadBackground"];
  277. XLFormRowDescriptor *rowAutoUploadFull = [self.form formRowWithTag:@"autoUploadFull"];
  278. XLFormRowDescriptor *rowAutoUploadCreateSubfolder = [self.form formRowWithTag:@"autoUploadCreateSubfolder"];
  279. XLFormRowDescriptor *rowAutoUploadFileName = [self.form formRowWithTag:@"autoUploadFileName"];
  280. // - STATUS ---------------------
  281. tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
  282. if (tableAccount.autoUpload)
  283. [rowAutoUpload setValue:@1]; else [rowAutoUpload setValue:@0];
  284. if (tableAccount.autoUploadImage)
  285. [rowAutoUploadImage setValue:@1]; else [rowAutoUploadImage setValue:@0];
  286. if (tableAccount.autoUploadWWAnPhoto)
  287. [rowAutoUploadWWAnPhoto setValue:@1]; else [rowAutoUploadWWAnPhoto setValue:@0];
  288. if (tableAccount.autoUploadVideo)
  289. [rowAutoUploadVideo setValue:@1]; else [rowAutoUploadVideo setValue:@0];
  290. if (tableAccount.autoUploadWWAnVideo)
  291. [rowAutoUploadWWAnVideo setValue:@1]; else [rowAutoUploadWWAnVideo setValue:@0];
  292. if (tableAccount.autoUploadBackground)
  293. [rowAutoUploadBackground setValue:@1]; else [rowAutoUploadBackground setValue:@0];
  294. if (tableAccount.autoUploadFull)
  295. [rowAutoUploadFull setValue:@1]; else [rowAutoUploadFull setValue:@0];
  296. if (tableAccount.autoUploadCreateSubfolder)
  297. [rowAutoUploadCreateSubfolder setValue:@1]; else [rowAutoUploadCreateSubfolder setValue:@0];
  298. // - HIDDEN --------------------------------------------------------------------------
  299. rowAutoUploadImage.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  300. rowAutoUploadWWAnPhoto.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  301. rowAutoUploadVideo.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  302. rowAutoUploadWWAnVideo.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  303. rowAutoUploadBackground.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  304. rowAutoUploadFull.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  305. rowAutoUploadCreateSubfolder.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  306. rowAutoUploadFileName.hidden = [NSString stringWithFormat:@"$%@==0", @"autoUpload"];
  307. // -----------------------------------------------------------------------------------
  308. [self.tableView reloadData];
  309. self.form.delegate = self;
  310. }
  311. - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
  312. {
  313. tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
  314. NSString *sectionName;
  315. NSString *autoUploadPath = [NSString stringWithFormat:@"%@/%@", [[NCManageDatabase sharedInstance] getAccountAutoUploadDirectory:appDelegate.activeUrl], [[NCManageDatabase sharedInstance] getAccountAutoUploadFileName]];
  316. switch (section)
  317. {
  318. case 0:
  319. sectionName = NSLocalizedString(@"_autoupload_description_", nil);
  320. break;
  321. case 1:
  322. if (tableAccount.autoUpload) sectionName = [NSString stringWithFormat:@"%@: %@", NSLocalizedString(@"_autoupload_current_folder_", nil), [CCUtility returnPathfromServerUrl:autoUploadPath activeUrl:appDelegate.activeUrl]];
  323. else sectionName = @"";
  324. break;
  325. case 4:
  326. if (tableAccount.autoUpload) sectionName = NSLocalizedString(@"_autoupload_description_background_", nil);
  327. else sectionName = @"";
  328. break;
  329. case 5:
  330. if (tableAccount.autoUpload) sectionName = NSLocalizedString(@"_autoupload_fullphotos_footer_", nil);
  331. else sectionName = @"";
  332. break;
  333. case 6:
  334. if (tableAccount.autoUpload) sectionName = NSLocalizedString(@"_autoupload_create_subfolder_footer_", nil);
  335. else sectionName = @"";
  336. break;
  337. case 7:
  338. if (tableAccount.autoUpload) sectionName = NSLocalizedString(@"_autoupload_filenamemask_footer_", nil);
  339. else sectionName = @"";
  340. break;
  341. }
  342. return sectionName;
  343. }
  344. - (void)dismissSelectWithServerUrl:(NSString *)serverUrl metadata:(tableMetadata *)metadata type:(NSString *)type
  345. {
  346. if (serverUrl != nil) {
  347. if ([serverUrl isEqualToString:[CCUtility getHomeServerUrlActiveUrl:appDelegate.activeUrl]]) {
  348. [appDelegate messageNotification:@"_error_" description:@"_autoupload_error_select_folder_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
  349. return;
  350. }
  351. // Clear data (old) Auto Upload
  352. [[NCManageDatabase sharedInstance] clearDateReadWithServerUrl:[[NCManageDatabase sharedInstance] getAccountAutoUploadDirectory:appDelegate.activeUrl] account:appDelegate.activeAccount];
  353. // Settings new folder Automatatic upload
  354. [[NCManageDatabase sharedInstance] setAccountAutoUploadFileName:[CCUtility getLastPathFromServerUrl:serverUrl activeUrl:appDelegate.activeUrl]];
  355. [[NCManageDatabase sharedInstance] setAccountAutoUploadDirectory:[CCUtility deletingLastPathComponentFromServerUrl:serverUrl] activeUrl:appDelegate.activeUrl];
  356. // Clear data new Auto Upload
  357. [[NCManageDatabase sharedInstance] clearDateReadWithServerUrl:serverUrl account:appDelegate.activeAccount];
  358. }
  359. }
  360. - (void)selectAutomaticUploadFolder
  361. {
  362. UINavigationController *navigationController = [[UIStoryboard storyboardWithName:@"NCSelect" bundle:nil] instantiateInitialViewController];
  363. NCSelect *viewController = (NCSelect *)navigationController.topViewController;
  364. viewController.delegate = self;
  365. viewController.hideButtonCreateFolder = false;
  366. viewController.selectFile = false;
  367. viewController.includeDirectoryE2EEncryption = false;
  368. viewController.includeImages = false;
  369. viewController.type = @"";
  370. viewController.titleButtonDone = NSLocalizedString(@"_select_", nil);
  371. viewController.layoutViewSelect = k_layout_view_move;
  372. [navigationController setModalPresentationStyle:UIModalPresentationFullScreen];
  373. [self presentViewController:navigationController animated:YES completion:nil];
  374. }
  375. @end