Skip to content

Commit 0962cdc

Browse files
NMC 1988 - Scan customisation changes
1 parent 2daeab8 commit 0962cdc

7 files changed

Lines changed: 119 additions & 79 deletions

iOSClient/Scan document/NCCreateFormUploadScanDocument.swift

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,37 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
141141

142142
var section: XLFormSectionDescriptor
143143
var row: XLFormRowDescriptor
144+
145+
// Section: Destination Folder
146+
147+
section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_save_path_", comment: ""))
148+
form.addFormSection(section)
149+
150+
XLFormViewController.cellClassesForRowDescriptorTypes()["NMCScamFileNameCustomInputField"] = FileNameInputTextField.self
151+
row = XLFormRowDescriptor(tag: "fileName", rowType: "NMCScamFileNameCustomInputField", title: NSLocalizedString("_filename_", comment: ""))
152+
row.cellClass = FileNameInputTextField.self
153+
row.cellConfig["fileNameInputTextField.placeholder"] = self.fileName
154+
155+
row.cellConfig["fileNameInputTextField.textAlignment"] = NSTextAlignment.left.rawValue
156+
row.cellConfig["fileNameInputTextField.font"] = UIFont.systemFont(ofSize: 15.0)
157+
row.cellConfig["fileNameInputTextField.textColor"] = NCBrandColor.shared.label
158+
159+
160+
section.addFormRow(row)
161+
//FileName custom view END
162+
163+
section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_location_", comment: ""))
164+
form.addFormSection(section)
165+
166+
//Scan documnet folder path
167+
XLFormViewController.cellClassesForRowDescriptorTypes()["NMCScanFolderPathCustomCell"] = ScanDocumentPathView.self
168+
row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: "NMCScanFolderPathCustomCell", title: self.titleServerUrl)
169+
row.action.formSelector = #selector(changeDestinationFolder(_:))
170+
row.cellConfig["backgroundColor"] = cellBackgoundColor
171+
row.cellConfig["folderImage.image"] = UIImage(named: "folder")?.imageColor(NCBrandColor.shared.customer)
172+
row.cellConfig["photoLabel.textAlignment"] = NSTextAlignment.left.rawValue
173+
row.cellConfig["photoLabel.font"] = UIFont.systemFont(ofSize: 15.0)
174+
row.cellConfig["photoLabel.textColor"] = NCBrandColor.shared.label
144175

145176
// Section: Destination Folder
146177

@@ -162,6 +193,10 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
162193
row.cellConfig["photoLabel.text"] = self.titleServerUrl
163194
}
164195
row.cellConfig["textLabel.text"] = ""
196+
197+
section.addFormRow(row)
198+
// END of Scan documnet folder path
199+
165200
section.addFormRow(row)
166201

167202
// Section: File Name
@@ -306,7 +341,8 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
306341
let fileNameNew = newValue as? String
307342

308343
if let fileNameNew = newValue as? String {
309-
self.fileName = FileAutoRenamer.rename(fileNameNew, account: session.account)
344+
self.fileName = utility.removeForbiddenCharacters(fileNameNew)
345+
self.fileName = FileAutoRenamer.rename(filename: fileNameNew, isFolderPath: true)
310346
} else {
311347
self.fileName = ""
312348
}
@@ -454,6 +490,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
454490

455491
if fileName == nil || fileName == "" {
456492
name = utilityFileSystem.createFileNameDate("scan", ext: "pdf")
493+
name = utilityFileSystem.createFileNameDate("scan", ext: "pdf")
457494
} else {
458495
name = fileName!
459496
}
@@ -769,6 +806,10 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
769806
}
770807
}
771808

809+
810+
let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate?.account ?? "", user: appDelegate?.user ?? "", userId: appDelegate?.userId ?? "", fileName: fileNameSave, fileNameView: fileNameSave, ocId: UUID().uuidString, serverUrl: serverUrl, urlBase: appDelegate?.urlBase ?? "", url: "", contentType: "")
811+
812+
// let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate?.account ?? "", user: appDelegate?.user ?? "", userId: appDelegate?.userId ?? "", fileName: fileNameSave, fileNameView: fileNameSave, ocId: UUID().uuidString, serverUrl: serverUrl, urlBase: appDelegate?.urlBase ?? "", url: "", contentType: "")
772813
let metadataForUpload = NCManageDatabase.shared.createMetadata(fileName: fileNameSave, fileNameView: fileNameSave, ocId: UUID().uuidString, serverUrl: serverUrl, url: "", contentType: "", session: session, sceneIdentifier: self.appDelegate?.sceneIdentifier)
773814

774815
metadataForUpload.session = NCNetworking.shared.sessionUploadBackground
@@ -1267,3 +1308,4 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
12671308
return nil
12681309
}
12691310
}
1311+

