|
@@ -69,15 +69,6 @@ class CreateMenuAdd: NSObject {
|
|
|
appDelegate.activeMain.openAssetsPickerController()
|
|
|
})
|
|
|
|
|
|
-/*
|
|
|
-#if DEBUG
|
|
|
- if #available(iOS 11.0, *) {
|
|
|
- actionSheet.addButton(withTitle: NSLocalizedString("_scans_document_", comment: ""), image: CCGraphics.changeThemingColorImage(UIImage(named: "scan"), multiplier:2, color: colorGray), backgroundColor: NCBrandColor.sharedInstance.backgroundView, height: 50.0, type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
|
|
|
- NCCreateScanDocument.sharedInstance.openScannerDocument(viewController: appDelegate.activeMain, openScan: true)
|
|
|
- })
|
|
|
- }
|
|
|
-#endif
|
|
|
-*/
|
|
|
actionSheet.addButton(withTitle: NSLocalizedString("_upload_file_", comment: ""), image: CCGraphics.changeThemingColorImage(UIImage(named: "file"), multiplier:2, color: colorGray), backgroundColor: NCBrandColor.sharedInstance.backgroundView, height: 50.0, type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
|
|
|
appDelegate.activeMain.openImportDocumentPicker()
|
|
|
})
|
|
@@ -90,6 +81,12 @@ class CreateMenuAdd: NSObject {
|
|
|
appDelegate.activeMain.present(controller, animated: true, completion: nil)
|
|
|
})
|
|
|
|
|
|
+ if #available(iOS 11.0, *) {
|
|
|
+ actionSheet.addButton(withTitle: NSLocalizedString("_scans_document_", comment: ""), image: CCGraphics.changeThemingColorImage(UIImage(named: "scan"), multiplier:2, color: colorGray), backgroundColor: NCBrandColor.sharedInstance.backgroundView, height: 50.0, type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
|
|
|
+ NCCreateScanDocument.sharedInstance.openScannerDocument(viewController: appDelegate.activeMain, openScan: true)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
actionSheet.addButton(withTitle: NSLocalizedString("_create_folder_", comment: ""), image: CCGraphics.changeThemingColorImage(UIImage(named: "folder"), multiplier:2, color: colorIcon), backgroundColor: NCBrandColor.sharedInstance.backgroundView, height: 50.0 ,type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
|
|
|
appDelegate.activeMain.createFolder()
|
|
|
})
|
|
@@ -141,7 +138,7 @@ class CreateFormUploadAssets: XLFormViewController, CCMoveDelegate {
|
|
|
|
|
|
func initializeForm() {
|
|
|
|
|
|
- let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor
|
|
|
+ let form : XLFormDescriptor = XLFormDescriptor(title: NSLocalizedString("_upload_photos_videos_", comment: "")) as XLFormDescriptor
|
|
|
form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow
|
|
|
|
|
|
var section : XLFormSectionDescriptor
|
|
@@ -149,83 +146,94 @@ class CreateFormUploadAssets: XLFormViewController, CCMoveDelegate {
|
|
|
|
|
|
// Section: Destination Folder
|
|
|
|
|
|
- section = XLFormSectionDescriptor.formSection()
|
|
|
+ section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_save_path_", comment: ""))
|
|
|
form.addFormSection(section)
|
|
|
|
|
|
row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: self.titleServerUrl)
|
|
|
- let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:2, color: NCBrandColor.sharedInstance.brandElement) as UIImage
|
|
|
- row.cellConfig.setObject(imageFolder, forKey: "imageView.image" as NSCopying)
|
|
|
- row.cellConfig.setObject(UIColor.black, forKey: "textLabel.textColor" as NSCopying)
|
|
|
- row.cellConfig.setObject(UIFont.systemFont(ofSize: 15.0), forKey: "textLabel.font" as NSCopying)
|
|
|
row.action.formSelector = #selector(changeDestinationFolder(_:))
|
|
|
- section.addFormRow(row)
|
|
|
-
|
|
|
- // Section Switch
|
|
|
+
|
|
|
+ let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:2, color: NCBrandColor.sharedInstance.brandElement) as UIImage
|
|
|
+ row.cellConfig["imageView.image"] = imageFolder
|
|
|
|
|
|
- section = XLFormSectionDescriptor.formSection()
|
|
|
- form.addFormSection(section)
|
|
|
+ row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
|
|
|
- // Folder Photo
|
|
|
+ section.addFormRow(row)
|
|
|
|
|
|
+ // User folder Media
|
|
|
row = XLFormRowDescriptor(tag: "useFolderMedia", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_use_folder_media_", comment: ""))
|
|
|
row.value = 0
|
|
|
- row.cellConfig.setObject(UIFont.systemFont(ofSize: 15.0), forKey: "textLabel.font" as NSCopying)
|
|
|
+
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
section.addFormRow(row)
|
|
|
|
|
|
// Use Sub folder
|
|
|
row = XLFormRowDescriptor(tag: "useSubFolder", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_autoupload_create_subfolder_", comment: ""))
|
|
|
- row.hidden = "$\("useFolderMedia") == 0"
|
|
|
- row.cellConfig.setObject(UIFont.systemFont(ofSize: 15.0), forKey: "textLabel.font" as NSCopying)
|
|
|
-
|
|
|
let tableAccount = NCManageDatabase.sharedInstance.getAccountActive()
|
|
|
-
|
|
|
if tableAccount?.autoUploadCreateSubfolder == true {
|
|
|
row.value = 1
|
|
|
} else {
|
|
|
row.value = 0
|
|
|
}
|
|
|
- section.addFormRow(row)
|
|
|
+ row.hidden = "$\("useFolderMedia") == 0"
|
|
|
+
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
|
|
|
+ section.addFormRow(row)
|
|
|
+
|
|
|
+ // Section Mode filename
|
|
|
+
|
|
|
+ section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_mode_filename_", comment: ""))
|
|
|
+ form.addFormSection(section)
|
|
|
+
|
|
|
// Maintain the original fileName
|
|
|
|
|
|
row = XLFormRowDescriptor(tag: "maintainOriginalFileName", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_maintain_original_filename_", comment: ""))
|
|
|
row.value = CCUtility.getOriginalFileName(k_keyFileNameOriginal)
|
|
|
- row.cellConfig.setObject(UIFont.systemFont(ofSize: 15.0), forKey: "textLabel.font" as NSCopying)
|
|
|
+
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
section.addFormRow(row)
|
|
|
|
|
|
// Add File Name Type
|
|
|
|
|
|
row = XLFormRowDescriptor(tag: "addFileNameType", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_add_filenametype_", comment: ""))
|
|
|
- row.hidden = "$\("maintainOriginalFileName") == 1"
|
|
|
- row.cellConfig.setObject(UIFont.systemFont(ofSize: 15.0), forKey: "textLabel.font" as NSCopying)
|
|
|
row.value = CCUtility.getFileNameType(k_keyFileNameType)
|
|
|
+ row.hidden = "$\("maintainOriginalFileName") == 1"
|
|
|
+
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
section.addFormRow(row)
|
|
|
|
|
|
// Section: Rename File Name
|
|
|
|
|
|
- section = XLFormSectionDescriptor.formSection()
|
|
|
+ section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_filename_", comment: ""))
|
|
|
form.addFormSection(section)
|
|
|
|
|
|
- row = XLFormRowDescriptor(tag: "maskFileName", rowType: XLFormRowDescriptorTypeAccount, title: (NSLocalizedString("_filename_", comment: ""))+":")
|
|
|
- row.hidden = "$\("maintainOriginalFileName") == 1"
|
|
|
- row.cellConfig.setObject(UIFont.systemFont(ofSize: 15.0), forKey: "textLabel.font" as NSCopying)
|
|
|
-
|
|
|
+ row = XLFormRowDescriptor(tag: "maskFileName", rowType: XLFormRowDescriptorTypeAccount, title: (NSLocalizedString("_filename_", comment: "")))
|
|
|
let fileNameMask : String = CCUtility.getFileNameMask(k_keyFileNameMask)
|
|
|
if fileNameMask.count > 0 {
|
|
|
row.value = fileNameMask
|
|
|
}
|
|
|
+ row.hidden = "$\("maintainOriginalFileName") == 1"
|
|
|
+
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
+ row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
|
|
|
+ row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
section.addFormRow(row)
|
|
|
|
|
|
// Section: Preview File Name
|
|
|
|
|
|
row = XLFormRowDescriptor(tag: "previewFileName", rowType: XLFormRowDescriptorTypeTextView, title: "")
|
|
|
-
|
|
|
row.height = 180
|
|
|
- row.cellConfig.setObject(NCBrandColor.sharedInstance.backgroundView, forKey: "backgroundColor" as NSCopying)
|
|
|
- row.cellConfig.setObject(NCBrandColor.sharedInstance.backgroundView, forKey: "textView.backgroundColor" as NSCopying)
|
|
|
-
|
|
|
row.disabled = true
|
|
|
- row.cellConfig.setObject(UIFont.systemFont(ofSize: 15.0), forKey: "textLabel.font" as NSCopying)
|
|
|
+
|
|
|
+ row.cellConfig["textView.backgroundColor"] = NCBrandColor.sharedInstance.backgroundView
|
|
|
+ row.cellConfig["textView.font"] = UIFont.systemFont(ofSize: 14.0)
|
|
|
+
|
|
|
section.addFormRow(row)
|
|
|
|
|
|
self.form = form
|
|
@@ -313,8 +321,6 @@ class CreateFormUploadAssets: XLFormViewController, CCMoveDelegate {
|
|
|
|
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyle.none
|
|
|
|
|
|
- self.tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundView
|
|
|
-
|
|
|
self.reloadForm()
|
|
|
}
|
|
|
|
|
@@ -482,24 +488,34 @@ class CreateFormUploadFileText: XLFormViewController, CCMoveDelegate {
|
|
|
|
|
|
// Section: Destination Folder
|
|
|
|
|
|
- section = XLFormSectionDescriptor.formSection()
|
|
|
+ section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_save_path_", comment: ""))
|
|
|
form.addFormSection(section)
|
|
|
+
|
|
|
row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: self.titleServerUrl)
|
|
|
- let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:2, color: NCBrandColor.sharedInstance.brandElement) as UIImage
|
|
|
- row.cellConfig.setObject(imageFolder, forKey: "imageView.image" as NSCopying)
|
|
|
- row.cellConfig.setObject(UIColor.black, forKey: "textLabel.textColor" as NSCopying)
|
|
|
- row.cellConfig.setObject(UIFont.systemFont(ofSize: 15.0), forKey: "textLabel.font" as NSCopying)
|
|
|
row.action.formSelector = #selector(changeDestinationFolder(_:))
|
|
|
+
|
|
|
+ let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:2, color: NCBrandColor.sharedInstance.brandElement) as UIImage
|
|
|
+ row.cellConfig["imageView.image"] = imageFolder
|
|
|
+
|
|
|
+ row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
section.addFormRow(row)
|
|
|
|
|
|
// Section: File Name
|
|
|
|
|
|
- section = XLFormSectionDescriptor.formSection()
|
|
|
+ section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_filename_", comment: ""))
|
|
|
form.addFormSection(section)
|
|
|
|
|
|
+
|
|
|
row = XLFormRowDescriptor(tag: "fileName", rowType: XLFormRowDescriptorTypeAccount, title: NSLocalizedString("_filename_", comment: ""))
|
|
|
- row.cellConfig.setObject(UIFont.systemFont(ofSize: 15.0), forKey: "textLabel.font" as NSCopying)
|
|
|
- row.value = fileName
|
|
|
+ row.value = self.fileName
|
|
|
+
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
+ row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
|
|
|
+ row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
section.addFormRow(row)
|
|
|
|
|
|
self.form = form
|
|
@@ -517,8 +533,11 @@ class CreateFormUploadFileText: XLFormViewController, CCMoveDelegate {
|
|
|
self.fileName = CCUtility.removeForbiddenCharactersServer(fileNameNew as! String)
|
|
|
}
|
|
|
|
|
|
+ formRow.value = self.fileName
|
|
|
self.title = fileName
|
|
|
-
|
|
|
+
|
|
|
+ self.updateFormRow(formRow)
|
|
|
+
|
|
|
self.form.delegate = self
|
|
|
}
|
|
|
}
|
|
@@ -530,7 +549,6 @@ class CreateFormUploadFileText: XLFormViewController, CCMoveDelegate {
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
let saveButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_save_", comment: ""), style: UIBarButtonItemStyle.plain, target: self, action: #selector(save))
|
|
|
-
|
|
|
self.navigationItem.rightBarButtonItem = saveButton
|
|
|
|
|
|
self.navigationController?.navigationBar.isTranslucent = false
|
|
@@ -539,23 +557,6 @@ class CreateFormUploadFileText: XLFormViewController, CCMoveDelegate {
|
|
|
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: NCBrandColor.sharedInstance.brandText]
|
|
|
|
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyle.none
|
|
|
- self.tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundView
|
|
|
-
|
|
|
- self.reloadForm()
|
|
|
- }
|
|
|
-
|
|
|
- func reloadForm() {
|
|
|
-
|
|
|
- self.form.delegate = nil
|
|
|
-
|
|
|
- let buttonDestinationFolder : XLFormRowDescriptor = self.form.formRow(withTag: "ButtonDestinationFolder")!
|
|
|
- buttonDestinationFolder.title = self.titleServerUrl
|
|
|
-
|
|
|
- self.title = fileName
|
|
|
-
|
|
|
- self.tableView.reloadData()
|
|
|
-
|
|
|
- self.form.delegate = self
|
|
|
}
|
|
|
|
|
|
// MARK: - Action
|
|
@@ -573,7 +574,10 @@ class CreateFormUploadFileText: XLFormViewController, CCMoveDelegate {
|
|
|
self.titleServerUrl = "/"
|
|
|
}
|
|
|
|
|
|
- self.reloadForm()
|
|
|
+ // Update
|
|
|
+ let row : XLFormRowDescriptor = self.form.formRow(withTag: "ButtonDestinationFolder")!
|
|
|
+ row.title = self.titleServerUrl
|
|
|
+ self.updateFormRow(row)
|
|
|
}
|
|
|
|
|
|
@objc func save() {
|
|
@@ -686,12 +690,15 @@ class CreateFormUploadScanDocument: XLFormViewController, CCMoveDelegate {
|
|
|
|
|
|
var serverUrl = ""
|
|
|
var titleServerUrl = ""
|
|
|
- var arrayFileName = [String]()
|
|
|
+ var arrayImages = [UIImage]()
|
|
|
var fileName = "scan.pdf"
|
|
|
+ var password : PDFPassword = ""
|
|
|
+ var compressionQuality: Double = 0.5
|
|
|
+ var fileType = "PDF"
|
|
|
|
|
|
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
|
|
|
|
- convenience init(serverUrl: String, arrayFileName: [String]) {
|
|
|
+ convenience init(serverUrl: String, arrayImages: [UIImage]) {
|
|
|
|
|
|
self.init()
|
|
|
|
|
@@ -702,7 +709,7 @@ class CreateFormUploadScanDocument: XLFormViewController, CCMoveDelegate {
|
|
|
}
|
|
|
|
|
|
self.serverUrl = serverUrl
|
|
|
- self.arrayFileName = arrayFileName
|
|
|
+ self.arrayImages = arrayImages
|
|
|
|
|
|
initializeForm()
|
|
|
}
|
|
@@ -711,7 +718,7 @@ class CreateFormUploadScanDocument: XLFormViewController, CCMoveDelegate {
|
|
|
|
|
|
func initializeForm() {
|
|
|
|
|
|
- let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor
|
|
|
+ let form : XLFormDescriptor = XLFormDescriptor(title: NSLocalizedString("_save_settings_", comment: "")) as XLFormDescriptor
|
|
|
form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow
|
|
|
|
|
|
var section : XLFormSectionDescriptor
|
|
@@ -719,26 +726,80 @@ class CreateFormUploadScanDocument: XLFormViewController, CCMoveDelegate {
|
|
|
|
|
|
// Section: Destination Folder
|
|
|
|
|
|
- section = XLFormSectionDescriptor.formSection()
|
|
|
+ section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_save_path_", comment: ""))
|
|
|
form.addFormSection(section)
|
|
|
+
|
|
|
row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: self.titleServerUrl)
|
|
|
- let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:2, color: NCBrandColor.sharedInstance.brandElement) as UIImage
|
|
|
- row.cellConfig.setObject(imageFolder, forKey: "imageView.image" as NSCopying)
|
|
|
- row.cellConfig.setObject(UIColor.black, forKey: "textLabel.textColor" as NSCopying)
|
|
|
- row.cellConfig.setObject(UIFont.systemFont(ofSize: 15.0), forKey: "textLabel.font" as NSCopying)
|
|
|
row.action.formSelector = #selector(changeDestinationFolder(_:))
|
|
|
+
|
|
|
+ let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:2, color: NCBrandColor.sharedInstance.brandElement) as UIImage
|
|
|
+ row.cellConfig["imageView.image"] = imageFolder
|
|
|
+
|
|
|
+ row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
section.addFormRow(row)
|
|
|
|
|
|
- // Section: File Name
|
|
|
+ // Section: Quality
|
|
|
|
|
|
- section = XLFormSectionDescriptor.formSection()
|
|
|
+ section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_quality_image_title_", comment: ""))
|
|
|
form.addFormSection(section)
|
|
|
|
|
|
- row = XLFormRowDescriptor(tag: "fileName", rowType: XLFormRowDescriptorTypeAccount, title: NSLocalizedString("_filename_", comment: ""))
|
|
|
- row.cellConfig.setObject(UIFont.systemFont(ofSize: 15.0), forKey: "textLabel.font" as NSCopying)
|
|
|
- row.value = fileName
|
|
|
+ row = XLFormRowDescriptor(tag: "compressionQuality", rowType: XLFormRowDescriptorTypeSlider)
|
|
|
+ row.value = 0.5
|
|
|
+ row.title = NSLocalizedString("_quality_medium_", comment: "")
|
|
|
+
|
|
|
+ row.cellConfig["slider.minimumTrackTintColor"] = NCBrandColor.sharedInstance.brand
|
|
|
+
|
|
|
+ row.cellConfig["slider.maximumValue"] = 1
|
|
|
+ row.cellConfig["slider.minimumValue"] = 0
|
|
|
+ row.cellConfig["steps"] = 2
|
|
|
+
|
|
|
+ row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.center.rawValue
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
+ section.addFormRow(row)
|
|
|
+
|
|
|
+ // Section: Password
|
|
|
+
|
|
|
+ section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_pdf_password_", comment: ""))
|
|
|
+ form.addFormSection(section)
|
|
|
+
|
|
|
+ row = XLFormRowDescriptor(tag: "password", rowType: XLFormRowDescriptorTypePassword, title: NSLocalizedString("_password_", comment: ""))
|
|
|
+
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
+ row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
|
|
|
+ row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
section.addFormRow(row)
|
|
|
|
|
|
+ // Section: File
|
|
|
+
|
|
|
+ section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_file_creation_", comment: ""))
|
|
|
+ form.addFormSection(section)
|
|
|
+
|
|
|
+ if arrayImages.count == 1 {
|
|
|
+ row = XLFormRowDescriptor(tag: "filetype", rowType: XLFormRowDescriptorTypeSelectorSegmentedControl, title: NSLocalizedString("_file_type_", comment: ""))
|
|
|
+ row.selectorOptions = ["PDF","JPG"]
|
|
|
+ row.value = "PDF"
|
|
|
+
|
|
|
+ row.cellConfig["tintColor"] = NCBrandColor.sharedInstance.brand
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
+ section.addFormRow(row)
|
|
|
+ }
|
|
|
+
|
|
|
+ row = XLFormRowDescriptor(tag: "fileName", rowType: XLFormRowDescriptorTypeAccount, title: NSLocalizedString("_filename_", comment: ""))
|
|
|
+ row.value = self.fileName
|
|
|
+
|
|
|
+ row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
+ row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
|
|
|
+ row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
|
|
|
+
|
|
|
+ section.addFormRow(row)
|
|
|
+
|
|
|
self.form = form
|
|
|
}
|
|
|
|
|
@@ -750,14 +811,92 @@ class CreateFormUploadScanDocument: XLFormViewController, CCMoveDelegate {
|
|
|
|
|
|
self.form.delegate = nil
|
|
|
|
|
|
- if let fileNameNew = formRow.value {
|
|
|
- self.fileName = CCUtility.removeForbiddenCharactersServer(fileNameNew as! String)
|
|
|
+ let fileNameNew = newValue as? String
|
|
|
+
|
|
|
+ if fileNameNew != nil {
|
|
|
+ self.fileName = CCUtility.removeForbiddenCharactersServer(fileNameNew)
|
|
|
+ } else {
|
|
|
+ self.fileName = ""
|
|
|
}
|
|
|
|
|
|
- self.title = fileName
|
|
|
+ formRow.value = self.fileName
|
|
|
+
|
|
|
+ self.updateFormRow(formRow)
|
|
|
|
|
|
self.form.delegate = self
|
|
|
}
|
|
|
+
|
|
|
+ if formRow.tag == "compressionQuality" {
|
|
|
+
|
|
|
+ self.form.delegate = nil
|
|
|
+
|
|
|
+ //let row : XLFormRowDescriptor = self.form.formRow(withTag: "descriptionQuality")!
|
|
|
+ let newQuality = newValue as? NSNumber
|
|
|
+ compressionQuality = (newQuality?.doubleValue)!
|
|
|
+
|
|
|
+ if compressionQuality >= 0.0 && compressionQuality <= 0.3 {
|
|
|
+ formRow.title = NSLocalizedString("_quality_low_", comment: "")
|
|
|
+ compressionQuality = 0.1
|
|
|
+ } else if compressionQuality >= 0.4 && compressionQuality <= 0.6 {
|
|
|
+ formRow.title = NSLocalizedString("_quality_medium_", comment: "")
|
|
|
+ compressionQuality = 0.5
|
|
|
+ } else if compressionQuality >= 0.7 && compressionQuality <= 1.0 {
|
|
|
+ formRow.title = NSLocalizedString("_quality_high_", comment: "")
|
|
|
+ compressionQuality = 0.8
|
|
|
+ }
|
|
|
+
|
|
|
+ self.updateFormRow(formRow)
|
|
|
+
|
|
|
+ self.form.delegate = self
|
|
|
+ }
|
|
|
+
|
|
|
+ if formRow.tag == "password" {
|
|
|
+ let stringPassword = newValue as? String
|
|
|
+ if stringPassword != nil {
|
|
|
+ password = PDFPassword(stringPassword!)
|
|
|
+ } else {
|
|
|
+ password = PDFPassword("")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if formRow.tag == "filetype" {
|
|
|
+ fileType = newValue as! String
|
|
|
+
|
|
|
+ let rowFileName : XLFormRowDescriptor = self.form.formRow(withTag: "fileName")!
|
|
|
+ let rowPassword : XLFormRowDescriptor = self.form.formRow(withTag: "password")!
|
|
|
+
|
|
|
+ // rowFileName
|
|
|
+ guard var name = rowFileName.value else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if name as! String == "" {
|
|
|
+ name = "scan"
|
|
|
+ }
|
|
|
+
|
|
|
+ let ext = (name as! NSString).pathExtension.uppercased()
|
|
|
+ var newFileName = ""
|
|
|
+
|
|
|
+ if (ext == "") {
|
|
|
+ newFileName = name as! String + "." + fileType.lowercased()
|
|
|
+ } else {
|
|
|
+ newFileName = (name as! NSString).deletingPathExtension + "." + fileType.lowercased()
|
|
|
+ }
|
|
|
+
|
|
|
+ rowFileName.value = newFileName
|
|
|
+
|
|
|
+ self.updateFormRow(rowFileName)
|
|
|
+
|
|
|
+ // rowPassword
|
|
|
+ if fileType == "JPG" {
|
|
|
+ rowPassword.value = ""
|
|
|
+ password = PDFPassword("")
|
|
|
+ rowPassword.disabled = true
|
|
|
+ } else {
|
|
|
+ rowPassword.disabled = false
|
|
|
+ }
|
|
|
+
|
|
|
+ self.updateFormRow(rowPassword)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// MARK: - View Life Cycle
|
|
@@ -767,7 +906,6 @@ class CreateFormUploadScanDocument: XLFormViewController, CCMoveDelegate {
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
let saveButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_save_", comment: ""), style: UIBarButtonItemStyle.plain, target: self, action: #selector(save))
|
|
|
-
|
|
|
self.navigationItem.rightBarButtonItem = saveButton
|
|
|
|
|
|
self.navigationController?.navigationBar.isTranslucent = false
|
|
@@ -776,23 +914,14 @@ class CreateFormUploadScanDocument: XLFormViewController, CCMoveDelegate {
|
|
|
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: NCBrandColor.sharedInstance.brandText]
|
|
|
|
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyle.none
|
|
|
- self.tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundView
|
|
|
+// self.tableView.sectionHeaderHeight = 10
|
|
|
+// self.tableView.sectionFooterHeight = 10
|
|
|
+// self.tableView.backgroundColor = NCBrandColor.sharedInstance.backgroundView
|
|
|
|
|
|
- self.reloadForm()
|
|
|
- }
|
|
|
-
|
|
|
- func reloadForm() {
|
|
|
-
|
|
|
- self.form.delegate = nil
|
|
|
-
|
|
|
- let buttonDestinationFolder : XLFormRowDescriptor = self.form.formRow(withTag: "ButtonDestinationFolder")!
|
|
|
- buttonDestinationFolder.title = self.titleServerUrl
|
|
|
-
|
|
|
- self.title = fileName
|
|
|
-
|
|
|
- self.tableView.reloadData()
|
|
|
|
|
|
- self.form.delegate = self
|
|
|
+// let row : XLFormRowDescriptor = self.form.formRow(withTag: "fileName")!
|
|
|
+// let rowCell = row.cell(forForm: self)
|
|
|
+// rowCell.becomeFirstResponder()
|
|
|
}
|
|
|
|
|
|
// MARK: - Action
|
|
@@ -810,7 +939,10 @@ class CreateFormUploadScanDocument: XLFormViewController, CCMoveDelegate {
|
|
|
self.titleServerUrl = "/"
|
|
|
}
|
|
|
|
|
|
- self.reloadForm()
|
|
|
+ // Update
|
|
|
+ let row : XLFormRowDescriptor = self.form.formRow(withTag: "ButtonDestinationFolder")!
|
|
|
+ row.title = self.titleServerUrl
|
|
|
+ self.updateFormRow(row)
|
|
|
}
|
|
|
|
|
|
@objc func save() {
|
|
@@ -819,13 +951,17 @@ class CreateFormUploadScanDocument: XLFormViewController, CCMoveDelegate {
|
|
|
guard let name = rowFileName.value else {
|
|
|
return
|
|
|
}
|
|
|
+ if name as! String == "" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
let ext = (name as! NSString).pathExtension.uppercased()
|
|
|
var fileNameSave = ""
|
|
|
|
|
|
if (ext == "") {
|
|
|
- fileNameSave = name as! String + ".pdf"
|
|
|
+ fileNameSave = name as! String + "." + fileType.lowercased()
|
|
|
} else {
|
|
|
- fileNameSave = (name as! NSString).deletingPathExtension + ".pdf"
|
|
|
+ fileNameSave = (name as! NSString).deletingPathExtension + "." + fileType.lowercased()
|
|
|
}
|
|
|
|
|
|
guard let directoryID = NCManageDatabase.sharedInstance.getDirectoryID(self.serverUrl) else {
|
|
@@ -858,37 +994,48 @@ class CreateFormUploadScanDocument: XLFormViewController, CCMoveDelegate {
|
|
|
|
|
|
func dismissAndUpload(_ fileNameSave: String, fileID: String, directoryID: String) {
|
|
|
|
|
|
- var pdfPages = [PDFPage]()
|
|
|
-
|
|
|
- guard let fileNameGeneratePDF = CCUtility.getDirectoryProviderStorageFileID(fileID, fileNameView: fileNameSave) else {
|
|
|
+ guard let fileNameGenerateExport = CCUtility.getDirectoryProviderStorageFileID(fileID, fileNameView: fileNameSave) else {
|
|
|
self.appDelegate.messageNotification("_error_", description: "_error_creation_file_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info, errorCode: 0)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- //Generate PDF
|
|
|
- for fileNameImage in self.arrayFileName {
|
|
|
- let fileNameImagePath = CCUtility.getDirectoryScanSelect() + "/" + fileNameImage
|
|
|
- let page = PDFPage.imagePath(fileNameImagePath)
|
|
|
- pdfPages.append(page)
|
|
|
- }
|
|
|
+ if fileType == "PDF" {
|
|
|
|
|
|
- do {
|
|
|
- try PDFGenerator.generate(pdfPages, to: fileNameGeneratePDF)
|
|
|
- } catch {
|
|
|
- self.appDelegate.messageNotification("_error_", description: "_error_creation_file_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info, errorCode: 0)
|
|
|
- return
|
|
|
+ var pdfPages = [PDFPage]()
|
|
|
+
|
|
|
+ //Generate PDF
|
|
|
+ for image in self.arrayImages {
|
|
|
+ guard let data = UIImageJPEGRepresentation(image, CGFloat(compressionQuality)) else {
|
|
|
+ self.appDelegate.messageNotification("_error_", description: "_error_creation_file_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info, errorCode: 0)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let page = PDFPage.image(UIImage(data: data)!)
|
|
|
+ pdfPages.append(page)
|
|
|
+ }
|
|
|
+
|
|
|
+ do {
|
|
|
+ try PDFGenerator.generate(pdfPages, to: fileNameGenerateExport, password: password)
|
|
|
+ } catch {
|
|
|
+ self.appDelegate.messageNotification("_error_", description: "_error_creation_file_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info, errorCode: 0)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //Remove images processed
|
|
|
- for fileNameImage in self.arrayFileName {
|
|
|
- let fileNameImagePath = CCUtility.getDirectoryScanSelect() + "/" + fileNameImage
|
|
|
- CCUtility.removeFile(atPath: fileNameImagePath)
|
|
|
+ if fileType == "JPG" {
|
|
|
+
|
|
|
+ guard let data = UIImageJPEGRepresentation(self.arrayImages[0], CGFloat(compressionQuality)) else {
|
|
|
+ self.appDelegate.messageNotification("_error_", description: "_error_creation_file_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info, errorCode: 0)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ do {
|
|
|
+ try data.write(to: NSURL.fileURL(withPath: fileNameGenerateExport), options: .atomic)
|
|
|
+ } catch {
|
|
|
+ self.appDelegate.messageNotification("_error_", description: "_error_creation_file_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info, errorCode: 0)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //Remove plist in reader for cache issue
|
|
|
- //let filePlistReader = CCUtility.getDirectoryReaderMetadata() + "/" + (fileNameSave as NSString).deletingPathExtension + ".plist"
|
|
|
- //CCUtility.removeFile(atPath: filePlistReader)
|
|
|
-
|
|
|
//Create metadata for upload
|
|
|
let metadataForUpload = tableMetadata()
|
|
|
|
|
@@ -962,15 +1109,24 @@ class NCCreateScanDocument : NSObject, ImageScannerControllerDelegate {
|
|
|
@available(iOS 10, *)
|
|
|
func imageScannerController(_ scanner: ImageScannerController, didFinishScanningWithResults results: ImageScannerResults) {
|
|
|
|
|
|
+ let fileName = CCUtility.createFileName("scan.png", fileDate: Date(), fileType: PHAssetMediaType.image, keyFileName: k_keyFileNameMask, keyFileNameType: k_keyFileNameType, keyFileNameOriginal: k_keyFileNameOriginal)!
|
|
|
+ let fileNamePath = CCUtility.getDirectoryScan() + "/" + fileName
|
|
|
+
|
|
|
+ // A4 74 DPI : 595 x 842 px
|
|
|
+
|
|
|
+ var image = results.scannedImage
|
|
|
+ let imageWidthInPixels = image.size.width * results.scannedImage.scale
|
|
|
+ let imageHeightInPixels = image.size.height * results.scannedImage.scale
|
|
|
+
|
|
|
+ if imageWidthInPixels > 595 || imageHeightInPixels > 842 {
|
|
|
+ image = CCGraphics.scale(image, to: CGSize(width: 595, height: 842), isAspectRation: true)
|
|
|
+ }
|
|
|
+
|
|
|
+ do {
|
|
|
+ try UIImagePNGRepresentation(image)?.write(to: NSURL.fileURL(withPath: fileNamePath), options: .atomic)
|
|
|
+ } catch { }
|
|
|
+
|
|
|
scanner.dismiss(animated: true, completion: {
|
|
|
-
|
|
|
- let fileName = CCUtility.createFileName("scan.png", fileDate: Date(), fileType: PHAssetMediaType.image, keyFileName: k_keyFileNameMask, keyFileNameType: k_keyFileNameType, keyFileNameOriginal: k_keyFileNameOriginal)!
|
|
|
- let fileNamePath = CCUtility.getDirectoryScan() + "/" + fileName
|
|
|
-
|
|
|
- do {
|
|
|
- try UIImagePNGRepresentation(results.scannedImage)?.write(to: NSURL.fileURL(withPath: fileNamePath), options: .atomic)
|
|
|
- } catch { }
|
|
|
-
|
|
|
if (self.openScan) {
|
|
|
let storyboard = UIStoryboard(name: "Scan", bundle: nil)
|
|
|
let controller = storyboard.instantiateInitialViewController()!
|
|
@@ -989,7 +1145,6 @@ class NCCreateScanDocument : NSObject, ImageScannerControllerDelegate {
|
|
|
@available(iOS 10, *)
|
|
|
func imageScannerController(_ scanner: ImageScannerController, didFailWithError error: Error) {
|
|
|
appDelegate.messageNotification("_error_", description: error.localizedDescription, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: Int(k_CCErrorInternalError))
|
|
|
- print(error)
|
|
|
}
|
|
|
}
|
|
|
|