From 0a2dd448584a9d68df5d25a11dc6ca154e0959b2 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:33:00 +0530 Subject: [PATCH 1/7] NMC 2169 - Media theming customisation --- iOSClient/AppDelegate.swift | 2 + iOSClient/Main/NCMainTabBar.swift | 2 +- iOSClient/Main/NCPickerViewController.swift | 5 +- iOSClient/Menu/NCMedia+Menu.swift | 203 ++++++++++++++++++ iOSClient/Menu/NCViewer+Menu.swift | 15 -- .../Viewer/NCViewerMedia/NCViewerMedia.swift | 2 +- .../Viewer/NCViewerPDF/NCViewerPDF.swift | 2 +- .../NCViewerQuickLook/NCViewerQuickLook.swift | 2 +- 8 files changed, 212 insertions(+), 21 deletions(-) create mode 100644 iOSClient/Menu/NCMedia+Menu.swift diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index ab5853646f..6ad9388155 100644 --- a/iOSClient/AppDelegate.swift +++ b/iOSClient/AppDelegate.swift @@ -64,6 +64,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD if isUiTestingEnabled { deleteAllAccounts() } + UINavigationBar.appearance().tintColor = NCBrandColor.shared.customer + UIToolbar.appearance().tintColor = NCBrandColor.shared.customer let utilityFileSystem = NCUtilityFileSystem() let utility = NCUtility() diff --git a/iOSClient/Main/NCMainTabBar.swift b/iOSClient/Main/NCMainTabBar.swift index b8c2c5dc8f..2b97471098 100644 --- a/iOSClient/Main/NCMainTabBar.swift +++ b/iOSClient/Main/NCMainTabBar.swift @@ -149,7 +149,7 @@ class NCMainTabBar: UITabBar { // Media if let item = items?[3] { item.title = NSLocalizedString("_media_", comment: "") - item.image = UIImage(named: "media")?.image(color: NCBrandColor.shared.brandElement, size: 25) + item.image = UIImage(named: "mediaSelected")?.image(color: NCBrandColor.shared.brandElement, size: 25) item.selectedImage = item.image } diff --git a/iOSClient/Main/NCPickerViewController.swift b/iOSClient/Main/NCPickerViewController.swift index a2494d74da..92f4562b63 100644 --- a/iOSClient/Main/NCPickerViewController.swift +++ b/iOSClient/Main/NCPickerViewController.swift @@ -106,8 +106,9 @@ class customPhotoPickerViewController: TLPhotosPickerViewController { override func makeUI() { super.makeUI() - self.customNavItem.leftBarButtonItem?.tintColor = .systemBlue - self.customNavItem.rightBarButtonItem?.tintColor = .systemBlue + self.customNavItem.leftBarButtonItem?.tintColor = NCBrandColor.shared.customer + self.customNavItem.rightBarButtonItem?.tintColor = NCBrandColor.shared.customer + self.albumPopView.tintColor = NCBrandColor.shared.customer } } diff --git a/iOSClient/Menu/NCMedia+Menu.swift b/iOSClient/Menu/NCMedia+Menu.swift new file mode 100644 index 0000000000..e530c373aa --- /dev/null +++ b/iOSClient/Menu/NCMedia+Menu.swift @@ -0,0 +1,203 @@ +// +// NCMedia+Menu.swift +// Nextcloud +// +// Created by Marino Faggiana on 03/03/2021. +// Copyright © 2021 Marino Faggiana. All rights reserved. +// +// Author Marino Faggiana +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +import UIKit +import FloatingPanel +import NextcloudKit + +extension NCMedia { + func tapSelect() { + self.isEditMode = false + self.selectOcId.removeAll() + self.selectIndexPath.removeAll() + self.collectionView?.reloadData() + } + + func toggleMenu() { + + var actions: [NCMenuAction] = [] + + defer { presentMenu(with: actions) } + + if !isEditMode { + if let metadatas = self.metadatas, !metadatas.isEmpty { + actions.append( + NCMenuAction( + title: NSLocalizedString("_select_", comment: ""), + icon: utility.loadImage(named: "selectFull", color: NCBrandColor.shared.iconColor), + action: { _ in + self.isEditMode = true + } + ) + ) + } + + actions.append(.seperator(order: 0)) + + actions.append( + NCMenuAction( + title: NSLocalizedString("_media_viewimage_show_", comment: ""), + icon: utility.loadImage(named: filterClassTypeImage ? "nocamera" : "file_photo_menu",color: NCBrandColor.shared.iconColor), + selected: showOnlyImages, + on: true, + action: { _ in + self.showOnlyImages = true + self.showOnlyVideos = false + self.reloadDataSourceWithCompletion { _ in } + } + ) + ) + + actions.append( + NCMenuAction( + title: NSLocalizedString("_media_viewvideo_show_", comment: ""), + icon: utility.loadImage(named: filterClassTypeVideo ? "videono" : "videoyes",color: NCBrandColor.shared.iconColor), + selected: showOnlyVideos, + on: true, + action: { _ in + self.showOnlyImages = false + self.showOnlyVideos = true + self.reloadDataSourceWithCompletion { _ in } + } + ) + ) + + actions.append( + NCMenuAction( + title: NSLocalizedString("_media_show_all_", comment: ""), + icon: utility.loadImage(named: "photo.on.rectangle.angled"), + selected: !showOnlyImages && !showOnlyVideos, + on: true, + action: { _ in + self.showOnlyImages = false + self.showOnlyVideos = false + self.reloadDataSourceWithCompletion { _ in } + } + ) + ) + + actions.append(.seperator(order: 0)) + + actions.append( + NCMenuAction( + title: NSLocalizedString("_select_media_folder_", comment: ""), + icon: utility.loadImage(named: "folder"), + action: { _ in + if let navigationController = UIStoryboard(name: "NCSelect", bundle: nil).instantiateInitialViewController() as? UINavigationController, + let viewController = navigationController.topViewController as? NCSelect { + + viewController.delegate = self + viewController.typeOfCommandView = .select + viewController.type = "mediaFolder" + viewController.selectIndexPath = self.selectIndexPath + + self.present(navigationController, animated: true, completion: nil) + } + } + ) + ) + + actions.append( + NCMenuAction( + title: NSLocalizedString("_media_by_modified_date_", comment: ""), + icon: utility.loadImage(named: "sortFileNameAZ", color: NCBrandColor.shared.iconColor), + selected: NCKeychain().mediaSortDate == "date", + on: true, + action: { _ in + NCKeychain().mediaSortDate = "date" + self.reloadDataSourceWithCompletion { _ in } + } + ) + ) + + actions.append( + NCMenuAction( + title: NSLocalizedString("_media_by_created_date_", comment: ""), + icon: utility.loadImage(named: "sortFileNameAZ", color: NCBrandColor.shared.iconColor), + selected: NCKeychain().mediaSortDate == "creationDate", + on: true, + action: { _ in + NCKeychain().mediaSortDate = "creationDate" + self.reloadDataSourceWithCompletion { _ in } + } + ) + ) + + actions.append( + NCMenuAction( + title: NSLocalizedString("_media_by_upload_date_", comment: ""), + icon: utility.loadImage(named: "sortFileNameAZ", color: NCBrandColor.shared.iconColor), + selected: NCKeychain().mediaSortDate == "uploadDate", + on: true, + action: { _ in + NCKeychain().mediaSortDate = "uploadDate" + self.reloadDataSourceWithCompletion { _ in } + } + ) + ) + + } else { + + // + // CANCEL + // + actions.append( + NCMenuAction( + title: NSLocalizedString("_cancel_", comment: ""), + icon: utility.loadImage(named: "xmark", color: NCBrandColor.shared.iconColor), + action: { _ in self.tapSelect() } + ) + ) + + guard !selectOcId.isEmpty else { return } + let selectedMetadatas = selectOcId.compactMap(NCManageDatabase.shared.getMetadataFromOcId) + + // + // OPEN IN + // + actions.append(.openInAction(selectedMetadatas: selectedMetadatas, viewController: self, completion: tapSelect)) + + // + // SAVE TO PHOTO GALLERY + // + actions.append(.saveMediaAction(selectedMediaMetadatas: selectedMetadatas, completion: tapSelect)) + + // + // COPY - MOVE + // + actions.append(.moveOrCopyAction(selectedMetadatas: selectedMetadatas, indexPath: selectIndexPath, completion: tapSelect)) + + // + // COPY + // + actions.append(.copyAction(selectOcId: selectOcId, completion: tapSelect)) + + // + // DELETE + // can't delete from cache because is needed for NCMedia view, and if locked can't delete from server either. + if !selectedMetadatas.contains(where: { $0.lock && $0.lockOwner != appDelegate.userId }) { + actions.append(.deleteAction(selectedMetadatas: selectedMetadatas, indexPath: selectIndexPath, metadataFolder: nil, viewController: self, completion: tapSelect)) + } + } + } +} diff --git a/iOSClient/Menu/NCViewer+Menu.swift b/iOSClient/Menu/NCViewer+Menu.swift index 42ffdfa179..b11e685a37 100644 --- a/iOSClient/Menu/NCViewer+Menu.swift +++ b/iOSClient/Menu/NCViewer+Menu.swift @@ -36,21 +36,6 @@ extension NCViewer { let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) let isOffline = localFile?.offline == true - // - // DETAIL - // - if !appDelegate.disableSharesView { - actions.append( - NCMenuAction( - title: NSLocalizedString("_details_", comment: ""), - icon: utility.loadImage(named: "info.circle"), - action: { _ in - NCActionCenter.shared.openShare(viewController: viewController, metadata: metadata, page: .activity) - } - ) - ) - } - // // VIEW IN FOLDER // diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift index 1c94738d39..413df249ea 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift @@ -120,7 +120,7 @@ class NCViewerMedia: UIViewController { // TIP var preferences = EasyTipView.Preferences() preferences.drawing.foregroundColor = .white - preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud + preferences.drawing.backgroundColor = NCBrandColor.shared.customer preferences.drawing.textAlignment = .left preferences.drawing.arrowPosition = .bottom preferences.drawing.cornerRadius = 10 diff --git a/iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift b/iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift index d46ab9fa38..118daff800 100644 --- a/iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift +++ b/iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift @@ -85,7 +85,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate { var preferences = EasyTipView.Preferences() preferences.drawing.foregroundColor = .white - preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud + preferences.drawing.backgroundColor = NCBrandColor.shared.customer preferences.drawing.textAlignment = .left preferences.drawing.arrowPosition = .right preferences.drawing.cornerRadius = 10 diff --git a/iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift b/iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift index 909540cbcb..9f0c483110 100644 --- a/iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift +++ b/iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift @@ -163,7 +163,7 @@ private var hasChangesQuickLook: Bool = false toolbarConfig.optionButtonFontSize = 16 toolbarConfig.optionButtonFontSizeForPad = 21 toolbarConfig.backgroundColor = .systemGray6 - toolbarConfig.foregroundColor = .systemBlue + toolbarConfig.foregroundColor = NCBrandColor.shared.customer var viewConfig = CropViewConfig() viewConfig.cropMaskVisualEffectType = .none From 7faf811548413fe4daf80e76f3f07f234150ab43 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Mon, 4 Dec 2023 13:14:42 +0530 Subject: [PATCH 2/7] NMC - 2169 - Merging conflicts resolve after NC 4.9.2 release --- iOSClient/Menu/NCMedia+Menu.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iOSClient/Menu/NCMedia+Menu.swift b/iOSClient/Menu/NCMedia+Menu.swift index e530c373aa..03be5b71dd 100644 --- a/iOSClient/Menu/NCMedia+Menu.swift +++ b/iOSClient/Menu/NCMedia+Menu.swift @@ -57,7 +57,7 @@ extension NCMedia { actions.append( NCMenuAction( title: NSLocalizedString("_media_viewimage_show_", comment: ""), - icon: utility.loadImage(named: filterClassTypeImage ? "nocamera" : "file_photo_menu",color: NCBrandColor.shared.iconColor), + icon: utility.loadImage(named: showOnlyImages ? "nocamera" : "file_photo_menu",color: NCBrandColor.shared.iconColor), selected: showOnlyImages, on: true, action: { _ in @@ -71,7 +71,7 @@ extension NCMedia { actions.append( NCMenuAction( title: NSLocalizedString("_media_viewvideo_show_", comment: ""), - icon: utility.loadImage(named: filterClassTypeVideo ? "videono" : "videoyes",color: NCBrandColor.shared.iconColor), + icon: utility.loadImage(named: showOnlyVideos ? "videono" : "videoyes",color: NCBrandColor.shared.iconColor), selected: showOnlyVideos, on: true, action: { _ in From f2561e779e00e48bcece24957949a73c3ad582ad Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:26:34 +0530 Subject: [PATCH 3/7] NMC 2169 - Merging conflict resolve after Nextcloud 4.9.3 release --- iOSClient/Menu/NCMedia+Menu.swift | 12 ++++++------ iOSClient/NCImageCache.swift | 16 ++++++++++++++-- iOSClient/Settings/NCKeychain.swift | 15 ++++++++++++++- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/iOSClient/Menu/NCMedia+Menu.swift b/iOSClient/Menu/NCMedia+Menu.swift index 03be5b71dd..6fe57d74e9 100644 --- a/iOSClient/Menu/NCMedia+Menu.swift +++ b/iOSClient/Menu/NCMedia+Menu.swift @@ -63,7 +63,7 @@ extension NCMedia { action: { _ in self.showOnlyImages = true self.showOnlyVideos = false - self.reloadDataSourceWithCompletion { _ in } + self.reloadDataSource { } } ) ) @@ -77,7 +77,7 @@ extension NCMedia { action: { _ in self.showOnlyImages = false self.showOnlyVideos = true - self.reloadDataSourceWithCompletion { _ in } + self.reloadDataSource { } } ) ) @@ -91,7 +91,7 @@ extension NCMedia { action: { _ in self.showOnlyImages = false self.showOnlyVideos = false - self.reloadDataSourceWithCompletion { _ in } + self.reloadDataSource { } } ) ) @@ -125,7 +125,7 @@ extension NCMedia { on: true, action: { _ in NCKeychain().mediaSortDate = "date" - self.reloadDataSourceWithCompletion { _ in } + self.reloadDataSource { } } ) ) @@ -138,7 +138,7 @@ extension NCMedia { on: true, action: { _ in NCKeychain().mediaSortDate = "creationDate" - self.reloadDataSourceWithCompletion { _ in } + self.reloadDataSource { } } ) ) @@ -151,7 +151,7 @@ extension NCMedia { on: true, action: { _ in NCKeychain().mediaSortDate = "uploadDate" - self.reloadDataSourceWithCompletion { _ in } + self.reloadDataSource { } } ) ) diff --git a/iOSClient/NCImageCache.swift b/iOSClient/NCImageCache.swift index 117a15a936..457ecc6805 100644 --- a/iOSClient/NCImageCache.swift +++ b/iOSClient/NCImageCache.swift @@ -196,8 +196,20 @@ import RealmSwift func getMediaMetadatas(account: String, predicate: NSPredicate? = nil) -> ThreadSafeArray? { guard let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)) else { return nil } let startServerUrl = NCUtilityFileSystem().getHomeServer(urlBase: tableAccount.urlBase, userId: tableAccount.userId) + tableAccount.mediaPath - let predicateBoth = NSPredicate(format: showBothPredicateMediaString, account, startServerUrl) - return NCManageDatabase.shared.getMediaMetadatas(predicate: predicate ?? predicateBoth) + let predicateBoth = NSPredicate(format: showBothPredicateMediaString, account, startServerUrl, NKCommon.TypeClassFile.image.rawValue, NKCommon.TypeClassFile.video.rawValue) + + var newMetadatas = NCManageDatabase.shared.getMediaMetadatas(predicate: predicate ?? predicateBoth) + switch NCKeychain().mediaSortDate { + case "date": + newMetadatas = newMetadatas.sorted(by: {($0.date as Date) > ($1.date as Date)}) + case "creationDate": + newMetadatas = newMetadatas.sorted(by: {($0.creationDate as Date) > ($1.creationDate as Date)}) + case "uploadDate": + newMetadatas = newMetadatas.sorted(by: {($0.uploadDate as Date) > ($1.uploadDate as Date)}) + default: + break + } + return newMetadatas } // MARK: - diff --git a/iOSClient/Settings/NCKeychain.swift b/iOSClient/Settings/NCKeychain.swift index 64a1565b62..66d065f861 100644 --- a/iOSClient/Settings/NCKeychain.swift +++ b/iOSClient/Settings/NCKeychain.swift @@ -302,7 +302,20 @@ import KeychainAccess keychain["mediaTypeLayout"] = String(newValue) } } - + + var mediaSortDate: String { + get { + migrate(key: "mediaSortDate") + if let value = try? keychain.get("mediaSortDate") { + return value + } + return "date" + } + set { + keychain["mediaSortDate"] = newValue + } + } + var textRecognitionStatus: Bool { get { migrate(key: "textRecognitionStatus") From 83f08f4c7cb48131134295bba413f1d71919be32 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:08:46 +0530 Subject: [PATCH 4/7] NMC 2169 - Media Menu option icon color changes --- iOSClient/Menu/NCMedia+Menu.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iOSClient/Menu/NCMedia+Menu.swift b/iOSClient/Menu/NCMedia+Menu.swift index 6fe57d74e9..0ad1f36838 100644 --- a/iOSClient/Menu/NCMedia+Menu.swift +++ b/iOSClient/Menu/NCMedia+Menu.swift @@ -85,7 +85,7 @@ extension NCMedia { actions.append( NCMenuAction( title: NSLocalizedString("_media_show_all_", comment: ""), - icon: utility.loadImage(named: "photo.on.rectangle.angled"), + icon: utility.loadImage(named: "photo.on.rectangle.angled", color: NCBrandColor.shared.iconColor), selected: !showOnlyImages && !showOnlyVideos, on: true, action: { _ in @@ -101,7 +101,7 @@ extension NCMedia { actions.append( NCMenuAction( title: NSLocalizedString("_select_media_folder_", comment: ""), - icon: utility.loadImage(named: "folder"), + icon: utility.loadImage(named: "folder", color: NCBrandColor.shared.iconColor), action: { _ in if let navigationController = UIStoryboard(name: "NCSelect", bundle: nil).instantiateInitialViewController() as? UINavigationController, let viewController = navigationController.topViewController as? NCSelect { From bc102373f910185eca3b39991959858824988033 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Wed, 10 Jan 2024 12:56:38 +0530 Subject: [PATCH 5/7] NMC 2169 - method changes after Nextcloud 4.9.6 release --- iOSClient/Menu/NCMedia+Menu.swift | 12 ++++++------ iOSClient/NCImageCache.swift | 11 +++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/iOSClient/Menu/NCMedia+Menu.swift b/iOSClient/Menu/NCMedia+Menu.swift index 0ad1f36838..cc1d094e39 100644 --- a/iOSClient/Menu/NCMedia+Menu.swift +++ b/iOSClient/Menu/NCMedia+Menu.swift @@ -63,7 +63,7 @@ extension NCMedia { action: { _ in self.showOnlyImages = true self.showOnlyVideos = false - self.reloadDataSource { } + self.reloadDataSource() } ) ) @@ -77,7 +77,7 @@ extension NCMedia { action: { _ in self.showOnlyImages = false self.showOnlyVideos = true - self.reloadDataSource { } + self.reloadDataSource() } ) ) @@ -91,7 +91,7 @@ extension NCMedia { action: { _ in self.showOnlyImages = false self.showOnlyVideos = false - self.reloadDataSource { } + self.reloadDataSource() } ) ) @@ -125,7 +125,7 @@ extension NCMedia { on: true, action: { _ in NCKeychain().mediaSortDate = "date" - self.reloadDataSource { } + self.reloadDataSource() } ) ) @@ -138,7 +138,7 @@ extension NCMedia { on: true, action: { _ in NCKeychain().mediaSortDate = "creationDate" - self.reloadDataSource { } + self.reloadDataSource() } ) ) @@ -151,7 +151,7 @@ extension NCMedia { on: true, action: { _ in NCKeychain().mediaSortDate = "uploadDate" - self.reloadDataSource { } + self.reloadDataSource() } ) ) diff --git a/iOSClient/NCImageCache.swift b/iOSClient/NCImageCache.swift index 457ecc6805..80901dc0f5 100644 --- a/iOSClient/NCImageCache.swift +++ b/iOSClient/NCImageCache.swift @@ -196,20 +196,19 @@ import RealmSwift func getMediaMetadatas(account: String, predicate: NSPredicate? = nil) -> ThreadSafeArray? { guard let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)) else { return nil } let startServerUrl = NCUtilityFileSystem().getHomeServer(urlBase: tableAccount.urlBase, userId: tableAccount.userId) + tableAccount.mediaPath - let predicateBoth = NSPredicate(format: showBothPredicateMediaString, account, startServerUrl, NKCommon.TypeClassFile.image.rawValue, NKCommon.TypeClassFile.video.rawValue) + let predicateBoth = NSPredicate(format: showBothPredicateMediaString, account, startServerUrl) - var newMetadatas = NCManageDatabase.shared.getMediaMetadatas(predicate: predicate ?? predicateBoth) switch NCKeychain().mediaSortDate { case "date": - newMetadatas = newMetadatas.sorted(by: {($0.date as Date) > ($1.date as Date)}) + return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "date") case "creationDate": - newMetadatas = newMetadatas.sorted(by: {($0.creationDate as Date) > ($1.creationDate as Date)}) + return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "creationDate") case "uploadDate": - newMetadatas = newMetadatas.sorted(by: {($0.uploadDate as Date) > ($1.uploadDate as Date)}) + return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "uploadDate") default: break } - return newMetadatas + return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "date") } // MARK: - From cf3190e3557d7fc2abec8ca79c2014fd7a9dd913 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Fri, 2 Feb 2024 12:17:57 +0530 Subject: [PATCH 6/7] NMC 2169 - NMC 2395 Media detail translation issue and theming customisation --- iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift index c54c76f567..3d8787a7f5 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift @@ -209,6 +209,7 @@ class NCViewerMediaDetailView: UIView { } if metadata.isImage && !utilityFileSystem.fileProviderStorageExists(metadata) && metadata.session.isEmpty { + downloadImageButton.tintColor = NCBrandColor.shared.brand downloadImageButton.setTitle(NSLocalizedString("_try_download_full_resolution_", comment: ""), for: .normal) downloadImageLabel.text = NSLocalizedString("_full_resolution_image_info_", comment: "") downloadImageButtonContainer.isHidden = false From 44f61223282dce1450de472eae0615207ff30932 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:36:24 +0530 Subject: [PATCH 7/7] NMC 2169 - Media Menu changes after NC 5.2 release --- iOSClient/Media/NCMedia+Command.swift | 35 +- iOSClient/Media/NCMedia.storyboard | 6 +- iOSClient/Media/NCMedia.swift | 332 +++++++++++++----- iOSClient/Media/NCMediaCommandView.xib | 178 ++++++++++ iOSClient/NCImageCache.swift | 8 +- .../NCViewerMedia/NCViewerMediaPage.swift | 6 +- 6 files changed, 450 insertions(+), 115 deletions(-) create mode 100644 iOSClient/Media/NCMediaCommandView.xib diff --git a/iOSClient/Media/NCMedia+Command.swift b/iOSClient/Media/NCMedia+Command.swift index 46b1d6b9a5..75a045dc6b 100644 --- a/iOSClient/Media/NCMedia+Command.swift +++ b/iOSClient/Media/NCMedia+Command.swift @@ -17,7 +17,7 @@ extension NCMedia { func setSelectcancelButton() { selectOcId.removeAll() - tabBarSelect.selectCount = selectOcId.count + tabBarSelect?.selectCount = selectOcId.count if let visibleCells = self.collectionView?.indexPathsForVisibleItems.compactMap({ self.collectionView?.cellForItem(at: $0) }) { for case let cell as NCGridMediaCell in visibleCells { cell.selected(false) @@ -25,35 +25,27 @@ extension NCMedia { } if isEditMode { activityIndicatorTrailing.constant = 150 - selectOrCancelButton.setTitle( NSLocalizedString("_cancel_", comment: ""), for: .normal) - selectOrCancelButtonTrailing.constant = 10 - selectOrCancelButton.isHidden = false - menuButton.isHidden = true - tabBarSelect.show() + tabBarSelect?.show() } else { activityIndicatorTrailing.constant = 150 - selectOrCancelButton.setTitle( NSLocalizedString("_select_", comment: ""), for: .normal) - selectOrCancelButtonTrailing.constant = 50 - selectOrCancelButton.isHidden = false - menuButton.isHidden = false - tabBarSelect.hide() + tabBarSelect?.hide() } } func setTitleDate(_ offset: CGFloat = 10) { - titleDate?.text = "" + mediaCommandView?.title.text = "" if let metadata = metadatas?.first { let contentOffsetY = collectionView.contentOffset.y let top = insetsTop + view.safeAreaInsets.top + offset if insetsTop + view.safeAreaInsets.top + contentOffsetY < 10 { - titleDate?.text = utility.getTitleFromDate(metadata.date as Date) + mediaCommandView?.title.text = utility.getTitleFromDate(metadata.date as Date) return } let point = CGPoint(x: offset, y: top + contentOffsetY) if let indexPath = collectionView.indexPathForItem(at: point) { let cell = self.collectionView(collectionView, cellForItemAt: indexPath) as? NCGridMediaCell - if let date = cell?.date { - self.titleDate?.text = utility.getTitleFromDate(date) + if let date = cell?.fileDate { + mediaCommandView?.title.text = utility.getTitleFromDate(date) } } else { if offset < 20 { @@ -65,16 +57,12 @@ extension NCMedia { func setColor() { if isTop { - titleDate?.textColor = .label + mediaCommandView?.title?.textColor = .label activityIndicator.color = .label - selectOrCancelButton.setTitleColor(.label, for: .normal) - menuButton.setImage(UIImage(systemName: "ellipsis")?.withTintColor(.label, renderingMode: .alwaysOriginal), for: .normal) gradientView.isHidden = true } else { - titleDate?.textColor = .white + mediaCommandView?.title?.textColor = .white activityIndicator.color = .white - selectOrCancelButton.setTitleColor(.white, for: .normal) - menuButton.setImage(UIImage(systemName: "ellipsis")?.withTintColor(.white, renderingMode: .alwaysOriginal), for: .normal) gradientView.isHidden = false } } @@ -85,7 +73,8 @@ extension NCMedia { let layoutTitle = (layout == NCGlobal.shared.mediaLayoutRatio) ? NSLocalizedString("_media_square_", comment: "") : NSLocalizedString("_media_ratio_", comment: "") let layoutImage = (layout == NCGlobal.shared.mediaLayoutRatio) ? UIImage(systemName: "square.grid.3x3") : UIImage(systemName: "rectangle.grid.3x2") - if UIDevice.current.userInterfaceIdiom == .phone, UIDevice.current.orientation.isLandscape { + if UIDevice.current.userInterfaceIdiom == .phone, + (UIDevice.current.orientation == .landscapeLeft || UIDevice.current.orientation == .landscapeRight) { columnCount += 2 } @@ -176,7 +165,7 @@ extension NCMedia { self.present(alert, animated: true) } - menuButton.menu = UIMenu(title: "", children: [zoomViewMediaFolder, playFile, playURL]) +// menuButton.menu = UIMenu(title: "", children: [zoomViewMediaFolder, playFile, playURL]) } } diff --git a/iOSClient/Media/NCMedia.storyboard b/iOSClient/Media/NCMedia.storyboard index f1e221f104..517f2fdfb8 100644 --- a/iOSClient/Media/NCMedia.storyboard +++ b/iOSClient/Media/NCMedia.storyboard @@ -1,9 +1,9 @@ - + - + @@ -51,7 +51,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOSClient/NCImageCache.swift b/iOSClient/NCImageCache.swift index 80901dc0f5..0a08f82f72 100644 --- a/iOSClient/NCImageCache.swift +++ b/iOSClient/NCImageCache.swift @@ -200,15 +200,15 @@ import RealmSwift switch NCKeychain().mediaSortDate { case "date": - return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "date") + return NCManageDatabase.shared.getMediaMetadatas(predicate: predicate ?? predicateBoth, sorted: "date") case "creationDate": - return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "creationDate") + return NCManageDatabase.shared.getMediaMetadatas(predicate: predicate ?? predicateBoth, sorted: "creationDate") case "uploadDate": - return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "uploadDate") + return NCManageDatabase.shared.getMediaMetadatas(predicate: predicate ?? predicateBoth, sorted: "uploadDate") default: break } - return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "date") + return NCManageDatabase.shared.getMediaMetadatas(predicate: predicate ?? predicateBoth, sorted: "date") } // MARK: - diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift index aba95bbc18..408f452ae9 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift @@ -398,7 +398,8 @@ class NCViewerMediaPage: UIViewController { @objc func deleteFile(_ notification: NSNotification) { - guard let userInfo = notification.userInfo as NSDictionary? else { return } + guard let userInfo = notification.userInfo as NSDictionary?, + let error = userInfo["error"] as? NKError else { return } if let ocIds = userInfo["ocId"] as? [String], let ocId = ocIds.first { @@ -416,6 +417,9 @@ class NCViewerMediaPage: UIViewController { shiftCurrentPage() } } + if error != .success { + NCContentPresenter().showError(error: error) + } } @objc func moveFile(_ notification: NSNotification) {