From cdf61c41ed1ed4aa8581020eccab47b82b8d35f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 3 Feb 2024 18:02:18 +0100 Subject: [PATCH 01/17] Adds v3.1.3 preliminary release notes --- piwigo.xcodeproj/project.pbxproj | 4 ++-- piwigo/Resources/en.lproj/ReleaseNotes.strings | 4 +++- piwigo/Settings/Information/ReleaseNotesViewController.swift | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/piwigo.xcodeproj/project.pbxproj b/piwigo.xcodeproj/project.pbxproj index ae7a4d3ec..30dbb09e5 100644 --- a/piwigo.xcodeproj/project.pbxproj +++ b/piwigo.xcodeproj/project.pbxproj @@ -4072,7 +4072,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 3.1.2; + MARKETING_VERSION = 3.1.3; MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; MTL_ENABLE_DEBUG_INFO = YES; @@ -4139,7 +4139,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 3.1.2; + MARKETING_VERSION = 3.1.3; MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu99 gnu++11"; MTL_ENABLE_DEBUG_INFO = NO; diff --git a/piwigo/Resources/en.lproj/ReleaseNotes.strings b/piwigo/Resources/en.lproj/ReleaseNotes.strings index 87eed52e2..c1f83cd28 100644 --- a/piwigo/Resources/en.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/en.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "Version 3.1.2\n\n• Requests Piwigo server update if necessary\n• Bug fixes"; +"v3.1.3_text" = "Version 3.1.3\n\n• Bug fixes"; + +"v3.1.2_text" = "Version 3.1.2\nFebruary 1, 2024\n\n• Requests Piwigo server update if necessary\n• Bug fixes"; "v3.1.1_text" = "Version 3.1.1\nDecember 1, 2023\n\n• Updates server statistics (requires Piwigo 14)\n• Bug fixes"; diff --git a/piwigo/Settings/Information/ReleaseNotesViewController.swift b/piwigo/Settings/Information/ReleaseNotesViewController.swift index da001a625..06c4d81b0 100644 --- a/piwigo/Settings/Information/ReleaseNotesViewController.swift +++ b/piwigo/Settings/Information/ReleaseNotesViewController.swift @@ -156,6 +156,7 @@ class ReleaseNotesViewController: UIViewController { let notesAttributedString = NSMutableAttributedString(string: "") // Release 3.1.x — Bundle string + notesAttributedString.append(releaseNotes("v3.1.3_text", comment: "v3.1.3 Release Notes text")) notesAttributedString.append(releaseNotes("v3.1.2_text", comment: "v3.1.2 Release Notes text")) notesAttributedString.append(releaseNotes("v3.1.1_text", comment: "v3.1.1 Release Notes text")) notesAttributedString.append(releaseNotes("v3.1.0_text", comment: "v3.1.0 Release Notes text")) From 95bce172a76901cedbd632e9e8fb275ccc8e4dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sun, 4 Feb 2024 20:41:35 +0100 Subject: [PATCH 02/17] Speeds up compilation --- piwigo/Settings/Help/Help01ViewController.swift | 4 +++- piwigo/Settings/Help/Help02ViewController.swift | 4 +++- piwigo/Settings/Help/Help03ViewController.swift | 4 +++- piwigo/Settings/Help/Help04ViewController.swift | 4 +++- piwigo/Settings/Help/Help05ViewController.swift | 4 +++- piwigo/Settings/Help/Help06ViewController.swift | 4 +++- piwigo/Settings/Help/Help07ViewController.swift | 4 +++- piwigo/Settings/Help/Help08ViewController.swift | 4 +++- 8 files changed, 24 insertions(+), 8 deletions(-) diff --git a/piwigo/Settings/Help/Help01ViewController.swift b/piwigo/Settings/Help/Help01ViewController.swift index 65bb725a7..a4767fae0 100644 --- a/piwigo/Settings/Help/Help01ViewController.swift +++ b/piwigo/Settings/Help/Help01ViewController.swift @@ -25,7 +25,9 @@ class Help01ViewController: UIViewController { // Title let titleString = "\(NSLocalizedString("help01_header", comment: "Multiple Selection"))\n" let titleAttributedString = NSMutableAttributedString(string: titleString) - titleAttributedString.addAttribute(.font, value: view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold), range: NSRange(location: 0, length: titleString.count)) + let titleFont = view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold) + let titleRange = NSRange(location: 0, length: titleString.count) + titleAttributedString.addAttribute(.font, value: titleFont, range: titleRange) legendAttributedString.append(titleAttributedString) // Text diff --git a/piwigo/Settings/Help/Help02ViewController.swift b/piwigo/Settings/Help/Help02ViewController.swift index 5200b15ef..3817a58e8 100644 --- a/piwigo/Settings/Help/Help02ViewController.swift +++ b/piwigo/Settings/Help/Help02ViewController.swift @@ -28,7 +28,9 @@ class Help02ViewController: UIViewController { // Title of legend above images let titleString = "\(NSLocalizedString("help02_header", comment: "Background Uploading"))\n" let titleAttributedString = NSMutableAttributedString(string: titleString) - titleAttributedString.addAttribute(.font, value: view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold), range: NSRange(location: 0, length: titleString.count)) + let titleFont = view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold) + let titleRange = NSRange(location: 0, length: titleString.count) + titleAttributedString.addAttribute(.font, value: titleFont, range: titleRange) legendTopAttributedString.append(titleAttributedString) // Comment below title diff --git a/piwigo/Settings/Help/Help03ViewController.swift b/piwigo/Settings/Help/Help03ViewController.swift index 3d692d5d1..18ced3514 100644 --- a/piwigo/Settings/Help/Help03ViewController.swift +++ b/piwigo/Settings/Help/Help03ViewController.swift @@ -25,7 +25,9 @@ class Help03ViewController: UIViewController { // Title let titleString = "\(NSLocalizedString("help03_header", comment: "Administrators"))\n" let titleAttributedString = NSMutableAttributedString(string: titleString) - titleAttributedString.addAttribute(.font, value: view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold), range: NSRange(location: 0, length: titleString.count)) + let titleFont = view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold) + let titleRange = NSRange(location: 0, length: titleString.count) + titleAttributedString.addAttribute(.font, value: titleFont, range: titleRange) legendAttributedString.append(titleAttributedString) // Text diff --git a/piwigo/Settings/Help/Help04ViewController.swift b/piwigo/Settings/Help/Help04ViewController.swift index 48e865c03..039a39194 100644 --- a/piwigo/Settings/Help/Help04ViewController.swift +++ b/piwigo/Settings/Help/Help04ViewController.swift @@ -25,7 +25,9 @@ class Help04ViewController: UIViewController { // Title let titleString = NSLocalizedString("localImages_deleteTitle", comment: "Remove from Camera Roll") + "\n" let titleAttributedString = NSMutableAttributedString(string: titleString) - titleAttributedString.addAttribute(.font, value: view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold), range: NSRange(location: 0, length: titleString.count)) + let titleFont = view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold) + let titleRange = NSRange(location: 0, length: titleString.count) + titleAttributedString.addAttribute(.font, value: titleFont, range: titleRange) legendAttributedString.append(titleAttributedString) // Text diff --git a/piwigo/Settings/Help/Help05ViewController.swift b/piwigo/Settings/Help/Help05ViewController.swift index 3e6b2fac7..839b6b739 100644 --- a/piwigo/Settings/Help/Help05ViewController.swift +++ b/piwigo/Settings/Help/Help05ViewController.swift @@ -28,7 +28,9 @@ class Help05ViewController: UIViewController { // Title of legend above images let titleString = "\(NSLocalizedString("help05_header", comment: "Upload Photos"))\n" let titleAttributedString = NSMutableAttributedString(string: titleString) - titleAttributedString.addAttribute(.font, value: view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold), range: NSRange(location: 0, length: titleString.count)) + let titleFont = view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold) + let titleRange = NSRange(location: 0, length: titleString.count) + titleAttributedString.addAttribute(.font, value: titleFont, range: titleRange) legendTopAttributedString.append(titleAttributedString) // Text of legend above images diff --git a/piwigo/Settings/Help/Help06ViewController.swift b/piwigo/Settings/Help/Help06ViewController.swift index 1fe188cb9..30894b981 100644 --- a/piwigo/Settings/Help/Help06ViewController.swift +++ b/piwigo/Settings/Help/Help06ViewController.swift @@ -25,7 +25,9 @@ class Help06ViewController: UIViewController { // Title let titleString = "\(NSLocalizedString("help06_header", comment: "Upload Management"))\n" let titleAttributedString = NSMutableAttributedString(string: titleString) - titleAttributedString.addAttribute(.font, value: view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold), range: NSRange(location: 0, length: titleString.count)) + let titleFont = view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold) + let titleRange = NSRange(location: 0, length: titleString.count) + titleAttributedString.addAttribute(.font, value: titleFont, range: titleRange) legendAttributedString.append(titleAttributedString) // Text diff --git a/piwigo/Settings/Help/Help07ViewController.swift b/piwigo/Settings/Help/Help07ViewController.swift index 7334506f8..a98e4b0cf 100644 --- a/piwigo/Settings/Help/Help07ViewController.swift +++ b/piwigo/Settings/Help/Help07ViewController.swift @@ -28,7 +28,9 @@ class Help07ViewController: UIViewController { // Title of legend above images let titleString = "\(NSLocalizedString("help07_header", comment: "Auto-Uploading"))\n" let titleAttributedString = NSMutableAttributedString(string: titleString) - titleAttributedString.addAttribute(.font, value: view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold), range: NSRange(location: 0, length: titleString.count)) + let titleFont = view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold) + let titleRange = NSRange(location: 0, length: titleString.count) + titleAttributedString.addAttribute(.font, value: titleFont, range: titleRange) legendTopAttributedString.append(titleAttributedString) // Comment below title diff --git a/piwigo/Settings/Help/Help08ViewController.swift b/piwigo/Settings/Help/Help08ViewController.swift index 4b47f7d40..8d838884f 100644 --- a/piwigo/Settings/Help/Help08ViewController.swift +++ b/piwigo/Settings/Help/Help08ViewController.swift @@ -28,7 +28,9 @@ class Help08ViewController: UIViewController { // Title of legend above images let titleString = "\(NSLocalizedString("help08_header", comment: "Parent Albums"))\n" let titleAttributedString = NSMutableAttributedString(string: titleString) - titleAttributedString.addAttribute(.font, value: view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold), range: NSRange(location: 0, length: titleString.count)) + let titleFont = view.bounds.size.width > 320 ? UIFont.systemFont(ofSize: 17, weight: .bold) : UIFont.systemFont(ofSize: 17, weight: .semibold) + let titleRange = NSRange(location: 0, length: titleString.count) + titleAttributedString.addAttribute(.font, value: titleFont, range: titleRange) legendTopAttributedString.append(titleAttributedString) // Text of legend above images From b7b2f4a49a16668ba9245f7c1ccd469cede28c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sun, 4 Feb 2024 21:49:31 +0100 Subject: [PATCH 03/17] Fixes crash occurring when changing album thumbnail --- .../SelectCategoryViewController.swift | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/piwigo/Album/AlbumSelector/SelectCategoryViewController.swift b/piwigo/Album/AlbumSelector/SelectCategoryViewController.swift index 936c82d00..405cefdd1 100644 --- a/piwigo/Album/AlbumSelector/SelectCategoryViewController.swift +++ b/piwigo/Album/AlbumSelector/SelectCategoryViewController.swift @@ -1054,12 +1054,23 @@ class SelectCategoryViewController: UIViewController, UITableViewDataSource, UIT extension SelectCategoryViewController: NSFetchedResultsControllerDelegate { func controllerWillChangeContent(_ controller: NSFetchedResultsController) { + // Check that this update should be managed by this view controller + if view.window == nil || [recentAlbums, albums].contains(controller) == false || + (wantedAction == .setAlbumThumbnail && controller == recentAlbums) { + return + } // Begin the update categoriesTableView.beginUpdates() } func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) { + // Check that this update should be managed by this view controller + if view.window == nil || [recentAlbums, albums].contains(controller) == false || + (wantedAction == .setAlbumThumbnail && controller == recentAlbums) { + return + } + // Initialisation var hasAlbumsInSection1 = false if controller == albums, categoriesTableView.numberOfSections == 2 { @@ -1071,12 +1082,12 @@ extension SelectCategoryViewController: NSFetchedResultsControllerDelegate { case .insert: guard var newIndexPath = newIndexPath else { return } if hasAlbumsInSection1 { newIndexPath.section = 1 } - print("••> Insert category item at \(newIndexPath)") + debugPrint("••> Insert category item at \(newIndexPath)") categoriesTableView?.insertRows(at: [newIndexPath], with: .automatic) case .update: guard var indexPath = indexPath else { return } if hasAlbumsInSection1 { indexPath.section = 1 } - print("••> Update category item at \(indexPath)") + debugPrint("••> Update category item at \(indexPath)") categoriesTableView?.reloadRows(at: [indexPath], with: .automatic) case .move: guard var indexPath = indexPath, var newIndexPath = newIndexPath else { return } @@ -1084,12 +1095,12 @@ extension SelectCategoryViewController: NSFetchedResultsControllerDelegate { indexPath.section = 1 newIndexPath.section = 1 } - print("••> Move category item from \(indexPath) to \(newIndexPath)") + debugPrint("••> Move category item from \(indexPath) to \(newIndexPath)") categoriesTableView?.moveRow(at: indexPath, to: newIndexPath) case .delete: guard var indexPath = indexPath else { return } if hasAlbumsInSection1 { indexPath.section = 1 } - print("••> Delete category item at \(indexPath)") + debugPrint("••> Delete category item at \(indexPath)") categoriesTableView?.deleteRows(at: [indexPath], with: .automatic) @unknown default: debugPrint("SelectCategoryViewController: unknown NSFetchedResultsChangeType") @@ -1097,6 +1108,11 @@ extension SelectCategoryViewController: NSFetchedResultsControllerDelegate { } func controllerDidChangeContent(_ controller: NSFetchedResultsController) { + // Check that this update should be managed by this view controller + if view.window == nil || [recentAlbums, albums].contains(controller) == false || + (wantedAction == .setAlbumThumbnail && controller == recentAlbums) { + return + } // End updates categoriesTableView.endUpdates() } From 7a4b28d60449cbf247310772fbdf0e7219c95304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sun, 4 Feb 2024 21:51:25 +0100 Subject: [PATCH 04/17] Fixes thumbnail not loaded when the file size is not set and default to NSURLSessionTransferSizeUnknown --- piwigo/Image/Download/ImageDownload.swift | 4 +-- piwigo/Image/Download/ImageSession.swift | 39 ++++++++++++----------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/piwigo/Image/Download/ImageDownload.swift b/piwigo/Image/Download/ImageDownload.swift index e996d4add..23400ef64 100644 --- a/piwigo/Image/Download/ImageDownload.swift +++ b/piwigo/Image/Download/ImageDownload.swift @@ -26,7 +26,7 @@ class ImageDownload { // MARK: - Initialization init(imageID: Int64, ofSize imageSize: pwgImageSize, atURL imageURL: URL, - fromServer serverID: String, fileSize: Int64 = NSURLSessionTransferSizeUnknown, + fromServer serverID: String, fileSize: Int64 = .zero, placeHolder: UIImage, progress: ((Float) -> Void)? = nil, completion: @escaping (URL) -> Void, failure: @escaping (Error) -> Void) { @@ -37,7 +37,7 @@ class ImageDownload { // Store file size and handlers self.imageURL = imageURL - self.fileSize = fileSize == Int64.zero ? NSURLSessionTransferSizeUnknown : fileSize + self.fileSize = fileSize self.placeHolder = placeHolder self.progressHandler = progress self.completionHandler = completion diff --git a/piwigo/Image/Download/ImageSession.swift b/piwigo/Image/Download/ImageSession.swift index 4f3119c1e..b772c7370 100644 --- a/piwigo/Image/Download/ImageSession.swift +++ b/piwigo/Image/Download/ImageSession.swift @@ -83,7 +83,7 @@ class ImageSession: NSObject { // MARK: - Asynchronous Methods func getImage(withID imageID: Int64?, ofSize imageSize: pwgImageSize, atURL imageURL: URL?, - fromServer serverID: String?, fileSize: Int64 = NSURLSessionTransferSizeUnknown, + fromServer serverID: String?, fileSize: Int64 = .zero, placeHolder: UIImage, progress: ((Float) -> Void)? = nil, completion: @escaping (URL) -> Void, failure: @escaping (Error) -> Void) { // Check arguments @@ -106,10 +106,9 @@ class ImageSession: NSObject { progress: progress, completion: completion, failure: failure) // Do we already have this image or video in cache? - if download.fileURL.fileSize != 0 { + if download.fileURL.fileSize > 0 { // We do have an image in cache, but is this the image or expected video? - if imageSize == .fullRes, - [NSURLSessionTransferSizeUnknown, 0].contains(fileSize) == false { + if imageSize == .fullRes { let cachedFileSize = download.fileURL.fileSize let diff = abs((Double(cachedFileSize) - Double(fileSize)) / Double(fileSize)) // print("••> Image \(download.fileURL.lastPathComponent) of \(cachedFileSize) bytes (\((diff * 1000).rounded(.awayFromZero)/10)%) retrieved from cache.") @@ -118,6 +117,7 @@ class ImageSession: NSObject { return } } else { +// debugPrint("••> return cached image \(String(describing: download.fileURL.lastPathComponent)) i.e., downloaded from \(imageURL)") completion(download.fileURL) return } @@ -126,17 +126,18 @@ class ImageSession: NSObject { // Download this image in the background thread downloadQueue.async { guard let download = self.activeDownloads[imageURL] else { -// print("••> Launch download: \(imageURL.lastPathComponent)") +// debugPrint("••> Launch download of image: \(imageURL)") download.task = self.dataSession.downloadTask(with: request) download.task?.countOfBytesClientExpectsToSend = Int64((request.allHTTPHeaderFields ?? [:]).count) - download.task?.countOfBytesClientExpectsToReceive = download.fileSize + let expectedSize: Int64 = fileSize == .zero ? NSURLSessionTransferSizeUnknown : fileSize + download.task?.countOfBytesClientExpectsToReceive = expectedSize download.task?.resume() self.activeDownloads[imageURL] = download return } // Resume download -// print("••> Resume download: \(imageURL)") +// debugPrint("••> Resume download of image: \(imageURL)") download.progressHandler = progress if let progressHandler = download.progressHandler { progressHandler(download.progress) @@ -163,7 +164,7 @@ class ImageSession: NSObject { // Cancel the download request download.task?.cancel(byProducingResumeData: { imageData in -// print("••> Pause download: \(imageURL.lastPathComponent)") +// debugPrint("••> Pause download: \(imageURL)") download.resumeData = imageData }) } @@ -175,7 +176,7 @@ class ImageSession: NSObject { } // Cancel the download request -// print("••> Cancel download: \(imageURL.lastPathComponent)") +// debugPrint("••> Cancel download: \(imageURL)") download.task?.cancel() activeDownloads[imageURL] = nil } @@ -186,13 +187,13 @@ class ImageSession: NSObject { extension ImageSession: URLSessionDelegate { func urlSession(_ session: URLSession, didBecomeInvalidWithError error: Error?) { -// print(" > The data session has been invalidated") +// debugPrint(" > The data session has been invalidated") activeDownloads = [ : ] } func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { -// print(" > Session-level authentication request from the remote server.") +// debugPrint(" > Session-level authentication request from the remote server.") // Get protection space for current domain let protectionSpace = challenge.protectionSpace @@ -246,7 +247,7 @@ extension ImageSession: URLSessionDelegate { extension ImageSession: URLSessionTaskDelegate { func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { - print(" > Task-level authentication request from the remote server") +// debugPrint(" > Task-level authentication request from the remote server") // Check authentication method let authMethod = challenge.protectionSpace.authenticationMethod @@ -287,7 +288,7 @@ extension ImageSession: URLSessionTaskDelegate { } } else { // Return cached image with completionHandler -// print("••> Did complete task #\(task.taskIdentifier)") +// debugPrint("••> Did complete task #\(task.taskIdentifier)") if let completion = download.completionHandler, let fileURL = download.fileURL { completion(fileURL) @@ -306,8 +307,8 @@ extension ImageSession: URLSessionDownloadDelegate { didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) { // Retrieve the original URL of this task -// print("••> Progress task #\(downloadTask.taskIdentifier) -> \(String(describing: downloadTask.currentRequest?.url))") -// print(" amongst \(activeDownloads.count) active downloads.") +// debugPrint("••> Progress task #\(downloadTask.taskIdentifier) -> \(String(describing: downloadTask.currentRequest?.url))") +// debugPrint(" amongst \(activeDownloads.count) active downloads.") guard let imageURL = downloadTask.originalRequest?.url ?? downloadTask.currentRequest?.url, let download = activeDownloads[imageURL] else { return @@ -316,7 +317,7 @@ extension ImageSession: URLSessionDownloadDelegate { // Update progress bar if any if let progressHandler = download.progressHandler { download.progress = Float(totalBytesWritten) / Float(totalBytesExpectedToWrite) -// print("••> Progress task #\(downloadTask.taskIdentifier) -> \(download.progress)") +// debugPrint("••> Progress task #\(downloadTask.taskIdentifier) -> \(download.progress)") progressHandler(download.progress) } } @@ -324,7 +325,7 @@ extension ImageSession: URLSessionDownloadDelegate { func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) { // Retrieve the URL of this task - print("••> Task #\(downloadTask.taskIdentifier) did finish downloading.") +// debugPrint("••> Task #\(downloadTask.taskIdentifier) did finish downloading.") guard let imageURL = downloadTask.originalRequest?.url ?? downloadTask.currentRequest?.url, let download = activeDownloads[imageURL], let fileURL = download.fileURL else { @@ -336,7 +337,7 @@ extension ImageSession: URLSessionDownloadDelegate { let fm = FileManager.default let dirURL = fileURL.deletingLastPathComponent() if fm.fileExists(atPath: dirURL.path) == false { - print("••> Create directory \(dirURL.path)") +// debugPrint("••> Create directory \(dirURL.path)") try fm.createDirectory(at: dirURL, withIntermediateDirectories: true, attributes: nil) } @@ -346,7 +347,7 @@ extension ImageSession: URLSessionDownloadDelegate { // Store image try fm.copyItem(at: location, to: fileURL) - print("••> Image \(fileURL.lastPathComponent) stored in cache") +// debugPrint("••> Image \(fileURL.lastPathComponent) stored in cache (downloaded at \(String(describing: download.imageURL)))") } catch { // Return error with failureHandler if let failure = download.failureHandler { From 0b99bb338ac31424c8b9a81495b174c3f7d78c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sun, 4 Feb 2024 21:51:44 +0100 Subject: [PATCH 05/17] Logs only in debug mode --- piwigo/Album/AlbumViewController.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/piwigo/Album/AlbumViewController.swift b/piwigo/Album/AlbumViewController.swift index e26a179ef..058a44461 100644 --- a/piwigo/Album/AlbumViewController.swift +++ b/piwigo/Album/AlbumViewController.swift @@ -1636,13 +1636,13 @@ extension AlbumViewController: NSFetchedResultsControllerDelegate { selectedImageIds.remove(image.pwgID) } updateOperations.append( BlockOperation { [weak self] in - print("••> Delete item of album #\(fetchDelegate.categoryId) at \(indexPath)") + debugPrint("••> Delete item of album #\(fetchDelegate.categoryId) at \(indexPath)") self?.imagesCollection?.deleteItems(at: [indexPath]) }) // Disable menu if this is the last deleted image if albumData.nbImages == 0 { updateOperations.append( BlockOperation { [weak self] in - print("••> Last removed image ► disable menu") + debugPrint("••> Last removed image ► disable menu") self?.isSelect = false self?.updateButtonsInPreviewMode() }) @@ -1652,7 +1652,7 @@ extension AlbumViewController: NSFetchedResultsControllerDelegate { if let image = anObject as? Image { let cellIndexPath = IndexPath(item: indexPath.item, section: 1) updateOperations.append( BlockOperation { [weak self] in - print("••> Update image at \(cellIndexPath) of album #\(fetchDelegate.categoryId)") + debugPrint("••> Update image at \(cellIndexPath) of album #\(fetchDelegate.categoryId)") if let cell = self?.imagesCollection?.cellForItem(at: cellIndexPath) as? ImageCollectionViewCell { // Re-configure image cell cell.config(with: image, inCategoryId: fetchDelegate.categoryId) @@ -1665,7 +1665,7 @@ extension AlbumViewController: NSFetchedResultsControllerDelegate { }) } else if let album = anObject as? Album { updateOperations.append( BlockOperation { [weak self] in - print("••> Update album at \(indexPath) of album #\(fetchDelegate.categoryId)") + debugPrint("••> Update album at \(indexPath) of album #\(fetchDelegate.categoryId)") if let cell = self?.imagesCollection?.cellForItem(at: indexPath) as? AlbumCollectionViewCell { // Re-configure album cell cell.albumData = album @@ -1676,13 +1676,13 @@ extension AlbumViewController: NSFetchedResultsControllerDelegate { guard var newIndexPath = newIndexPath else { return } if anObject is Image { newIndexPath.section = 1 } updateOperations.append( BlockOperation { [weak self] in - print("••> Insert item of album #\(fetchDelegate.categoryId) at \(newIndexPath)") + debugPrint("••> Insert item of album #\(fetchDelegate.categoryId) at \(newIndexPath)") self?.imagesCollection?.insertItems(at: [newIndexPath]) }) // Enable menu if this is the first added image if albumData.nbImages == 1 { updateOperations.append( BlockOperation { [weak self] in - print("••> First added image ► enable menu") + debugPrint("••> First added image ► enable menu") self?.updateButtonsInPreviewMode() }) } @@ -1695,7 +1695,7 @@ extension AlbumViewController: NSFetchedResultsControllerDelegate { newIndexPath.section = 1 } updateOperations.append( BlockOperation { [weak self] in - print("••> Move item of album #\(fetchDelegate.categoryId) from \(indexPath) to \(newIndexPath)") + debugPrint("••> Move item of album #\(fetchDelegate.categoryId) from \(indexPath) to \(newIndexPath)") self?.imagesCollection?.moveItem(at: indexPath, to: newIndexPath) }) default: From 11e7e0948ff0d935f975fa7ce8d878cdb83ad155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 10 Feb 2024 11:04:18 +0100 Subject: [PATCH 06/17] Moves Info.plist files of frameworks to root --- piwigoKit/{Resources => }/Info.plist | 0 uploadKit/{Resources => }/Info.plist | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename piwigoKit/{Resources => }/Info.plist (100%) rename uploadKit/{Resources => }/Info.plist (100%) diff --git a/piwigoKit/Resources/Info.plist b/piwigoKit/Info.plist similarity index 100% rename from piwigoKit/Resources/Info.plist rename to piwigoKit/Info.plist diff --git a/uploadKit/Resources/Info.plist b/uploadKit/Info.plist similarity index 100% rename from uploadKit/Resources/Info.plist rename to uploadKit/Info.plist From 36acca62510f4bf34650c7cbe3096785d349de96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 10 Feb 2024 11:28:50 +0100 Subject: [PATCH 07/17] Fixes image resizing by not updating image resolution (API returns different width and height resolutions!), Addds HEIC, TAG andd WebP properties management --- piwigo.xcodeproj/project.pbxproj | 12 +- .../Extensions/UploadManager+Image.swift | 17 +- uploadKit/Info.plist | 2 +- .../Supporting Files/ImageMetadata.swift | 275 +++++++++--------- 4 files changed, 150 insertions(+), 156 deletions(-) diff --git a/piwigo.xcodeproj/project.pbxproj b/piwigo.xcodeproj/project.pbxproj index 30dbb09e5..50c93c212 100644 --- a/piwigo.xcodeproj/project.pbxproj +++ b/piwigo.xcodeproj/project.pbxproj @@ -1210,6 +1210,7 @@ AD2913E826696A8300403026 /* Network */, AD7F1C162B667BDD008E100E /* Resources */, AD97CFB6265B0B0700719ED5 /* Supporting Files */, + ADA0049D2739C038006FE8ED /* Info.plist */, ); path = piwigoKit; sourceTree = ""; @@ -1401,6 +1402,7 @@ AD7F1C142B667BAF008E100E /* Extensions */, AD7F1C152B667BD2008E100E /* Resources */, AD7DE0912A85898D00C1424E /* Supporting Files */, + AD2C625C2A4899F700671582 /* Info.plist */, ); path = uploadKit; sourceTree = ""; @@ -1658,7 +1660,6 @@ isa = PBXGroup; children = ( AD2C623C2A4896A600671582 /* uploadKit.h */, - AD2C625C2A4899F700671582 /* Info.plist */, ); path = Resources; sourceTree = ""; @@ -1667,7 +1668,6 @@ isa = PBXGroup; children = ( ADA0049C2739C036006FE8ED /* piwigoKit.h */, - ADA0049D2739C038006FE8ED /* Info.plist */, ); path = Resources; sourceTree = ""; @@ -3503,7 +3503,7 @@ ENABLE_MODULE_VERIFIER = YES; ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = piwigoKit/Resources/Info.plist; + INFOPLIST_FILE = piwigoKit/Info.plist; INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2024 Piwigo.org. All rights reserved."; INSTALL_PATH = "@executable_path/../Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; @@ -3556,7 +3556,7 @@ ENABLE_MODULE_VERIFIER = YES; ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu11; - INFOPLIST_FILE = piwigoKit/Resources/Info.plist; + INFOPLIST_FILE = piwigoKit/Info.plist; INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2024 Piwigo.org. All rights reserved."; INSTALL_PATH = "@executable_path/../Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; @@ -3686,7 +3686,7 @@ ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = NO; - INFOPLIST_FILE = uploadKit/Resources/Info.plist; + INFOPLIST_FILE = uploadKit/Info.plist; INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2024 Piwigo.org. All rights reserved."; INSTALL_PATH = "@executable_path/../Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; @@ -3742,7 +3742,7 @@ ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu11; GENERATE_INFOPLIST_FILE = NO; - INFOPLIST_FILE = uploadKit/Resources/Info.plist; + INFOPLIST_FILE = uploadKit/Info.plist; INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2024 Piwigo.org. All rights reserved."; INSTALL_PATH = "@executable_path/../Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; diff --git a/uploadKit/Extensions/UploadManager+Image.swift b/uploadKit/Extensions/UploadManager+Image.swift index 901c550dc..351069ed1 100644 --- a/uploadKit/Extensions/UploadManager+Image.swift +++ b/uploadKit/Extensions/UploadManager+Image.swift @@ -176,7 +176,7 @@ extension UploadManager { failure(error) return } - + // Get number of images in source let nberOfImages = CGImageSourceGetCount(sourceRef) if nberOfImages == 0 { @@ -226,7 +226,7 @@ extension UploadManager { // Set options for retrieving the primary image let maxSize = pwgPhotoMaxSizes(rawValue: upload.photoMaxSize)?.pixels ?? Int.max let resizeOptions = [kCGImageSourceCreateThumbnailFromImageAlways : true, - kCGImageSourceCreateThumbnailWithTransform : false, + kCGImageSourceCreateThumbnailWithTransform : true, kCGImageSourceThumbnailMaxPixelSize : maxSize] as [CFString : Any] // Get image guard let resized = CGImageSourceCreateThumbnailAtIndex(sourceRef, imageIndex, @@ -306,11 +306,8 @@ extension UploadManager { return } - // Get index of the primary image (assumes 0 before iOS 12) - var imageIndex = 0 - if #available(iOS 12.0, *) { - imageIndex = CGImageSourceGetPrimaryImageIndex(sourceRef) - } + // Get index of the primary image + var imageIndex = CGImageSourceGetPrimaryImageIndex(sourceRef) // Should we resize the image? var image:CGImage @@ -318,7 +315,7 @@ extension UploadManager { // Set options for retrieving the primary image let maxSize = pwgPhotoMaxSizes(rawValue: upload.photoMaxSize)?.pixels ?? Int.max let resizeOptions = [kCGImageSourceCreateThumbnailFromImageAlways : true, - kCGImageSourceCreateThumbnailWithTransform : false, + kCGImageSourceCreateThumbnailWithTransform : true, kCGImageSourceThumbnailMaxPixelSize : maxSize] as [CFString : Any] // Get image guard let resized = CGImageSourceCreateThumbnailAtIndex(sourceRef, imageIndex, @@ -364,7 +361,7 @@ extension UploadManager { return } - // Apply properties of the source to the destination + // Apply container properties of the source to the destination /// - must be done before adding images if let containerProperties = CGImageSourceCopyProperties(sourceRef, imageSourceOptions) as? [CFString : Any] { // Should we remove private metadata? @@ -380,7 +377,7 @@ extension UploadManager { // Fix properties options.fixProperties(from: containerProperties) - // Copy metadata w/o private infos + // Copy metadata w/ or w/o private infos CGImageDestinationSetProperties(destinationRef, options as CFDictionary) } diff --git a/uploadKit/Info.plist b/uploadKit/Info.plist index 3161b7ced..00b88cc14 100644 --- a/uploadKit/Info.plist +++ b/uploadKit/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 1.0.5 + 1.0.6 CFBundleVersion 375 diff --git a/uploadKit/Supporting Files/ImageMetadata.swift b/uploadKit/Supporting Files/ImageMetadata.swift index 9e3f75a3e..cf939083a 100644 --- a/uploadKit/Supporting Files/ImageMetadata.swift +++ b/uploadKit/Supporting Files/ImageMetadata.swift @@ -225,13 +225,9 @@ extension Dictionary where Key == CFString, Value == Any { mutating func fixContents(from image:CGImage) { var metadata = self - // Extract image data from UIImage object (orientation managed) - guard let imageData = UIImage(cgImage: image).jpegData(compressionQuality: 1.0) else { - return - } - - // Create image source from image data - guard let source = CGImageSourceCreateWithData(imageData as CFData, nil) else { + // Extract image source from UIImage object (orientation managed) + guard let imageData = UIImage(cgImage: image).jpegData(compressionQuality: 1.0), + let source = CGImageSourceCreateWithData(imageData as CFData, nil) else { return } @@ -245,17 +241,7 @@ extension Dictionary where Key == CFString, Value == Any { if let imageMetadata = CGImageSourceCopyPropertiesAtIndex(source, 0, nil) as? [CFString : Any] { // Update TIFF, GIF, etc. metadata from properties found in the image metadata.fixProperties(from: imageMetadata) - - // Update/add DPI height from image properties - if let DPIheight = imageMetadata[kCGImagePropertyDPIHeight] { - metadata[kCGImagePropertyDPIHeight] = DPIheight - } - - // Update/add DPI width from image properties - if let DPIwidth = imageMetadata[kCGImagePropertyDPIWidth] { - metadata[kCGImagePropertyDPIHeight] = DPIwidth - } - + // Update/add width from image properties if let width = imageMetadata[kCGImagePropertyPixelWidth] { metadata[kCGImagePropertyPixelWidth] = width @@ -265,90 +251,16 @@ extension Dictionary where Key == CFString, Value == Any { if let height = imageMetadata[kCGImagePropertyPixelHeight] { metadata[kCGImagePropertyPixelHeight] = height } - - // Update/add depth from image properties - if let depth = imageMetadata[kCGImagePropertyDepth] { - metadata[kCGImagePropertyDepth] = depth - } - - // The orientation was unchanged during the resize or conversion. - // So we keep the original orientation. -// if let orientation = imageMetadata[kCGImagePropertyOrientation] as? UInt32 { -// metadata[kCGImagePropertyOrientation] = CGImagePropertyOrientation(rawValue: orientation) -// } - - // Update/add isFloat from image properties - if let isFloat = imageMetadata[kCGImagePropertyIsFloat] { - metadata[kCGImagePropertyIsFloat] = isFloat - } - - // Update/add isIndexed from image properties - if let isIndexed = imageMetadata[kCGImagePropertyIsIndexed] { - metadata[kCGImagePropertyIsIndexed] = isIndexed - } - - // Update/add asAlpha from image properties - if let asAlpha = imageMetadata[kCGImagePropertyHasAlpha] { - metadata[kCGImagePropertyHasAlpha] = asAlpha - } - - // Update/add colour model from image properties - if let colorModel = imageMetadata[kCGImagePropertyColorModel] { - metadata[kCGImagePropertyColorModel] = colorModel - } - - // Update/add ICC profile from image properties - if let iccProfile = imageMetadata[kCGImagePropertyProfileName] { - metadata[kCGImagePropertyProfileName] = iccProfile - } } self = metadata } // Fix image properties from (resized) image metadata - mutating func fixProperties(from imageMetadata: [CFString:Any]) { + mutating func fixProperties(from imageMetadata: [CFString: Any]) { var metadata = self - // Update TIFF dictionary from image metadata - if let imageTIFFDictionary = imageMetadata[kCGImagePropertyTIFFDictionary] as? [CFString : Any] { - // Image contains a TIFF dictionary - if var metadataTIFFDictionary = metadata[kCGImagePropertyTIFFDictionary] as? [CFString : Any] { - // A TIFF dictionary already exists -> update key/value pairs - for (k, v) in imageTIFFDictionary { metadataTIFFDictionary[k] = v } - metadata[kCGImagePropertyTIFFDictionary] = metadataTIFFDictionary - } else { - // No TIFF dictionary -> Add it - metadata[kCGImagePropertyTIFFDictionary] = imageTIFFDictionary - } - } - - // Update/add GIF dictionary from image metadata - if let imageGIFDictionary = imageMetadata[kCGImagePropertyGIFDictionary] as? [CFString : Any] { - // Image contains a GIF dictionary - if var metadataGIFDictionary = metadata[kCGImagePropertyGIFDictionary] as? [CFString : Any] { - // A GIF dictionary already exists -> update key/value pairs - for (k, v) in imageGIFDictionary { metadataGIFDictionary[k] = v } - metadata[kCGImagePropertyGIFDictionary] = metadataGIFDictionary - } else { - // No GIF dictionary -> Add it - metadata[kCGImagePropertyGIFDictionary] = imageGIFDictionary - } - } - - // Update/add JFIF dictionary from image metadata - if let imageJFIFDictionary = imageMetadata[kCGImagePropertyJFIFDictionary] as? [CFString : Any] { - // Image contains a JFIF dictionary - if var metadataJFIFDictionary = metadata[kCGImagePropertyJFIFDictionary] as? [CFString : Any] { - // A JIFF dictionary already exists -> update key/value pairs - for (k, v) in imageJFIFDictionary { metadataJFIFDictionary[k] = v } - metadata[kCGImagePropertyJFIFDictionary] = metadataJFIFDictionary - } else { - // No JIFF dictionary -> Add it - metadata[kCGImagePropertyJFIFDictionary] = imageJFIFDictionary - } - } - + // Common Image Properties // Update/add Exif dictionary from image metadata if let imageEXIFDictionary = imageMetadata[kCGImagePropertyExifDictionary] as? [CFString : Any] { // Image contains an EXIF dictionary @@ -362,19 +274,19 @@ extension Dictionary where Key == CFString, Value == Any { } } - // Update/add PNG dictionary from image metadata - if let imagePNGDictionary = imageMetadata[kCGImagePropertyPNGDictionary] as? [CFString : Any] { - // Image contains a PNG dictionary - if var metadataPNGDictionary = metadata[kCGImagePropertyPNGDictionary] as? [CFString : Any] { - // A PNG dictionary already exists -> update key/value pairs - for (k, v) in imagePNGDictionary { metadataPNGDictionary[k] = v } - metadata[kCGImagePropertyPNGDictionary] = metadataPNGDictionary + // Update/add ExifAux dictionary from image metadata + if let imageExifAuxDictionary = imageMetadata[kCGImagePropertyExifAuxDictionary] as? [CFString : Any] { + // Image contains an EXIF Aux dictionary + if var metadataExifAuxDictionary = metadata[kCGImagePropertyExifAuxDictionary] as? [CFString : Any] { + // An EXIF Aux dictionary already exists -> update key/value pairs + for (k, v) in imageExifAuxDictionary { metadataExifAuxDictionary[k] = v } + metadata[kCGImagePropertyExifAuxDictionary] = metadataExifAuxDictionary } else { - // No PNG dictionary -> Add it - metadata[kCGImagePropertyPNGDictionary] = imagePNGDictionary + // No EXIF Aux dictionary -> Add it + metadata[kCGImagePropertyExifAuxDictionary] = imageExifAuxDictionary } } - + // Update/add IPTC dictionary from image metadata if let imageIPTCDictionary = metadata[kCGImagePropertyIPTCDictionary] as? [CFString : Any] { // Image contains an IPTC dictionary @@ -392,28 +304,31 @@ extension Dictionary where Key == CFString, Value == Any { if let imageGPSDictionary = metadata[kCGImagePropertyGPSDictionary] as? [CFString : Any] { // Image contains a GPS dictionary if var metadataGPSDictionary = metadata[kCGImagePropertyGPSDictionary] as? [CFString : Any] { - // A IPTC dictionary already exists -> update key/value pairs + // A GPS dictionary already exists -> update key/value pairs for (k, v) in imageGPSDictionary { metadataGPSDictionary[k] = v } metadata[kCGImagePropertyGPSDictionary] = metadataGPSDictionary } else { - // No IPTC dictionary -> Add it + // No GPS dictionary -> Add it metadata[kCGImagePropertyGPSDictionary] = imageGPSDictionary } } - // Update RAW dictionary from image metadata - if let imageRawDictionary = imageMetadata[kCGImagePropertyRawDictionary] as? [CFString : Any] { - // Image contains a RAW dictionary - if var metadataRawDictionary = metadata[kCGImagePropertyRawDictionary] as? [CFString : Any] { - // A Raw dictionary already exists -> update key/value pairs - for (k, v) in imageRawDictionary { metadataRawDictionary[k] = v } - metadata[kCGImagePropertyRawDictionary] = metadataRawDictionary - } else { - // No Raw dictionary -> Add it - metadata[kCGImagePropertyRawDictionary] = imageRawDictionary + // Update/add WebP dictionary from image metadata + if #available(iOS 14, *) { + if let imageWebPDictionary = metadata[kCGImagePropertyWebPDictionary] as? [CFString : Any] { + // Image contains a WebP dictionary + if var metadataWebPDictionary = metadata[kCGImagePropertyWebPDictionary] as? [CFString : Any] { + // A WebP dictionary already exists -> update key/value pairs + for (k, v) in imageWebPDictionary { metadataWebPDictionary[k] = v } + metadata[kCGImagePropertyGPSDictionary] = metadataWebPDictionary + } else { + // No WebP dictionary -> Add it + metadata[kCGImagePropertyGPSDictionary] = imageWebPDictionary + } } } - + + // Format-Specific Properties // Update/add CIFF dictionary from image metadata if let imageCIFFDictionary = imageMetadata[kCGImagePropertyCIFFDictionary] as? [CFString : Any] { // Image contains a CIFF dictionary @@ -427,19 +342,6 @@ extension Dictionary where Key == CFString, Value == Any { } } - // Update/add 8BIM dictionary from image metadata - if let image8BIMDictionary = imageMetadata[kCGImageProperty8BIMDictionary] as? [CFString : Any] { - // Image contains a 8BIM dictionary - if var metadata8BIMDictionary = metadata[kCGImageProperty8BIMDictionary] as? [CFString : Any] { - // A 8BIM dictionary already exists -> update key/value pairs - for (k, v) in image8BIMDictionary { metadata8BIMDictionary[k] = v } - metadata[kCGImageProperty8BIMDictionary] = metadata8BIMDictionary - } else { - // No 8BIM dictionary -> Add it - metadata[kCGImageProperty8BIMDictionary] = image8BIMDictionary - } - } - // Update/add DNG dictionary from image metadata if let imageDNGDictionary = imageMetadata[kCGImagePropertyDNGDictionary] as? [CFString : Any] { // Image contains a DNG dictionary @@ -453,16 +355,111 @@ extension Dictionary where Key == CFString, Value == Any { } } - // Update/add ExifAux dictionary from image metadata - if let imageExifAuxDictionary = imageMetadata[kCGImagePropertyExifAuxDictionary] as? [CFString : Any] { - // Image contains an EXIF Aux dictionary - if var metadataExifAuxDictionary = metadata[kCGImagePropertyExifAuxDictionary] as? [CFString : Any] { - // An EXIF Aux dictionary already exists -> update key/value pairs - for (k, v) in imageExifAuxDictionary { metadataExifAuxDictionary[k] = v } - metadata[kCGImagePropertyExifAuxDictionary] = metadataExifAuxDictionary + // Update/add GIF dictionary from image metadata + if let imageGIFDictionary = imageMetadata[kCGImagePropertyGIFDictionary] as? [CFString : Any] { + // Image contains a GIF dictionary + if var metadataGIFDictionary = metadata[kCGImagePropertyGIFDictionary] as? [CFString : Any] { + // A GIF dictionary already exists -> update key/value pairs + for (k, v) in imageGIFDictionary { metadataGIFDictionary[k] = v } + metadata[kCGImagePropertyGIFDictionary] = metadataGIFDictionary } else { - // No EXIF Aux dictionary -> Add it - metadata[kCGImagePropertyExifAuxDictionary] = imageExifAuxDictionary + // No GIF dictionary -> Add it + metadata[kCGImagePropertyGIFDictionary] = imageGIFDictionary + } + } + + // Update/add HEIC dictionary from image metadata + if #available(iOS 13, *) { + if let imageHEICDictionary = imageMetadata[kCGImagePropertyHEICSDictionary] as? [CFString : Any] { + // Image contains an HEIC dictionary + if var metadataHEICDictionary = metadata[kCGImagePropertyHEICSDictionary] as? [CFString : Any] { + // An HEIC dictionary already exists -> update key/value pairs + for (k, v) in imageHEICDictionary { metadataHEICDictionary[k] = v } + metadata[kCGImagePropertyHEICSDictionary] = metadataHEICDictionary + } else { + // No HEIC dictionary -> Add it + metadata[kCGImagePropertyHEICSDictionary] = imageHEICDictionary + } + } + } + + // Update/add JFIF dictionary from image metadata + if let imageJFIFDictionary = imageMetadata[kCGImagePropertyJFIFDictionary] as? [CFString : Any] { + // Image contains a JFIF dictionary + if var metadataJFIFDictionary = metadata[kCGImagePropertyJFIFDictionary] as? [CFString : Any] { + // A JIFF dictionary already exists -> update key/value pairs + for (k, v) in imageJFIFDictionary { metadataJFIFDictionary[k] = v } + metadata[kCGImagePropertyJFIFDictionary] = metadataJFIFDictionary + } else { + // No JIFF dictionary -> Add it + metadata[kCGImagePropertyJFIFDictionary] = imageJFIFDictionary + } + } + + // Update/add PNG dictionary from image metadata + if let imagePNGDictionary = imageMetadata[kCGImagePropertyPNGDictionary] as? [CFString : Any] { + // Image contains a PNG dictionary + if var metadataPNGDictionary = metadata[kCGImagePropertyPNGDictionary] as? [CFString : Any] { + // A PNG dictionary already exists -> update key/value pairs + for (k, v) in imagePNGDictionary { metadataPNGDictionary[k] = v } + metadata[kCGImagePropertyPNGDictionary] = metadataPNGDictionary + } else { + // No PNG dictionary -> Add it + metadata[kCGImagePropertyPNGDictionary] = imagePNGDictionary + } + } + + // Update/add TGA dictionary from image metadata + if #available(iOS 14, *) { + if let imageTGADictionary = imageMetadata[kCGImagePropertyTGADictionary] as? [CFString : Any] { + // Image contains a TGA dictionary + if var metadataTGADictionary = metadata[kCGImagePropertyTGADictionary] as? [CFString : Any] { + // A TGA dictionary already exists -> update key/value pairs + for (k, v) in imageTGADictionary { metadataTGADictionary[k] = v } + metadata[kCGImagePropertyTIFFDictionary] = metadataTGADictionary + } else { + // No TGA dictionary -> Add it + metadata[kCGImagePropertyTGADictionary] = imageTGADictionary + } + } + } + + // Update TIFF dictionary from image metadata + if let imageTIFFDictionary = imageMetadata[kCGImagePropertyTIFFDictionary] as? [CFString : Any] { + // Image contains a TIFF dictionary + if var metadataTIFFDictionary = metadata[kCGImagePropertyTIFFDictionary] as? [CFString : Any] { + // A TIFF dictionary already exists -> update key/value pairs + for (k, v) in imageTIFFDictionary { metadataTIFFDictionary[k] = v } + metadata[kCGImagePropertyTIFFDictionary] = metadataTIFFDictionary + } else { + // No TIFF dictionary -> Add it + metadata[kCGImagePropertyTIFFDictionary] = imageTIFFDictionary + } + } + + // Update/add 8BIM dictionary from image metadata + if let image8BIMDictionary = imageMetadata[kCGImageProperty8BIMDictionary] as? [CFString : Any] { + // Image contains a 8BIM dictionary + if var metadata8BIMDictionary = metadata[kCGImageProperty8BIMDictionary] as? [CFString : Any] { + // A 8BIM dictionary already exists -> update key/value pairs + for (k, v) in image8BIMDictionary { metadata8BIMDictionary[k] = v } + metadata[kCGImageProperty8BIMDictionary] = metadata8BIMDictionary + } else { + // No 8BIM dictionary -> Add it + metadata[kCGImageProperty8BIMDictionary] = image8BIMDictionary + } + } + + // Update RAW dictionary from image metadata + if let imageRawDictionary = imageMetadata[kCGImagePropertyRawDictionary] as? [CFString : Any] { + // Image contains a RAW dictionary + if var metadataRawDictionary = metadata[kCGImagePropertyRawDictionary] as? [CFString : Any] { + // A Raw dictionary already exists -> update key/value pairs + for (k, v) in imageRawDictionary { metadataRawDictionary[k] = v } + metadata[kCGImagePropertyRawDictionary] = metadataRawDictionary + } else { + // No Raw dictionary -> Add it + metadata[kCGImagePropertyRawDictionary] = imageRawDictionary } } From ffc80169df63c79309e175217b435d2061961fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 10 Feb 2024 11:47:19 +0100 Subject: [PATCH 08/17] Adds translations --- piwigo/Resources/ar.lproj/ReleaseNotes.strings | 2 ++ piwigo/Resources/da.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/de.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/es.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/fr.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/hu.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/id.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/it.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/ja.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/nl.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/pl.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/ru.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/sv.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/zh-Hans.lproj/ReleaseNotes.strings | 4 +++- piwigo/Resources/zh-Hant.lproj/ReleaseNotes.strings | 4 +++- 15 files changed, 44 insertions(+), 14 deletions(-) diff --git a/piwigo/Resources/ar.lproj/ReleaseNotes.strings b/piwigo/Resources/ar.lproj/ReleaseNotes.strings index 63084fc88..b721eca90 100644 --- a/piwigo/Resources/ar.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/ar.lproj/ReleaseNotes.strings @@ -6,6 +6,8 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ +"v3.1.3_text" = "Version 3.1.3\n\n• Bug fixes"; + "v3.1.2_text" = "الإصدار 3.1.2\n\n• طلبات تحديث خادم Piwigo إذا لزم الأمر\n• إصلاحات الشوائب"; "v3.1.1_text" = "الإصدار 3.1.1\n1 كانون الأول/ديسمبر 2023\n\n• تحديث إحصائيات الخادم (يتطلب Piwigo 14)\n• إصلاحات الشوائب"; diff --git a/piwigo/Resources/da.lproj/ReleaseNotes.strings b/piwigo/Resources/da.lproj/ReleaseNotes.strings index 71b0996ed..0b1fbcc19 100644 --- a/piwigo/Resources/da.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/da.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "Version 3.1.2\n\n• Anmodninger om opdatering af Piwigo server om nødvendigt\n• Fejlrettelser"; +"v3.1.3_text" = "Version 3.1.3\n\n• Fejlrettelser"; + +"v3.1.2_text" = "Version 3.1.2\n1 februar 2024\n\n• Anmodninger om opdatering af Piwigo server om nødvendigt\n• Fejlrettelser"; "v3.1.1_text" = "Version 3.1.1\n1 december 2023\n\n• Opdaterer serverstatistikker (kræver Piwigo 14)\n• Fejlrettelser"; diff --git a/piwigo/Resources/de.lproj/ReleaseNotes.strings b/piwigo/Resources/de.lproj/ReleaseNotes.strings index 92b30fd55..ed2a07af4 100644 --- a/piwigo/Resources/de.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/de.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "Version 3.1.2\n\n• Erfordert das Piwigo Server Update falls erforderlich\n• Fehlerbehebungen"; +"v3.1.3_text" = "Version 3.1.3\n\n• Fehlerbehebungen"; + +"v3.1.2_text" = "Version 3.1.2\n1. Februar 2024\n\n• Erfordert das Piwigo Server Update falls erforderlich\n• Fehlerbehebungen"; "v3.1.1_text" = "Version 3.1.1\n1. Dezember 2023\n\n• Aktualisiert Serverstatistiken(erfordert Piwigo 14)\n• Fehlerbehebungen"; diff --git a/piwigo/Resources/es.lproj/ReleaseNotes.strings b/piwigo/Resources/es.lproj/ReleaseNotes.strings index 87bcd959c..92d2d8bb9 100644 --- a/piwigo/Resources/es.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/es.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "Versión 3.1.2\n\n• Solicita la actualización del servidor Piwigo si es necesario\n• Corrección de errores"; +"v3.1.3_text" = "Versión 3.1.3\n\n• Corrección de errores"; + +"v3.1.2_text" = "Versión 3.1.2\n1 de febrero de 2024\n\n• Solicita la actualización del servidor Piwigo si es necesario\n• Corrección de errores"; "v3.1.1_text" = "Versión 3.1.1\n1 de diciembre de 2023\n\n• Actualiza el servidor de estadísticas (requiere Piwigo 14)\n• Correcciones de errores"; diff --git a/piwigo/Resources/fr.lproj/ReleaseNotes.strings b/piwigo/Resources/fr.lproj/ReleaseNotes.strings index e7b5d9774..be7067219 100644 --- a/piwigo/Resources/fr.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/fr.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "Version 3.1.2\n\n• Demande la mise à jour du serveur Piwigo si nécessaire\n• Corrections de bugs"; +"v3.1.3_text" = "Version 3.1.3\n\n• Correction de bugs"; + +"v3.1.2_text" = "Version 3.1.2\n1 février 2024\n\n• Demande la mise à jour du serveur Piwigo si nécessaire\n• Corrections de bugs"; "v3.1.1_text" = "Version 3.1.1\n1 décembre 2023\n\n• Met à jour les statistiques du serveur (nécessite Piwigo 14)\n• Corrections de bugs"; diff --git a/piwigo/Resources/hu.lproj/ReleaseNotes.strings b/piwigo/Resources/hu.lproj/ReleaseNotes.strings index 0ba3d5be4..d712aa928 100644 --- a/piwigo/Resources/hu.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/hu.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "3.1.2 verzió\n\n• Szükség esetén kéri a Piwigo szerver frissítését\n• Hibajavítások"; +"v3.1.3_text" = "3.1.3-es verzió\n\n• Hibajavítások"; + +"v3.1.2_text" = "3.1.2 verzió\n2024 Február 1\n\n• Szükség esetén kéri a Piwigo szerver frissítését\n• Hibajavítások"; "v3.1.1_text" = "3.1.1 verzió\n2023 December 1\n\n• Szerver statisztikák frissítése (Piwigo 14 szükséges)\n• Hibajavítások"; diff --git a/piwigo/Resources/id.lproj/ReleaseNotes.strings b/piwigo/Resources/id.lproj/ReleaseNotes.strings index a647616d0..6b075aa39 100644 --- a/piwigo/Resources/id.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/id.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "Version 3.1.2\n\n• Requests Piwigo server update if necessary\n• Bug fixes"; +"v3.1.3_text" = "Versi 3.1.3\n\n• Perbaikan bug"; + +"v3.1.2_text" = "Version 3.1.2\nFebruary 1, 2024\n\n• Requests Piwigo server update if necessary\n• Bug fixes"; "v3.1.1_text" = "Version 3.1.1\nDecember 1, 2023\n\n• Updates server statistics (requires Piwigo 14)\n• Bug fixes"; diff --git a/piwigo/Resources/it.lproj/ReleaseNotes.strings b/piwigo/Resources/it.lproj/ReleaseNotes.strings index 5c3a90c95..3407f6679 100644 --- a/piwigo/Resources/it.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/it.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "Versione 3.1.2\n\n• Richiede l'aggiornamento del server Piwigo se necessario\n• Correzioni di bug"; +"v3.1.3_text" = "Versione 3.1.3\n\n• Correzioni di bug"; + +"v3.1.2_text" = "Versione 3.1.2\n1 febbraio 2024\n\n• Richiede l'aggiornamento del server Piwigo se necessario\n• Correzioni di bug"; "v3.1.1_text" = "Versione 3.1.1\n1 dicembre 2023\n\n• Aggiorna le statistiche del server (richiede Piwigo 14)\n• Correzioni di bug"; diff --git a/piwigo/Resources/ja.lproj/ReleaseNotes.strings b/piwigo/Resources/ja.lproj/ReleaseNotes.strings index 7dfa508c8..e372a088c 100644 --- a/piwigo/Resources/ja.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/ja.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "バージョン 3.1.2\n\n• 必要に応じて Piwigo サーバーの更新を要求します\n• バグの修正"; +"v3.1.3_text" = "バージョン 3.1.3\n\n• バグの修正"; + +"v3.1.2_text" = "バージョン 3.1.2\n2024年2月1日\n\n• 必要に応じて Piwigo サーバーの更新を要求します\n• バグの修正"; "v3.1.1_text" = "バージョン 3.1.1\n2023年12月1日\n\n• サーバーの統計情報を更新(Piwigo 14が必要)\n• バグの修正"; diff --git a/piwigo/Resources/nl.lproj/ReleaseNotes.strings b/piwigo/Resources/nl.lproj/ReleaseNotes.strings index de3d13f80..8262015ba 100644 --- a/piwigo/Resources/nl.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/nl.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "Versie 3.1.2\n\n• Verzoeken Piwigo server update indien nodig\n• Foutjes verbeterd"; +"v3.1.3_text" = "Versie 3.1.3\n\n• Foutjes verbeterd"; + +"v3.1.2_text" = "Versie 3.1.2\n1 februari 2024\n\n• Verzoeken Piwigo server update indien nodig\n• Foutjes verbeterd"; "v3.1.1_text" = "Versie 3.1.1\n1 December 2023\n\n• Serverstatistieken bijwerken (vereist Piwigo 14)\n• Foutjes verbeterd"; diff --git a/piwigo/Resources/pl.lproj/ReleaseNotes.strings b/piwigo/Resources/pl.lproj/ReleaseNotes.strings index 341e6ded4..bc70891c8 100644 --- a/piwigo/Resources/pl.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/pl.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "Wersja 3.1.2\n\n• Żądanie aktualizacji serwera Piwigo w razie potrzeby\n• Poprawki błędów"; +"v3.1.3_text" = "Wersja 3.1.3\n\n• Poprawki błędów"; + +"v3.1.2_text" = "Wersja 3.1.2\n1 lutego 2024\n\n• Żądanie aktualizacji serwera Piwigo w razie potrzeby\n• Poprawki błędów"; "v3.1.1_text" = "Wersja 3.1.1\n1 grudnia 2023\n\n• Aktualizacja statystyk serwera (wymaga Piwigo 14)\n• Poprawki błędów"; diff --git a/piwigo/Resources/ru.lproj/ReleaseNotes.strings b/piwigo/Resources/ru.lproj/ReleaseNotes.strings index 0f41e6fda..b0409cdc0 100644 --- a/piwigo/Resources/ru.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/ru.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "Версия 3.1.2\n\n• Запрос обновления Piwigo сервера при необходимости\n• Исправления ошибок"; +"v3.1.3_text" = "Версия 3.1.3\n\n• Исправления ошибок"; + +"v3.1.2_text" = "Версия 3.1.2\n1 февраля 2024\n\n• Запрос обновления Piwigo сервера при необходимости\n• Исправления ошибок"; "v3.1.1_text" = "Версия 3.1.1\n1 февраля 2023\n\n• Обновления статистики сервера (требует Piwigo 14)\n• Исправления ошибок"; diff --git a/piwigo/Resources/sv.lproj/ReleaseNotes.strings b/piwigo/Resources/sv.lproj/ReleaseNotes.strings index 887f290a0..bf2513925 100644 --- a/piwigo/Resources/sv.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/sv.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "Version 3.1.2\n\n• Begär Piwigo server uppdatering om det behövs\n• Felrättelser"; +"v3.1.3_text" = "Version 3.1.3\n\n• Buggfixar"; + +"v3.1.2_text" = "Version 3.1.2\n1 februari 2024\n\n• Begär Piwigo server uppdatering om det behövs\n• Felrättelser"; "v3.1.1_text" = "Version 3.1.1\n1 december 2023\n\n• Uppdaterar serverstatistik (kräver Piwigo 14)\n• Felrättelser"; diff --git a/piwigo/Resources/zh-Hans.lproj/ReleaseNotes.strings b/piwigo/Resources/zh-Hans.lproj/ReleaseNotes.strings index b996682fb..b34c664d4 100644 --- a/piwigo/Resources/zh-Hans.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/zh-Hans.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "版本 3.1.2\n\n• 如有必要,请求 Piwigo 服务器更新\n• Bug修复"; +"v3.1.3_text" = "版本 3.1.3\n\n• 错误修复"; + +"v3.1.2_text" = "版本 3.1.2\n2024年2月1日\n\n• 如有必要,请求 Piwigo 服务器更新\n• Bug修复"; "v3.1.1_text" = "版本 3.1.1\n2023年12月1日\n\n• 更新服务器统计(需要 Piwigo 14)\n• Bug 修复"; diff --git a/piwigo/Resources/zh-Hant.lproj/ReleaseNotes.strings b/piwigo/Resources/zh-Hant.lproj/ReleaseNotes.strings index b92852648..180a29013 100644 --- a/piwigo/Resources/zh-Hant.lproj/ReleaseNotes.strings +++ b/piwigo/Resources/zh-Hant.lproj/ReleaseNotes.strings @@ -6,7 +6,9 @@ Copyright © 2017 Piwigo.org. All rights reserved. */ -"v3.1.2_text" = "版本 3.1.2\n\n• 如有必要,提示需要更新 Piwigo 伺服器\n• Bug修復"; +"v3.1.3_text" = "版本 3.1.3\n\n• 錯誤修正"; + +"v3.1.2_text" = "版本 3.1.2\n2024年2月1日\n\n• 如有必要,提示需要更新 Piwigo 伺服器\n• Bug修復"; "v3.1.1_text" = "版本 3.1.1\n2023年12月1日\n\n• 更新伺服器統計數據 (需要 Piwigo 14)\n• 錯誤修正"; From 6114c0f0d07dc8b1a2ad0aa70acb3b0a7f70e858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 10 Feb 2024 12:02:21 +0100 Subject: [PATCH 09/17] Fixes constant declaration --- uploadKit/Extensions/UploadManager+Image.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uploadKit/Extensions/UploadManager+Image.swift b/uploadKit/Extensions/UploadManager+Image.swift index 351069ed1..f61042a4e 100644 --- a/uploadKit/Extensions/UploadManager+Image.swift +++ b/uploadKit/Extensions/UploadManager+Image.swift @@ -307,7 +307,7 @@ extension UploadManager { } // Get index of the primary image - var imageIndex = CGImageSourceGetPrimaryImageIndex(sourceRef) + let imageIndex = CGImageSourceGetPrimaryImageIndex(sourceRef) // Should we resize the image? var image:CGImage From 3420eeb7099ac444772365356f8dd5a0d7932690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 10 Feb 2024 12:09:33 +0100 Subject: [PATCH 10/17] Version 3.1.3 buil 556 for TestFlight testing --- piwigo/Info.plist | 2 +- piwigoKit/Info.plist | 2 +- uploadKit/Info.plist | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/piwigo/Info.plist b/piwigo/Info.plist index 2f62bdc9f..3d50d214b 100644 --- a/piwigo/Info.plist +++ b/piwigo/Info.plist @@ -25,7 +25,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 555 + 556 INIntentsSupported AutoUploadIntent diff --git a/piwigoKit/Info.plist b/piwigoKit/Info.plist index 51632a597..cf15e0d5a 100644 --- a/piwigoKit/Info.plist +++ b/piwigoKit/Info.plist @@ -17,6 +17,6 @@ CFBundleShortVersionString 3.0.2 CFBundleVersion - 555 + 556 diff --git a/uploadKit/Info.plist b/uploadKit/Info.plist index 00b88cc14..e3e16f3a5 100644 --- a/uploadKit/Info.plist +++ b/uploadKit/Info.plist @@ -17,6 +17,6 @@ CFBundleShortVersionString 1.0.6 CFBundleVersion - 375 + 376 From 8729f22abb9d5c23cc071dfeb61a28b9780a5732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 10 Feb 2024 12:10:08 +0100 Subject: [PATCH 11/17] Fixes crash occurring when user is fault --- piwigo/Album/AlbumViewController.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/piwigo/Album/AlbumViewController.swift b/piwigo/Album/AlbumViewController.swift index 058a44461..9d398e588 100644 --- a/piwigo/Album/AlbumViewController.swift +++ b/piwigo/Album/AlbumViewController.swift @@ -163,6 +163,12 @@ class AlbumViewController: UIViewController, UICollectionViewDelegate, UICollect ClearCache.closeSession() return User() } + // User available ► Job done + if user.isFault { + // The user is not fired yet. + user.willAccessValue(forKey: nil) + user.didAccessValue(forKey: nil) + } return user }() From 6b86171710f31786e2c8e7ae4dcff4918fb35f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 10 Feb 2024 12:59:24 +0100 Subject: [PATCH 12/17] Fixes crash occuring when trying to update the limited library selection --- piwigo.xcodeproj/project.pbxproj | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/piwigo.xcodeproj/project.pbxproj b/piwigo.xcodeproj/project.pbxproj index 50c93c212..b249606c1 100644 --- a/piwigo.xcodeproj/project.pbxproj +++ b/piwigo.xcodeproj/project.pbxproj @@ -53,6 +53,8 @@ AD1AC30A29746F9E00CEA7A9 /* ImageSessionError.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD1AC30929746F9E00CEA7A9 /* ImageSessionError.swift */; }; AD1BB5EC29AE82E50041E24E /* MappingModel_0A_to_0B.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = AD1BB5EB29AE82E50041E24E /* MappingModel_0A_to_0B.xcmappingmodel */; }; AD1BFE3E2745A15800858145 /* UIImageView+AppTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD1BFE3D2745A15800858145 /* UIImageView+AppTools.swift */; }; + AD2058832B779AF500CF7E0B /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058822B779AF500CF7E0B /* Photos.framework */; }; + AD2058852B779B0200CF7E0B /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058842B779B0100CF7E0B /* PhotosUI.framework */; }; AD211A7627A85EDB005D5E4F /* ImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD211A7527A85EDB005D5E4F /* ImageCollectionViewCell.swift */; }; AD211A7827AB1FA8005D5E4F /* ImageCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD211A7727AB1FA8005D5E4F /* ImageCollectionViewCell.xib */; }; AD211A7A27BAD596005D5E4F /* LoginUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD211A7927BAD596005D5E4F /* LoginUtilities.swift */; }; @@ -607,6 +609,10 @@ AD1BB5EB29AE82E50041E24E /* MappingModel_0A_to_0B.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = MappingModel_0A_to_0B.xcmappingmodel; sourceTree = ""; }; AD1BFE3D2745A15800858145 /* UIImageView+AppTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImageView+AppTools.swift"; sourceTree = ""; }; AD1F60012402B1B70099E5E5 /* UIColor+AppColors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+AppColors.swift"; sourceTree = ""; }; + AD2058822B779AF500CF7E0B /* Photos.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Photos.framework; path = System/Library/Frameworks/Photos.framework; sourceTree = SDKROOT; }; + AD2058842B779B0100CF7E0B /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; }; + AD2058862B779BBC00CF7E0B /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; }; + AD2058882B779BC500CF7E0B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; AD2114592122D3E4004FFC8C /* AlbumTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AlbumTableViewCell.xib; sourceTree = ""; }; AD211A7527A85EDB005D5E4F /* ImageCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCollectionViewCell.swift; sourceTree = ""; }; AD211A7727AB1FA8005D5E4F /* ImageCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ImageCollectionViewCell.xib; sourceTree = ""; }; @@ -1163,6 +1169,8 @@ buildActionMask = 2147483647; files = ( 91E6078914BDFB42EBBA866B /* libPods-piwigo.a in Frameworks */, + AD2058852B779B0200CF7E0B /* PhotosUI.framework in Frameworks */, + AD2058832B779AF500CF7E0B /* Photos.framework in Frameworks */, AD084E4D2659A27100159FE1 /* piwigoKit.framework in Frameworks */, AD2C62402A4896A600671582 /* uploadKit.framework in Frameworks */, ); @@ -1174,6 +1182,10 @@ 1F042DC0C96A55B227088605 /* Frameworks */ = { isa = PBXGroup; children = ( + AD2058882B779BC500CF7E0B /* UIKit.framework */, + AD2058862B779BBC00CF7E0B /* MessageUI.framework */, + AD2058842B779B0100CF7E0B /* PhotosUI.framework */, + AD2058822B779AF500CF7E0B /* Photos.framework */, A19C73FF8142EEEBCD99AD87 /* libPods-piwigo.a */, B37F5B7464A6A11CDDABA253 /* libPods-piwigoTests.a */, 297CC11501571E3E266D8AB5 /* libPods-piwigoAppStore.a */, From 8a11c74a585b7c2c7970a1c4d5073676023385ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 10 Feb 2024 13:51:01 +0100 Subject: [PATCH 13/17] Version 3.1.3 build 557 for TestFlight testing --- piwigo/Info.plist | 2 +- piwigoKit/Info.plist | 2 +- uploadKit/Info.plist | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/piwigo/Info.plist b/piwigo/Info.plist index 3d50d214b..1deff7d73 100644 --- a/piwigo/Info.plist +++ b/piwigo/Info.plist @@ -25,7 +25,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 556 + 557 INIntentsSupported AutoUploadIntent diff --git a/piwigoKit/Info.plist b/piwigoKit/Info.plist index cf15e0d5a..a37c5bfc2 100644 --- a/piwigoKit/Info.plist +++ b/piwigoKit/Info.plist @@ -17,6 +17,6 @@ CFBundleShortVersionString 3.0.2 CFBundleVersion - 556 + 557 diff --git a/uploadKit/Info.plist b/uploadKit/Info.plist index e3e16f3a5..21b48ecb4 100644 --- a/uploadKit/Info.plist +++ b/uploadKit/Info.plist @@ -17,6 +17,6 @@ CFBundleShortVersionString 1.0.6 CFBundleVersion - 376 + 377 From e02201fec73820ae61f45a5d90e8870c9ce46f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 10 Feb 2024 17:36:02 +0100 Subject: [PATCH 14/17] Fixes local image collection not updated after changing photo selection --- .../Pick Local Images/LocalImagesViewController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/piwigo/Upload/Pick Local Images/LocalImagesViewController.swift b/piwigo/Upload/Pick Local Images/LocalImagesViewController.swift index 99919398a..067964a1f 100644 --- a/piwigo/Upload/Pick Local Images/LocalImagesViewController.swift +++ b/piwigo/Upload/Pick Local Images/LocalImagesViewController.swift @@ -1879,9 +1879,11 @@ extension LocalImagesViewController: PHPhotoLibraryChangeObserver { // This method may be called on a background queue; use the main queue to update the UI. DispatchQueue.main.async { - // Any photo to insert or delete? + debugPrint(changes.fetchResultAfterChanges.count, self.fetchedImages.count) + // Any new photo inserted? or delete? or added to selection? if changes.insertedObjects.isEmpty, - changes.removedObjects.isEmpty { + changes.removedObjects.isEmpty, + changes.fetchResultAfterChanges.count == self.fetchedImages.count { return } From 24a1d10eb1fa76122d349e6ad1062f1a7b2fbb8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 10 Feb 2024 18:31:39 +0100 Subject: [PATCH 15/17] Adds frameworks to targets --- piwigo.xcodeproj/project.pbxproj | 104 +++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/piwigo.xcodeproj/project.pbxproj b/piwigo.xcodeproj/project.pbxproj index b249606c1..01bafab46 100644 --- a/piwigo.xcodeproj/project.pbxproj +++ b/piwigo.xcodeproj/project.pbxproj @@ -55,6 +55,42 @@ AD1BFE3E2745A15800858145 /* UIImageView+AppTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD1BFE3D2745A15800858145 /* UIImageView+AppTools.swift */; }; AD2058832B779AF500CF7E0B /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058822B779AF500CF7E0B /* Photos.framework */; }; AD2058852B779B0200CF7E0B /* PhotosUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058842B779B0100CF7E0B /* PhotosUI.framework */; }; + AD20588B2B77DDEA00CF7E0B /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20588A2B77DDEA00CF7E0B /* CoreData.framework */; }; + AD20588D2B77DE0B00CF7E0B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20588C2B77DE0B00CF7E0B /* Foundation.framework */; }; + AD20588E2B77DE2700CF7E0B /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058862B779BBC00CF7E0B /* MessageUI.framework */; }; + AD20588F2B77DE4400CF7E0B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058882B779BC500CF7E0B /* UIKit.framework */; }; + AD2058912B77DED300CF7E0B /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058902B77DED300CF7E0B /* CoreMedia.framework */; }; + AD2058932B77DF5C00CF7E0B /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058922B77DF5C00CF7E0B /* ImageIO.framework */; }; + AD2058952B77DF6A00CF7E0B /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058942B77DF6A00CF7E0B /* MobileCoreServices.framework */; }; + AD2058972B77DF8400CF7E0B /* AVKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058962B77DF8400CF7E0B /* AVKit.framework */; }; + AD2058992B77DFB700CF7E0B /* LinkPresentation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058982B77DFB700CF7E0B /* LinkPresentation.framework */; }; + AD20589B2B77DFD600CF7E0B /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20589A2B77DFD600CF7E0B /* AVFoundation.framework */; }; + AD20589D2B77E03F00CF7E0B /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20589C2B77E03F00CF7E0B /* UniformTypeIdentifiers.framework */; }; + AD20589E2B77E0D200CF7E0B /* Intents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2913B32669440000403026 /* Intents.framework */; }; + AD2058A02B77E15700CF7E0B /* LocalAuthentication.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20589F2B77E15700CF7E0B /* LocalAuthentication.framework */; }; + AD2058A22B77E1B700CF7E0B /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058A12B77E1B600CF7E0B /* CoreHaptics.framework */; }; + AD2058A42B77E1EF00CF7E0B /* Vision.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058A32B77E1EF00CF7E0B /* Vision.framework */; }; + AD2058A62B77E22000CF7E0B /* BackgroundTasks.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058A52B77E22000CF7E0B /* BackgroundTasks.framework */; }; + AD2058A72B77E27700CF7E0B /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20588A2B77DDEA00CF7E0B /* CoreData.framework */; }; + AD2058A82B77E28000CF7E0B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20588C2B77DE0B00CF7E0B /* Foundation.framework */; }; + AD2058A92B77E29D00CF7E0B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20588C2B77DE0B00CF7E0B /* Foundation.framework */; }; + AD2058AA2B77E2B100CF7E0B /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058822B779AF500CF7E0B /* Photos.framework */; }; + AD2058AB2B77E2BA00CF7E0B /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20588A2B77DDEA00CF7E0B /* CoreData.framework */; }; + AD2058AC2B77E2CA00CF7E0B /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058942B77DF6A00CF7E0B /* MobileCoreServices.framework */; }; + AD2058AD2B77E2E900CF7E0B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058882B779BC500CF7E0B /* UIKit.framework */; }; + AD2058AE2B77E31200CF7E0B /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20589A2B77DFD600CF7E0B /* AVFoundation.framework */; }; + AD2058AF2B77E32500CF7E0B /* BackgroundTasks.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058A52B77E22000CF7E0B /* BackgroundTasks.framework */; }; + AD2058B02B77E34A00CF7E0B /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058922B77DF5C00CF7E0B /* ImageIO.framework */; }; + AD2058B12B77E36F00CF7E0B /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20588A2B77DDEA00CF7E0B /* CoreData.framework */; }; + AD2058B22B77E37600CF7E0B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20588C2B77DE0B00CF7E0B /* Foundation.framework */; }; + AD2058B32B77E3E700CF7E0B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058882B779BC500CF7E0B /* UIKit.framework */; }; + AD2058B42B77E40900CF7E0B /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058942B77DF6A00CF7E0B /* MobileCoreServices.framework */; }; + AD2058B52B77E41400CF7E0B /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD20589C2B77E03F00CF7E0B /* UniformTypeIdentifiers.framework */; }; + AD2058B62B77E43B00CF7E0B /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058902B77DED300CF7E0B /* CoreMedia.framework */; }; + AD2058B82B77E45900CF7E0B /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058B72B77E45800CF7E0B /* CoreLocation.framework */; }; + AD2058B92B77E47E00CF7E0B /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058822B779AF500CF7E0B /* Photos.framework */; }; + AD2058BB2B77E49A00CF7E0B /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058BA2B77E49A00CF7E0B /* SystemConfiguration.framework */; }; + AD2058BD2B77E51B00CF7E0B /* CryptoKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD2058BC2B77E51B00CF7E0B /* CryptoKit.framework */; }; AD211A7627A85EDB005D5E4F /* ImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD211A7527A85EDB005D5E4F /* ImageCollectionViewCell.swift */; }; AD211A7827AB1FA8005D5E4F /* ImageCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AD211A7727AB1FA8005D5E4F /* ImageCollectionViewCell.xib */; }; AD211A7A27BAD596005D5E4F /* LoginUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD211A7927BAD596005D5E4F /* LoginUtilities.swift */; }; @@ -613,6 +649,22 @@ AD2058842B779B0100CF7E0B /* PhotosUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhotosUI.framework; path = System/Library/Frameworks/PhotosUI.framework; sourceTree = SDKROOT; }; AD2058862B779BBC00CF7E0B /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; }; AD2058882B779BC500CF7E0B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + AD20588A2B77DDEA00CF7E0B /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + AD20588C2B77DE0B00CF7E0B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + AD2058902B77DED300CF7E0B /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; }; + AD2058922B77DF5C00CF7E0B /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; }; + AD2058942B77DF6A00CF7E0B /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; + AD2058962B77DF8400CF7E0B /* AVKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVKit.framework; path = System/Library/Frameworks/AVKit.framework; sourceTree = SDKROOT; }; + AD2058982B77DFB700CF7E0B /* LinkPresentation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LinkPresentation.framework; path = System/Library/Frameworks/LinkPresentation.framework; sourceTree = SDKROOT; }; + AD20589A2B77DFD600CF7E0B /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + AD20589C2B77E03F00CF7E0B /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; }; + AD20589F2B77E15700CF7E0B /* LocalAuthentication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalAuthentication.framework; path = System/Library/Frameworks/LocalAuthentication.framework; sourceTree = SDKROOT; }; + AD2058A12B77E1B600CF7E0B /* CoreHaptics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreHaptics.framework; path = System/Library/Frameworks/CoreHaptics.framework; sourceTree = SDKROOT; }; + AD2058A32B77E1EF00CF7E0B /* Vision.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Vision.framework; path = System/Library/Frameworks/Vision.framework; sourceTree = SDKROOT; }; + AD2058A52B77E22000CF7E0B /* BackgroundTasks.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BackgroundTasks.framework; path = System/Library/Frameworks/BackgroundTasks.framework; sourceTree = SDKROOT; }; + AD2058B72B77E45800CF7E0B /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; + AD2058BA2B77E49A00CF7E0B /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + AD2058BC2B77E51B00CF7E0B /* CryptoKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CryptoKit.framework; path = System/Library/Frameworks/CryptoKit.framework; sourceTree = SDKROOT; }; AD2114592122D3E4004FFC8C /* AlbumTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AlbumTableViewCell.xib; sourceTree = ""; }; AD211A7527A85EDB005D5E4F /* ImageCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCollectionViewCell.swift; sourceTree = ""; }; AD211A7727AB1FA8005D5E4F /* ImageCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ImageCollectionViewCell.xib; sourceTree = ""; }; @@ -1118,6 +1170,16 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + AD2058B62B77E43B00CF7E0B /* CoreMedia.framework in Frameworks */, + AD2058BB2B77E49A00CF7E0B /* SystemConfiguration.framework in Frameworks */, + AD2058BD2B77E51B00CF7E0B /* CryptoKit.framework in Frameworks */, + AD2058B92B77E47E00CF7E0B /* Photos.framework in Frameworks */, + AD2058B12B77E36F00CF7E0B /* CoreData.framework in Frameworks */, + AD2058B42B77E40900CF7E0B /* MobileCoreServices.framework in Frameworks */, + AD2058B32B77E3E700CF7E0B /* UIKit.framework in Frameworks */, + AD2058B82B77E45900CF7E0B /* CoreLocation.framework in Frameworks */, + AD2058B22B77E37600CF7E0B /* Foundation.framework in Frameworks */, + AD2058B52B77E41400CF7E0B /* UniformTypeIdentifiers.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1135,6 +1197,14 @@ buildActionMask = 2147483647; files = ( AD2C62452A4896EB00671582 /* piwigoKit.framework in Frameworks */, + AD2058AD2B77E2E900CF7E0B /* UIKit.framework in Frameworks */, + AD2058B02B77E34A00CF7E0B /* ImageIO.framework in Frameworks */, + AD2058AB2B77E2BA00CF7E0B /* CoreData.framework in Frameworks */, + AD2058AF2B77E32500CF7E0B /* BackgroundTasks.framework in Frameworks */, + AD2058A92B77E29D00CF7E0B /* Foundation.framework in Frameworks */, + AD2058AC2B77E2CA00CF7E0B /* MobileCoreServices.framework in Frameworks */, + AD2058AE2B77E31200CF7E0B /* AVFoundation.framework in Frameworks */, + AD2058AA2B77E2B100CF7E0B /* Photos.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1150,7 +1220,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + AD2058A82B77E28000CF7E0B /* Foundation.framework in Frameworks */, ADE1AB8A267E4D43001C1EEB /* piwigoKit.framework in Frameworks */, + AD2058A72B77E27700CF7E0B /* CoreData.framework in Frameworks */, AD778357267E34F800317F36 /* Intents.framework in Frameworks */, AD2C62582A48993F00671582 /* uploadKit.framework in Frameworks */, ); @@ -1169,9 +1241,25 @@ buildActionMask = 2147483647; files = ( 91E6078914BDFB42EBBA866B /* libPods-piwigo.a in Frameworks */, + AD20588F2B77DE4400CF7E0B /* UIKit.framework in Frameworks */, + AD20589B2B77DFD600CF7E0B /* AVFoundation.framework in Frameworks */, + AD20588B2B77DDEA00CF7E0B /* CoreData.framework in Frameworks */, + AD20588E2B77DE2700CF7E0B /* MessageUI.framework in Frameworks */, + AD2058912B77DED300CF7E0B /* CoreMedia.framework in Frameworks */, AD2058852B779B0200CF7E0B /* PhotosUI.framework in Frameworks */, + AD2058A22B77E1B700CF7E0B /* CoreHaptics.framework in Frameworks */, + AD2058A42B77E1EF00CF7E0B /* Vision.framework in Frameworks */, AD2058832B779AF500CF7E0B /* Photos.framework in Frameworks */, + AD20589D2B77E03F00CF7E0B /* UniformTypeIdentifiers.framework in Frameworks */, + AD2058932B77DF5C00CF7E0B /* ImageIO.framework in Frameworks */, + AD2058A02B77E15700CF7E0B /* LocalAuthentication.framework in Frameworks */, + AD2058992B77DFB700CF7E0B /* LinkPresentation.framework in Frameworks */, + AD2058A62B77E22000CF7E0B /* BackgroundTasks.framework in Frameworks */, AD084E4D2659A27100159FE1 /* piwigoKit.framework in Frameworks */, + AD2058952B77DF6A00CF7E0B /* MobileCoreServices.framework in Frameworks */, + AD2058972B77DF8400CF7E0B /* AVKit.framework in Frameworks */, + AD20589E2B77E0D200CF7E0B /* Intents.framework in Frameworks */, + AD20588D2B77DE0B00CF7E0B /* Foundation.framework in Frameworks */, AD2C62402A4896A600671582 /* uploadKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1182,6 +1270,22 @@ 1F042DC0C96A55B227088605 /* Frameworks */ = { isa = PBXGroup; children = ( + AD2058BC2B77E51B00CF7E0B /* CryptoKit.framework */, + AD2058BA2B77E49A00CF7E0B /* SystemConfiguration.framework */, + AD2058B72B77E45800CF7E0B /* CoreLocation.framework */, + AD2058A52B77E22000CF7E0B /* BackgroundTasks.framework */, + AD2058A32B77E1EF00CF7E0B /* Vision.framework */, + AD2058A12B77E1B600CF7E0B /* CoreHaptics.framework */, + AD20589F2B77E15700CF7E0B /* LocalAuthentication.framework */, + AD20589C2B77E03F00CF7E0B /* UniformTypeIdentifiers.framework */, + AD20589A2B77DFD600CF7E0B /* AVFoundation.framework */, + AD2058982B77DFB700CF7E0B /* LinkPresentation.framework */, + AD2058962B77DF8400CF7E0B /* AVKit.framework */, + AD2058942B77DF6A00CF7E0B /* MobileCoreServices.framework */, + AD2058922B77DF5C00CF7E0B /* ImageIO.framework */, + AD2058902B77DED300CF7E0B /* CoreMedia.framework */, + AD20588C2B77DE0B00CF7E0B /* Foundation.framework */, + AD20588A2B77DDEA00CF7E0B /* CoreData.framework */, AD2058882B779BC500CF7E0B /* UIKit.framework */, AD2058862B779BBC00CF7E0B /* MessageUI.framework */, AD2058842B779B0100CF7E0B /* PhotosUI.framework */, From 4ee34c9876f78e3e554416e07e1289918201e1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sat, 10 Feb 2024 19:32:46 +0100 Subject: [PATCH 16/17] Speeds up compilation --- piwigo.xcodeproj/project.pbxproj | 2 +- piwigo/Album/AlbumViewController.swift | 6 +- .../AlbumViewController+Search.swift | 7 +- .../AlbumViewController+Select.swift | 2 +- piwigo/Image/ImageViewController.swift | 292 +++++++++--------- ...ViewController+UITableViewDataSource.swift | 3 +- piwigo/Image/VideoDetailViewController.swift | 4 +- 7 files changed, 168 insertions(+), 148 deletions(-) diff --git a/piwigo.xcodeproj/project.pbxproj b/piwigo.xcodeproj/project.pbxproj index 01bafab46..2e15c61fa 100644 --- a/piwigo.xcodeproj/project.pbxproj +++ b/piwigo.xcodeproj/project.pbxproj @@ -4326,7 +4326,7 @@ "-framework", "\"UIKit\"", ); - OTHER_SWIFT_FLAGS = "$(inherited) -Xfrontend -warn-long-function-bodies=300 -Xfrontend -warn-long-expression-type-checking=50"; + OTHER_SWIFT_FLAGS = "$(inherited) -Xfrontend -warn-long-function-bodies=300 -Xfrontend -warn-long-expression-type-checking=40"; PRODUCT_BUNDLE_IDENTIFIER = "net.lelievre-berna.piwigo"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = "21fe80f9-851b-4da9-93bc-779c033d04e7"; diff --git a/piwigo/Album/AlbumViewController.swift b/piwigo/Album/AlbumViewController.swift index 9d398e588..9d46b68d3 100644 --- a/piwigo/Album/AlbumViewController.swift +++ b/piwigo/Album/AlbumViewController.swift @@ -1586,9 +1586,11 @@ class AlbumViewController: UIViewController, UICollectionViewDelegate, UICollect // MARK: - UIScrollViewDelegate func scrollViewDidScroll(_ scrollView: UIScrollView) { - let navBarHeight = Float(navigationController?.navigationBar.frame.origin.y ?? 0.0) + Float(navigationController?.navigationBar.frame.size.height ?? 0.0) + let navBarYpos = navigationController?.navigationBar.frame.origin.y ?? 0.0 + let navBarThickness = navigationController?.navigationBar.frame.size.height ?? 0.0 + let navBarHeight = navBarYpos + navBarThickness // NSLog(@"==>> %f", scrollView.contentOffset.y + navBarHeight); - if roundf(Float(scrollView.contentOffset.y) + navBarHeight) > 1 || + if round(scrollView.contentOffset.y + navBarHeight) > 1 || (categoryId != AlbumVars.shared.defaultCategory) { // Show navigation bar border if #available(iOS 13.0, *) { diff --git a/piwigo/Album/Extensions/AlbumViewController+Search.swift b/piwigo/Album/Extensions/AlbumViewController+Search.swift index f6c75f0f3..5c43ea38b 100644 --- a/piwigo/Album/Extensions/AlbumViewController+Search.swift +++ b/piwigo/Album/Extensions/AlbumViewController+Search.swift @@ -47,14 +47,15 @@ extension AlbumViewController: UISearchControllerDelegate // Initialise albumData albumData = albumProvider.getAlbum(ofUser: user, withId: categoryId)! - self.resetSearchAlbum(withQuery: "") + resetSearchAlbum(withQuery: "") // Update albums - fetchAlbumsRequest.predicate = albumPredicate.withSubstitutionVariables(["catId" : categoryId]) + let substitute: [String : Any] = ["catId" : categoryId] + fetchAlbumsRequest.predicate = albumPredicate.withSubstitutionVariables(substitute) try? albums.performFetch() // Update images - fetchImagesRequest.predicate = imagePredicate.withSubstitutionVariables(["catId" : categoryId]) + fetchImagesRequest.predicate = imagePredicate.withSubstitutionVariables(substitute) try? images.performFetch() // Reload collection diff --git a/piwigo/Album/Extensions/AlbumViewController+Select.swift b/piwigo/Album/Extensions/AlbumViewController+Select.swift index f5c6f47ef..19cb1bfa8 100644 --- a/piwigo/Album/Extensions/AlbumViewController+Select.swift +++ b/piwigo/Album/Extensions/AlbumViewController+Select.swift @@ -328,7 +328,7 @@ extension AlbumViewController // Will interpret touches only in horizontal direction if let gPR = gestureRecognizer as? UIPanGestureRecognizer { let translation = gPR.translation(in: imagesCollection) - if abs(Float(translation.x)) > abs(Float(translation.y)) { + if abs(translation.x) > abs(translation.y) { return true } } diff --git a/piwigo/Image/ImageViewController.swift b/piwigo/Image/ImageViewController.swift index 434a313c3..ae3449e03 100644 --- a/piwigo/Image/ImageViewController.swift +++ b/piwigo/Image/ImageViewController.swift @@ -466,166 +466,182 @@ class ImageViewController: UIViewController { favoriteBarButton = getFavoriteBarButton() if #available(iOS 14, *) { - // Interface depends on device and orientation - let orientation = view.window?.windowScene?.interfaceOrientation ?? .portrait + updateNavBarNew() + } else { + // Fallback on earlier versions + updateNavBarOld() + } + } + + @available(iOS 14, *) + private func updateNavBarNew() { + // Interface depends on device and orientation + let orientation = view.window?.windowScene?.interfaceOrientation ?? .portrait + + // User with admin or upload rights can do everything + if user.hasUploadRights(forCatID: categoryId) { + // The action button proposes: + /// - to copy or move images to other albums + /// - to set the image as album thumbnail + /// - to edit image parameters, + let menu = UIMenu(title: "", children: [albumMenu(), editMenu()].compactMap({$0})) + actionBarButton = UIBarButtonItem(image: UIImage(systemName: "ellipsis.circle"), menu: menu) + actionBarButton?.accessibilityIdentifier = "actions" - // User with admin or upload rights can do everything - if user.hasUploadRights(forCatID: categoryId) { - // The action button proposes: - /// - to copy or move images to other albums - /// - to set the image as album thumbnail - /// - to edit image parameters, - let menu = UIMenu(title: "", children: [albumMenu(), editMenu()].compactMap({$0})) - actionBarButton = UIBarButtonItem(image: UIImage(systemName: "ellipsis.circle"), menu: menu) - actionBarButton?.accessibilityIdentifier = "actions" - - if UIDevice.current.userInterfaceIdiom == .phone, orientation.isPortrait { - // Buttons in the navigation bar - navigationItem.leftBarButtonItems = [backButton].compactMap {$0} - navigationItem.rightBarButtonItems = [actionBarButton].compactMap {$0} - - // Remaining buttons in navigation toolbar - /// Fixed space added on both sides of play/pause button so that its global width - /// matches the width of the mute/unmute button. - isToolbarRequired = true - setToolbarItems([shareBarButton, UIBarButtonItem.space(), - playBarButton == nil ? nil : UIBarButtonItem.fixedSpace(4.3333), - playBarButton, playBarButton == nil ? nil : UIBarButtonItem.space(), - playBarButton == nil ? nil : UIBarButtonItem.fixedSpace(4.3333), - favoriteBarButton, favoriteBarButton == nil ? nil : UIBarButtonItem.space(), - muteBarButton, muteBarButton == nil ? nil : UIBarButtonItem.space(), - deleteBarButton].compactMap { $0 }, animated: false) - let isNavigationBarHidden = navigationController?.isNavigationBarHidden ?? false - navigationController?.setToolbarHidden(isNavigationBarHidden, animated: true) - } - else { - // Buttons in the navigation bar - navigationItem.leftBarButtonItems = [backButton, playBarButton, muteBarButton].compactMap {$0} - navigationItem.rightBarButtonItems = [actionBarButton, deleteBarButton, favoriteBarButton, shareBarButton].compactMap { $0 } - - // No toolbar - isToolbarRequired = false - setToolbarItems([], animated: false) - navigationController?.setToolbarHidden(true, animated: true) - } - } - else if favoriteBarButton != nil { - if UIDevice.current.userInterfaceIdiom == .phone, orientation.isPortrait { - // Buttons in the navigation bar - navigationItem.leftBarButtonItems = [backButton].compactMap {$0} - navigationItem.rightBarButtonItems = [] - - // Remaining buttons in navigation toolbar - /// Fixed space added on both sides of play/pause button so that its global width - /// matches the width of the mute/unmute button. - isToolbarRequired = true - let isNavigationBarHidden = navigationController?.isNavigationBarHidden ?? false - setToolbarItems([shareBarButton, UIBarButtonItem.space(), - playBarButton == nil ? nil : UIBarButtonItem.fixedSpace(4.3333), - playBarButton, playBarButton == nil ? nil : UIBarButtonItem.space(), - playBarButton == nil ? nil : UIBarButtonItem.fixedSpace(4.3333), - muteBarButton, muteBarButton == nil ? nil : UIBarButtonItem.space(), - favoriteBarButton].compactMap { $0 }, animated: false) - navigationController?.setToolbarHidden(isNavigationBarHidden, animated: true) - } - else { - // All buttons in navigation bar - navigationItem.leftBarButtonItems = [backButton, playBarButton, muteBarButton].compactMap {$0} - navigationItem.rightBarButtonItems = [favoriteBarButton, shareBarButton].compactMap { $0 } - - // Hide navigation toolbar - isToolbarRequired = false - navigationController?.setToolbarHidden(true, animated: true) - } - } - else if NetworkVars.userStatus != .guest { - // All buttons in navigation bar - navigationItem.leftBarButtonItems = [backButton, playBarButton].compactMap {$0} - navigationItem.rightBarButtonItems = [shareBarButton, muteBarButton].compactMap { $0 } - - // Hide navigation toolbar - isToolbarRequired = false - navigationController?.setToolbarHidden(true, animated: false) + if UIDevice.current.userInterfaceIdiom == .phone, orientation.isPortrait { + // Buttons in the navigation bar + navigationItem.leftBarButtonItems = [backButton].compactMap {$0} + navigationItem.rightBarButtonItems = [actionBarButton].compactMap {$0} + + // Remaining buttons in navigation toolbar + /// Fixed space added on both sides of play/pause button so that its global width + /// matches the width of the mute/unmute button. + isToolbarRequired = true + var toolbarItems = [UIBarButtonItem?]() + toolbarItems.append(contentsOf: [shareBarButton, .space()]) + toolbarItems.append(contentsOf: [playBarButton == nil ? nil : .fixedSpace(4.3333)]) + toolbarItems.append(contentsOf: [playBarButton, playBarButton == nil ? nil : .space()]) + toolbarItems.append(contentsOf: [playBarButton == nil ? nil : .fixedSpace(4.3333)]) + toolbarItems.append(contentsOf: [favoriteBarButton, favoriteBarButton == nil ? nil : .space()]) + toolbarItems.append(contentsOf: [muteBarButton, muteBarButton == nil ? nil : .space()]) + toolbarItems.append(deleteBarButton) + setToolbarItems(toolbarItems.compactMap { $0 }, animated: false) + let isNavigationBarHidden = navigationController?.isNavigationBarHidden ?? false + navigationController?.setToolbarHidden(isNavigationBarHidden, animated: true) } else { - // All buttons in navigation bar - navigationItem.leftBarButtonItems = [backButton].compactMap {$0} - navigationItem.rightBarButtonItems = [playBarButton, muteBarButton].compactMap {$0} + // Buttons in the navigation bar + navigationItem.leftBarButtonItems = [backButton, playBarButton, muteBarButton].compactMap {$0} + navigationItem.rightBarButtonItems = [actionBarButton, deleteBarButton, favoriteBarButton, shareBarButton].compactMap { $0 } - // Hide navigation toolbar + // No toolbar isToolbarRequired = false - navigationController?.setToolbarHidden(true, animated: false) + setToolbarItems([], animated: false) + navigationController?.setToolbarHidden(true, animated: true) } } - else { - // Fallback on earlier versions - // Interface depends on device and orientation - let orientation = UIApplication.shared.statusBarOrientation - - // User with admin or upload rights can do everything - // WRONG =====> 'normal' user with upload access to the current category can edit images - // SHOULD BE => 'normal' user having uploaded images can edit them. This requires 'user_id' and 'added_by' values of images for checking rights - if user.hasUploadRights(forCatID: categoryId) { - // Navigation bar - // The action menu is simply an Edit button - actionBarButton = UIBarButtonItem(barButtonSystemItem: .edit, - target: self, action: #selector(editImage)) - actionBarButton?.accessibilityIdentifier = "edit" - navigationItem.leftBarButtonItems = [backButton, playBarButton].compactMap {$0} - navigationItem.rightBarButtonItems = [actionBarButton, muteBarButton].compactMap { $0 } - - // Navigation toolbar + else if favoriteBarButton != nil { + if UIDevice.current.userInterfaceIdiom == .phone, orientation.isPortrait { + // Buttons in the navigation bar + navigationItem.leftBarButtonItems = [backButton].compactMap {$0} + navigationItem.rightBarButtonItems = [] + + // Remaining buttons in navigation toolbar + /// Fixed space added on both sides of play/pause button so that its global width + /// matches the width of the mute/unmute button. isToolbarRequired = true let isNavigationBarHidden = navigationController?.isNavigationBarHidden ?? false - setToolbarItems([shareBarButton, UIBarButtonItem.space(), - moveBarButton, UIBarButtonItem.space(), - favoriteBarButton, favoriteBarButton == nil ? nil : UIBarButtonItem.space(), - setThumbnailBarButton, UIBarButtonItem.space(), - deleteBarButton].compactMap { $0 }, animated: false) + var toolbarItems = [UIBarButtonItem?]() + toolbarItems.append(contentsOf: [shareBarButton, .space()]) + toolbarItems.append(contentsOf: [playBarButton == nil ? nil : .fixedSpace(4.3333)]) + toolbarItems.append(contentsOf: [playBarButton, playBarButton == nil ? nil : .space()]) + toolbarItems.append(contentsOf: [playBarButton == nil ? nil : .fixedSpace(4.3333)]) + toolbarItems.append(contentsOf: [muteBarButton, muteBarButton == nil ? nil : .space()]) + toolbarItems.append(favoriteBarButton) + setToolbarItems(toolbarItems.compactMap { $0 }, animated: false) navigationController?.setToolbarHidden(isNavigationBarHidden, animated: true) } - else if favoriteBarButton != nil { - if UIDevice.current.userInterfaceIdiom == .phone, orientation.isPortrait { - // Navigation bar - navigationItem.leftBarButtonItems = [backButton].compactMap {$0} - navigationItem.rightBarButtonItems = [] - - // Remaining buttons in navigation toolbar - isToolbarRequired = true - let isNavigationBarHidden = navigationController?.isNavigationBarHidden ?? false - setToolbarItems([shareBarButton, UIBarButtonItem.space(), - playBarButton, playBarButton == nil ? nil : UIBarButtonItem.space(), - muteBarButton, muteBarButton == nil ? nil : UIBarButtonItem.space(), - favoriteBarButton!].compactMap { $0 }, animated: false) - navigationController?.setToolbarHidden(isNavigationBarHidden, animated: true) - } else { - navigationItem.leftBarButtonItems = [backButton, playBarButton, muteBarButton].compactMap {$0} - navigationItem.rightBarButtonItems = [favoriteBarButton, shareBarButton].compactMap { $0 } - - // Hide navigation toolbar - isToolbarRequired = false - navigationController?.setToolbarHidden(true, animated: true) - } - } - else if NetworkVars.userStatus != .guest { + else { // All buttons in navigation bar - navigationItem.leftBarButtonItems = [backButton, playBarButton].compactMap {$0} - navigationItem.rightBarButtonItems = [shareBarButton, muteBarButton].compactMap { $0 } + navigationItem.leftBarButtonItems = [backButton, playBarButton, muteBarButton].compactMap {$0} + navigationItem.rightBarButtonItems = [favoriteBarButton, shareBarButton].compactMap { $0 } // Hide navigation toolbar isToolbarRequired = false - navigationController?.setToolbarHidden(true, animated: false) + navigationController?.setToolbarHidden(true, animated: true) } - else { - // All buttons in navigation bar + } + else if NetworkVars.userStatus != .guest { + // All buttons in navigation bar + navigationItem.leftBarButtonItems = [backButton, playBarButton].compactMap {$0} + navigationItem.rightBarButtonItems = [shareBarButton, muteBarButton].compactMap { $0 } + + // Hide navigation toolbar + isToolbarRequired = false + navigationController?.setToolbarHidden(true, animated: false) + } + else { + // All buttons in navigation bar + navigationItem.leftBarButtonItems = [backButton].compactMap {$0} + navigationItem.rightBarButtonItems = [playBarButton, muteBarButton].compactMap {$0} + + // Hide navigation toolbar + isToolbarRequired = false + navigationController?.setToolbarHidden(true, animated: false) + } + } + + private func updateNavBarOld() { + // Interface depends on device and orientation + let orientation = UIApplication.shared.statusBarOrientation + + // User with admin or upload rights can do everything + // WRONG =====> 'normal' user with upload access to the current category can edit images + // SHOULD BE => 'normal' user having uploaded images can edit them. This requires 'user_id' and 'added_by' values of images for checking rights + if user.hasUploadRights(forCatID: categoryId) { + // Navigation bar + // The action menu is simply an Edit button + actionBarButton = UIBarButtonItem(barButtonSystemItem: .edit, + target: self, action: #selector(editImage)) + actionBarButton?.accessibilityIdentifier = "edit" + navigationItem.leftBarButtonItems = [backButton, playBarButton].compactMap {$0} + navigationItem.rightBarButtonItems = [actionBarButton, muteBarButton].compactMap { $0 } + + // Navigation toolbar + isToolbarRequired = true + let isNavigationBarHidden = navigationController?.isNavigationBarHidden ?? false + var toolbarItems = [UIBarButtonItem?]() + toolbarItems.append(contentsOf: [shareBarButton, .space()]) + toolbarItems.append(contentsOf: [moveBarButton, .space()]) + toolbarItems.append(contentsOf: [favoriteBarButton, favoriteBarButton == nil ? nil : .space()]) + toolbarItems.append(contentsOf: [setThumbnailBarButton, .space()]) + toolbarItems.append(deleteBarButton) + setToolbarItems(toolbarItems.compactMap { $0 }, animated: false) + navigationController?.setToolbarHidden(isNavigationBarHidden, animated: true) + } + else if favoriteBarButton != nil { + if UIDevice.current.userInterfaceIdiom == .phone, orientation.isPortrait { + // Navigation bar navigationItem.leftBarButtonItems = [backButton].compactMap {$0} - navigationItem.rightBarButtonItems = [playBarButton, muteBarButton].compactMap {$0} + navigationItem.rightBarButtonItems = [] + + // Remaining buttons in navigation toolbar + isToolbarRequired = true + let isNavigationBarHidden = navigationController?.isNavigationBarHidden ?? false + var toolbarItems = [UIBarButtonItem?]() + toolbarItems.append(contentsOf: [shareBarButton, .space()]) + toolbarItems.append(contentsOf: [playBarButton, playBarButton == nil ? nil : .space()]) + toolbarItems.append(contentsOf: [muteBarButton, muteBarButton == nil ? nil : .space()]) + toolbarItems.append(favoriteBarButton) + setToolbarItems(toolbarItems.compactMap { $0 }, animated: false) + navigationController?.setToolbarHidden(isNavigationBarHidden, animated: true) + } else { + navigationItem.leftBarButtonItems = [backButton, playBarButton, muteBarButton].compactMap {$0} + navigationItem.rightBarButtonItems = [favoriteBarButton, shareBarButton].compactMap { $0 } // Hide navigation toolbar isToolbarRequired = false - navigationController?.setToolbarHidden(true, animated: false) + navigationController?.setToolbarHidden(true, animated: true) } } + else if NetworkVars.userStatus != .guest { + // All buttons in navigation bar + navigationItem.leftBarButtonItems = [backButton, playBarButton].compactMap {$0} + navigationItem.rightBarButtonItems = [shareBarButton, muteBarButton].compactMap { $0 } + + // Hide navigation toolbar + isToolbarRequired = false + navigationController?.setToolbarHidden(true, animated: false) + } + else { + // All buttons in navigation bar + navigationItem.leftBarButtonItems = [backButton].compactMap {$0} + navigationItem.rightBarButtonItems = [playBarButton, muteBarButton].compactMap {$0} + + // Hide navigation toolbar + isToolbarRequired = false + navigationController?.setToolbarHidden(true, animated: false) + } } // Buttons are disabled (greyed) when retrieving image data diff --git a/piwigo/Image/Parameters/Extensions/EditImageParamsViewController+UITableViewDataSource.swift b/piwigo/Image/Parameters/Extensions/EditImageParamsViewController+UITableViewDataSource.swift index 37086d4df..78bdb887a 100644 --- a/piwigo/Image/Parameters/Extensions/EditImageParamsViewController+UITableViewDataSource.swift +++ b/piwigo/Image/Parameters/Extensions/EditImageParamsViewController+UITableViewDataSource.swift @@ -44,7 +44,8 @@ extension EditImageParamsViewController: UITableViewDataSource print("Error: tableView.dequeueReusableCell does not return a EditImageTextFieldTableViewCell!") return EditImageTextFieldTableViewCell() } - let wholeRange = NSRange(location: 0, length: commonTitle.string.count) + let titleLength: Int = commonTitle.string.count + let wholeRange = NSRange(location: 0, length: titleLength) let style = NSMutableParagraphStyle() style.alignment = NSTextAlignment.right let attributes = [ diff --git a/piwigo/Image/VideoDetailViewController.swift b/piwigo/Image/VideoDetailViewController.swift index 52c94cd48..8ef9582ac 100644 --- a/piwigo/Image/VideoDetailViewController.swift +++ b/piwigo/Image/VideoDetailViewController.swift @@ -262,7 +262,7 @@ class VideoDetailViewController: UIViewController // Center video horizontally in scrollview let videoWidth = videoContainerView.bounds.size.width * scrollView.zoomScale - let horizontalSpace = max(0, (view.bounds.width - videoWidth) / 2) + let horizontalSpace = max(0, (view.bounds.width - videoWidth) / 2.0) scrollView.contentInset.left = horizontalSpace scrollView.contentInset.right = horizontalSpace if horizontalSpace > 0 { @@ -271,7 +271,7 @@ class VideoDetailViewController: UIViewController // Center image vertically in scrollview let videoHeight = videoContainerView.bounds.size.height * scrollView.zoomScale - let verticalSpace = max(0, (view.bounds.height - videoHeight) / 2 ) + let verticalSpace = max(0, (view.bounds.height - videoHeight) / 2.0) scrollView.contentInset.top = verticalSpace scrollView.contentInset.bottom = verticalSpace if verticalSpace > 0 { From 1715fa99d506eeab0afdc8f2d1f83f2f47325509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eddy=20Leli=C3=A8vre-Berna?= Date: Sun, 11 Feb 2024 10:45:33 +0100 Subject: [PATCH 17/17] Version 3.1.3 build 558 for TestFlight testing and App Store --- piwigo/Info.plist | 2 +- piwigoKit/Info.plist | 2 +- uploadKit/Info.plist | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/piwigo/Info.plist b/piwigo/Info.plist index 1deff7d73..eee073a9e 100644 --- a/piwigo/Info.plist +++ b/piwigo/Info.plist @@ -25,7 +25,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 557 + 558 INIntentsSupported AutoUploadIntent diff --git a/piwigoKit/Info.plist b/piwigoKit/Info.plist index a37c5bfc2..d2e457e17 100644 --- a/piwigoKit/Info.plist +++ b/piwigoKit/Info.plist @@ -17,6 +17,6 @@ CFBundleShortVersionString 3.0.2 CFBundleVersion - 557 + 558 diff --git a/uploadKit/Info.plist b/uploadKit/Info.plist index 21b48ecb4..a7c6a45db 100644 --- a/uploadKit/Info.plist +++ b/uploadKit/Info.plist @@ -17,6 +17,6 @@ CFBundleShortVersionString 1.0.6 CFBundleVersion - 377 + 378