|
@@ -68,6 +68,10 @@ class NCDetailViewController: UIViewController {
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(moveFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_moveFile), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(triggerProgressTask(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_progressTask), object:nil)
|
|
|
|
|
|
+ NotificationCenter.default.addObserver(self, selector: #selector(downloadImage), name: NSNotification.Name(rawValue: k_notificationCenter_menuDownloadImage), object: nil)
|
|
|
+ NotificationCenter.default.addObserver(self, selector: #selector(saveLivePhoto(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_menuSaveLivePhoto), object: nil)
|
|
|
+ NotificationCenter.default.addObserver(self, selector: #selector(viewUnload), name: NSNotification.Name(rawValue: k_notificationCenter_menuDetailClose), object: nil)
|
|
|
+
|
|
|
changeTheming()
|
|
|
|
|
|
if metadata != nil {
|
|
@@ -136,33 +140,6 @@ class NCDetailViewController: UIViewController {
|
|
|
return backgroundView.subviews.first
|
|
|
}
|
|
|
|
|
|
- @objc func viewUnload() {
|
|
|
-
|
|
|
- metadata = nil
|
|
|
- selector = nil
|
|
|
-
|
|
|
- if let splitViewController = self.splitViewController as? NCSplitViewController {
|
|
|
- if splitViewController.isCollapsed {
|
|
|
- if let navigationController = splitViewController.viewControllers.last as? UINavigationController {
|
|
|
- navigationController.popToRootViewController(animated: true)
|
|
|
- }
|
|
|
- } else {
|
|
|
- if backgroundView != nil {
|
|
|
- for view in backgroundView.subviews {
|
|
|
- view.removeFromSuperview()
|
|
|
- }
|
|
|
- }
|
|
|
- self.navigationController?.navigationBar.topItem?.title = ""
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- self.splitViewController?.preferredDisplayMode = .allVisible
|
|
|
- self.navigationController?.isNavigationBarHidden = false
|
|
|
- view.backgroundColor = NCBrandColor.sharedInstance.backgroundView
|
|
|
-
|
|
|
- backgroundView.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "logo"), multiplier: 2, color: NCBrandColor.sharedInstance.brand.withAlphaComponent(0.4))
|
|
|
- }
|
|
|
-
|
|
|
@objc func navigateControllerBarHidden(_ state: Bool) {
|
|
|
|
|
|
if state {
|
|
@@ -306,6 +283,75 @@ class NCDetailViewController: UIViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @objc func downloadImage() {
|
|
|
+
|
|
|
+ guard let metadata = self.metadata else {return }
|
|
|
+
|
|
|
+ metadata.session = k_download_session
|
|
|
+ metadata.sessionError = ""
|
|
|
+ metadata.sessionSelector = ""
|
|
|
+ metadata.status = Int(k_metadataStatusWaitDownload)
|
|
|
+
|
|
|
+ self.metadata = NCManageDatabase.sharedInstance.addMetadata(metadata)
|
|
|
+
|
|
|
+ if let index = metadatas.firstIndex(where: { $0.ocId == metadata.ocId }) {
|
|
|
+ metadatas[index] = self.metadata!
|
|
|
+ }
|
|
|
+
|
|
|
+ appDelegate.startLoadAutoDownloadUpload()
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func saveLivePhoto(_ notification: NSNotification) {
|
|
|
+ if let userInfo = notification.userInfo as NSDictionary? {
|
|
|
+ if let metadata = userInfo["metadata"] as? tableMetadata, let metadataMov = userInfo["metadataMov"] as? tableMetadata {
|
|
|
+ let fileNameImage = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!)
|
|
|
+ let fileNameMov = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadataMov.ocId, fileNameView: metadataMov.fileNameView)!)
|
|
|
+
|
|
|
+ NCLivePhoto.generate(from: fileNameImage, videoURL: fileNameMov, progress: { progress in
|
|
|
+ self.progress(Float(progress))
|
|
|
+ }, completion: { livePhoto, resources in
|
|
|
+ self.progress(0)
|
|
|
+ if resources != nil {
|
|
|
+ NCLivePhoto.saveToLibrary(resources!) { (result) in
|
|
|
+ if !result {
|
|
|
+ NCContentPresenter.shared.messageNotification("_error_", description: "_livephoto_save_error_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ NCContentPresenter.shared.messageNotification("_error_", description: "_livephoto_save_error_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError))
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func viewUnload() {
|
|
|
+
|
|
|
+ metadata = nil
|
|
|
+ selector = nil
|
|
|
+
|
|
|
+ if let splitViewController = self.splitViewController as? NCSplitViewController {
|
|
|
+ if splitViewController.isCollapsed {
|
|
|
+ if let navigationController = splitViewController.viewControllers.last as? UINavigationController {
|
|
|
+ navigationController.popToRootViewController(animated: true)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if backgroundView != nil {
|
|
|
+ for view in backgroundView.subviews {
|
|
|
+ view.removeFromSuperview()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.navigationController?.navigationBar.topItem?.title = ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ self.splitViewController?.preferredDisplayMode = .allVisible
|
|
|
+ self.navigationController?.isNavigationBarHidden = false
|
|
|
+ view.backgroundColor = NCBrandColor.sharedInstance.backgroundView
|
|
|
+
|
|
|
+ backgroundView.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "logo"), multiplier: 2, color: NCBrandColor.sharedInstance.brand.withAlphaComponent(0.4))
|
|
|
+ }
|
|
|
+
|
|
|
//MARK: - View File
|
|
|
|
|
|
@objc func viewFile(metadata: tableMetadata, selector: String?) {
|
|
@@ -686,45 +732,6 @@ extension NCDetailViewController: NCViewerImageViewControllerDelegate, NCViewerI
|
|
|
viewUnload()
|
|
|
}
|
|
|
|
|
|
- @objc func downloadImage() {
|
|
|
-
|
|
|
- guard let metadata = self.metadata else {return }
|
|
|
-
|
|
|
- metadata.session = k_download_session
|
|
|
- metadata.sessionError = ""
|
|
|
- metadata.sessionSelector = ""
|
|
|
- metadata.status = Int(k_metadataStatusWaitDownload)
|
|
|
-
|
|
|
- self.metadata = NCManageDatabase.sharedInstance.addMetadata(metadata)
|
|
|
-
|
|
|
- if let index = metadatas.firstIndex(where: { $0.ocId == metadata.ocId }) {
|
|
|
- metadatas[index] = self.metadata!
|
|
|
- }
|
|
|
-
|
|
|
- appDelegate.startLoadAutoDownloadUpload()
|
|
|
- }
|
|
|
-
|
|
|
- func saveLivePhoto(metadata: tableMetadata, metadataMov: tableMetadata) {
|
|
|
-
|
|
|
- let fileNameImage = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!)
|
|
|
- let fileNameMov = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadataMov.ocId, fileNameView: metadataMov.fileNameView)!)
|
|
|
-
|
|
|
- NCLivePhoto.generate(from: fileNameImage, videoURL: fileNameMov, progress: { progress in
|
|
|
- self.progress(Float(progress))
|
|
|
- }, completion: { livePhoto, resources in
|
|
|
- self.progress(0)
|
|
|
- if resources != nil {
|
|
|
- NCLivePhoto.saveToLibrary(resources!) { (result) in
|
|
|
- if !result {
|
|
|
- NCContentPresenter.shared.messageNotification("_error_", description: "_livephoto_save_error_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError))
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- NCContentPresenter.shared.messageNotification("_error_", description: "_livephoto_save_error_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: Int(k_CCErrorInternalError))
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
func statusViewImage(metadata: tableMetadata, viewerImageViewController: NCViewerImageViewController) {
|
|
|
|
|
|
var colorStatus: UIColor = UIColor.white.withAlphaComponent(0.8)
|