Skip to content
Merged
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: 3 additions & 3 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,7 @@
isa = PBXGroup;
children = (
F7603298252F0E550015A421 /* Collection Common */,
F7DFB7E9219C5A0500680748 /* Create cloud */,
F7DFB7E9219C5A0500680748 /* Create */,
F7226EDB1EE4089300EBECB1 /* Main.storyboard */,
F7B934FD2BDCFE1E002B2FC9 /* NCDragDrop.swift */,
F794E13C2BBBFF2E003693D7 /* NCMainTabBarController.swift */,
Expand Down Expand Up @@ -3116,7 +3116,7 @@
path = TOPasscodeViewController;
sourceTree = "<group>";
};
F7DFB7E9219C5A0500680748 /* Create cloud */ = {
F7DFB7E9219C5A0500680748 /* Create */ = {
isa = PBXGroup;
children = (
F7FA7FFD2C0F4F3B0072FC60 /* Upload Assets */,
Expand All @@ -3126,7 +3126,7 @@
F704B5E82430C0B800632F5F /* NCCreateFormUploadConflictCell.swift */,
F704B5E62430C06700632F5F /* NCCreateFormUploadConflictCell.xib */,
);
path = "Create cloud";
path = Create;
sourceTree = "<group>";
};
F7E9C41320F4CA870040CF18 /* Transfers */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
}
}
await MainActor.run {
LucidBanner.shared.dismiss(for: token)
LucidBanner.shared.dismiss()
}

if results.nkError == .success || results.afError?.isExplicitlyCancelledError ?? false {
Expand Down Expand Up @@ -153,9 +153,9 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
}
let identifier = indexPath as NSCopying
var image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: global.previewExt1024, userId: metadata.userId, urlBase: metadata.urlBase)
let cell = collectionView.cellForItem(at: indexPath)

