|
@@ -33,7 +33,7 @@ class NCScanCollectionView: UIViewController {
|
|
|
private var imagesDestination: [UIImage] = []
|
|
|
private var itemsDestination: [String] = []
|
|
|
|
|
|
- private let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
|
+ private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
|
|
|
|
|
|
// MARK: Outlets
|
|
|
@IBOutlet weak var collectionViewSource: UICollectionView!
|
|
@@ -109,6 +109,7 @@ class NCScanCollectionView: UIViewController {
|
|
|
// MARK: Button Action
|
|
|
|
|
|
@IBAction func cancelAction(sender: UIBarButtonItem) {
|
|
|
+
|
|
|
self.dismiss(animated: true, completion: nil)
|
|
|
}
|
|
|
|
|
@@ -258,7 +259,7 @@ class NCScanCollectionView: UIViewController {
|
|
|
if collectionView === collectionViewDestination {
|
|
|
|
|
|
imagesDestination.remove(at: sourceIndexPath.row)
|
|
|
- imagesDestination.insert(item.dragItem.localObject as! UIImage, at: dIndexPath.row)
|
|
|
+ imagesDestination.insert((item.dragItem.localObject as? UIImage)!, at: dIndexPath.row)
|
|
|
|
|
|
let fileName = itemsDestination[sourceIndexPath.row]
|
|
|
itemsDestination.remove(at: sourceIndexPath.row)
|
|
@@ -267,7 +268,7 @@ class NCScanCollectionView: UIViewController {
|
|
|
} else {
|
|
|
|
|
|
itemsSource.remove(at: sourceIndexPath.row)
|
|
|
- itemsSource.insert(item.dragItem.localObject as! String, at: dIndexPath.row)
|
|
|
+ itemsSource.insert((item.dragItem.localObject as? String)!, at: dIndexPath.row)
|
|
|
}
|
|
|
|
|
|
collectionView.deleteItems(at: [sourceIndexPath])
|
|
@@ -296,7 +297,7 @@ class NCScanCollectionView: UIViewController {
|
|
|
|
|
|
if collectionView === collectionViewDestination {
|
|
|
|
|
|
- let fileName = item.dragItem.localObject as! String
|
|
|
+ let fileName = (item.dragItem.localObject as? String)!
|
|
|
let fileNamePathAt = CCUtility.getDirectoryScan() + "/" + fileName
|
|
|
|
|
|
guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePathAt)) else {
|
|
@@ -354,7 +355,12 @@ class NCScanCollectionView: UIViewController {
|
|
|
|
|
|
if pasteboard.hasImages {
|
|
|
|
|
|
- let fileName = CCUtility.createFileName("scan.png", fileDate: Date(), fileType: PHAssetMediaType.image, keyFileName: NCGlobal.shared.keyFileNameMask, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, forcedNewFileName: true)!
|
|
|
+ let fileName = CCUtility.createFileName("scan.png", fileDate: Date(),
|
|
|
+ fileType: PHAssetMediaType.image,
|
|
|
+ keyFileName: NCGlobal.shared.keyFileNameMask,
|
|
|
+ keyFileNameType: NCGlobal.shared.keyFileNameType,
|
|
|
+ keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal,
|
|
|
+ forcedNewFileName: true)!
|
|
|
let fileNamePath = CCUtility.getDirectoryScan() + "/" + fileName
|
|
|
|
|
|
guard let image = pasteboard.image?.fixedOrientation() else {
|
|
@@ -386,7 +392,7 @@ extension NCScanCollectionView: UICollectionViewDataSource {
|
|
|
|
|
|
if collectionView == collectionViewSource {
|
|
|
|
|
|
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell1", for: indexPath) as! NCScanCell
|
|
|
+ let cell = (collectionView.dequeueReusableCell(withReuseIdentifier: "cell1", for: indexPath) as? NCScanCell)!
|
|
|
|
|
|
let fileNamePath = CCUtility.getDirectoryScan() + "/" + itemsSource[indexPath.row]
|
|
|
|
|
@@ -409,7 +415,7 @@ extension NCScanCollectionView: UICollectionViewDataSource {
|
|
|
cell.customImageView?.image = image
|
|
|
cell.delete.action(for: .touchUpInside) { sender in
|
|
|
|
|
|
- let buttonPosition: CGPoint = (sender as! UIButton).convert(.zero, to: self.collectionViewSource)
|
|
|
+ let buttonPosition: CGPoint = (sender as? UIButton)!.convert(.zero, to: self.collectionViewSource)
|
|
|
if let indexPath = self.collectionViewSource.indexPathForItem(at: buttonPosition) {
|
|
|
|
|
|
let fileNameAtPath = CCUtility.getDirectoryScan() + "/" + self.itemsSource[indexPath.row]
|
|
@@ -424,7 +430,7 @@ extension NCScanCollectionView: UICollectionViewDataSource {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell2", for: indexPath) as! NCScanCell
|
|
|
+ let cell = (collectionView.dequeueReusableCell(withReuseIdentifier: "cell2", for: indexPath) as? NCScanCell)!
|
|
|
|
|
|
var image = imagesDestination[indexPath.row]
|
|
|
|
|
@@ -440,7 +446,7 @@ extension NCScanCollectionView: UICollectionViewDataSource {
|
|
|
cell.customLabel.text = NSLocalizedString("_scan_document_pdf_page_", comment: "") + " " + "\(indexPath.row+1)"
|
|
|
cell.delete.action(for: .touchUpInside) { sender in
|
|
|
|
|
|
- let buttonPosition: CGPoint = (sender as! UIButton).convert(.zero, to: self.collectionViewDestination)
|
|
|
+ let buttonPosition: CGPoint = (sender as? UIButton)!.convert(.zero, to: self.collectionViewDestination)
|
|
|
if let indexPath = self.collectionViewDestination.indexPathForItem(at: buttonPosition) {
|
|
|
|
|
|
self.imagesDestination.remove(at: indexPath.row)
|
|
@@ -458,7 +464,7 @@ extension NCScanCollectionView: UICollectionViewDataSource {
|
|
|
}
|
|
|
cell.rotate.action(for: .touchUpInside) { sender in
|
|
|
|
|
|
- let buttonPosition: CGPoint = (sender as! UIButton).convert(.zero, to: self.collectionViewDestination)
|
|
|
+ let buttonPosition: CGPoint = (sender as? UIButton)!.convert(.zero, to: self.collectionViewDestination)
|
|
|
if let indexPath = self.collectionViewDestination.indexPathForItem(at: buttonPosition), let cell = self.collectionViewDestination.cellForItem(at: indexPath) as? NCScanCell {
|
|
|
|
|
|
var image = self.imagesDestination[indexPath.row]
|