NCCollectionViewCommon+Menu.swift 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. //
  2. // NCCollectionViewCommon+Menu.swift
  3. // Nextcloud
  4. //
  5. // Created by Philippe Weidmann on 24.01.20.
  6. // Copyright © 2020 Philippe Weidmann. All rights reserved.
  7. // Copyright © 2020 Marino Faggiana All rights reserved.
  8. //
  9. // Author Philippe Weidmann
  10. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  11. //
  12. // This program is free software: you can redistribute it and/or modify
  13. // it under the terms of the GNU General Public License as published by
  14. // the Free Software Foundation, either version 3 of the License, or
  15. // (at your option) any later version.
  16. //
  17. // This program is distributed in the hope that it will be useful,
  18. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. // GNU General Public License for more details.
  21. //
  22. // You should have received a copy of the GNU General Public License
  23. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. //
  25. import UIKit
  26. import FloatingPanel
  27. import NCCommunication
  28. import Queuer
  29. extension NCCollectionViewCommon {
  30. func toggleMenu(metadata: tableMetadata, imageIcon: UIImage?) {
  31. let menuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateInitialViewController() as! NCMenu
  32. var actions = [NCMenuAction]()
  33. guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(metadata.ocId) else { return }
  34. let serverUrl = metadata.serverUrl+"/"+metadata.fileName
  35. let isFolderEncrypted = CCUtility.isFolderEncrypted(metadata.serverUrl, e2eEncrypted: metadata.e2eEncrypted, account: metadata.account, urlBase: metadata.urlBase)
  36. let serverUrlHome = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
  37. var isOffline = false
  38. var titleDelete = NSLocalizedString("_delete_", comment: "")
  39. if NCManageDatabase.shared.isMetadataShareOrMounted(metadata: metadata, metadataFolder: metadataFolder) {
  40. titleDelete = NSLocalizedString("_leave_share_", comment: "")
  41. } else if metadata.directory {
  42. titleDelete = NSLocalizedString("_delete_folder_", comment: "")
  43. } else {
  44. titleDelete = NSLocalizedString("_delete_file_", comment: "")
  45. }
  46. if let metadataFolder = metadataFolder {
  47. let isShare = metadata.permissions.contains(NCGlobal.shared.permissionShared) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionShared)
  48. let isMounted = metadata.permissions.contains(NCGlobal.shared.permissionMounted) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionMounted)
  49. if isShare || isMounted {
  50. titleDelete = NSLocalizedString("_leave_share_", comment: "")
  51. }
  52. }
  53. if metadata.directory {
  54. if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl)) {
  55. isOffline = directory.offline
  56. }
  57. } else {
  58. if let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) {
  59. isOffline = localFile.offline
  60. }
  61. }
  62. var iconHeader: UIImage!
  63. if imageIcon != nil {
  64. iconHeader = imageIcon!
  65. } else {
  66. if metadata.directory {
  67. iconHeader = NCBrandColor.cacheImages.folder
  68. } else {
  69. iconHeader = NCBrandColor.cacheImages.file
  70. }
  71. }
  72. actions.append(
  73. NCMenuAction(
  74. title: metadata.fileNameView,
  75. icon: iconHeader,
  76. action: nil
  77. )
  78. )
  79. //
  80. // FAVORITE
  81. //
  82. actions.append(
  83. NCMenuAction(
  84. title: metadata.favorite ? NSLocalizedString("_remove_favorites_", comment: "") : NSLocalizedString("_add_favorites_", comment: ""),
  85. icon: NCUtility.shared.loadImage(named: "star.fill", color: NCBrandColor.shared.yellowFavorite),
  86. action: { menuAction in
  87. NCNetworking.shared.favoriteMetadata(metadata, urlBase: self.appDelegate.urlBase) { (errorCode, errorDescription) in
  88. if errorCode != 0 {
  89. NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
  90. }
  91. }
  92. }
  93. )
  94. )
  95. //
  96. // DETAIL
  97. //
  98. if !isFolderEncrypted && !appDelegate.disableSharesView {
  99. actions.append(
  100. NCMenuAction(
  101. title: NSLocalizedString("_details_", comment: ""),
  102. icon: NCUtility.shared.loadImage(named: "info"),
  103. action: { menuAction in
  104. NCFunctionCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: 0)
  105. }
  106. )
  107. )
  108. }
  109. //
  110. // OFFLINE
  111. //
  112. if !isFolderEncrypted {
  113. actions.append(
  114. NCMenuAction(
  115. title: isOffline ? NSLocalizedString("_remove_available_offline_", comment: "") : NSLocalizedString("_set_available_offline_", comment: ""),
  116. icon: NCUtility.shared.loadImage(named: "tray.and.arrow.down"),
  117. action: { menuAction in
  118. if isOffline {
  119. if metadata.directory {
  120. NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, offline: false, account: self.appDelegate.account)
  121. } else {
  122. NCManageDatabase.shared.setLocalFile(ocId: metadata.ocId, offline: false)
  123. }
  124. } else {
  125. if metadata.directory {
  126. NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, offline: true, account: self.appDelegate.account)
  127. NCOperationQueue.shared.synchronizationMetadata(metadata, selector: NCGlobal.shared.selectorDownloadAllFile)
  128. } else {
  129. NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorLoadOffline) { (_) in }
  130. if let metadataLivePhoto = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) {
  131. NCNetworking.shared.download(metadata: metadataLivePhoto, selector: NCGlobal.shared.selectorLoadOffline) { (_) in }
  132. }
  133. }
  134. }
  135. self.reloadDataSource()
  136. }
  137. )
  138. )
  139. }
  140. //
  141. // OPEN IN
  142. //
  143. if !metadata.directory && !NCBrandOptions.shared.disable_openin_file {
  144. actions.append(
  145. NCMenuAction(
  146. title: NSLocalizedString("_open_in_", comment: ""),
  147. icon: NCUtility.shared.loadImage(named: "square.and.arrow.up"),
  148. action: { menuAction in
  149. NCFunctionCenter.shared.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorOpenIn)
  150. }
  151. )
  152. )
  153. }
  154. //
  155. // PRINT
  156. //
  157. if (metadata.typeFile == NCGlobal.shared.metadataTypeFileImage && metadata.contentType != "image/svg+xml") || metadata.contentType == "application/pdf" || metadata.contentType == "com.adobe.pdf" {
  158. actions.append(
  159. NCMenuAction(
  160. title: NSLocalizedString("_print_", comment: ""),
  161. icon: NCUtility.shared.loadImage(named: "printer"),
  162. action: { menuAction in
  163. NCFunctionCenter.shared.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorPrint)
  164. }
  165. )
  166. )
  167. }
  168. //
  169. // SAVE
  170. //
  171. if (metadata.typeFile == NCGlobal.shared.metadataTypeFileImage && metadata.contentType != "image/svg+xml") || metadata.typeFile == NCGlobal.shared.metadataTypeFileVideo {
  172. var title: String = NSLocalizedString("_save_selected_files_", comment: "")
  173. var icon = NCUtility.shared.loadImage(named: "square.and.arrow.down")
  174. let metadataMOV = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata)
  175. if metadataMOV != nil {
  176. title = NSLocalizedString("_livephoto_save_", comment: "")
  177. icon = NCUtility.shared.loadImage(named: "livephoto")
  178. }
  179. actions.append(
  180. NCMenuAction(
  181. title: title,
  182. icon: icon,
  183. action: { menuAction in
  184. if metadataMOV != nil {
  185. NCFunctionCenter.shared.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV!)
  186. } else {
  187. if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
  188. NCFunctionCenter.shared.saveAlbum(metadata: metadata)
  189. } else {
  190. NCOperationQueue.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveAlbum)
  191. }
  192. }
  193. }
  194. )
  195. )
  196. }
  197. //
  198. // SAVE AS SCAN
  199. //
  200. if #available(iOS 13.0, *) {
  201. if (metadata.typeFile == NCGlobal.shared.metadataTypeFileImage && metadata.contentType != "image/svg+xml") {
  202. actions.append(
  203. NCMenuAction(
  204. title: NSLocalizedString("_save_as_scan_", comment: ""),
  205. icon: NCUtility.shared.loadImage(named: "viewfinder.circle"),
  206. action: { menuAction in
  207. NCFunctionCenter.shared.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorSaveAsScan)
  208. }
  209. )
  210. )
  211. }
  212. }
  213. //
  214. // RENAME
  215. //
  216. if !(isFolderEncrypted && metadata.serverUrl == serverUrlHome) {
  217. actions.append(
  218. NCMenuAction(
  219. title: NSLocalizedString("_rename_", comment: ""),
  220. icon: NCUtility.shared.loadImage(named: "pencil"),
  221. action: { menuAction in
  222. if let vcRename = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile {
  223. vcRename.metadata = metadata
  224. vcRename.imagePreview = imageIcon
  225. let popup = NCPopupViewController(contentController: vcRename, popupWidth: vcRename.width, popupHeight: vcRename.height)
  226. self.present(popup, animated: true)
  227. }
  228. }
  229. )
  230. )
  231. }
  232. //
  233. // COPY - MOVE
  234. //
  235. if !isFolderEncrypted && serverUrl != "" {
  236. actions.append(
  237. NCMenuAction(
  238. title: NSLocalizedString("_move_or_copy_", comment: ""),
  239. icon: NCUtility.shared.loadImage(named: "arrow.up.right.square"),
  240. action: { menuAction in
  241. NCFunctionCenter.shared.openSelectView(items: [metadata], viewController: self)
  242. }
  243. )
  244. )
  245. }
  246. //
  247. // COPY
  248. //
  249. if !metadata.directory {
  250. actions.append(
  251. NCMenuAction(
  252. title: NSLocalizedString("_copy_file_", comment: ""),
  253. icon: NCUtility.shared.loadImage(named: "doc.on.doc"),
  254. action: { menuAction in
  255. self.appDelegate.pasteboardOcIds = [metadata.ocId];
  256. NCFunctionCenter.shared.copyPasteboard()
  257. }
  258. )
  259. )
  260. }
  261. //
  262. // VIEW IN FOLDER
  263. //
  264. if layoutKey == NCGlobal.shared.layoutViewRecent && appDelegate.activeFileViewInFolder == nil {
  265. actions.append(
  266. NCMenuAction(
  267. title: NSLocalizedString("_view_in_folder_", comment: ""),
  268. icon: NCUtility.shared.loadImage(named: "arrow.forward.square"),
  269. action: { menuAction in
  270. NCFunctionCenter.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileName: metadata.fileName)
  271. }
  272. )
  273. )
  274. }
  275. /*
  276. //
  277. // USE AS BACKGROUND
  278. //
  279. if #available(iOS 13.0, *) {
  280. if metadata.typeFile == NCGlobal.shared.metadataTypeFileImage && self.layoutKey == NCGlobal.shared.layoutViewFiles && !NCBrandOptions.shared.disable_background_image {
  281. actions.append(
  282. NCMenuAction(
  283. title: NSLocalizedString("_use_as_background_", comment: ""),
  284. icon: NCUtility.shared.loadImage(named: "text.below.photo"),
  285. action: { menuAction in
  286. if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
  287. NCFunctionCenter.shared.saveBackground(metadata: metadata)
  288. } else {
  289. NCOperationQueue.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveBackground)
  290. }
  291. }
  292. )
  293. )
  294. }
  295. }
  296. */
  297. //
  298. // MODIFY
  299. //
  300. if #available(iOS 13.0, *) {
  301. if !isFolderEncrypted && metadata.contentType != "image/gif" && metadata.contentType != "image/svg+xml" && (metadata.contentType == "com.adobe.pdf" || metadata.contentType == "application/pdf" || metadata.typeFile == NCGlobal.shared.metadataTypeFileImage) {
  302. actions.append(
  303. NCMenuAction(
  304. title: NSLocalizedString("_modify_", comment: ""),
  305. icon: NCUtility.shared.loadImage(named: "pencil.tip.crop.circle"),
  306. action: { menuAction in
  307. NCFunctionCenter.shared.openDownload(metadata: metadata, selector: NCGlobal.shared.selectorLoadFileQuickLook)
  308. }
  309. )
  310. )
  311. }
  312. }
  313. //
  314. // DELETE
  315. //
  316. actions.append(
  317. NCMenuAction(
  318. title: titleDelete,
  319. icon: NCUtility.shared.loadImage(named: "trash"),
  320. action: { menuAction in
  321. let alertController = UIAlertController(title: "", message: metadata.fileNameView + "\n\n" + NSLocalizedString("_want_delete_", comment: ""), preferredStyle: .alert)
  322. alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_delete_", comment: ""), style: .default) { (action:UIAlertAction) in
  323. NCOperationQueue.shared.delete(metadata: metadata, onlyLocal: false)
  324. })
  325. alertController.addAction(UIAlertAction(title: NSLocalizedString("_remove_local_file_", comment: ""), style: .default) { (action:UIAlertAction) in
  326. NCOperationQueue.shared.delete(metadata: metadata, onlyLocal: true)
  327. })
  328. alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_delete_", comment: ""), style: .default) { (action:UIAlertAction) in })
  329. self.present(alertController, animated: true, completion:nil)
  330. }
  331. )
  332. )
  333. //
  334. // SET FOLDER E2EE
  335. //
  336. if !metadata.e2eEncrypted && metadata.directory && CCUtility.isEnd(toEndEnabled: appDelegate.account) && metadata.serverUrl == serverUrlHome {
  337. actions.append(
  338. NCMenuAction(
  339. title: NSLocalizedString("_e2e_set_folder_encrypted_", comment: ""),
  340. icon:NCUtility.shared.loadImage(named: "lock"),
  341. action: { menuAction in
  342. NCCommunication.shared.markE2EEFolder(fileId: metadata.fileId, delete: false) { (account, errorCode, errorDescription) in
  343. if errorCode == 0 {
  344. NCManageDatabase.shared.deleteE2eEncryption(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, serverUrl))
  345. NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, serverUrlTo: nil, etag: nil, ocId: nil, fileId: nil, encrypted: true, richWorkspace: nil, account: metadata.account)
  346. NCManageDatabase.shared.setMetadataEncrypted(ocId: metadata.ocId, encrypted: true)
  347. NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeStatusFolderE2EE, userInfo: ["serverUrl":metadata.serverUrl])
  348. } else {
  349. NCContentPresenter.shared.messageNotification(NSLocalizedString("_e2e_error_mark_folder_", comment: ""), description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: .error, errorCode: errorCode)
  350. }
  351. }
  352. }
  353. )
  354. )
  355. }
  356. //
  357. // UNSET FOLDER E2EE
  358. //
  359. if metadata.e2eEncrypted && metadata.directory && CCUtility.isEnd(toEndEnabled: appDelegate.account) && metadata.serverUrl == serverUrlHome {
  360. actions.append(
  361. NCMenuAction(
  362. title: NSLocalizedString("_e2e_remove_folder_encrypted_", comment: ""),
  363. icon: NCUtility.shared.loadImage(named: "lock"),
  364. action: { menuAction in
  365. NCCommunication.shared.markE2EEFolder(fileId: metadata.fileId, delete: true) { (account, errorCode, errorDescription) in
  366. if errorCode == 0 {
  367. NCManageDatabase.shared.deleteE2eEncryption(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, serverUrl))
  368. NCManageDatabase.shared.setDirectory(serverUrl: serverUrl, serverUrlTo: nil, etag: nil, ocId: nil, fileId: nil, encrypted: false, richWorkspace: nil, account: metadata.account)
  369. NCManageDatabase.shared.setMetadataEncrypted(ocId: metadata.ocId, encrypted: false)
  370. NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeStatusFolderE2EE, userInfo: ["serverUrl":metadata.serverUrl])
  371. } else {
  372. NCContentPresenter.shared.messageNotification(NSLocalizedString("_e2e_error_delete_mark_folder_", comment: ""), description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: .error, errorCode: errorCode)
  373. }
  374. }
  375. }
  376. )
  377. )
  378. }
  379. menuViewController.actions = actions
  380. let menuPanelController = NCMenuPanelController()
  381. menuPanelController.parentPresenter = self
  382. menuPanelController.delegate = menuViewController
  383. menuPanelController.set(contentViewController: menuViewController)
  384. menuPanelController.track(scrollView: menuViewController.tableView)
  385. present(menuPanelController, animated: true, completion: nil)
  386. }
  387. func toggleMenuSelect() {
  388. let menuViewController = UIStoryboard.init(name: "NCMenu", bundle: nil).instantiateInitialViewController() as! NCMenu
  389. var actions = [NCMenuAction]()
  390. //
  391. // SELECT ALL
  392. //
  393. actions.append(
  394. NCMenuAction(
  395. title: NSLocalizedString("_select_all_", comment: ""),
  396. icon: NCUtility.shared.loadImage(named: "checkmark.circle.fill"),
  397. action: { menuAction in
  398. self.collectionViewSelectAll()
  399. }
  400. )
  401. )
  402. //
  403. // OPEN IN
  404. //
  405. actions.append(
  406. NCMenuAction(
  407. title: NSLocalizedString("_open_in_", comment: ""),
  408. icon: NCUtility.shared.loadImage(named: "square.and.arrow.up"),
  409. action: { menuAction in
  410. NCFunctionCenter.shared.openActivityViewController(selectOcId: self.selectOcId)
  411. self.tapSelect(sender: self)
  412. }
  413. )
  414. )
  415. //
  416. // SAVE TO PHOTO GALLERY
  417. //
  418. actions.append(
  419. NCMenuAction(
  420. title: NSLocalizedString("_save_selected_files_", comment: ""),
  421. icon: NCUtility.shared.loadImage(named: "square.and.arrow.down"),
  422. action: { menuAction in
  423. for ocId in self.selectOcId {
  424. if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
  425. if metadata.typeFile == NCGlobal.shared.metadataTypeFileImage || metadata.typeFile == NCGlobal.shared.metadataTypeFileVideo {
  426. if let metadataMOV = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) {
  427. NCFunctionCenter.shared.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV)
  428. } else {
  429. if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
  430. NCFunctionCenter.shared.saveAlbum(metadata: metadata)
  431. } else {
  432. NCOperationQueue.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorSaveAlbum)
  433. }
  434. }
  435. }
  436. }
  437. }
  438. self.tapSelect(sender: self)
  439. }
  440. )
  441. )
  442. //
  443. // COPY - MOVE
  444. //
  445. actions.append(
  446. NCMenuAction(
  447. title: NSLocalizedString("_move_or_copy_selected_files_", comment: ""),
  448. icon: NCUtility.shared.loadImage(named: "arrow.up.right.square"),
  449. action: { menuAction in
  450. var meradatasSelect = [tableMetadata]()
  451. for ocId in self.selectOcId {
  452. if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
  453. meradatasSelect.append(metadata)
  454. }
  455. }
  456. if meradatasSelect.count > 0 {
  457. NCFunctionCenter.shared.openSelectView(items: meradatasSelect, viewController: self)
  458. }
  459. self.tapSelect(sender: self)
  460. }
  461. )
  462. )
  463. //
  464. // COPY
  465. //
  466. actions.append(
  467. NCMenuAction(
  468. title: NSLocalizedString("_copy_file_", comment: ""),
  469. icon: NCUtility.shared.loadImage(named: "doc.on.doc"),
  470. action: { menuAction in
  471. self.appDelegate.pasteboardOcIds.removeAll()
  472. for ocId in self.selectOcId {
  473. self.appDelegate.pasteboardOcIds.append(ocId)
  474. }
  475. NCFunctionCenter.shared.copyPasteboard()
  476. self.tapSelect(sender: self)
  477. }
  478. )
  479. )
  480. //
  481. // DELETE
  482. //
  483. actions.append(
  484. NCMenuAction(
  485. title: NSLocalizedString("_delete_selected_files_", comment: ""),
  486. icon: NCUtility.shared.loadImage(named: "trash"),
  487. action: { menuAction in
  488. let alertController = UIAlertController(title: "", message: NSLocalizedString("_want_delete_", comment: ""), preferredStyle: .alert)
  489. alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_delete_", comment: ""), style: .default) { (action:UIAlertAction) in
  490. for ocId in self.selectOcId {
  491. if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
  492. NCOperationQueue.shared.delete(metadata: metadata, onlyLocal: false)
  493. }
  494. }
  495. self.tapSelect(sender: self)
  496. })
  497. alertController.addAction(UIAlertAction(title: NSLocalizedString("_remove_local_file_", comment: ""), style: .default) { (action:UIAlertAction) in
  498. for ocId in self.selectOcId {
  499. if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
  500. NCOperationQueue.shared.delete(metadata: metadata, onlyLocal: true)
  501. }
  502. }
  503. self.tapSelect(sender: self)
  504. })
  505. alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_delete_", comment: ""), style: .default) { (action:UIAlertAction) in })
  506. self.present(alertController, animated: true, completion:nil)
  507. }
  508. )
  509. )
  510. menuViewController.actions = actions
  511. let menuPanelController = NCMenuPanelController()
  512. menuPanelController.parentPresenter = self
  513. menuPanelController.delegate = menuViewController
  514. menuPanelController.set(contentViewController: menuViewController)
  515. menuPanelController.track(scrollView: menuViewController.tableView)
  516. present(menuPanelController, animated: true, completion: nil)
  517. }
  518. }