if image == nil {
let cell = collectionView.cellForItem(at: indexPath)
if cell is NCListCell {
image = (cell as? NCListCell)?.imageItem.image
} else if cell is NCGridCell {
Expand All @@ -168,7 +168,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
return UIContextMenuConfiguration(identifier: identifier, previewProvider: {
return NCViewerProviderContextMenu(metadata: metadata, image: image, sceneIdentifier: self.sceneIdentifier)
}, actionProvider: { _ in
let contextMenu = NCContextMenu(metadata: metadata.detachedCopy(), viewController: self, sceneIdentifier: self.sceneIdentifier, image: image)
let contextMenu = NCContextMenu(metadata: metadata.detachedCopy(), viewController: self, sceneIdentifier: self.sceneIdentifier, image: image, sender: cell)
return contextMenu.viewMenu()
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
}
}
}
LucidBanner.shared.dismiss(for: token)
LucidBanner.shared.dismiss()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ extension NCSectionFirstHeader: UICollectionViewDelegate {
return UIContextMenuConfiguration(identifier: identifier, previewProvider: {
return NCViewerProviderContextMenu(metadata: metadata, image: image, sceneIdentifier: self.sceneIdentifier)
}, actionProvider: { _ in
let contextMenu = NCContextMenu(metadata: metadata.detachedCopy(), viewController: viewController, sceneIdentifier: self.sceneIdentifier, image: image)
let cell = collectionView.cellForItem(at: indexPath)
let contextMenu = NCContextMenu(metadata: metadata.detachedCopy(), viewController: viewController, sceneIdentifier: self.sceneIdentifier, image: image, sender: cell)
return contextMenu.viewMenu()
})
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,14 @@ class NCCreate: NSObject {
/// - sender: The UI element that triggered the action (for iPad popover anchoring).
@MainActor
func createActivityViewController(selectedMetadata: [tableMetadata], controller: NCMainTabBarController?, sender: Any?) async {
guard let controller else { return }
guard let controller else {
return
}

let metadatas = selectedMetadata.filter { !$0.directory }
var exportURLs: [URL] = []
var downloadMetadata: [(tableMetadata, URL)] = []

let scene = SceneManager.shared.getWindow(controller: controller)?.windowScene
let token = showHudBanner(
scene: scene,
title: NSLocalizedString("_download_in_progress_", comment: "")
)

for metadata in metadatas {
let localPath = utilityFileSystem.getDirectoryProviderStorageOcId(
Expand All @@ -254,56 +251,63 @@ class NCCreate: NSObject {
userId: metadata.userId,
urlBase: metadata.urlBase
)
let fileURL = URL(fileURLWithPath: localPath)

if utilityFileSystem.fileProviderStorageExists(metadata) {
downloadMetadata.append((metadata, fileURL))
if utilityFileSystem.fileProviderStorageExists(metadata),
let url = exportFileForSharing(from: URL(fileURLWithPath: localPath)) {
exportURLs.append(url)
} else {
downloadMetadata.append((metadata, fileURL))
downloadMetadata.append((metadata, URL(fileURLWithPath: localPath)))
}
}

// Download missing files
for (originalMetadata, localFileURL) in downloadMetadata {
guard let metadata = await NCManageDatabase.shared.setMetadataSessionInWaitDownloadAsync(
ocId: originalMetadata.ocId,
session: NCNetworking.shared.sessionDownload,
selector: "",
sceneIdentifier: controller.sceneIdentifier
) else {
LucidBanner.shared.dismiss(for: token)
return
}
if !downloadMetadata.isEmpty {
let token = showHudBanner(
scene: scene,
title: NSLocalizedString("_download_in_progress_", comment: "")
)

let results = await NCNetworking.shared.downloadFile(
metadata: metadata
) { _ in
// downloadStartHandler not used here
} progressHandler: { progress in
Task { @MainActor in
LucidBanner.shared.update(
progress: progress.fractionCompleted,
for: token
)
// Download missing files
for (originalMetadata, localFileURL) in downloadMetadata {
guard let metadata = await NCManageDatabase.shared.setMetadataSessionInWaitDownloadAsync(
ocId: originalMetadata.ocId,
session: NCNetworking.shared.sessionDownload,
selector: "",
sceneIdentifier: controller.sceneIdentifier
) else {
LucidBanner.shared.dismiss()
return
}
}

if results.nkError == .success {
if let exportedURL = exportFileForSharing(from: localFileURL) {
exportURLs.append(exportedURL)
let results = await NCNetworking.shared.downloadFile(
metadata: metadata
) { _ in
// downloadStartHandler not used here
} progressHandler: { progress in
Task { @MainActor in
LucidBanner.shared.update(
progress: progress.fractionCompleted,
for: token
)
}
}
} else {
Task { @MainActor in
showErrorBanner(
scene: scene,
errorDescription: results.nkError.errorDescription,
errorCode: results.nkError.errorCode
)

if results.nkError == .success {
if let url = exportFileForSharing(from: localFileURL) {
exportURLs.append(url)
}
} else {
Task { @MainActor in
showErrorBanner(
scene: scene,
errorDescription: results.nkError.errorDescription,
errorCode: results.nkError.errorCode
)
}
}
}
}

LucidBanner.shared.dismiss(for: token)
LucidBanner.shared.dismiss()
}

guard !exportURLs.isEmpty else { return }

Expand Down
46 changes: 22 additions & 24 deletions iOSClient/Main/NCDragDrop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import UIKit
import UniformTypeIdentifiers
import NextcloudKit
import Alamofire
import LucidBanner

class NCDragDrop: NSObject {
let utilityFileSystem = NCUtilityFileSystem()
Expand Down Expand Up @@ -181,25 +182,29 @@ class NCDragDrop: NSObject {

@MainActor
func transfers(collectionViewCommon: NCCollectionViewCommon, destination: String, session: NCSession.Session) async {
defer {
LucidBanner.shared.dismiss()
}

guard let metadatas = DragDropHover.shared.sourceMetadatas else {
return
}
let hud = NCHud(collectionViewCommon.controller?.view)
var uploadRequest: UploadRequest?
var downloadRequest: DownloadRequest?

func setDetailText(status: String, percent: Int) {
let text = "\(NSLocalizedString("_tap_to_cancel_", comment: "")) \(status) (\(percent)%)"
hud.setDetailText(text)
}

hud.pieProgress(text: NSLocalizedString("_keep_active_for_transfers_", comment: ""),
tapToCancelDetailText: true) {
if let downloadRequest {
downloadRequest.cancel()
} else if let uploadRequest {
uploadRequest.cancel()
}
let scene = SceneManager.shared.getWindow(sceneIdentifier: collectionViewCommon.controller?.sceneIdentifier)?.windowScene

let token = showUploadBanner(
scene: scene,
title: NSLocalizedString("_transfer_in_progress_", comment: ""),
subtitle: NSLocalizedString("_keep_active_for_transfers_", comment: ""),
footnote: "( " + NSLocalizedString("_tap_to_cancel_", comment: "") + " )",
systemImage: "arrow.left.arrow.right.circle",
imageAnimation: .pulsebyLayer) { _, _ in
if let downloadRequest {
downloadRequest.cancel()
} else if let uploadRequest {
uploadRequest.cancel()
}
}

for (index, metadata) in metadatas.enumerated() {
Expand All @@ -214,12 +219,9 @@ class NCDragDrop: NSObject {
if !utilityFileSystem.fileProviderStorageExists(metadata) {
let results = await NCNetworking.shared.downloadFile(metadata: metadata) { request in
downloadRequest = request
} progressHandler: { progress in
let status = NSLocalizedString("_status_downloading_", comment: "").lowercased()
setDetailText(status: status, percent: Int(progress.fractionCompleted * 100))
}
guard results.nkError == .success else {
hud.error(text: results.nkError.errorDescription)
showErrorBanner(scene: scene, errorDescription: results.nkError.errorDescription, errorCode: results.nkError.errorCode)
break
}
}
Expand All @@ -239,20 +241,16 @@ class NCDragDrop: NSObject {
creationDate: metadata.creationDate as Date,
dateModificationFile: metadata.date as Date) { request in
uploadRequest = request
} progressHandler: { _, _, fractionCompleted in
let status = NSLocalizedString("_status_uploading_", comment: "").lowercased()
setDetailText(status: status, percent: Int(fractionCompleted * 100))
}
guard results.error == .success else {
hud.error(text: results.error.errorDescription)
showErrorBanner(scene: scene, errorDescription: results.error.errorDescription, errorCode: results.error.errorCode)
break
}

hud.progress(Double(index + 1) / Double(metadatas.count))
LucidBanner.shared.update(progress: Double(index + 1) / Double(metadatas.count), for: token)
}

await collectionViewCommon.getServerData(forced: true)
hud.success()
}
}

Expand Down
3 changes: 2 additions & 1 deletion iOSClient/Media/NCMedia+CollectionViewDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ extension NCMedia: UICollectionViewDelegate {
return UIContextMenuConfiguration(identifier: identifier, previewProvider: {
return NCViewerProviderContextMenu(metadata: metadata, image: image, sceneIdentifier: self.sceneIdentifier)
}, actionProvider: { _ in
let contextMenu = NCContextMenu(metadata: metadata.detachedCopy(), viewController: self, sceneIdentifier: self.sceneIdentifier, image: image)
let cell = collectionView.cellForItem(at: indexPath)
let contextMenu = NCContextMenu(metadata: metadata.detachedCopy(), viewController: self, sceneIdentifier: self.sceneIdentifier, image: image, sender: collectionView)
return contextMenu.viewMenu()
})
}
Expand Down
Loading
Loading