iOSClient/Scan document/NCDocumentCamera.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class NCDocumentCamera: NSObject, VNDocumentCameraViewControllerDelegate {
4646
func documentCameraViewController(_ controller: VNDocumentCameraViewController, didFinishWith scan: VNDocumentCameraScan) {
4747
for pageNumber in 0..<scan.pageCount {
4848
let fileName = utilityFileSystem.createFileName("scan.png", fileDate: Date(), fileType: PHAssetMediaType.image, notUseMask: true)
49-
let fileNamePath = utilityFileSystem.directoryScan + "/" + fileName
49+
let fileNamePath = utilityFileSystem.createServerUrl(serverUrl: utilityFileSystem.directoryScan, fileName: fileName)
5050
let image = scan.imageOfPage(at: pageNumber)
5151
do {
5252
try image.pngData()?.write(to: NSURL.fileURL(withPath: fileNamePath))

iOSClient/Scan document/NCScan.swift

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
6868
super.viewDidLoad()
6969

7070
view.backgroundColor = .secondarySystemGroupedBackground
71-
// navigationController?.navigationBar.tintColor = NCBrandColor.shared.iconImageColor
7271
navigationItem.title = NSLocalizedString("_scanned_images_", comment: "")
7372

7473
let interaction = UIEditMenuInteraction(delegate: self)
@@ -146,7 +145,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
146145
override var canBecomeFirstResponder: Bool { return true }
147146

148147
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
149-
if action == #selector(pasteImage) {
148+
if action == #selector(pasteImage(_:)) {
150149
return true
151150
}
152151
return false
@@ -184,7 +183,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
184183

185184
@IBAction func transferDown(sender: UIButton) {
186185
for fileName in itemsSource where !itemsDestination.contains(fileName) {
187-
let fileNamePathAt = utilityFileSystem.directoryScan + "/" + fileName
186+
let fileNamePathAt = utilityFileSystem.createServerUrl(serverUrl: utilityFileSystem.directoryScan, fileName: fileName)
188187
guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePathAt)), let image = UIImage(data: data) else { return }
189188

190189
imagesDestination.append(image)
@@ -203,7 +202,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
203202
break
204203
}
205204

206-
NCKeychain().typeFilterScanDocument = filter
205+
NCPreferences().typeFilterScanDocument = filter
207206
collectionViewDestination.reloadData()
208207
}
209208

@@ -279,7 +278,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
279278

280279
if collectionView === collectionViewDestination {
281280
let fileName = (item.dragItem.localObject as? String)!
282-
let fileNamePathAt = utilityFileSystem.directoryScan + "/" + fileName
281+
let fileNamePathAt = utilityFileSystem.createServerUrl(serverUrl: utilityFileSystem.directoryScan, fileName: fileName)
283282
guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePathAt)), let image = UIImage(data: data) else { return }
284283

285284
imagesDestination.insert(image, at: indexPath.row)
@@ -333,7 +332,7 @@ class NCScan: UIViewController, NCScanCellCellDelegate {
333332
return collectionViewSource.reloadData()
334333
}
335334
let fileName = self.itemsSource[index]
336-
let fileNamePath = utilityFileSystem.directoryScan + "/" + fileName
335+
let fileNamePath = utilityFileSystem.createServerUrl(serverUrl: utilityFileSystem.directoryScan, fileName: fileName)
337336
guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePath)), let image = UIImage(data: data) else {
338337
return collectionViewSource.reloadData()
339338
}
@@ -349,7 +348,7 @@ extension NCScan: EasyTipViewDelegate {
349348
if !self.database.tipExists(NCGlobal.shared.tipScanAddImage) {
350349
var preferences = EasyTipView.Preferences()
351350
preferences.drawing.foregroundColor = .white
352-
preferences.drawing.backgroundColor = NCBrandColor.shared.customer
351+
preferences.drawing.backgroundColor = .lightGray
353352
preferences.drawing.textAlignment = .left
354353
preferences.drawing.arrowPosition = .left
355354
preferences.drawing.cornerRadius = 10
@@ -360,9 +359,9 @@ extension NCScan: EasyTipViewDelegate {
360359
preferences.animating.showDuration = 1.5
361360
preferences.animating.dismissDuration = 1.5
362361

363-
if tipView == nil {
362+
if tipView == nil, let view = self.view {
364363
tipView = EasyTipView(text: NSLocalizedString("_tip_addcopyimage_", comment: ""), preferences: preferences, delegate: self)
365-
tipView?.show(forView: add, withinSuperview: self.view)
364+
tipView?.show(forView: add, withinSuperview: view)
366365
}
367366
}
368367
}
@@ -385,7 +384,7 @@ extension NCScan: EasyTipViewDelegate {
385384
extension NCScan: NCViewerQuickLookDelegate {
386385
func dismissQuickLook(fileNameSource: String, hasChangesQuickLook: Bool) {
387386
let fileNameAtPath = NSTemporaryDirectory() + fileNameSource
388-
let fileNameToPath = utilityFileSystem.directoryScan + "/" + fileNameSource
387+
let fileNameToPath = utilityFileSystem.createServerUrl(serverUrl: utilityFileSystem.directoryScan, fileName: fileNameSource)
389388
utilityFileSystem.copyFile(atPath: fileNameAtPath, toPath: fileNameToPath)
390389
guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNameToPath)), let image = UIImage(data: data) else { return }
391390
var index = 0

0 commit comments

Comments
 (0)