From e458015e3c483ba0197eaf10e2af26d5a2d7fe94 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Mon, 20 May 2024 09:56:23 +0200 Subject: [PATCH] improved images Signed-off-by: Marino Faggiana --- iOSClient/Activity/NCActivityCommentView.swift | 2 +- iOSClient/Activity/NCActivityTableViewCell.swift | 6 ++++-- .../Collection Common/NCCollectionViewCommon.swift | 1 - iOSClient/Utility/NCUtility+Image.swift | 12 ++---------- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/iOSClient/Activity/NCActivityCommentView.swift b/iOSClient/Activity/NCActivityCommentView.swift index e8456f9cd4..22f9072798 100644 --- a/iOSClient/Activity/NCActivityCommentView.swift +++ b/iOSClient/Activity/NCActivityCommentView.swift @@ -40,7 +40,7 @@ class NCActivityCommentView: UIView, UITextFieldDelegate { if let image = UIImage(contentsOfFile: fileNameLocalPath) { imageItem.image = image } else { - imageItem.image = UIImage(named: "avatar") + imageItem.image = NCUtility().loadImage(named: "person.crop.circle", colors: [NCBrandColor.shared.iconImageColor]) } if account.displayName.isEmpty { diff --git a/iOSClient/Activity/NCActivityTableViewCell.swift b/iOSClient/Activity/NCActivityTableViewCell.swift index 3f53ef746d..5662d92fcb 100644 --- a/iOSClient/Activity/NCActivityTableViewCell.swift +++ b/iOSClient/Activity/NCActivityTableViewCell.swift @@ -176,7 +176,7 @@ extension NCActivityTableViewCell: UICollectionViewDataSource { let source = activityPreview.source - utility.convertSVGtoPNGWriteToUserData(svgUrlString: source, width: 100, rewrite: false, account: appDelegate.account, id: idActivity) { imageNamePath, id in + utility.convertSVGtoPNGWriteToUserData(svgUrlString: source, width: 150, rewrite: false, account: appDelegate.account, id: idActivity) { imageNamePath, id in if let imageNamePath = imageNamePath, id == self.idActivity, let image = UIImage(contentsOfFile: imageNamePath) { cell.imageView.image = image } else { @@ -192,8 +192,10 @@ extension NCActivityTableViewCell: UICollectionViewDataSource { if FileManager.default.fileExists(atPath: fileNamePath), let image = UIImage(contentsOfFile: fileNamePath) { cell.imageView.image = image + cell.imageView?.contentMode = .scaleAspectFill } else { - cell.imageView?.image = UIImage(named: "file_photo") + cell.imageView?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) + cell.imageView?.contentMode = .scaleAspectFit cell.fileId = fileId if !FileManager.default.fileExists(atPath: fileNamePath) { if NCNetworking.shared.downloadThumbnailActivityQueue.operations.filter({ ($0 as? NCOperationDownloadThumbnailActivity)?.fileId == fileId }).isEmpty { diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index cbdc687813..e1b3df3865 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -1215,7 +1215,6 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } if metadata.name == NCGlobal.shared.appName { if let image = utility.createFilePreviewImage(ocId: metadata.ocId, etag: metadata.etag, fileNameView: metadata.fileNameView, classFile: metadata.classFile, status: metadata.status, createPreviewMedia: !metadata.hasPreview) { - cell.filePreviewImageView?.image = image } else { if metadata.iconName.isEmpty { diff --git a/iOSClient/Utility/NCUtility+Image.swift b/iOSClient/Utility/NCUtility+Image.swift index f9c7fd7f2f..7d9cfd7cd6 100644 --- a/iOSClient/Utility/NCUtility+Image.swift +++ b/iOSClient/Utility/NCUtility+Image.swift @@ -84,7 +84,6 @@ extension NCUtility { } @objc func loadUserImage(for user: String, displayName: String?, userBaseUrl: NCUserBaseUrl) -> UIImage { - let fileName = userBaseUrl.userBaseUrl + "-" + user + ".png" let localFilePath = utilityFileSystem.directoryUserData + "/" + fileName @@ -101,12 +100,11 @@ extension NCUtility { } else if let displayName = displayName, !displayName.isEmpty, let avatarImg = createAvatar(displayName: displayName, size: 30) { return avatarImg } else { - return UIImage(systemName: "person.crop.circle", withConfiguration: UIImage.SymbolConfiguration(pointSize: 30))! + return loadImage(named: "person.crop.circle", colors: [NCBrandColor.shared.iconImageColor]) } } func imageFromVideo(url: URL, at time: TimeInterval) -> UIImage? { - let asset = AVURLAsset(url: url) let assetIG = AVAssetImageGenerator(asset: asset) @@ -126,9 +124,7 @@ extension NCUtility { } func createImageFrom(fileNameView: String, ocId: String, etag: String, classFile: String) { - var originalImage, scaleImagePreview, scaleImageIcon: UIImage? - let fileNamePath = utilityFileSystem.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView) let fileNamePathPreview = utilityFileSystem.getDirectoryProviderStoragePreviewOcId(ocId, etag: etag) let fileNamePathIcon = utilityFileSystem.getDirectoryProviderStorageIconOcId(ocId, etag: etag) @@ -159,10 +155,7 @@ extension NCUtility { } func getImageMetadata(_ metadata: tableMetadata, for size: CGFloat) -> UIImage? { - - if let image = getImage(metadata: metadata) { - return image - } + if let image = getImage(metadata: metadata) { return image } if metadata.isVideo && !metadata.hasPreview { createImageFrom(fileNameView: metadata.fileNameView, ocId: metadata.ocId, etag: metadata.etag, classFile: metadata.classFile) @@ -182,7 +175,6 @@ extension NCUtility { } func getImage(metadata: tableMetadata) -> UIImage? { - let ext = (metadata.fileNameView as NSString).pathExtension.uppercased() var image: UIImage?