diff --git a/iOSClient/AppDelegate.swift b/iOSClient/AppDelegate.swift index d82b1cb27e..6111da4ede 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 fe8c41a157..1358ece48d 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..cc1d094e39 --- /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: showOnlyImages ? "nocamera" : "file_photo_menu",color: NCBrandColor.shared.iconColor), + selected: showOnlyImages, + on: true, + action: { _ in + self.showOnlyImages = true + self.showOnlyVideos = false + self.reloadDataSource() + } + ) + ) + + actions.append( + NCMenuAction( + title: NSLocalizedString("_media_viewvideo_show_", comment: ""), + icon: utility.loadImage(named: showOnlyVideos ? "videono" : "videoyes",color: NCBrandColor.shared.iconColor), + selected: showOnlyVideos, + on: true, + action: { _ in + self.showOnlyImages = false + self.showOnlyVideos = true + self.reloadDataSource() + } + ) + ) + + actions.append( + NCMenuAction( + title: NSLocalizedString("_media_show_all_", comment: ""), + icon: utility.loadImage(named: "photo.on.rectangle.angled", color: NCBrandColor.shared.iconColor), + selected: !showOnlyImages && !showOnlyVideos, + on: true, + action: { _ in + self.showOnlyImages = false + self.showOnlyVideos = false + self.reloadDataSource() + } + ) + ) + + actions.append(.seperator(order: 0)) + + actions.append( + NCMenuAction( + title: NSLocalizedString("_select_media_folder_", comment: ""), + 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 { + + 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.reloadDataSource() + } + ) + ) + + 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.reloadDataSource() + } + ) + ) + + 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.reloadDataSource() + } + ) + ) + + } 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 c8b736b4ca..e167cb4222 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/NCImageCache.swift b/iOSClient/NCImageCache.swift index 117a15a936..80901dc0f5 100644 --- a/iOSClient/NCImageCache.swift +++ b/iOSClient/NCImageCache.swift @@ -197,7 +197,18 @@ import RealmSwift 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) + + switch NCKeychain().mediaSortDate { + case "date": + return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "date") + case "creationDate": + return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "creationDate") + case "uploadDate": + return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "uploadDate") + default: + break + } + return NCManageDatabase.shared.getResultsMetadatas(predicate: predicate ?? predicateBoth, sorted: "date") } // MARK: - diff --git a/iOSClient/Settings/NCKeychain.swift b/iOSClient/Settings/NCKeychain.swift index 28310e9979..748ab13cf2 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") diff --git a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift index 19d64a7f07..19bdf56a3f 100644 --- a/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift +++ b/iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift @@ -114,7 +114,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/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 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