|
@@ -132,8 +132,27 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
|
|
|
|
|
|
setAccount(account: activeAccount.account)
|
|
|
getFilesExtensionContext { (filesName, error) in
|
|
|
+
|
|
|
+ self.filesName = filesName
|
|
|
DispatchQueue.main.async {
|
|
|
- self.filesName = filesName
|
|
|
+
|
|
|
+ var saveHtml: [String] = []
|
|
|
+ var saveOther: [String] = []
|
|
|
+
|
|
|
+ for fileName in self.filesName {
|
|
|
+ if (fileName as NSString).pathExtension.lowercased() == "html" {
|
|
|
+ saveHtml.append(fileName)
|
|
|
+ } else {
|
|
|
+ saveOther.append(fileName)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if saveOther.count > 0 && saveHtml.count > 0 {
|
|
|
+ for file in saveHtml {
|
|
|
+ self.filesName = self.filesName.filter(){$0 != file}
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
self.setCommandView()
|
|
|
}
|
|
|
}
|
|
@@ -404,19 +423,40 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @objc func renameButtonPressed(sender: NCShareExtensionButtonWithIndexPath) {
|
|
|
+ @objc func moreButtonPressed(sender: NCShareExtensionButtonWithIndexPath) {
|
|
|
|
|
|
if let fileName = sender.fileName {
|
|
|
- if let vcRename = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile {
|
|
|
+ let alertController = UIAlertController(title: "", message: fileName, preferredStyle: .alert)
|
|
|
|
|
|
- vcRename.delegate = self
|
|
|
- vcRename.fileName = fileName
|
|
|
- vcRename.imagePreview = sender.image
|
|
|
+ alertController.addAction(UIAlertAction(title: NSLocalizedString("_delete_file_", comment: ""), style: .default) { (action:UIAlertAction) in
|
|
|
+ if let index = self.filesName.firstIndex(of: fileName) {
|
|
|
+
|
|
|
+ self.filesName.remove(at: index)
|
|
|
+ if self.filesName.count == 0 {
|
|
|
+ self.extensionContext?.completeRequest(returningItems: self.extensionContext?.inputItems, completionHandler: nil)
|
|
|
+ } else {
|
|
|
+ self.setCommandView()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ alertController.addAction(UIAlertAction(title: NSLocalizedString("_rename_file_", comment: ""), style: .default) { (action:UIAlertAction) in
|
|
|
+
|
|
|
+ if let vcRename = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile {
|
|
|
+
|
|
|
+ vcRename.delegate = self
|
|
|
+ vcRename.fileName = fileName
|
|
|
+ vcRename.imagePreview = sender.image
|
|
|
|
|
|
- let popup = NCPopupViewController(contentController: vcRename, popupWidth: vcRename.width, popupHeight: vcRename.height)
|
|
|
-
|
|
|
- self.present(popup, animated: true)
|
|
|
- }
|
|
|
+ let popup = NCPopupViewController(contentController: vcRename, popupWidth: vcRename.width, popupHeight: vcRename.height)
|
|
|
+
|
|
|
+ self.present(popup, animated: true)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ alertController.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel) { (action:UIAlertAction) in })
|
|
|
+
|
|
|
+ self.present(alertController, animated: true, completion:nil)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -646,7 +686,7 @@ extension NCShareExtension: UITableViewDataSource {
|
|
|
|
|
|
let imageCell = cell.viewWithTag(10) as? UIImageView
|
|
|
let fileNameCell = cell.viewWithTag(20) as? UILabel
|
|
|
- let renameButton = cell.viewWithTag(30) as? NCShareExtensionButtonWithIndexPath
|
|
|
+ let moreButton = cell.viewWithTag(30) as? NCShareExtensionButtonWithIndexPath
|
|
|
|
|
|
imageCell?.layer.cornerRadius = 6
|
|
|
imageCell?.layer.masksToBounds = true
|
|
@@ -666,11 +706,11 @@ extension NCShareExtension: UITableViewDataSource {
|
|
|
|
|
|
fileNameCell?.text = fileName
|
|
|
|
|
|
- renameButton?.setImage(NCUtility.shared.loadImage(named: "pencil").image(color: NCBrandColor.shared.label, size: 15), for: .normal)
|
|
|
- renameButton?.indexPath = indexPath
|
|
|
- renameButton?.fileName = fileName
|
|
|
- renameButton?.image = imageCell?.image
|
|
|
- renameButton?.addTarget(self, action:#selector(renameButtonPressed(sender:)), for: .touchUpInside)
|
|
|
+ moreButton?.setImage(NCUtility.shared.loadImage(named: "more").image(color: NCBrandColor.shared.label, size: 15), for: .normal)
|
|
|
+ moreButton?.indexPath = indexPath
|
|
|
+ moreButton?.fileName = fileName
|
|
|
+ moreButton?.image = imageCell?.image
|
|
|
+ moreButton?.addTarget(self, action:#selector(moreButtonPressed(sender:)), for: .touchUpInside)
|
|
|
|
|
|
return cell
|
|
|
}
|
|
@@ -768,14 +808,13 @@ extension NCShareExtension {
|
|
|
if let url = item as? NSURL {
|
|
|
if FileManager.default.fileExists(atPath: url.path ?? "") {
|
|
|
fileNameOriginal = url.lastPathComponent!
|
|
|
- } else if url.scheme?.lowercased().contains("http") == true || url.scheme?.lowercased().contains("https") == true {
|
|
|
+ } else if url.scheme?.lowercased().contains("http") == true {
|
|
|
fileNameOriginal = "\(dateFormatter.string(from: Date()))\(conuter).html"
|
|
|
} else {
|
|
|
fileNameOriginal = "\(dateFormatter.string(from: Date()))\(conuter)"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if error == nil {
|
|
|
|
|
|
if let image = item as? UIImage {
|