Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
C0DECA022F65000100C0D001 /* NCCameraRollTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DECA012F65000100C0D001 /* NCCameraRollTests.swift */; };
CA1700013000000000000001 /* NCUploadedAssetsCleanupTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA1700013000000000000002 /* NCUploadedAssetsCleanupTests.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 */; };
F0A1B2C430B5000100D4E5F6 /* NCMediaViewerFloatingTitleViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0A1B2C330B5000100D4E5F6 /* NCMediaViewerFloatingTitleViewTests.swift */; };
F0A1B2C630B6000100D4E5F6 /* NCImageZoomViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0A1B2C530B6000100D4E5F6 /* NCImageZoomViewTests.swift */; };
Expand Down Expand Up @@ -1448,6 +1450,7 @@
AFCE353827E5DE0400FEA6C2 /* Shareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shareable.swift; sourceTree = "<group>"; };
B601AA002F10000100C0D3E5 /* NCLogFilesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCLogFilesView.swift; sourceTree = "<group>"; };
BB7697C94BA14450A0867940 /* NCContextMenuProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCContextMenuProfile.swift; sourceTree = "<group>"; };
B516E8DB2EF026F2005E049B /* NCViewer+Menu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCViewer+Menu.swift"; sourceTree = "<group>"; };
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; };
C0DECA012F65000100C0D001 /* NCCameraRollTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCCameraRollTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2302,6 +2305,8 @@
isa = PBXGroup;
children = (
F7637D7F2FE28CBF00F4F90E /* NCContextMenuActions.swift */,
B516E8DB2EF026F2005E049B /* NCViewer+Menu.swift */,
F376A3732E5CC5FF0067EE25 /* ContextMenuActions.swift */,
8932E90EC4278026D86CCCC9 /* NCContextMenuComment.swift */,
F78C6FDD296D677300C952C3 /* NCContextMenuMain.swift */,
F72EC7252F45C90600A2135C /* NCContextMenuNavigation.swift */,
Expand Down Expand Up @@ -5270,6 +5275,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 */,
Expand Down
34 changes: 34 additions & 0 deletions iOSClient/Menu/NCContextMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,38 @@ enum NCContextMenuActions {
}
}
}

/// Save selected files to user's photo library
static func saveMediaAction(selectedMediaMetadatas: [tableMetadata], controller: NCMainTabBarController?, completion: (() -> Void)? = nil) -> UIAction {
return UIAction(
title: NSLocalizedString("_save_selected_files_", comment: ""),
image: NCUtility().loadImage(named: "save_files",colors: [NCBrandColor.shared.iconImageColor]).withTintColor(NCBrandColor.shared.iconImageColor),
) { _ in

for metadata in selectedMediaMetadatas {
Task {
if NCUtilityFileSystem().fileProviderStorageExists(metadata) {
await NCNetworking.shared.transferDispatcher.notifyAllDelegates { delegate in
delegate.transferChange(status: NCGlobal.shared.networkingStatusDownloaded,
account: metadata.account,
fileName: metadata.fileName,
serverUrl: metadata.serverUrl,
selector: NCGlobal.shared.selectorSaveAlbum,
ocId: metadata.ocId,
destination: nil,
error: .success)
}
} else {
if let metadata = await NCManageDatabase.shared.setMetadataSessionInWaitDownloadAsync(ocId: metadata.ocId,
session: NCNetworking.shared.sessionDownload,
selector: NCGlobal.shared.selectorSaveAlbum,
sceneIdentifier: controller?.sceneIdentifier) {
await NCNetworking.shared.downloadFile(metadata: metadata)
}
}
}
}
completion?()
}
}
}
76 changes: 72 additions & 4 deletions iOSClient/Menu/NCContextMenuViewer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ class NCContextMenuViewer: NSObject {
)
}

// FAVORITE
if !metadata.lock {
topMenuItems.append(NCContextMenuActions.favorite(metadata: metadata))
}

// VIEW IN FOLDER
if !webView {
menuElements.append(makeViewInFolderAction(metadata: metadata, controller: controller, viewController: viewController))
}

