|
@@ -24,7 +24,7 @@
|
|
|
import Foundation
|
|
|
import NCCommunication
|
|
|
|
|
|
-class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCEmptyDataSetDelegate, UIAdaptivePresentationControllerDelegate {
|
|
|
+class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, UIAdaptivePresentationControllerDelegate, NCEmptyDataSetDelegate {
|
|
|
|
|
|
@IBOutlet weak var collectionView: UICollectionView!
|
|
|
|
|
@@ -33,7 +33,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
internal let refreshControl = UIRefreshControl()
|
|
|
internal var searchController: UISearchController?
|
|
|
internal var emptyDataSet: NCEmptyDataSet?
|
|
|
-
|
|
|
+
|
|
|
internal var serverUrl: String = ""
|
|
|
internal var isEncryptedFolder = false
|
|
|
internal var isEditMode = false
|
|
@@ -68,6 +68,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
|
|
|
internal var isReloadDataSourceNetworkInProgress: Bool = false
|
|
|
|
|
|
+ var selectedIndexPath: IndexPath!
|
|
|
+
|
|
|
+
|
|
|
// DECLARE
|
|
|
internal var layoutKey = ""
|
|
|
internal var titleCurrentFolder = ""
|
|
@@ -83,7 +86,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
- self.navigationController?.navigationBar.prefersLargeTitles = true
|
|
|
+ self.navigationController?.presentationController?.delegate = self
|
|
|
|
|
|
if enableSearchBar {
|
|
|
searchController = UISearchController(searchResultsController: nil)
|
|
@@ -136,6 +139,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(initializeMain), name: NSNotification.Name(rawValue: k_notificationCenter_initializeMain), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataSource), object: nil)
|
|
|
+ NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSourceNetworkForced(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataSourceNetworkForced), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(changeStatusFolderE2EE(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_changeStatusFolderE2EE), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(closeRichWorkspaceWebView), name: NSNotification.Name(rawValue: k_notificationCenter_closeRichWorkspaceWebView), object: nil)
|
|
|
|
|
@@ -162,16 +166,14 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
|
super.viewWillAppear(animated)
|
|
|
|
|
|
+ appDelegate.activeViewController = self
|
|
|
+
|
|
|
if serverUrl == "" {
|
|
|
appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
|
|
|
} else {
|
|
|
appDelegate.activeServerUrl = serverUrl
|
|
|
}
|
|
|
|
|
|
- appDelegate.activeViewController = self
|
|
|
-
|
|
|
- self.navigationItem.title = titleCurrentFolder
|
|
|
-
|
|
|
(layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
|
|
|
gridLayout.itemForLine = CGFloat(itemForLine)
|
|
|
|
|
@@ -181,7 +183,10 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
collectionView?.collectionViewLayout = gridLayout
|
|
|
}
|
|
|
|
|
|
+ navigationController?.navigationBar.prefersLargeTitles = true
|
|
|
+ navigationController?.setNavigationBarHidden(false, animated: true)
|
|
|
setNavigationItem()
|
|
|
+
|
|
|
reloadDataSource()
|
|
|
}
|
|
|
|
|
@@ -215,14 +220,15 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
}
|
|
|
|
|
|
func setNavigationItem() {
|
|
|
+
|
|
|
if isEditMode {
|
|
|
- self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage.init(named: "navigationMore"), style: .plain, target: self, action:#selector(tapSelectMenu(sender:)))
|
|
|
- self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: .plain, target: self, action: #selector(tapSelect(sender:)))
|
|
|
- self.navigationItem.title = NSLocalizedString("_selected_", comment: "") + " : \(selectOcId.count)" + " / \(dataSource.metadatas.count)"
|
|
|
+ navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage.init(named: "navigationMore"), style: .plain, target: self, action:#selector(tapSelectMenu(sender:)))
|
|
|
+ navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: .plain, target: self, action: #selector(tapSelect(sender:)))
|
|
|
+ navigationItem.title = NSLocalizedString("_selected_", comment: "") + " : \(selectOcId.count)" + " / \(dataSource.metadatas.count)"
|
|
|
} else {
|
|
|
- self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_select_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(tapSelect(sender:)))
|
|
|
- self.navigationItem.leftBarButtonItem = nil
|
|
|
- self.navigationItem.title = titleCurrentFolder
|
|
|
+ navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_select_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(tapSelect(sender:)))
|
|
|
+ navigationItem.leftBarButtonItem = nil
|
|
|
+ navigationItem.title = titleCurrentFolder
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -255,7 +261,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
}
|
|
|
|
|
|
@objc func changeTheming() {
|
|
|
- appDelegate.changeTheming(self, tableView: nil, collectionView: collectionView, form: false)
|
|
|
+ view.backgroundColor = NCBrandColor.shared.backgroundView
|
|
|
+ collectionView.backgroundColor = NCBrandColor.shared.backgroundView
|
|
|
+ collectionView.reloadData()
|
|
|
}
|
|
|
|
|
|
@objc func reloadDataSource(_ notification: NSNotification) {
|
|
@@ -264,6 +272,19 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
reloadDataSource()
|
|
|
}
|
|
|
|
|
|
+ @objc func reloadDataSourceNetworkForced(_ notification: NSNotification) {
|
|
|
+ if self.view?.window == nil { return }
|
|
|
+ if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
+ if let serverUrl = userInfo["serverUrl"] as? String {
|
|
|
+ if serverUrl == self.serverUrl {
|
|
|
+ reloadDataSourceNetwork(forced: true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ reloadDataSourceNetwork(forced: true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@objc func changeStatusFolderE2EE(_ notification: NSNotification) {
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
@@ -303,9 +324,11 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let ocId = userInfo["ocId"] as? String, let ocIdNew = userInfo["ocIdNew"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId), let metadataNew = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocIdNew) {
|
|
|
- if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
- if let row = dataSource.deleteMetadata(ocId: metadata.ocId) {
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let serverUrlFrom = userInfo["serverUrlFrom"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
+
|
|
|
+ // DEL
|
|
|
+ if serverUrlFrom == serverUrl && metadata.account == appDelegate.account {
|
|
|
+ if let row = dataSource.deleteMetadata(ocId: ocId) {
|
|
|
let indexPath = IndexPath(row: row, section: 0)
|
|
|
collectionView?.performBatchUpdates({
|
|
|
collectionView?.deleteItems(at: [indexPath])
|
|
@@ -313,8 +336,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
self.collectionView?.reloadData()
|
|
|
})
|
|
|
}
|
|
|
- } else if metadataNew.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
- if let row = dataSource.addMetadata(metadataNew) {
|
|
|
+ // ADD
|
|
|
+ } else if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
+ if let row = dataSource.addMetadata(metadata) {
|
|
|
let indexPath = IndexPath(row: row, section: 0)
|
|
|
collectionView?.performBatchUpdates({
|
|
|
collectionView?.insertItems(at: [indexPath])
|
|
@@ -332,6 +356,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
if let serverUrlTo = userInfo["serverUrlTo"] as? String {
|
|
|
+
|
|
|
if serverUrlTo == self.serverUrl {
|
|
|
reloadDataSource()
|
|
|
}
|
|
@@ -349,7 +374,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
+
|
|
|
if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
if let row = dataSource.addMetadata(metadata) {
|
|
|
let indexPath = IndexPath(row: row, section: 0)
|
|
@@ -370,7 +396,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
+
|
|
|
if dataSource.getIndexMetadata(ocId: metadata.ocId) != nil {
|
|
|
reloadDataSource()
|
|
|
}
|
|
@@ -382,7 +409,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
if let row = dataSource.reloadMetadata(ocId: metadata.ocId) {
|
|
|
let indexPath = IndexPath(row: row, section: 0)
|
|
|
if indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section) {
|
|
@@ -397,7 +424,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let ocId = userInfo["ocId"] as? String, let _ = userInfo["errorCode"] as? Int, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let _ = userInfo["errorCode"] as? Int, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
if let row = dataSource.reloadMetadata(ocId: metadata.ocId) {
|
|
|
let indexPath = IndexPath(row: row, section: 0)
|
|
|
if indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section) {
|
|
@@ -412,7 +439,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
if let row = dataSource.reloadMetadata(ocId: metadata.ocId) {
|
|
|
let indexPath = IndexPath(row: row, section: 0)
|
|
|
if indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section) {
|
|
@@ -427,7 +454,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
dataSource.addMetadata(metadata)
|
|
|
self.collectionView?.reloadData()
|
|
@@ -440,7 +467,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let ocId = userInfo["ocId"] as? String, let ocIdTemp = userInfo["ocIdTemp"] as? String, let _ = userInfo["errorCode"] as? Int, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let ocIdTemp = userInfo["ocIdTemp"] as? String, let _ = userInfo["errorCode"] as? Int, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
dataSource.reloadMetadata(ocId: metadata.ocId, ocIdTemp: ocIdTemp)
|
|
|
collectionView?.reloadData()
|
|
@@ -453,9 +480,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if self.view?.window == nil { return }
|
|
|
|
|
|
if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
- if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if let ocId = userInfo["ocId"] as? String, let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
+
|
|
|
if metadata.serverUrl == serverUrl && metadata.account == appDelegate.account {
|
|
|
-
|
|
|
if let row = dataSource.deleteMetadata(ocId: metadata.ocId) {
|
|
|
let indexPath = IndexPath(row: row, section: 0)
|
|
|
collectionView?.performBatchUpdates({
|
|
@@ -544,9 +571,15 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
view.emptyTitle.text = NSLocalizedString("_request_in_progress_", comment: "")
|
|
|
view.emptyDescription.text = ""
|
|
|
} else {
|
|
|
- view.emptyImage.image = emptyImage
|
|
|
- view.emptyTitle.text = NSLocalizedString(emptyTitle, comment: "")
|
|
|
- view.emptyDescription.text = NSLocalizedString(emptyDescription, comment: "")
|
|
|
+ if serverUrl == "" {
|
|
|
+ view.emptyImage.image = emptyImage
|
|
|
+ view.emptyTitle.text = NSLocalizedString(emptyTitle, comment: "")
|
|
|
+ view.emptyDescription.text = NSLocalizedString(emptyDescription, comment: "")
|
|
|
+ } else {
|
|
|
+ view.emptyImage.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), width: 300, height: 300, color: NCBrandColor.shared.brandElement)
|
|
|
+ view.emptyTitle.text = NSLocalizedString("_files_no_files_", comment: "")
|
|
|
+ view.emptyDescription.text = NSLocalizedString("_no_file_pull_down_", comment: "")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -633,7 +666,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
func tapShareListItem(with objectId: String, sender: Any) {
|
|
|
|
|
|
if isEditMode { return }
|
|
|
- guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) else { return }
|
|
|
+ guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId) else { return }
|
|
|
|
|
|
NCNetworkingNotificationCenter.shared.openShare(ViewController: self, metadata: metadata, indexPage: 2)
|
|
|
}
|
|
@@ -642,7 +675,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
|
|
|
if isEditMode { return }
|
|
|
|
|
|
- guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) else { return }
|
|
|
+ guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId) else { return }
|
|
|
|
|
|
if namedButtonMore == k_buttonMoreMore {
|
|
|
toggleMoreMenu(viewController: self, metadata: metadata)
|
|
@@ -687,7 +720,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if gestureRecognizer.state != .began { return }
|
|
|
if serverUrl == "" { return }
|
|
|
|
|
|
- if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) {
|
|
|
+ if let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId) {
|
|
|
metadataTouch = metadata
|
|
|
} else {
|
|
|
metadataTouch = nil
|
|
@@ -706,7 +739,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
|
|
|
if metadataTouch != nil {
|
|
|
listMenuItems.append(UIMenuItem.init(title: NSLocalizedString("_open_quicklook_", comment: ""), action: #selector(openQuickLookMenu(_:))))
|
|
|
- if !NCBrandOptions.sharedInstance.disable_openin_file {
|
|
|
+ if !NCBrandOptions.shared.disable_openin_file {
|
|
|
listMenuItems.append(UIMenuItem.init(title: NSLocalizedString("_open_in_", comment: ""), action: #selector(openInMenu(_:))))
|
|
|
}
|
|
|
}
|
|
@@ -744,7 +777,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
|
|
|
if isEditMode {
|
|
|
for ocId in selectOcId {
|
|
|
- if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
metadatas.append(metadata)
|
|
|
}
|
|
|
}
|
|
@@ -823,33 +856,33 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- let metadataForUpload = NCManageDatabase.sharedInstance.createMetadata(account: appDelegate.account, fileName: fileNameView, ocId: ocId, serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: contentType, livePhoto: false)
|
|
|
+ let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate.account, fileName: fileNameView, ocId: ocId, serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: contentType, livePhoto: false)
|
|
|
|
|
|
metadataForUpload.session = NCNetworking.shared.sessionIdentifierBackground
|
|
|
metadataForUpload.sessionSelector = selectorUploadFile
|
|
|
metadataForUpload.size = Double(NCUtilityFileSystem.shared.getFileSize(filePath: filePath))
|
|
|
metadataForUpload.status = Int(k_metadataStatusWaitUpload)
|
|
|
|
|
|
- NCManageDatabase.sharedInstance.addMetadata(metadataForUpload)
|
|
|
+ NCManageDatabase.shared.addMetadata(metadataForUpload)
|
|
|
|
|
|
} catch { }
|
|
|
}
|
|
|
|
|
|
private func uploadPasteOcId(_ ocId: String) {
|
|
|
- if let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(ocId) {
|
|
|
+ if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
|
|
|
if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
|
|
|
let fileNameView = NCUtility.shared.createFileName(metadata.fileNameView, serverUrl: serverUrl, account: appDelegate.account)
|
|
|
let ocId = NSUUID().uuidString
|
|
|
|
|
|
CCUtility.copyFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), toPath: CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileNameView))
|
|
|
- let metadataForUpload = NCManageDatabase.sharedInstance.createMetadata(account: appDelegate.account, fileName: fileNameView, ocId: ocId, serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "", livePhoto: false)
|
|
|
+ let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate.account, fileName: fileNameView, ocId: ocId, serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "", livePhoto: false)
|
|
|
|
|
|
metadataForUpload.session = NCNetworking.shared.sessionIdentifierBackground
|
|
|
metadataForUpload.sessionSelector = selectorUploadFile
|
|
|
metadataForUpload.size = metadata.size
|
|
|
metadataForUpload.status = Int(k_metadataStatusWaitUpload)
|
|
|
|
|
|
- NCManageDatabase.sharedInstance.addMetadata(metadataForUpload)
|
|
|
+ NCManageDatabase.shared.addMetadata(metadataForUpload)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -874,31 +907,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // MARK: - SEGUE
|
|
|
-
|
|
|
- @objc func segue(metadata: tableMetadata) {
|
|
|
- self.metadataTouch = metadata
|
|
|
- performSegue(withIdentifier: "segueDetail", sender: self)
|
|
|
- }
|
|
|
-
|
|
|
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
|
|
-
|
|
|
- let photoDataSource: NSMutableArray = []
|
|
|
-
|
|
|
- for metadata in (dataSource.metadatas) {
|
|
|
- if metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video {
|
|
|
- photoDataSource.add(metadata)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if let segueNavigationController = segue.destination as? UINavigationController {
|
|
|
- if let segueViewController = segueNavigationController.topViewController as? NCDetailViewController {
|
|
|
- segueViewController.metadata = metadataTouch
|
|
|
- segueViewController.layoutKey = layoutKey
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// MARK: - DataSource + NC Endpoint
|
|
|
|
|
|
@objc func reloadDataSource() {
|
|
@@ -906,15 +914,15 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
if appDelegate.account == nil || appDelegate.account.count == 0 { return }
|
|
|
|
|
|
// Get richWorkspace Text
|
|
|
- let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl))
|
|
|
+ let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl))
|
|
|
richWorkspaceText = directory?.richWorkspace
|
|
|
|
|
|
// E2EE
|
|
|
isEncryptedFolder = CCUtility.isFolderEncrypted(serverUrl, e2eEncrypted: metadataFolder?.e2eEncrypted ?? false, account: appDelegate.account, urlBase: appDelegate.urlBase)
|
|
|
|
|
|
// get auto upload folder
|
|
|
- autoUploadFileName = NCManageDatabase.sharedInstance.getAccountAutoUploadFileName()
|
|
|
- autoUploadDirectory = NCManageDatabase.sharedInstance.getAccountAutoUploadDirectory(urlBase: appDelegate.urlBase, account: appDelegate.account)
|
|
|
+ autoUploadFileName = NCManageDatabase.shared.getAccountAutoUploadFileName()
|
|
|
+ autoUploadDirectory = NCManageDatabase.shared.getAccountAutoUploadDirectory(urlBase: appDelegate.urlBase, account: appDelegate.account)
|
|
|
|
|
|
// get layout for view
|
|
|
(layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
|
|
@@ -952,7 +960,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
|
|
|
if errorCode == 0 {
|
|
|
|
|
|
- let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
|
|
|
+ let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
|
|
|
|
|
|
if forced || directory?.etag != metadata?.etag || directory?.e2eEncrypted ?? false {
|
|
|
|
|
@@ -968,7 +976,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
|
|
|
NCCommunication.shared.getE2EEMetadata(fileId: metadataFolder.ocId, e2eToken: nil) { (account, e2eMetadata, errorCode, errorDescription) in
|
|
|
if errorCode == 0 && e2eMetadata != nil {
|
|
|
|
|
|
- if !NCEndToEndMetadata.sharedInstance.decoderMetadata(e2eMetadata!, privateKey: CCUtility.getEndToEndPrivateKey(account), serverUrl: self.serverUrl, account: account, urlBase: self.appDelegate.urlBase) {
|
|
|
+ if !NCEndToEndMetadata.shared.decoderMetadata(e2eMetadata!, privateKey: CCUtility.getEndToEndPrivateKey(account), serverUrl: self.serverUrl, account: account, urlBase: self.appDelegate.urlBase) {
|
|
|
|
|
|
NCContentPresenter.shared.messageNotification("_error_e2ee_", description: "_e2e_error_decode_metadata_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorDecodeMetadata), forced: true)
|
|
|
} else {
|
|
@@ -1048,6 +1056,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
|
|
|
|
|
|
guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return }
|
|
|
metadataTouch = metadata
|
|
|
+ selectedIndexPath = indexPath
|
|
|
|
|
|
if isEditMode {
|
|
|
if let index = selectOcId.firstIndex(of: metadata.ocId) {
|
|
@@ -1163,6 +1172,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //VIEW IN FOLDER
|
|
|
if layoutKey == k_layout_view_viewInFolder {
|
|
|
|
|
|
let vcFileViewInFolder:NCFileViewInFolder = UIStoryboard(name: "NCFileViewInFolder", bundle: nil).instantiateInitialViewController() as! NCFileViewInFolder
|
|
@@ -1173,16 +1183,37 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
|
|
|
self.navigationController?.pushViewController(vcFileViewInFolder, animated: true)
|
|
|
}
|
|
|
|
|
|
+ // SHARES ( for push use Files ... he he he )
|
|
|
+ if layoutKey == k_layout_view_shares {
|
|
|
+
|
|
|
+ if let viewController = appDelegate.listFilesVC.value(forKey: serverUrlPush) {
|
|
|
+ guard let vcFiles = (viewController as? NCFiles) else { return }
|
|
|
+
|
|
|
+ if vcFiles.isViewLoaded {
|
|
|
+ self.navigationController?.pushViewController(vcFiles, animated: true)
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ let vcFiles:NCFiles = UIStoryboard(name: "NCFiles", bundle: nil).instantiateInitialViewController() as! NCFiles
|
|
|
+
|
|
|
+ vcFiles.isRoot = false
|
|
|
+ vcFiles.serverUrl = serverUrlPush
|
|
|
+ vcFiles.titleCurrentFolder = metadataTouch!.fileNameView
|
|
|
+
|
|
|
+ appDelegate.listFilesVC.setValue(vcFiles, forKey: serverUrlPush)
|
|
|
+
|
|
|
+ self.navigationController?.pushViewController(vcFiles, animated: true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
|
|
|
- if metadata.typeFile == k_metadataTypeFile_video {
|
|
|
- performSegue(withIdentifier: "segueDetail", sender: self)
|
|
|
- return
|
|
|
- }
|
|
|
+ guard let metadataTouch = metadataTouch else { return }
|
|
|
|
|
|
if metadata.typeFile == k_metadataTypeFile_document && NCUtility.shared.isDirectEditing(account: metadata.account, contentType: metadata.contentType) != nil {
|
|
|
if NCCommunication.shared.isNetworkReachable() {
|
|
|
- performSegue(withIdentifier: "segueDetail", sender: self)
|
|
|
+ NCViewer.shared.view(viewController: self, metadata: metadataTouch, metadatas: [metadataTouch])
|
|
|
} else {
|
|
|
NCContentPresenter.shared.messageNotification("_info_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorOffline), forced: true)
|
|
|
}
|
|
@@ -1191,17 +1222,28 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
|
|
|
|
|
|
if metadata.typeFile == k_metadataTypeFile_document && NCUtility.shared.isRichDocument(metadata) {
|
|
|
if NCCommunication.shared.isNetworkReachable() {
|
|
|
- performSegue(withIdentifier: "segueDetail", sender: self)
|
|
|
+ NCViewer.shared.view(viewController: self, metadata: metadataTouch, metadatas: [metadataTouch])
|
|
|
} else {
|
|
|
NCContentPresenter.shared.messageNotification("_info_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorOffline), forced: true)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if CCUtility.fileProviderStorageExists(metadataTouch?.ocId, fileNameView: metadataTouch?.fileNameView) {
|
|
|
- performSegue(withIdentifier: "segueDetail", sender: self)
|
|
|
+ if metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio {
|
|
|
+ var metadatas: [tableMetadata] = []
|
|
|
+ for metadata in dataSource.metadatas {
|
|
|
+ if metadata.typeFile == k_metadataTypeFile_image || metadata.typeFile == k_metadataTypeFile_video || metadata.typeFile == k_metadataTypeFile_audio {
|
|
|
+ metadatas.append(metadata)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ NCViewer.shared.view(viewController: self, metadata: metadataTouch, metadatas: metadatas)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if CCUtility.fileProviderStorageExists(metadataTouch.ocId, fileNameView: metadataTouch.fileNameView) {
|
|
|
+ NCViewer.shared.view(viewController: self, metadata: metadataTouch, metadatas: [metadataTouch])
|
|
|
} else {
|
|
|
- NCNetworking.shared.download(metadata: metadataTouch!, selector: selectorLoadFileView) { (_) in }
|
|
|
+ NCNetworking.shared.download(metadata: metadataTouch, selector: selectorLoadFileView) { (_) in }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1234,9 +1276,9 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
|
|
|
let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
|
|
|
|
|
|
if collectionView.collectionViewLayout == gridLayout {
|
|
|
- header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchList"), width: 100, height: 100, color: NCBrandColor.sharedInstance.icon), for: .normal)
|
|
|
+ header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchList"), width: 100, height: 100, color: NCBrandColor.shared.icon), for: .normal)
|
|
|
} else {
|
|
|
- header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchGrid"), width: 100, height: 100, color: NCBrandColor.sharedInstance.icon), for: .normal)
|
|
|
+ header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchGrid"), width: 100, height: 100, color: NCBrandColor.shared.icon), for: .normal)
|
|
|
}
|
|
|
|
|
|
header.delegate = self
|
|
@@ -1302,8 +1344,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
|
|
|
cell.objectId = metadata.ocId
|
|
|
cell.indexPath = indexPath
|
|
|
cell.labelTitle.text = metadata.fileNameView
|
|
|
- cell.labelTitle.textColor = NCBrandColor.sharedInstance.textView
|
|
|
- cell.separator.backgroundColor = NCBrandColor.sharedInstance.separator
|
|
|
+ cell.labelTitle.textColor = NCBrandColor.shared.textView
|
|
|
+ cell.separator.backgroundColor = NCBrandColor.shared.separator
|
|
|
|
|
|
cell.imageSelect.image = nil
|
|
|
cell.imageStatus.image = nil
|
|
@@ -1340,7 +1382,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
|
|
|
cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
|
|
|
|
|
|
let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
|
|
|
- let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
|
|
|
+ let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
|
|
|
|
|
|
// Local image: offline
|
|
|
if tableDirectory != nil && tableDirectory!.offline {
|
|
@@ -1476,6 +1518,11 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
|
|
|
cell.selectMode(false)
|
|
|
}
|
|
|
|
|
|
+ // Disable Share Button
|
|
|
+ if appDelegate.disableSharesView {
|
|
|
+ cell.hideButtonShare(true)
|
|
|
+ }
|
|
|
+
|
|
|
return cell
|
|
|
}
|
|
|
|
|
@@ -1490,7 +1537,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
|
|
|
cell.objectId = metadata.ocId
|
|
|
cell.indexPath = indexPath
|
|
|
cell.labelTitle.text = metadata.fileNameView
|
|
|
- cell.labelTitle.textColor = NCBrandColor.sharedInstance.textView
|
|
|
+ cell.labelTitle.textColor = NCBrandColor.shared.textView
|
|
|
|
|
|
cell.imageSelect.image = nil
|
|
|
cell.imageStatus.image = nil
|
|
@@ -1523,7 +1570,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
|
|
|
}
|
|
|
|
|
|
let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
|
|
|
- let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
|
|
|
+ let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, lockServerUrl))
|
|
|
|
|
|
// Local image: offline
|
|
|
if tableDirectory != nil && tableDirectory!.offline {
|
|
@@ -1613,3 +1660,4 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
|
|
|
return CGSize(width: collectionView.frame.width, height: footerHeight)
|
|
|
}
|
|
|
}
|
|
|
+
|