CCDetail.m 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. //
  2. // CCDetail.m
  3. // Nextcloud iOS
  4. //
  5. // Created by Marino Faggiana on 16/01/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 "CCDetail.h"
  24. #import "AppDelegate.h"
  25. #import "CCMain.h"
  26. #import "NCUchardet.h"
  27. #import "NCBridgeSwift.h"
  28. #import <KTVHTTPCache/KTVHTTPCache.h>
  29. #import "NCBridgeSwift.h"
  30. #define TOOLBAR_HEIGHT 49.0f
  31. #define alertRequestPasswordPDF 1
  32. @interface CCDetail () <NCTextDelegate, UIDocumentInteractionControllerDelegate>
  33. {
  34. AppDelegate *appDelegate;
  35. UIDocumentInteractionController *docController;
  36. UIBarButtonItem *buttonModifyTxt;
  37. UIBarButtonItem *buttonShare;
  38. UIBarButtonItem *buttonDelete;
  39. NSInteger indexNowVisible;
  40. NSString *fileIDNowVisible;
  41. NSMutableOrderedSet *dataSourceDirectoryID;
  42. NSString *fileNameExtension;
  43. }
  44. @end
  45. @implementation CCDetail
  46. #pragma --------------------------------------------------------------------------------------------
  47. #pragma mark ===== init =====
  48. #pragma --------------------------------------------------------------------------------------------
  49. - (id)initWithCoder:(NSCoder *)aDecoder
  50. {
  51. if (self = [super initWithCoder:aDecoder]) {
  52. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  53. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
  54. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
  55. self.metadataDetail = [[tableMetadata alloc] init];
  56. self.photos = [[NSMutableArray alloc] init];
  57. self.photoDataSource = [NSMutableArray new];
  58. dataSourceDirectoryID = [[NSMutableOrderedSet alloc] init];
  59. indexNowVisible = -1;
  60. fileIDNowVisible = nil;
  61. appDelegate.activeDetail = self;
  62. }
  63. return self;
  64. }
  65. #pragma --------------------------------------------------------------------------------------------
  66. #pragma mark ===== View =====
  67. #pragma --------------------------------------------------------------------------------------------
  68. - (void)viewDidLoad
  69. {
  70. [super viewDidLoad];
  71. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(insertGeocoderLocation:) name:@"insertGeocoderLocation" object:nil];
  72. self.imageBackground.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"logo"] multiplier:2 color:[[[NCBrandColor sharedInstance] brand] colorWithAlphaComponent:0.4]];
  73. // Change bar bottom line shadow and remove title back button <"title"
  74. self.navigationController.navigationBar.shadowImage = [CCGraphics generateSinglePixelImageWithColor:[NCBrandColor sharedInstance].brand];
  75. self.navigationController.navigationBar.topItem.title = @"";
  76. // Color Navigation Controller
  77. [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
  78. // TabBar
  79. self.tabBarController.tabBar.hidden = YES;
  80. self.tabBarController.tabBar.translucent = YES;
  81. // Open View
  82. if ([self.metadataDetail.fileNameView length] > 0 || [self.metadataDetail.directoryID length] > 0 || [self.metadataDetail.fileID length] > 0) {
  83. // open view
  84. [self viewFile];
  85. }
  86. }
  87. - (void)viewWillAppear:(BOOL)animated
  88. {
  89. [super viewWillAppear:animated];
  90. self.tabBarController.tabBar.hidden = YES;
  91. self.tabBarController.tabBar.translucent = YES;
  92. }
  93. - (void)viewWillDisappear:(BOOL)animated
  94. {
  95. [super viewWillDisappear:animated];
  96. [self.navigationController setNavigationBarHidden:false];
  97. }
  98. - (void)viewDidDisappear:(BOOL)animated
  99. {
  100. [super viewDidDisappear:animated];
  101. // If AVPlayer in play -> Stop
  102. if (appDelegate.player != nil && appDelegate.player.rate != 0) {
  103. [appDelegate.player pause];
  104. }
  105. // remove Observer AVPlayer
  106. if (self.isMediaObserver) {
  107. self.isMediaObserver = NO;
  108. @try{
  109. [[NCViewerMedia sharedInstance] removeObserver];
  110. }@catch(id anException) { }
  111. }
  112. }
  113. - (void)changeTheming
  114. {
  115. [appDelegate changeTheming:self];
  116. if (self.toolbar) {
  117. self.toolbar.barTintColor = [NCBrandColor sharedInstance].tabBar;
  118. self.toolbar.tintColor = [NCBrandColor sharedInstance].brandElement;
  119. }
  120. }
  121. - (void)changeToDisplayMode
  122. {
  123. if (_readerPDFViewController)
  124. [self.readerPDFViewController updateContentViews];
  125. }
  126. #pragma --------------------------------------------------------------------------------------------
  127. #pragma mark ===== View File =====
  128. #pragma --------------------------------------------------------------------------------------------
  129. - (void)viewFile
  130. {
  131. // Remove all subview except ..
  132. //for (UIView *view in self.view.superview.subviews) {
  133. // NSInteger tag = view.tag;
  134. //}
  135. // Title
  136. self.navigationController.navigationBar.topItem.title = _metadataDetail.fileNameView;
  137. // verifico se esiste l'icona e se la posso creare
  138. if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:self.metadataDetail.fileID fileNameView:self.metadataDetail.fileNameView]] == NO) {
  139. [CCGraphics createNewImageFrom:self.metadataDetail.fileNameView fileID:self.metadataDetail.fileID extension:[self.metadataDetail.fileNameView pathExtension] filterGrayScale:NO typeFile:self.metadataDetail.typeFile writeImage:YES];
  140. }
  141. // remove Observer AVPlayer
  142. if (self.isMediaObserver) {
  143. self.isMediaObserver = NO;
  144. [[NCViewerMedia sharedInstance] removeObserver];
  145. }
  146. // IMAGE
  147. if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_image]) {
  148. self.edgesForExtendedLayout = UIRectEdgeAll;
  149. [self viewImage];
  150. }
  151. // AUDIO VIDEO
  152. if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_video] || [self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_audio]) {
  153. self.edgesForExtendedLayout = UIRectEdgeAll;
  154. [self createToolbar];
  155. [[NCViewerMedia sharedInstance] viewMedia:self.metadataDetail detail:self];
  156. }
  157. // DOCUMENT
  158. if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_document]) {
  159. fileNameExtension = [[self.metadataDetail.fileNameView pathExtension] uppercaseString];
  160. if ([fileNameExtension isEqualToString:@"PDF"]) {
  161. self.edgesForExtendedLayout = UIRectEdgeBottom;
  162. [self createToolbar];
  163. [self viewPDF:@""];
  164. return;
  165. }
  166. // RichDocument
  167. if ([[NCViewerRichdocument sharedInstance] isRichDocument:self.metadataDetail]) {
  168. [[NCUtility sharedInstance] startActivityIndicatorWithView:self.view];
  169. if ([self.metadataDetail.url isEqualToString:@""]) {
  170. OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:appDelegate.activeUser withUserID:appDelegate.activeUserID withPassword:appDelegate.activePassword withUrl:appDelegate.activeUrl];
  171. [ocNetworking createLinkRichdocumentsWithFileID:self.metadataDetail.fileID success:^(NSString *link) {
  172. [[NCViewerRichdocument sharedInstance] viewRichDocumentAt:link detail:self];
  173. } failure:^(NSString *message, NSInteger errorCode) {
  174. [[NCUtility sharedInstance] stopActivityIndicator];
  175. [appDelegate messageNotification:@"_error_" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
  176. [self.navigationController popViewControllerAnimated:YES];
  177. }];
  178. } else {
  179. [[NCViewerRichdocument sharedInstance] viewRichDocumentAt:self.metadataDetail.url detail:self];
  180. }
  181. return;
  182. }
  183. self.edgesForExtendedLayout = UIRectEdgeBottom;
  184. [self createToolbar];
  185. [[NCViewerDocumentWeb sharedInstance] viewDocumentWebAt:self.metadataDetail detail:self];
  186. }
  187. }
  188. #pragma --------------------------------------------------------------------------------------------
  189. #pragma mark ===== Toolbar =====
  190. #pragma --------------------------------------------------------------------------------------------
  191. - (void)createToolbar
  192. {
  193. CGFloat safeAreaBottom = 0;
  194. if (@available(iOS 11, *)) {
  195. safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
  196. }
  197. self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - TOOLBAR_HEIGHT - safeAreaBottom, self.view.bounds.size.width, TOOLBAR_HEIGHT)];
  198. UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
  199. UIBarButtonItem *fixedSpaceMini = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
  200. fixedSpaceMini.width = 25;
  201. buttonModifyTxt = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"actionSheetModify"] style:UIBarButtonItemStylePlain target:self action:@selector(modifyTxtButtonPressed:)];
  202. if (![NCBrandOptions sharedInstance].disable_openin_file) {
  203. self.buttonAction = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"openFile"] style:UIBarButtonItemStylePlain target:self action:@selector(actionButtonPressed:)];
  204. }
  205. buttonShare = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"share"] style:UIBarButtonItemStylePlain target:self action:@selector(shareButtonPressed:)];
  206. buttonDelete = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"delete"] style:UIBarButtonItemStylePlain target:self action:@selector(deleteButtonPressed:)];
  207. if ([CCUtility isDocumentModifiableExtension:fileNameExtension]) {
  208. if ([CCUtility isFolderEncrypted:_metadataDetail.serverUrl account:appDelegate.activeAccount]) // E2EE
  209. [self.toolbar setItems:[NSArray arrayWithObjects: buttonModifyTxt, flexible, buttonDelete, fixedSpaceMini, self.buttonAction, nil]];
  210. else
  211. [self.toolbar setItems:[NSArray arrayWithObjects: buttonModifyTxt, flexible, buttonDelete, fixedSpaceMini, buttonShare, fixedSpaceMini, self.buttonAction, nil]];
  212. } else {
  213. if ([CCUtility isFolderEncrypted:_metadataDetail.serverUrl account:appDelegate.activeAccount]) // E2EE
  214. [self.toolbar setItems:[NSArray arrayWithObjects: flexible, buttonDelete, fixedSpaceMini, self.buttonAction, nil]];
  215. else
  216. [self.toolbar setItems:[NSArray arrayWithObjects: flexible, buttonDelete, fixedSpaceMini, buttonShare, fixedSpaceMini, self.buttonAction, nil]];
  217. }
  218. [self.toolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin];
  219. self.toolbar.barTintColor = [NCBrandColor sharedInstance].tabBar;
  220. self.toolbar.tintColor = [NCBrandColor sharedInstance].brandElement;
  221. [self.view addSubview:self.toolbar];
  222. }
  223. #pragma --------------------------------------------------------------------------------------------
  224. #pragma mark ===== View Image =====
  225. #pragma --------------------------------------------------------------------------------------------
  226. - (void)viewImage
  227. {
  228. self.photoBrowser = [[MWPhotoBrowser alloc] initWithDelegate:self];
  229. indexNowVisible = -1;
  230. fileIDNowVisible = nil;
  231. [self.photos removeAllObjects];
  232. [dataSourceDirectoryID removeAllObjects];
  233. // if not images, exit
  234. if ([self.photoDataSource count] == 0)
  235. return;
  236. NSUInteger index = 0;
  237. for (tableMetadata *metadata in self.photoDataSource) {
  238. // start from here ?
  239. if (self.metadataDetail.fileID && [metadata.fileID isEqualToString:self.metadataDetail.fileID])
  240. [self.photoBrowser setCurrentPhotoIndex:index];
  241. [self.photos addObject:[MWPhoto photoWithImage:nil]];
  242. // add directory
  243. [dataSourceDirectoryID addObject:metadata.directoryID];
  244. index++;
  245. }
  246. // PhotoBrowser
  247. if ([NCBrandOptions sharedInstance].disable_openin_file) {
  248. self.photoBrowser.displayActionButton = NO;
  249. } else {
  250. self.photoBrowser.displayActionButton = YES;
  251. }
  252. self.photoBrowser.displayDeleteButton = YES;
  253. if ([CCUtility isFolderEncrypted:_metadataDetail.serverUrl account:appDelegate.activeAccount]) // E2EE
  254. self.photoBrowser.displayShareButton = NO;
  255. else
  256. self.photoBrowser.displayShareButton = YES;
  257. self.photoBrowser.displayNavArrows = YES;
  258. self.photoBrowser.displaySelectionButtons = NO;
  259. self.photoBrowser.alwaysShowControls = NO;
  260. self.photoBrowser.zoomPhotosToFill = NO;
  261. self.photoBrowser.autoPlayOnAppear = NO;
  262. self.photoBrowser.delayToHideElements = 15;
  263. if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
  264. self.photoBrowser.enableSwipeToDismiss = NO;
  265. if (self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact) {
  266. [self addChildViewController:self.photoBrowser];
  267. [self.view addSubview:self.photoBrowser.view];
  268. [self.photoBrowser didMoveToParentViewController:self];
  269. } else {
  270. [self.navigationController pushViewController:self.photoBrowser animated:NO];
  271. }
  272. }
  273. - (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser
  274. {
  275. return [self.photoDataSource count];
  276. }
  277. - (NSString *)photoBrowser:(MWPhotoBrowser *)photoBrowser titleForPhotoAtIndex:(NSUInteger)index
  278. {
  279. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  280. NSString *titleDir = metadata.fileNameView;
  281. self.title = titleDir;
  282. return titleDir;
  283. }
  284. - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser didDisplayPhotoAtIndex:(NSUInteger)index
  285. {
  286. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  287. indexNowVisible = index;
  288. fileIDNowVisible = metadata.fileID;
  289. photoBrowser.toolbar.hidden = NO;
  290. // Download image ?
  291. if (metadata) {
  292. NSInteger status;
  293. tableMetadata *metadataDB = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", metadata.fileID]];
  294. if (metadataDB) {
  295. status = metadataDB.status;
  296. } else {
  297. status = k_metadataStatusNormal;
  298. }
  299. if ([CCUtility fileProviderStorageExists:metadata.fileID fileNameView:metadata.fileNameView] == NO && status == k_metadataStatusNormal) {
  300. if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]] == NO && metadata.hasPreview) {
  301. [CCGraphics addImageToTitle:NSLocalizedString(@"_...loading..._", nil) colorTitle:[NCBrandColor sharedInstance].brandText imageTitle:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"load"] multiplier:2 color:[NCBrandColor sharedInstance].brandText] imageRight:NO navigationItem:self.navigationItem];
  302. CGFloat width = [[NCUtility sharedInstance] getScreenWidthForPreview];
  303. CGFloat height = [[NCUtility sharedInstance] getScreenHeightForPreview];
  304. OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:appDelegate.activeUser withUserID:appDelegate.activeUserID withPassword:appDelegate.activePassword withUrl:appDelegate.activeUrl];
  305. [ocNetworking downloadPreviewWithMetadata:metadata withWidth:width andHeight:height completion:^(NSString *message, NSInteger errorCode) {
  306. self.navigationItem.titleView = nil;
  307. self.title = metadata.fileNameView;
  308. [self.photoBrowser reloadData];
  309. }];
  310. } else {
  311. [self downloadPhotoBrowser:metadata];
  312. }
  313. }
  314. }
  315. // Title
  316. if (metadata)
  317. self.title = metadata.fileNameView;
  318. }
  319. - (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index
  320. {
  321. UIImage *image;
  322. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  323. if (index < self.photos.count) {
  324. if (metadata.fileID) {
  325. UIImage *imagePreview = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]];
  326. // if (!imagePreview) imagePreview = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"file_photo"] multiplier:3 color:[[NCBrandColor sharedInstance] icon]];
  327. if ([metadata.typeFile isEqualToString: k_metadataTypeFile_image]) {
  328. NSString *fileImage = [CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView];
  329. NSString *ext = [CCUtility getExtension:metadata.fileNameView];
  330. if ([ext isEqualToString:@"GIF"]) image = [UIImage animatedImageWithAnimatedGIFURL:[NSURL fileURLWithPath:fileImage]];
  331. else image = [UIImage imageWithContentsOfFile:fileImage];
  332. if (image) {
  333. MWPhoto *photo = [MWPhoto photoWithImage:image];
  334. // Location ??
  335. [self setLocationCaptionPhoto:photo fileID:metadata.fileID];
  336. [self.photos replaceObjectAtIndex:index withObject:photo];
  337. } else {
  338. if (metadata.status == k_metadataStatusDownloadError) {
  339. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
  340. } else {
  341. if (imagePreview)
  342. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
  343. }
  344. }
  345. }
  346. if ([metadata.typeFile isEqualToString: k_metadataTypeFile_video]) {
  347. if ([CCUtility fileProviderStorageExists:metadata.fileID fileNameView:metadata.fileNameView]) {
  348. NSURL *url = [NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView]];
  349. MWPhoto *video = [MWPhoto photoWithImage:[CCGraphics thumbnailImageForVideo:url atTime:1.0]];
  350. video.videoURL = url;
  351. [self.photos replaceObjectAtIndex:index withObject:video];
  352. } else {
  353. if (metadata.status == k_metadataStatusDownloadError) {
  354. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
  355. } else {
  356. if (imagePreview)
  357. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
  358. }
  359. }
  360. }
  361. if ([metadata.typeFile isEqualToString: k_metadataTypeFile_audio]) {
  362. if ([CCUtility fileProviderStorageExists:metadata.fileID fileNameView:metadata.fileNameView]) {
  363. MWPhoto *audio;
  364. UIImage *audioImage;
  365. NSURL *url = [NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView]];
  366. if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]]) {
  367. audioImage = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]];
  368. } else {
  369. audioImage = [UIImage imageNamed:@"notaMusic"]; //[CCGraphics scaleImage:[UIImage imageNamed:@"notaMusic"] toSize:CGSizeMake(200, 200) isAspectRation:YES];
  370. }
  371. audio = [MWPhoto photoWithImage:audioImage];
  372. audio.videoURL = url;
  373. [self.photos replaceObjectAtIndex:index withObject:audio];
  374. } else {
  375. if (metadata.status == k_metadataStatusDownloadError) {
  376. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
  377. } else {
  378. if (imagePreview)
  379. [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
  380. }
  381. }
  382. }
  383. }
  384. // energy saving memory
  385. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  386. int iPrev = (int)index - 2;
  387. if (iPrev >= 0) {
  388. if ([self.photos objectAtIndex:iPrev] != nil)
  389. [self.photos replaceObjectAtIndex:iPrev withObject:[MWPhoto photoWithImage:nil]];
  390. }
  391. int iNext = (int)index + 2;
  392. if (iNext < _photos.count) {
  393. if ([self.photos objectAtIndex:iNext] != nil)
  394. [self.photos replaceObjectAtIndex:iNext withObject:[MWPhoto photoWithImage:nil]];
  395. }
  396. });
  397. return [self.photos objectAtIndex:index];
  398. }
  399. return nil;
  400. }
  401. - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser actionButtonPressedForPhotoAtIndex:(NSUInteger)index
  402. {
  403. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  404. if (metadata == nil) return;
  405. docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileNameView:metadata.fileNameView]]];
  406. docController.delegate = self;
  407. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  408. [docController presentOptionsMenuFromRect:photoBrowser.view.frame inView:photoBrowser.view animated:YES];
  409. [docController presentOptionsMenuFromBarButtonItem:photoBrowser.actionButton animated:YES];
  410. }
  411. - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser shareButtonPressedForPhotoAtIndex:(NSUInteger)index
  412. {
  413. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  414. [appDelegate.activeMain openWindowShare:metadata];
  415. }
  416. - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser deleteButtonPressedForPhotoAtIndex:(NSUInteger)index deleteButton:(UIBarButtonItem *)deleteButton
  417. {
  418. tableMetadata *metadata = [self.photoDataSource objectAtIndex:index];
  419. if (metadata == nil || [CCUtility fileProviderStorageExists:metadata.fileID fileNameView:metadata.fileNameView] == NO) {
  420. [appDelegate messageNotification:@"_info_" description:@"_file_not_found_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeInfo errorCode:0];
  421. return;
  422. }
  423. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  424. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_delete_", nil)
  425. style:UIAlertActionStyleDestructive
  426. handler:^(UIAlertAction *action) {
  427. [self deleteFile:metadata];
  428. }]];
  429. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil)
  430. style:UIAlertActionStyleCancel
  431. handler:^(UIAlertAction *action) {
  432. }]];
  433. alertController.popoverPresentationController.barButtonItem = deleteButton;
  434. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  435. [alertController.view layoutIfNeeded];
  436. [self.parentViewController presentViewController:alertController animated:YES completion:NULL];
  437. }
  438. - (void)photoBrowserDidFinishPresentation:(MWPhotoBrowser *)photoBrowser
  439. {
  440. [self.navigationController popViewControllerAnimated:YES];
  441. }
  442. - (void)triggerProgressTask:(NSNotification *)notification
  443. {
  444. /*
  445. NSDictionary *dict = notification.userInfo;
  446. NSString *fileID = [dict valueForKey:@"fileID"];
  447. //NSString *serverUrl = [dict valueForKey:@"serverUrl"];
  448. //long status = [[dict valueForKey:@"status"] longValue];
  449. float progress = [[dict valueForKey:@"progress"] floatValue];
  450. //long long totalBytes = [[dict valueForKey:@"totalBytes"] longLongValue];
  451. //long long totalBytesExpected = [[dict valueForKey:@"totalBytesExpected"] longLongValue];
  452. if ([fileID isEqualToString:_fileIDNowVisible])
  453. [_hud progress:progress];
  454. */
  455. }
  456. - (void)downloadPhotoBrowserSuccessFailure:(tableMetadata *)metadata selector:(NSString *)selector errorCode:(NSInteger)errorCode
  457. {
  458. // if a message for a directory of these
  459. if (![metadata.fileID isEqualToString:fileIDNowVisible])
  460. return;
  461. // Title
  462. self.navigationItem.titleView = nil;
  463. self.title = metadata.fileNameView;
  464. if (errorCode == 0) {
  465. // verifico se esiste l'icona e se la posso creare
  466. if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]] == NO) {
  467. [CCGraphics createNewImageFrom:metadata.fileNameView fileID:metadata.fileID extension:[metadata.fileNameView pathExtension] filterGrayScale:NO typeFile:metadata.typeFile writeImage:YES];
  468. }
  469. [self.photoBrowser reloadData];
  470. } else {
  471. [appDelegate messageNotification:@"_download_selected_files_" description:@"_error_download_photobrowser_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
  472. [self.navigationController popViewControllerAnimated:YES];
  473. }
  474. }
  475. - (void)downloadPhotoBrowser:(tableMetadata *)metadata
  476. {
  477. tableMetadata *metadataForDownload = [[NCManageDatabase sharedInstance] initNewMetadata:metadata];
  478. metadataForDownload.session = k_download_session;
  479. metadataForDownload.sessionError = @"";
  480. metadataForDownload.sessionSelector = selectorLoadViewImage;
  481. metadataForDownload.status = k_metadataStatusWaitDownload;
  482. // Add Metadata for Download
  483. (void)[[NCManageDatabase sharedInstance] addMetadata:metadataForDownload];
  484. [appDelegate performSelectorOnMainThread:@selector(loadAutoDownloadUpload) withObject:nil waitUntilDone:YES];
  485. [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:metadata.serverUrl fileID:metadataForDownload.fileID action:k_action_MOD];
  486. [CCGraphics addImageToTitle:NSLocalizedString(@"_...loading..._", nil) colorTitle:[NCBrandColor sharedInstance].brandText imageTitle:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"load"] multiplier:2 color:[NCBrandColor sharedInstance].brandText] imageRight:NO navigationItem:self.navigationItem];
  487. }
  488. - (void)insertGeocoderLocation:(NSNotification *)notification
  489. {
  490. if (notification.userInfo.count == 0)
  491. return;
  492. NSString *fileID = [[notification.userInfo allKeys] objectAtIndex:0];
  493. //NSDate *date = [[notification.userInfo allValues] objectAtIndex:0];
  494. // test [Chrash V 1.14,15]
  495. if (indexNowVisible >= [self.photos count])
  496. return;
  497. if ([fileID isEqualToString:fileIDNowVisible]) {
  498. MWPhoto *photo = [self.photos objectAtIndex:indexNowVisible];
  499. [self setLocationCaptionPhoto:photo fileID:fileID];
  500. [self.photoBrowser reloadData];
  501. }
  502. }
  503. - (void)setLocationCaptionPhoto:(MWPhoto *)photo fileID:(NSString *)fileID
  504. {
  505. tableLocalFile *localFile;
  506. // read Geocoder
  507. localFile = [[NCManageDatabase sharedInstance] getTableLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", fileID]];
  508. if ([localFile.exifLatitude doubleValue] != 0 || [localFile.exifLongitude doubleValue] != 0) {
  509. // Fix BUG Geo latitude & longitude
  510. if ([localFile.exifLatitude doubleValue] == 9999 || [localFile.exifLongitude doubleValue] == 9999) {
  511. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", fileID]];
  512. if (metadata) {
  513. [[CCExifGeo sharedInstance] setExifLocalTableEtag:metadata];
  514. }
  515. }
  516. [[CCExifGeo sharedInstance] setGeocoderEtag:fileID exifDate:localFile.exifDate latitude:localFile.exifLatitude longitude:localFile.exifLongitude];
  517. localFile = [[NCManageDatabase sharedInstance] getTableLocalFileWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", fileID]];
  518. if ([localFile.exifLatitude floatValue] != 0 || [localFile.exifLongitude floatValue] != 0) {
  519. NSString *location = [[NCManageDatabase sharedInstance] getLocationFromGeoLatitude:localFile.exifLatitude longitude:localFile.exifLongitude];
  520. if ([localFile.exifDate isEqualToDate:[NSDate distantPast]] == NO && location) {
  521. NSString *localizedDateTime = [NSDateFormatter localizedStringFromDate:localFile.exifDate dateStyle:NSDateFormatterFullStyle timeStyle:NSDateFormatterMediumStyle];
  522. photo.caption = [NSString stringWithFormat:NSLocalizedString(@"%@\n%@", nil), localizedDateTime, location];
  523. }
  524. }
  525. }
  526. }
  527. #pragma --------------------------------------------------------------------------------------------
  528. #pragma mark ===== View PDF =====
  529. #pragma --------------------------------------------------------------------------------------------
  530. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  531. {
  532. [alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];
  533. [[alertView textFieldAtIndex:0] resignFirstResponder];
  534. if (alertView.tag == alertRequestPasswordPDF) [self performSelector:@selector(viewPDF:) withObject:[alertView textFieldAtIndex:0].text afterDelay:0.3];
  535. }
  536. - (void)viewPDF:(NSString *)password
  537. {
  538. // remove cache PDF
  539. NSString *filePlistReader = [NSString stringWithFormat:@"%@/%@.plist", [CCUtility getDirectoryReaderMetadata], self.metadataDetail.fileNameView.stringByDeletingPathExtension];
  540. [CCUtility removeFileAtPath:filePlistReader];
  541. NSString *fileNamePath = [CCUtility getDirectoryProviderStorageFileID:self.metadataDetail.fileID fileNameView:self.metadataDetail.fileNameView];
  542. if ([CCUtility fileProviderStorageExists:self.metadataDetail.fileID fileNameView:self.metadataDetail.fileNameView] == NO) {
  543. // read file error
  544. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_read_file_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
  545. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  546. [alertController addAction:okAction];
  547. [self presentViewController:alertController animated:YES completion:nil];
  548. }
  549. CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL((CFURLRef)[NSURL fileURLWithPath:fileNamePath]);
  550. if (pdf) {
  551. // Encrypted
  552. if (CGPDFDocumentIsEncrypted(pdf) == YES) {
  553. // Try a blank password first, per Apple's Quartz PDF example
  554. if (CGPDFDocumentUnlockWithPassword(pdf, "") == YES) {
  555. // blank password
  556. [self readerPDF:fileNamePath password:@""];
  557. } else {
  558. if ([password length] == 0) {
  559. // password request
  560. UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_insert_password_pfd_",nil) message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"_ok_", nil), nil];
  561. [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
  562. alertView.tag = alertRequestPasswordPDF;
  563. [alertView show];
  564. } else {
  565. const char *key = [password UTF8String];
  566. // failure
  567. if (CGPDFDocumentUnlockWithPassword(pdf, key) == NO) {
  568. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_password_pdf_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
  569. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  570. [alertController addAction:okAction];
  571. [self presentViewController:alertController animated:YES completion:nil];
  572. } else {
  573. // pdf with password
  574. [self readerPDF:fileNamePath password:password];
  575. }
  576. }
  577. }
  578. } else{
  579. // No password
  580. [self readerPDF:fileNamePath password:@""];
  581. }
  582. } else {
  583. // read file error
  584. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_read_file_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
  585. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  586. [alertController addAction:okAction];
  587. [self presentViewController:alertController animated:YES completion:nil];
  588. }
  589. }
  590. - (void)readerPDF:(NSString *)fileName password:(NSString *)password
  591. {
  592. ReaderDocument *documentPDF = [ReaderDocument withDocumentFilePath:fileName password:password];
  593. CGFloat safeAreaBottom = 0;
  594. if (@available(iOS 11, *)) {
  595. safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
  596. }
  597. if (documentPDF != nil) {
  598. self.readerPDFViewController = [[ReaderViewController alloc] initWithReaderDocument:documentPDF];
  599. self.readerPDFViewController.delegate = self;
  600. self.readerPDFViewController.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - TOOLBAR_HEIGHT - safeAreaBottom);
  601. [self.readerPDFViewController updateContentViews];
  602. [self addChildViewController:self.readerPDFViewController];
  603. [self.view addSubview:self.readerPDFViewController.view];
  604. [self.readerPDFViewController didMoveToParentViewController:self];
  605. } else {
  606. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message:NSLocalizedString(@"_read_file_error_", nil) preferredStyle:UIAlertControllerStyleAlert];
  607. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}];
  608. [alertController addAction:okAction];
  609. [self presentViewController:alertController animated:YES completion:nil];
  610. }
  611. }
  612. - (void)handleSingleTapReader
  613. {
  614. UILayoutGuide *layoutGuide;
  615. CGFloat safeAreaTop = 0;
  616. CGFloat safeAreaBottom = 0;
  617. if (@available(iOS 11, *)) {
  618. layoutGuide = [UIApplication sharedApplication].delegate.window.safeAreaLayoutGuide;
  619. safeAreaTop = [UIApplication sharedApplication].delegate.window.safeAreaInsets.top;
  620. safeAreaBottom = [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
  621. }
  622. self.navigationController.navigationBarHidden = !self.navigationController.navigationBarHidden;
  623. self.toolbar.hidden = !self.toolbar.isHidden;
  624. if (self.toolbar.isHidden) {
  625. self.readerPDFViewController.view.frame = CGRectMake(0, safeAreaTop, self.view.bounds.size.width, self.view.bounds.size.height - safeAreaTop - safeAreaBottom);
  626. } else {
  627. self.readerPDFViewController.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - TOOLBAR_HEIGHT - safeAreaBottom);
  628. }
  629. [self.readerPDFViewController updateContentViews];
  630. }
  631. - (void)handleSwipeUpDown
  632. {
  633. // REMOVE IT'S UNUSABLE
  634. /*
  635. self.navigationController.navigationBarHidden = false; // iOS App is unusable after swipe up or down with PDF in fullscreen #526
  636. [self removeAllView];
  637. [self.navigationController popViewControllerAnimated:YES];
  638. */
  639. }
  640. #pragma --------------------------------------------------------------------------------------------
  641. #pragma mark ===== Delete =====
  642. #pragma --------------------------------------------------------------------------------------------
  643. - (void)deleteFile:(tableMetadata *)metadata
  644. {
  645. tableDirectory *tableDirectory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND e2eEncrypted == 1 AND serverUrl == %@", appDelegate.activeAccount, metadata.serverUrl]];
  646. [[NCMainCommon sharedInstance ] deleteFileWithMetadatas:[[NSArray alloc] initWithObjects:metadata, nil] e2ee:tableDirectory.e2eEncrypted serverUrl:tableDirectory.serverUrl folderFileID:tableDirectory.fileID completion:^(NSInteger errorCode, NSString *message) {
  647. if (errorCode == 0) {
  648. // reload data source
  649. [[NCMainCommon sharedInstance] reloadDatasourceWithServerUrl:tableDirectory.serverUrl fileID:metadata.fileID action:k_action_DEL];
  650. // Not image
  651. if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_image] == NO) {
  652. // exit
  653. [self.navigationController popViewControllerAnimated:YES];
  654. } else {
  655. for (NSUInteger index=0; index < [self.photoDataSource count] && _photoBrowser; index++ ) {
  656. tableMetadata *metadataTemp = [self.photoDataSource objectAtIndex:index];
  657. if ([metadata isInvalidated] || [metadataTemp.fileID isEqualToString:metadata.fileID]) {
  658. [self.photoDataSource removeObjectAtIndex:index];
  659. [self.photos removeObjectAtIndex:index];
  660. [self.photoBrowser reloadData];
  661. // exit
  662. if ([self.photoDataSource count] == 0) {
  663. [self.navigationController popViewControllerAnimated:YES];
  664. }
  665. }
  666. }
  667. }
  668. } else {
  669. NSLog(@"[LOG] DeleteFileOrFolder failure error %d, %@", (int)errorCode, message);
  670. }
  671. }];
  672. }
  673. #pragma --------------------------------------------------------------------------------------------
  674. #pragma mark ===== ButtonPressed =====
  675. #pragma --------------------------------------------------------------------------------------------
  676. - (void)dismissTextView
  677. {
  678. if (self.webView) {
  679. NSString *fileNamePath = [NSTemporaryDirectory() stringByAppendingString:self.metadataDetail.fileNameView];
  680. [[NSFileManager defaultManager] removeItemAtPath:fileNamePath error:nil];
  681. [[NSFileManager defaultManager] linkItemAtPath:[CCUtility getDirectoryProviderStorageFileID:self.metadataDetail.fileID fileNameView:self.metadataDetail.fileNameView] toPath:fileNamePath error:nil];
  682. [self.webView reload];
  683. }
  684. }
  685. - (void)modifyTxtButtonPressed:(UIBarButtonItem *)sender
  686. {
  687. tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"fileID == %@", self.metadataDetail.fileID]];
  688. if (metadata) {
  689. UINavigationController* navigationController = [[UIStoryboard storyboardWithName:@"NCText" bundle:nil] instantiateViewControllerWithIdentifier:@"NCText"];
  690. NCText *viewController = (NCText *)navigationController.topViewController;
  691. viewController.metadata = metadata;
  692. viewController.delegate = self;
  693. navigationController.modalPresentationStyle = UIModalPresentationPageSheet;
  694. navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  695. [self presentViewController:navigationController animated:YES completion:nil];
  696. }
  697. }
  698. - (void)actionButtonPressed:(UIBarButtonItem *)sender
  699. {
  700. if ([self.metadataDetail.fileNameView length] == 0) return;
  701. NSString *filePath = [CCUtility getDirectoryProviderStorageFileID:self.metadataDetail.fileID fileNameView:self.metadataDetail.fileNameView];
  702. docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
  703. docController.delegate = self;
  704. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  705. [docController presentOptionsMenuFromRect:self.view.frame inView:self.view animated:YES];
  706. [docController presentOptionsMenuFromBarButtonItem:sender animated:YES];
  707. }
  708. - (void)shareButtonPressed:(UIBarButtonItem *)sender
  709. {
  710. [appDelegate.activeMain openWindowShare:self.metadataDetail];
  711. }
  712. - (void)deleteButtonPressed:(UIBarButtonItem *)sender
  713. {
  714. if ([self.metadataDetail.fileNameView length] == 0) return;
  715. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  716. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_delete_", nil)
  717. style:UIAlertActionStyleDestructive
  718. handler:^(UIAlertAction *action) {
  719. [self deleteFile:self.metadataDetail];
  720. }]];
  721. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil)
  722. style:UIAlertActionStyleCancel
  723. handler:^(UIAlertAction *action) {
  724. [alertController dismissViewControllerAnimated:YES completion:nil];
  725. }]];
  726. alertController.popoverPresentationController.barButtonItem = buttonDelete;
  727. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  728. [alertController.view layoutIfNeeded];
  729. [self presentViewController:alertController animated:YES completion:NULL];
  730. }
  731. @end