// OFFLINE
if !webView,
metadata.canSetAsAvailableOffline {
menuElements.append(NCContextMenuActions.setAvailableOffline(metadatas: [metadata], isAnyOffline: isOffline, controller: controller))
Expand All @@ -86,33 +89,98 @@ class NCContextMenuViewer: NSObject {
menuElements.append(NCContextMenuActions.saveAsScan(metadata: metadata, sceneIdentifier: controller.sceneIdentifier))
}

//
// RENAME
//
// if !webView, metadata.isRenameable, !metadata.isDirectoryE2EE {
// menuElements.append(
// UIAction(
// title: NSLocalizedString("_rename_", comment: ""),
// image: NCUtility().loadImage(named: "rename", colors: [NCBrandColor.shared.iconImageColor]).withTintColor(NCBrandColor.shared.iconImageColor),
// ) { _ 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)
//
// controller.present(popup, animated: true)
// }
// }
// )
// }
if !webView,
metadata.isRenameable {
menuElements.append(NCContextMenuActions.rename(metadata: metadata, presenter: viewController ?? controller, windowScene: windowScene))
}

//
// SAVE CAMERA ROLL
//
if !webView, metadata.isSavebleInCameraRoll {
menuElements.append(ContextMenuActions.saveMediaAction(selectedMediaMetadatas: [metadata], controller: controller))
}

// COPY - MOVE
if !webView,
metadata.isCopyableMovable {
menuElements.append(NCContextMenuActions.moveOrCopy(metadatas: [metadata], account: metadata.account, controller: controller))
}

// LIVE PHOTO
if !webView,
NCNetworking.shared.isOnline,
let metadataMOV = NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) {
menuElements.append(NCContextMenuActions.saveLivePhoto(metadata: metadata, metadataMOV: metadataMOV, windowScene: windowScene))
}

//
// ADD TO ALBUM
//
// Check if file is image or video and add "Add to Album" action
if metadata.isImage || metadata.isVideo {
menuElements.append(UIAction(
title: NSLocalizedString("_add_to_album", comment: ""),
image: NCUtility().loadImage(named: "plus", colors: [NCBrandColor.shared.iconImageColor], size: 24).withTintColor(NCBrandColor.shared.iconImageColor),
handler: { _ in
// Present existing albums UI to add this media item
NCMediaNavigationController.presentExistingAlbums(presentingController: controller, selectedPhotos: [metadata.ocId], account: metadata.account)
}
))
}

// // COPY - MOVE
// if !webView, metadata.isCopyableMovable {
// menuElements.append(ContextMenuActions.moveOrCopy(
// metadatas: [metadata],
// account: metadata.account,
// controller: controller
// ))
// }

// COPY IN PASTEBOARD
if !webView, metadata.isCopyableInPasteboard, !metadata.isDirectoryE2EE {
// menuElements.append(ContextMenuActions.copyAction(fileSelect: [metadata.ocId], controller: controller))
}

// PDF ACTIONS
if !webView,
metadata.isPDF {
menuElements.append(contentsOf: makePDFActions())
}

// MODIFY WITH QUICK LOOK
if !webView,
metadata.isImage,
utilityFileSystem.fileSizeIfExists(metadata) {
menuElements.append(makeModifyPhoto())
}

// DELETE
if !webView,
metadata.isDeletable {
menuElements.append(UIMenu(options: .displayInline, children: [
Expand Down Expand Up @@ -142,7 +210,7 @@ class NCContextMenuViewer: NSObject {
private func makeViewInFolderAction(metadata: tableMetadata, controller: NCMainTabBarController, viewController: UIViewController?) -> UIAction {
UIAction(
title: NSLocalizedString("_view_in_folder_", comment: ""),
image: UIImage(systemName: "questionmark.folder")
image: NCUtility().loadImage(named: "arrow.forward.square", colors: [NCBrandColor.shared.iconImageColor]).withTintColor(NCBrandColor.shared.iconImageColor)
) { _ in
Task {
if let files = await NCNetworking.shared.moveInFolder(serverUrl: metadata.serverUrl,
Expand Down Expand Up @@ -171,15 +239,15 @@ class NCContextMenuViewer: NSObject {
[
UIAction(
title: NSLocalizedString("_search_", comment: ""),
image: UIImage(systemName: "magnifyingglass")
image: UIImage(named: "search")?.withTintColor(NCBrandColor.shared.iconImageColor)
) { _ in
NotificationCenter.default.postOnMainThread(
name: NCGlobal.shared.notificationCenterMenuSearchTextPDF
)
},
UIAction(
title: NSLocalizedString("_go_to_page_", comment: ""),
image: UIImage(systemName: "number.circle")
image: UIImage(named: "go-to-page")?.image(color: NCBrandColor.shared.iconImageColor, size: 24).withTintColor(NCBrandColor.shared.iconImageColor)
) { _ in
NotificationCenter.default.postOnMainThread(
name: NCGlobal.shared.notificationCenterMenuGotToPageInPDF
Expand All @@ -191,7 +259,7 @@ class NCContextMenuViewer: NSObject {
private func makeModifyPhoto() -> UIAction {
return UIAction(
title: NSLocalizedString("_modify_", comment: ""),
image: utility.loadImage(named: "pencil.tip.crop.circle", colors: [NCBrandColor.shared.iconImageColor])
image: utility.loadImage(named: "pencil.tip.crop.circle", colors: [NCBrandColor.shared.iconImageColor], size: 24).withTintColor(NCBrandColor.shared.iconImageColor)
) { _ in
Task {
await NCNetworking.shared.transferDispatcher.notifyAllDelegates { delegate in
Expand Down
Loading