From 8a7f73a4bcde7ccaa5477d32f366e02e07f4243d Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Mon, 30 Oct 2023 15:57:57 +0530 Subject: [PATCH 1/5] NMC 2253 - Context menu customisation changes --- iOSClient/Menu/NCViewer+Menu.swift | 263 +++++++++++++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 iOSClient/Menu/NCViewer+Menu.swift diff --git a/iOSClient/Menu/NCViewer+Menu.swift b/iOSClient/Menu/NCViewer+Menu.swift new file mode 100644 index 0000000000..c304c45045 --- /dev/null +++ b/iOSClient/Menu/NCViewer+Menu.swift @@ -0,0 +1,263 @@ +// +// NCViewer.swift +// Nextcloud +// +// Created by Marino Faggiana on 07/02/2020. +// Copyright © 2020 Marino Faggiana All rights reserved. +// +// Author Marino Faggiana +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +import UIKit +import FloatingPanel +import NextcloudKit + +extension NCViewer { + func toggleMenu(controller: NCMainTabBarController?, metadata: tableMetadata, webView: Bool, imageIcon: UIImage?, indexPath: IndexPath = IndexPath(), sender: Any?) { + guard let metadata = self.database.getMetadataFromOcId(metadata.ocId), + let controller else { return } + var actions = [NCMenuAction]() + let localFile = self.database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) + let isOffline = localFile?.offline == true + let capabilities = NKCapabilities.shared.getCapabilitiesBlocking(for: metadata.account) + + // + // DETAIL + // + if !(!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { + actions.append( + NCMenuAction( + title: NSLocalizedString("_details_", comment: ""), + icon: utility.loadImage(named: "info.circle", colors: [NCBrandColor.shared.iconImageColor]), + sender: sender, + action: { _ in + NCDownloadAction.shared.openShare(viewController: controller, metadata: metadata, page: .activity) + } + ) + ) + } + + // + // VIEW IN FOLDER + // + if !webView { + actions.append( + NCMenuAction( + title: NSLocalizedString("_view_in_folder_", comment: ""), + icon: utility.loadImage(named: "questionmark.folder", colors: [NCBrandColor.shared.iconImageColor]), + sender: sender, + action: { _ in + NCDownloadAction.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileNameBlink: metadata.fileName, fileNameOpen: nil, sceneIdentifier: controller.sceneIdentifier) + } + ) + ) + } + + // + // FAVORITE + // Workaround: PROPPATCH doesn't work + // https://github.com/nextcloud/files_lock/issues/68 + if !metadata.lock { + actions.append( + NCMenuAction( + title: metadata.favorite ? NSLocalizedString("_remove_favorites_", comment: "") : NSLocalizedString("_add_favorites_", comment: ""), + icon: utility.loadImage(named: metadata.favorite ? "star.slash" : "star", colors: [NCBrandColor.shared.yellowFavorite]), + sender: sender, + action: { _ in + NCNetworking.shared.favoriteMetadata(metadata) { error in + if error != .success { + NCContentPresenter().showError(error: error) + } + } + } + ) + ) + } + + // + // OFFLINE + // + if !webView, metadata.canSetAsAvailableOffline { + actions.append(.setAvailableOfflineAction(selectedMetadatas: [metadata], isAnyOffline: isOffline, viewController: controller, sender: sender)) + } + + // + // SHARE + // + if !webView, metadata.canShare { + actions.append(.share(selectedMetadatas: [metadata], + controller: controller, + sender: sender)) + } + + // + // SAVE LIVE PHOTO + // + if let metadataMOV = self.database.getMetadataLivePhoto(metadata: metadata), + let hudView = controller.view { + actions.append( + NCMenuAction( + title: NSLocalizedString("_livephoto_save_", comment: ""), + icon: NCUtility().loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]), + sender: sender, + action: { _ in + NCNetworking.shared.saveLivePhotoQueue.addOperation(NCOperationSaveLivePhoto(metadata: metadata, metadataMOV: metadataMOV, hudView: hudView)) + } + ) + ) + } + + // + // SAVE AS SCAN + // + if !webView, metadata.isSavebleAsImage { + actions.append( + NCMenuAction( + title: NSLocalizedString("_save_as_scan_", comment: ""), + icon: utility.loadImage(named: "doc.viewfinder", colors: [NCBrandColor.shared.iconImageColor]), + sender: sender, + action: { _ in + if self.utilityFileSystem.fileProviderStorageExists(metadata) { + NCNetworking.shared.notifyAllDelegates { delegate in + let metadata = metadata.detachedCopy() + metadata.sessionSelector = NCGlobal.shared.selectorSaveAsScan + delegate.transferChange(status: NCGlobal.shared.networkingStatusDownloaded, + metadata: metadata, + error: .success) + } + } else { + Task { + if let metadata = await self.database.setMetadataSessionInWaitDownloadAsync(ocId: metadata.ocId, + session: NCNetworking.shared.sessionDownload, + selector: NCGlobal.shared.selectorSaveAsScan, + sceneIdentifier: controller.sceneIdentifier) { + NCNetworking.shared.download(metadata: metadata) + } + } + } + } + ) + ) + } + + // + // DOWNLOAD - LOCAL + // + if !webView, metadata.session.isEmpty, !self.utilityFileSystem.fileProviderStorageExists(metadata) { + var title = "" + if metadata.isImage { + title = NSLocalizedString("_try_download_full_resolution_", comment: "") + } else if metadata.isVideo { + title = NSLocalizedString("_download_video_", comment: "") + } else if metadata.isAudio { + title = NSLocalizedString("_download_audio_", comment: "") + } else { + title = NSLocalizedString("_download_file_", comment: "") + } + actions.append( + NCMenuAction( + title: title, + icon: utility.loadImage(named: "iphone.circle", colors: [NCBrandColor.shared.iconImageColor]), + sender: sender, + action: { _ in + Task { + if let metadata = await self.database.setMetadataSessionInWaitDownloadAsync(ocId: metadata.ocId, + session: NCNetworking.shared.sessionDownload, + selector: "", + sceneIdentifier: controller.sceneIdentifier) { + NCNetworking.shared.download(metadata: metadata) + } + } + } + ) + ) + } + // COPY IN PASTEBOARD + // + if !webView, metadata.isCopyableInPasteboard { + actions.append(.copyAction(selectOcId: [metadata.ocId])) + } + + // + // PDF + // + if metadata.isPDF { + actions.append( + NCMenuAction( + title: NSLocalizedString("_search_", comment: ""), + icon: utility.loadImage(named: "magnifyingglass", colors: [NCBrandColor.shared.iconImageColor]), + sender: sender, + action: { _ in + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterMenuSearchTextPDF) + } + ) + ) + + actions.append( + NCMenuAction( + title: NSLocalizedString("_go_to_page_", comment: ""), + icon: utility.loadImage(named: "number.circle", colors: [NCBrandColor.shared.iconImageColor]), + sender: sender, + action: { _ in + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterMenuGotToPageInPDF) + } + ) + ) + } + + // + // MODIFY WITH QUICK LOOK + // + if !webView, metadata.isModifiableWithQuickLook { + actions.append( + NCMenuAction( + title: NSLocalizedString("_modify_", comment: ""), + icon: utility.loadImage(named: "pencil.tip.crop.circle", colors: [NCBrandColor.shared.iconImageColor]), + sender: sender, + action: { _ in + if self.utilityFileSystem.fileProviderStorageExists(metadata) { + NCNetworking.shared.notifyAllDelegates { delegate in + let metadata = metadata.detachedCopy() + metadata.sessionSelector = NCGlobal.shared.selectorLoadFileQuickLook + delegate.transferChange(status: NCGlobal.shared.networkingStatusDownloaded, + metadata: metadata, + error: .success) + } + } else { + Task { + if let metadata = await self.database.setMetadataSessionInWaitDownloadAsync(ocId: metadata.ocId, + session: NCNetworking.shared.sessionDownload, + selector: NCGlobal.shared.selectorLoadFileQuickLook, + sceneIdentifier: controller.sceneIdentifier) { + NCNetworking.shared.download(metadata: metadata) + } + } + } + } + ) + ) + } + + // + // DELETE + // + if !webView, metadata.isDeletable { + actions.append(.deleteAction(selectedMetadatas: [metadata], metadataFolder: nil, controller: controller, sender: sender)) + } + + controller.presentMenu(with: actions, sender: sender) + } +} From e0269a2c4ce48aa3310d4e5708ed7b632931bc13 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:52:24 +0530 Subject: [PATCH 2/5] NMC 2253 - Menu update after NC 5.0 Release --- iOSClient/Menu/NCViewer+Menu.swift | 49 +++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/iOSClient/Menu/NCViewer+Menu.swift b/iOSClient/Menu/NCViewer+Menu.swift index c304c45045..6f071b0343 100644 --- a/iOSClient/Menu/NCViewer+Menu.swift +++ b/iOSClient/Menu/NCViewer+Menu.swift @@ -70,7 +70,7 @@ extension NCViewer { // FAVORITE // Workaround: PROPPATCH doesn't work // https://github.com/nextcloud/files_lock/issues/68 - if !metadata.lock { + if !metadata.lock, !metadata.isDirectoryE2EE{ actions.append( NCMenuAction( title: metadata.favorite ? NSLocalizedString("_remove_favorites_", comment: "") : NSLocalizedString("_add_favorites_", comment: ""), @@ -102,9 +102,9 @@ extension NCViewer { controller: controller, sender: sender)) } - + // - // SAVE LIVE PHOTO + // PRINT // if let metadataMOV = self.database.getMetadataLivePhoto(metadata: metadata), let hudView = controller.view { @@ -152,6 +152,47 @@ extension NCViewer { ) ) } + + // + // SAVE CAMERA ROLL + // + if !webView, metadata.isSavebleInCameraRoll { + actions.append(.saveMediaAction(selectedMediaMetadatas: [metadata])) + } + + + // + // RENAME + // + if !webView, metadata.isRenameable, !metadata.isDirectoryE2EE { + actions.append( + NCMenuAction( + title: NSLocalizedString("_rename_", comment: ""), + icon: utility.loadImage(named: "text.cursor", colors: [NCBrandColor.shared.iconImageColor]), + action: { _ in + + if let vcRename = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile { + + vcRename.metadata = metadata + vcRename.disableChangeExt = true + vcRename.imagePreview = imageIcon + vcRename.indexPath = indexPath + + let popup = NCPopupViewController(contentController: vcRename, popupWidth: vcRename.width, popupHeight: vcRename.height) + + viewController.present(popup, animated: true) + } + } + ) + ) + } + + // + // COPY - MOVE + // + if !webView, metadata.isCopyableMovable { + actions.append(.moveOrCopyAction(selectedMetadatas: [metadata], viewController: viewController, indexPath: [])) + } // // DOWNLOAD - LOCAL @@ -187,7 +228,7 @@ extension NCViewer { } // COPY IN PASTEBOARD // - if !webView, metadata.isCopyableInPasteboard { + if !webView, metadata.isCopyableInPasteboard, !metadata.isDirectoryE2EE { actions.append(.copyAction(selectOcId: [metadata.ocId])) } From 1afc8417a35ef441084d4054b719413bcdd9ce25 Mon Sep 17 00:00:00 2001 From: harshada-15-tsys Date: Thu, 10 Apr 2025 12:49:31 +0530 Subject: [PATCH 3/5] NMC 2253 - Context menu customisation changes --- iOSClient/Menu/NCViewer+Menu.swift | 43 ++++++++++-------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/iOSClient/Menu/NCViewer+Menu.swift b/iOSClient/Menu/NCViewer+Menu.swift index 6f071b0343..734a5978c1 100644 --- a/iOSClient/Menu/NCViewer+Menu.swift +++ b/iOSClient/Menu/NCViewer+Menu.swift @@ -58,6 +58,7 @@ extension NCViewer { NCMenuAction( title: NSLocalizedString("_view_in_folder_", comment: ""), icon: utility.loadImage(named: "questionmark.folder", colors: [NCBrandColor.shared.iconImageColor]), +// icon: utility.loadImage(named: "arrow.forward.square", colors: [NCBrandColor.shared.iconColor]), sender: sender, action: { _ in NCDownloadAction.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileNameBlink: metadata.fileName, fileNameOpen: nil, sceneIdentifier: controller.sceneIdentifier) @@ -74,7 +75,7 @@ extension NCViewer { actions.append( NCMenuAction( title: metadata.favorite ? NSLocalizedString("_remove_favorites_", comment: "") : NSLocalizedString("_add_favorites_", comment: ""), - icon: utility.loadImage(named: metadata.favorite ? "star.slash" : "star", colors: [NCBrandColor.shared.yellowFavorite]), + icon: utility.loadImage(named: "star.fill", colors: [NCBrandColor.shared.yellowFavorite]), sender: sender, action: { _ in NCNetworking.shared.favoriteMetadata(metadata) { error in @@ -106,29 +107,11 @@ extension NCViewer { // // PRINT // - if let metadataMOV = self.database.getMetadataLivePhoto(metadata: metadata), - let hudView = controller.view { + if !webView, metadata.isPrintable { actions.append( NCMenuAction( - title: NSLocalizedString("_livephoto_save_", comment: ""), - icon: NCUtility().loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]), - sender: sender, - action: { _ in - NCNetworking.shared.saveLivePhotoQueue.addOperation(NCOperationSaveLivePhoto(metadata: metadata, metadataMOV: metadataMOV, hudView: hudView)) - } - ) - ) - } - - // - // SAVE AS SCAN - // - if !webView, metadata.isSavebleAsImage { - actions.append( - NCMenuAction( - title: NSLocalizedString("_save_as_scan_", comment: ""), - icon: utility.loadImage(named: "doc.viewfinder", colors: [NCBrandColor.shared.iconImageColor]), - sender: sender, + title: NSLocalizedString("_print_", comment: ""), + icon: utility.loadImage(named: "printer", colors: [NCBrandColor.shared.iconColor]), action: { _ in if self.utilityFileSystem.fileProviderStorageExists(metadata) { NCNetworking.shared.notifyAllDelegates { delegate in @@ -157,7 +140,7 @@ extension NCViewer { // SAVE CAMERA ROLL // if !webView, metadata.isSavebleInCameraRoll { - actions.append(.saveMediaAction(selectedMediaMetadatas: [metadata])) + actions.append(.saveMediaAction(selectedMediaMetadatas: [metadata], controller: controller)) } @@ -168,7 +151,7 @@ extension NCViewer { actions.append( NCMenuAction( title: NSLocalizedString("_rename_", comment: ""), - icon: utility.loadImage(named: "text.cursor", colors: [NCBrandColor.shared.iconImageColor]), + icon: utility.loadImage(named: "rename", colors: [NCBrandColor.shared.iconColor]), action: { _ in if let vcRename = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile { @@ -180,7 +163,7 @@ extension NCViewer { let popup = NCPopupViewController(contentController: vcRename, popupWidth: vcRename.width, popupHeight: vcRename.height) - viewController.present(popup, animated: true) + controller.present(popup, animated: true) } } ) @@ -225,11 +208,13 @@ extension NCViewer { } ) ) + actions.append(.moveOrCopyAction(selectedMetadatas: [metadata], controller: controller)) } + // COPY IN PASTEBOARD // if !webView, metadata.isCopyableInPasteboard, !metadata.isDirectoryE2EE { - actions.append(.copyAction(selectOcId: [metadata.ocId])) + actions.append(.copyAction(fileSelect: [metadata.ocId], controller: controller)) } // @@ -239,7 +224,7 @@ extension NCViewer { actions.append( NCMenuAction( title: NSLocalizedString("_search_", comment: ""), - icon: utility.loadImage(named: "magnifyingglass", colors: [NCBrandColor.shared.iconImageColor]), + icon: utility.loadImage(named: "search", colors: [NCBrandColor.shared.iconColor]), sender: sender, action: { _ in NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterMenuSearchTextPDF) @@ -250,7 +235,7 @@ extension NCViewer { actions.append( NCMenuAction( title: NSLocalizedString("_go_to_page_", comment: ""), - icon: utility.loadImage(named: "number.circle", colors: [NCBrandColor.shared.iconImageColor]), + icon: utility.loadImage(named: "go-to-page", colors: [NCBrandColor.shared.iconColor]), sender: sender, action: { _ in NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterMenuGotToPageInPDF) @@ -266,7 +251,7 @@ extension NCViewer { actions.append( NCMenuAction( title: NSLocalizedString("_modify_", comment: ""), - icon: utility.loadImage(named: "pencil.tip.crop.circle", colors: [NCBrandColor.shared.iconImageColor]), + icon: utility.loadImage(named: "pencil.tip.crop.circle", colors: [NCBrandColor.shared.iconColor]), sender: sender, action: { _ in if self.utilityFileSystem.fileProviderStorageExists(metadata) { From ba79374c9d626413d3dad664c5fcf3fe9ad32bbd Mon Sep 17 00:00:00 2001 From: harshada-15-tsys Date: Wed, 1 Oct 2025 13:50:34 +0530 Subject: [PATCH 4/5] NMC 2253 - Context menu customisation changes --- iOSClient/Menu/NCViewer+Menu.swift | 121 ++++++----------------------- 1 file changed, 24 insertions(+), 97 deletions(-) diff --git a/iOSClient/Menu/NCViewer+Menu.swift b/iOSClient/Menu/NCViewer+Menu.swift index 734a5978c1..4202df8fae 100644 --- a/iOSClient/Menu/NCViewer+Menu.swift +++ b/iOSClient/Menu/NCViewer+Menu.swift @@ -26,29 +26,12 @@ import FloatingPanel import NextcloudKit extension NCViewer { - func toggleMenu(controller: NCMainTabBarController?, metadata: tableMetadata, webView: Bool, imageIcon: UIImage?, indexPath: IndexPath = IndexPath(), sender: Any?) { + func toggleMenu(controller: NCMainTabBarController?, metadata: tableMetadata, webView: Bool, imageIcon: UIImage?, indexPath: IndexPath = IndexPath()) { guard let metadata = self.database.getMetadataFromOcId(metadata.ocId), let controller else { return } var actions = [NCMenuAction]() let localFile = self.database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) let isOffline = localFile?.offline == true - let capabilities = NKCapabilities.shared.getCapabilitiesBlocking(for: metadata.account) - - // - // DETAIL - // - if !(!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { - actions.append( - NCMenuAction( - title: NSLocalizedString("_details_", comment: ""), - icon: utility.loadImage(named: "info.circle", colors: [NCBrandColor.shared.iconImageColor]), - sender: sender, - action: { _ in - NCDownloadAction.shared.openShare(viewController: controller, metadata: metadata, page: .activity) - } - ) - ) - } // // VIEW IN FOLDER @@ -57,11 +40,9 @@ extension NCViewer { actions.append( NCMenuAction( title: NSLocalizedString("_view_in_folder_", comment: ""), - icon: utility.loadImage(named: "questionmark.folder", colors: [NCBrandColor.shared.iconImageColor]), -// icon: utility.loadImage(named: "arrow.forward.square", colors: [NCBrandColor.shared.iconColor]), - sender: sender, + icon: utility.loadImage(named: "arrow.forward.square", colors: [NCBrandColor.shared.iconColor]), action: { _ in - NCDownloadAction.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileNameBlink: metadata.fileName, fileNameOpen: nil, sceneIdentifier: controller.sceneIdentifier) + NCActionCenter.shared.openFileViewInFolder(serverUrl: metadata.serverUrl, fileNameBlink: metadata.fileName, fileNameOpen: nil, sceneIdentifier: controller.sceneIdentifier) } ) ) @@ -76,7 +57,6 @@ extension NCViewer { NCMenuAction( title: metadata.favorite ? NSLocalizedString("_remove_favorites_", comment: "") : NSLocalizedString("_add_favorites_", comment: ""), icon: utility.loadImage(named: "star.fill", colors: [NCBrandColor.shared.yellowFavorite]), - sender: sender, action: { _ in NCNetworking.shared.favoriteMetadata(metadata) { error in if error != .success { @@ -92,16 +72,14 @@ extension NCViewer { // OFFLINE // if !webView, metadata.canSetAsAvailableOffline { - actions.append(.setAvailableOfflineAction(selectedMetadatas: [metadata], isAnyOffline: isOffline, viewController: controller, sender: sender)) + actions.append(.setAvailableOfflineAction(selectedMetadatas: [metadata], isAnyOffline: isOffline, viewController: controller)) } // // SHARE // if !webView, metadata.canShare { - actions.append(.share(selectedMetadatas: [metadata], - controller: controller, - sender: sender)) + actions.append(.share(selectedMetadatas: [metadata], controller: controller)) } // @@ -114,22 +92,9 @@ extension NCViewer { icon: utility.loadImage(named: "printer", colors: [NCBrandColor.shared.iconColor]), action: { _ in if self.utilityFileSystem.fileProviderStorageExists(metadata) { - NCNetworking.shared.notifyAllDelegates { delegate in - let metadata = metadata.detachedCopy() - metadata.sessionSelector = NCGlobal.shared.selectorSaveAsScan - delegate.transferChange(status: NCGlobal.shared.networkingStatusDownloaded, - metadata: metadata, - error: .success) - } + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, userInfo: ["ocId": metadata.ocId, "selector": NCGlobal.shared.selectorPrint, "error": NKError(), "account": metadata.account, "ocIdTransfer": metadata.ocIdTransfer]) } else { - Task { - if let metadata = await self.database.setMetadataSessionInWaitDownloadAsync(ocId: metadata.ocId, - session: NCNetworking.shared.sessionDownload, - selector: NCGlobal.shared.selectorSaveAsScan, - sceneIdentifier: controller.sceneIdentifier) { - NCNetworking.shared.download(metadata: metadata) - } - } + NCNetworking.shared.downloadQueue.addOperation(NCOperationDownload(metadata: metadata, selector: NCGlobal.shared.selectorPrint)) } } ) @@ -169,45 +134,11 @@ extension NCViewer { ) ) } - + // // COPY - MOVE // if !webView, metadata.isCopyableMovable { - actions.append(.moveOrCopyAction(selectedMetadatas: [metadata], viewController: viewController, indexPath: [])) - } - - // - // DOWNLOAD - LOCAL - // - if !webView, metadata.session.isEmpty, !self.utilityFileSystem.fileProviderStorageExists(metadata) { - var title = "" - if metadata.isImage { - title = NSLocalizedString("_try_download_full_resolution_", comment: "") - } else if metadata.isVideo { - title = NSLocalizedString("_download_video_", comment: "") - } else if metadata.isAudio { - title = NSLocalizedString("_download_audio_", comment: "") - } else { - title = NSLocalizedString("_download_file_", comment: "") - } - actions.append( - NCMenuAction( - title: title, - icon: utility.loadImage(named: "iphone.circle", colors: [NCBrandColor.shared.iconImageColor]), - sender: sender, - action: { _ in - Task { - if let metadata = await self.database.setMetadataSessionInWaitDownloadAsync(ocId: metadata.ocId, - session: NCNetworking.shared.sessionDownload, - selector: "", - sceneIdentifier: controller.sceneIdentifier) { - NCNetworking.shared.download(metadata: metadata) - } - } - } - ) - ) actions.append(.moveOrCopyAction(selectedMetadatas: [metadata], controller: controller)) } @@ -225,7 +156,6 @@ extension NCViewer { NCMenuAction( title: NSLocalizedString("_search_", comment: ""), icon: utility.loadImage(named: "search", colors: [NCBrandColor.shared.iconColor]), - sender: sender, action: { _ in NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterMenuSearchTextPDF) } @@ -236,7 +166,6 @@ extension NCViewer { NCMenuAction( title: NSLocalizedString("_go_to_page_", comment: ""), icon: utility.loadImage(named: "go-to-page", colors: [NCBrandColor.shared.iconColor]), - sender: sender, action: { _ in NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterMenuGotToPageInPDF) } @@ -252,25 +181,23 @@ extension NCViewer { NCMenuAction( title: NSLocalizedString("_modify_", comment: ""), icon: utility.loadImage(named: "pencil.tip.crop.circle", colors: [NCBrandColor.shared.iconColor]), - sender: sender, action: { _ in if self.utilityFileSystem.fileProviderStorageExists(metadata) { - NCNetworking.shared.notifyAllDelegates { delegate in - let metadata = metadata.detachedCopy() - metadata.sessionSelector = NCGlobal.shared.selectorLoadFileQuickLook - delegate.transferChange(status: NCGlobal.shared.networkingStatusDownloaded, - metadata: metadata, - error: .success) - } + NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterDownloadedFile, + object: nil, + userInfo: ["ocId": metadata.ocId, + "ocIdTransfer": metadata.ocIdTransfer, + "session": metadata.session, + "selector": NCGlobal.shared.selectorLoadFileQuickLook, + "error": NKError(), + "account": metadata.account], + second: 0.5) } else { - Task { - if let metadata = await self.database.setMetadataSessionInWaitDownloadAsync(ocId: metadata.ocId, - session: NCNetworking.shared.sessionDownload, - selector: NCGlobal.shared.selectorLoadFileQuickLook, - sceneIdentifier: controller.sceneIdentifier) { - NCNetworking.shared.download(metadata: metadata) - } - } + guard let metadata = self.database.setMetadatasSessionInWaitDownload(metadatas: [metadata], + session: NCNetworking.shared.sessionDownload, + selector: NCGlobal.shared.selectorLoadFileQuickLook, + sceneIdentifier: controller.sceneIdentifier) else { return } + NCNetworking.shared.download(metadata: metadata, withNotificationProgressTask: true) } } ) @@ -281,9 +208,9 @@ extension NCViewer { // DELETE // if !webView, metadata.isDeletable { - actions.append(.deleteAction(selectedMetadatas: [metadata], metadataFolder: nil, controller: controller, sender: sender)) + actions.append(.deleteAction(selectedMetadatas: [metadata], metadataFolder: nil, controller: controller)) } - controller.presentMenu(with: actions, sender: sender) + controller.presentMenu(with: actions) } } From 80a826b95ba5b0ffb0b84271a15ea0af2e5cc0e8 Mon Sep 17 00:00:00 2001 From: harshada-15-tsys Date: Mon, 15 Dec 2025 16:53:05 +0530 Subject: [PATCH 5/5] NMC 2253 - Context menu customisation changes --- Nextcloud.xcodeproj/project.pbxproj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index de48cf1181..ec8c704363 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -85,6 +85,8 @@ AFCE353727E4ED7B00FEA6C2 /* NCShareCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */; }; AFCE353927E5DE0500FEA6C2 /* Shareable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* Shareable.swift */; }; CB3666201AF7550816B5CD6A /* NCContextMenuComment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8932E90EC4278026D86CCCC9 /* NCContextMenuComment.swift */; }; + B516E8DC2EF026F2005E049B /* NCViewer+Menu.swift in Sources */ = {isa = PBXBuildFile; fileRef = B516E8DB2EF026F2005E049B /* NCViewer+Menu.swift */; }; + D575039F27146F93008DC9DC /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extension.swift */; }; D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */; }; F310B1EF2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = F310B1EE2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift */; }; F31165022F9674A1009A1E37 /* AppIcon.icon in Resources */ = {isa = PBXBuildFile; fileRef = F31165012F9674A1009A1E37 /* AppIcon.icon */; }; @@ -1263,6 +1265,7 @@ AFCE353827E5DE0400FEA6C2 /* Shareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shareable.swift; sourceTree = ""; }; B4C7A5B36D1ED178FB6B76CB /* NCContextMenuPlayerTracks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCContextMenuPlayerTracks.swift; sourceTree = ""; }; BB7697C94BA14450A0867940 /* NCContextMenuProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCContextMenuProfile.swift; sourceTree = ""; }; + B516E8DB2EF026F2005E049B /* NCViewer+Menu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCViewer+Menu.swift"; sourceTree = ""; }; C0046CDA2A17B98400D87C9D /* NextcloudUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; C04E2F202A17BB4D001BAD85 /* NextcloudIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivityTableViewCell.swift; sourceTree = ""; }; @@ -2046,6 +2049,7 @@ 371B5A2F23D0B04B00FAFAE9 /* Menu */ = { isa = PBXGroup; children = ( + B516E8DB2EF026F2005E049B /* NCViewer+Menu.swift */, F376A3732E5CC5FF0067EE25 /* ContextMenuActions.swift */, 8932E90EC4278026D86CCCC9 /* NCContextMenuComment.swift */, F78C6FDD296D677300C952C3 /* NCContextMenuMain.swift */, @@ -4659,6 +4663,7 @@ F7D4BF402CA2E8D800A5E746 /* TOPasscodeButtonLabel.m in Sources */, F70898692EDDB51700EF85BD /* NCSelectOpen+SelectDelegate.swift in Sources */, F7D4BF412CA2E8D800A5E746 /* TOPasscodeViewControllerAnimatedTransitioning.m in Sources */, + B516E8DC2EF026F2005E049B /* NCViewer+Menu.swift in Sources */, F7D4BF422CA2E8D800A5E746 /* TOPasscodeSettingsViewController.m in Sources */, F7D4BF432CA2E8D800A5E746 /* TOPasscodeCircleImage.m in Sources */, F78026102E9CFA3700B63436 /* NCTransfersView.swift in Sources */,