ScanCollectionView.swift 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. //
  2. // ScanCollectionView.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 21/08/18.
  6. // Copyright (c) 2018 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import UIKit
  24. class DragDropViewController: UIViewController {
  25. //Data Source for collectionViewSource
  26. private var itemsSource: [String] = []
  27. //Data Source for collectionViewDestination
  28. private var imagesDestination: [UIImage] = []
  29. private var itemsDestination: [String] = []
  30. //AppDelegate
  31. private let appDelegate = UIApplication.shared.delegate as! AppDelegate
  32. //MARK: Outlets
  33. @IBOutlet weak var collectionViewSource: UICollectionView!
  34. @IBOutlet weak var collectionViewDestination: UICollectionView!
  35. @IBOutlet weak var cancel: UIBarButtonItem!
  36. @IBOutlet weak var save: UIBarButtonItem!
  37. @IBOutlet weak var add: UIButton!
  38. @IBOutlet weak var transferDown: UIButton!
  39. @IBOutlet weak var labelTitlePDFzone: UILabel!
  40. @IBOutlet weak var segmentControlFilter: UISegmentedControl!
  41. // filter
  42. enum typeFilter {
  43. case original
  44. case grayScale
  45. case bn
  46. }
  47. private var filter: typeFilter = typeFilter.original
  48. override var canBecomeFirstResponder: Bool { return true }
  49. //MARK: View Lifecycle Methods
  50. override func viewDidLoad() {
  51. super.viewDidLoad()
  52. collectionViewSource.dragInteractionEnabled = true
  53. collectionViewSource.dragDelegate = self
  54. collectionViewSource.dropDelegate = self
  55. collectionViewDestination.dragInteractionEnabled = true
  56. collectionViewDestination.dropDelegate = self
  57. collectionViewDestination.dragDelegate = self
  58. collectionViewDestination.reorderingCadence = .fast //default value - .immediate
  59. self.navigationItem.title = NSLocalizedString("_scanned_images_", comment: "")
  60. cancel.title = NSLocalizedString("_cancel_", comment: "")
  61. save.title = NSLocalizedString("_save_", comment: "")
  62. labelTitlePDFzone.text = NSLocalizedString("_scan_label_document_zone_", comment: "")
  63. segmentControlFilter.setTitle(NSLocalizedString("_filter_original_", comment: ""), forSegmentAt: 0)
  64. segmentControlFilter.setTitle(NSLocalizedString("_filter_grayscale_", comment: ""), forSegmentAt: 1)
  65. segmentControlFilter.setTitle(NSLocalizedString("_filter_bn_", comment: ""), forSegmentAt: 2)
  66. add.setImage(CCGraphics.changeThemingColorImage(UIImage(named: "add"), multiplier:2, color: NCBrandColor.sharedInstance.brandElement), for: .normal)
  67. transferDown.setImage(CCGraphics.changeThemingColorImage(UIImage(named: "transferDown"), multiplier:2, color: NCBrandColor.sharedInstance.brandElement), for: .normal)
  68. let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPressGesture(recognizer:)))
  69. add.addGestureRecognizer(longPressRecognizer)
  70. // changeTheming
  71. NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
  72. changeTheming()
  73. loadImage()
  74. }
  75. @objc func changeTheming() {
  76. view.backgroundColor = NCBrandColor.sharedInstance.backgroundForm
  77. collectionViewSource.backgroundColor = NCBrandColor.sharedInstance.backgroundForm
  78. collectionViewDestination.backgroundColor = NCBrandColor.sharedInstance.backgroundForm
  79. collectionViewSource.reloadData()
  80. collectionViewDestination.reloadData()
  81. labelTitlePDFzone.textColor = NCBrandColor.sharedInstance.textView
  82. if #available(iOS 13.0, *) {
  83. labelTitlePDFzone.backgroundColor = .systemBackground
  84. } else {
  85. labelTitlePDFzone.backgroundColor = .systemGray
  86. }
  87. }
  88. //MARK: Button Action
  89. @IBAction func cancelAction(sender: UIBarButtonItem) {
  90. self.dismiss(animated: true, completion: nil)
  91. }
  92. @IBAction func saveAction(sender: UIBarButtonItem) {
  93. if imagesDestination.count > 0 {
  94. var images: [UIImage] = []
  95. var serverUrl = appDelegate.activeServerUrl!
  96. for image in imagesDestination {
  97. images.append(filter(image: image)!)
  98. }
  99. if let directory = CCUtility.getDirectoryScanDocuments() {
  100. serverUrl = directory
  101. }
  102. let formViewController = NCCreateFormUploadScanDocument.init(serverUrl: serverUrl, arrayImages: images)
  103. self.navigationController?.pushViewController(formViewController, animated: true)
  104. }
  105. }
  106. @IBAction func add(sender: UIButton) {
  107. NCCreateScanDocument.sharedInstance.openScannerDocument(viewController: self)
  108. }
  109. @IBAction func transferDown(sender: UIButton) {
  110. for fileName in itemsSource {
  111. if !itemsDestination.contains(fileName) {
  112. let fileNamePathAt = CCUtility.getDirectoryScan() + "/" + fileName
  113. guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePathAt)) else { return }
  114. guard let image = UIImage(data: data) else { return }
  115. imagesDestination.append(image)
  116. itemsDestination.append(fileName)
  117. }
  118. }
  119. // Save button
  120. if imagesDestination.count == 0 {
  121. save.isEnabled = false
  122. } else {
  123. save.isEnabled = true
  124. }
  125. collectionViewDestination.reloadData()
  126. }
  127. @IBAction func indexChanged(_ sender: AnyObject) {
  128. switch segmentControlFilter.selectedSegmentIndex
  129. {
  130. case 0:
  131. filter = typeFilter.original
  132. case 1:
  133. filter = typeFilter.grayScale
  134. case 2:
  135. filter = typeFilter.bn
  136. default:
  137. break
  138. }
  139. collectionViewDestination.reloadData()
  140. }
  141. func loadImage() {
  142. itemsSource.removeAll()
  143. do {
  144. let atPath = CCUtility.getDirectoryScan()!
  145. let directoryContents = try FileManager.default.contentsOfDirectory(atPath: atPath)
  146. for fileName in directoryContents {
  147. if fileName.first != "." {
  148. itemsSource.append(fileName)
  149. }
  150. }
  151. } catch {
  152. print(error.localizedDescription)
  153. }
  154. itemsSource = itemsSource.sorted()
  155. collectionViewSource.reloadData()
  156. // Save button
  157. if imagesDestination.count == 0 {
  158. save.isEnabled = false
  159. } else {
  160. save.isEnabled = true
  161. }
  162. }
  163. //MARK: Private Methods
  164. func filter(image: UIImage) -> UIImage? {
  165. var inputContrast: Double = 0
  166. if filter == typeFilter.original {
  167. return image
  168. }
  169. if filter == typeFilter.grayScale {
  170. inputContrast = 1
  171. }
  172. if filter == typeFilter.bn {
  173. inputContrast = 4
  174. }
  175. let ciImage = CIImage(image: image)!
  176. let imageFilter = ciImage.applyingFilter("CIColorControls", parameters: ["inputSaturation": 0, "inputContrast": inputContrast])
  177. let context:CIContext = CIContext.init(options: nil)
  178. let cgImage:CGImage = context.createCGImage(imageFilter, from: imageFilter.extent)!
  179. let image:UIImage = UIImage.init(cgImage: cgImage)
  180. return image
  181. }
  182. /// This method moves a cell from source indexPath to destination indexPath within the same collection view. It works for only 1 item. If multiple items selected, no reordering happens.
  183. ///
  184. /// - Parameters:
  185. /// - coordinator: coordinator obtained from performDropWith: UICollectionViewDropDelegate method
  186. /// - destinationIndexPath: indexpath of the collection view where the user drops the element
  187. /// - collectionView: collectionView in which reordering needs to be done.
  188. private func reorderItems(coordinator: UICollectionViewDropCoordinator, destinationIndexPath: IndexPath, collectionView: UICollectionView) {
  189. let items = coordinator.items
  190. if items.count == 1, let item = items.first, let sourceIndexPath = item.sourceIndexPath {
  191. var dIndexPath = destinationIndexPath
  192. if dIndexPath.row >= collectionView.numberOfItems(inSection: 0) {
  193. dIndexPath.row = collectionView.numberOfItems(inSection: 0) - 1
  194. }
  195. collectionView.performBatchUpdates({
  196. if collectionView === collectionViewDestination {
  197. imagesDestination.remove(at: sourceIndexPath.row)
  198. imagesDestination.insert(item.dragItem.localObject as! UIImage, at: dIndexPath.row)
  199. let fileName = itemsDestination[sourceIndexPath.row]
  200. itemsDestination.remove(at: sourceIndexPath.row)
  201. itemsDestination.insert(fileName, at: dIndexPath.row)
  202. } else {
  203. itemsSource.remove(at: sourceIndexPath.row)
  204. itemsSource.insert(item.dragItem.localObject as! String, at: dIndexPath.row)
  205. }
  206. collectionView.deleteItems(at: [sourceIndexPath])
  207. collectionView.insertItems(at: [dIndexPath])
  208. })
  209. coordinator.drop(items.first!.dragItem, toItemAt: dIndexPath)
  210. }
  211. }
  212. /// This method copies a cell from source indexPath in 1st collection view to destination indexPath in 2nd collection view. It works for multiple items.
  213. ///
  214. /// - Parameters:
  215. /// - coordinator: coordinator obtained from performDropWith: UICollectionViewDropDelegate method
  216. /// - destinationIndexPath: indexpath of the collection view where the user drops the element
  217. /// - collectionView: collectionView in which reordering needs to be done.
  218. private func copyItems(coordinator: UICollectionViewDropCoordinator, destinationIndexPath: IndexPath, collectionView: UICollectionView)
  219. {
  220. collectionView.performBatchUpdates({
  221. var indexPaths: [IndexPath] = []
  222. for (index, item) in coordinator.items.enumerated() {
  223. let indexPath = IndexPath(row: destinationIndexPath.row + index, section: destinationIndexPath.section)
  224. if collectionView === collectionViewDestination {
  225. let fileName = item.dragItem.localObject as! String
  226. let fileNamePathAt = CCUtility.getDirectoryScan() + "/" + fileName
  227. guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePathAt)) else {
  228. return
  229. }
  230. guard let image = UIImage(data: data) else {
  231. return
  232. }
  233. imagesDestination.insert(image, at: indexPath.row)
  234. itemsDestination.insert(fileName, at: indexPath.row)
  235. } else {
  236. // NOT PERMITTED
  237. return
  238. }
  239. indexPaths.append(indexPath)
  240. }
  241. collectionView.insertItems(at: indexPaths)
  242. })
  243. }
  244. // MARK: - UIGestureRecognizerv - Paste
  245. @objc func handleLongPressGesture(recognizer: UIGestureRecognizer) {
  246. if recognizer.state == UIGestureRecognizer.State.began {
  247. self.becomeFirstResponder()
  248. let pasteboard = UIPasteboard.general
  249. if let recognizerView = recognizer.view, let recognizerSuperView = recognizerView.superview, pasteboard.hasImages {
  250. UIMenuController.shared.menuItems = [UIMenuItem(title: "Paste", action: #selector(pasteImage))]
  251. UIMenuController.shared.setTargetRect(recognizerView.frame, in: recognizerSuperView)
  252. UIMenuController.shared.setMenuVisible(true, animated:true)
  253. }
  254. }
  255. }
  256. override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
  257. if action == #selector(pasteImage) {
  258. return true
  259. }
  260. return false
  261. }
  262. @objc func pasteImage() {
  263. let pasteboard = UIPasteboard.general
  264. if pasteboard.hasImages {
  265. let fileName = CCUtility.createFileName("scan.png", fileDate: Date(), fileType: PHAssetMediaType.image, keyFileName: k_keyFileNameMask, keyFileNameType: k_keyFileNameType, keyFileNameOriginal: k_keyFileNameOriginal)!
  266. let fileNamePath = CCUtility.getDirectoryScan() + "/" + fileName
  267. guard let image = pasteboard.image else {
  268. return
  269. }
  270. do {
  271. try image.pngData()?.write(to: NSURL.fileURL(withPath: fileNamePath), options: .atomic)
  272. } catch {
  273. return
  274. }
  275. loadImage()
  276. }
  277. }
  278. }
  279. // MARK: - UICollectionViewDataSource Methods
  280. extension DragDropViewController : UICollectionViewDataSource {
  281. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  282. return collectionView == collectionViewSource ? itemsSource.count : imagesDestination.count
  283. }
  284. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  285. if collectionView == collectionViewSource {
  286. let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell1", for: indexPath) as! ScanCell
  287. let fileNamePath = CCUtility.getDirectoryScan() + "/" + itemsSource[indexPath.row]
  288. guard let data = try? Data(contentsOf: URL(fileURLWithPath: fileNamePath)) else {
  289. return cell
  290. }
  291. guard var image = UIImage(data: data) else {
  292. return cell
  293. }
  294. let imageWidthInPixels = image.size.width * image.scale
  295. let imageHeightInPixels = image.size.height * image.scale
  296. // 72 DPI
  297. if imageWidthInPixels > 595 || imageHeightInPixels > 842 {
  298. image = CCGraphics.scale(image, to: CGSize(width: 595, height: 842), isAspectRation: true)
  299. }
  300. cell.customImageView?.image = image
  301. cell.delete.addTarget(self, action: #selector(deleteSource(_:)), for: .touchUpInside)
  302. return cell
  303. } else {
  304. let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell2", for: indexPath) as! ScanCell
  305. var image = imagesDestination[indexPath.row]
  306. let imageWidthInPixels = image.size.width * image.scale
  307. let imageHeightInPixels = image.size.height * image.scale
  308. // 72 DPI
  309. if imageWidthInPixels > 595 || imageHeightInPixels > 842 {
  310. image = CCGraphics.scale(image, to: CGSize(width: 595, height: 842), isAspectRation: true)
  311. }
  312. cell.customImageView?.image = self.filter(image: image)
  313. cell.customLabel.text = NSLocalizedString("_scan_document_pdf_page_", comment: "") + " " + "\(indexPath.row+1)"
  314. cell.delete.addTarget(self, action: #selector(deleteDestination(_:)), for: .touchUpInside)
  315. cell.rotate.addTarget(self, action: #selector(rotateDestination(_:)), for: .touchUpInside)
  316. return cell
  317. }
  318. }
  319. @objc func deleteSource(_ sender: UIButton) {
  320. let buttonPosition:CGPoint = sender.convert(.zero, to: collectionViewSource)
  321. let indexPath:IndexPath = collectionViewSource.indexPathForItem(at: buttonPosition)!
  322. let fileNameAtPath = CCUtility.getDirectoryScan() + "/" + itemsSource[indexPath.row]
  323. CCUtility.removeFile(atPath: fileNameAtPath)
  324. itemsSource.remove(at: indexPath.row)
  325. collectionViewSource.reloadData()
  326. }
  327. @objc func deleteDestination(_ sender:UIButton) {
  328. let buttonPosition:CGPoint = sender.convert(.zero, to: collectionViewDestination)
  329. let indexPath:IndexPath = collectionViewDestination.indexPathForItem(at: buttonPosition)!
  330. imagesDestination.remove(at: indexPath.row)
  331. itemsDestination.remove(at: indexPath.row)
  332. collectionViewDestination.reloadData()
  333. // Save button
  334. if imagesDestination.count == 0 {
  335. save.isEnabled = false
  336. } else {
  337. save.isEnabled = true
  338. }
  339. }
  340. @objc func rotateDestination(_ sender:UIButton) {
  341. let buttonPosition:CGPoint = sender.convert(.zero, to: collectionViewDestination)
  342. let indexPath:IndexPath = collectionViewDestination.indexPathForItem(at: buttonPosition)!
  343. let image = imagesDestination[indexPath.row]
  344. imagesDestination[indexPath.row] = image.rotate(radians: .pi/2)!
  345. collectionViewDestination.reloadData()
  346. }
  347. }
  348. extension UIImage {
  349. func rotate(radians: Float) -> UIImage? {
  350. var newSize = CGRect(origin: CGPoint.zero, size: self.size).applying(CGAffineTransform(rotationAngle: CGFloat(radians))).size
  351. // Trim off the extremely small float value to prevent core graphics from rounding it up
  352. newSize.width = floor(newSize.width)
  353. newSize.height = floor(newSize.height)
  354. UIGraphicsBeginImageContextWithOptions(newSize, true, self.scale)
  355. let context = UIGraphicsGetCurrentContext()!
  356. // Move origin to middle
  357. context.translateBy(x: newSize.width/2, y: newSize.height/2)
  358. // Rotate around middle
  359. context.rotate(by: CGFloat(radians))
  360. // Draw the image at its center
  361. self.draw(in: CGRect(x: -self.size.width/2, y: -self.size.height/2, width: self.size.width, height: self.size.height))
  362. let newImage = UIGraphicsGetImageFromCurrentImageContext()
  363. UIGraphicsEndImageContext()
  364. return newImage
  365. }
  366. }
  367. // MARK: - UICollectionViewDragDelegate Methods
  368. extension DragDropViewController : UICollectionViewDragDelegate
  369. {
  370. func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
  371. if collectionView == collectionViewSource {
  372. let item = itemsSource[indexPath.row]
  373. let itemProvider = NSItemProvider(object: item as NSString)
  374. let dragItem = UIDragItem(itemProvider: itemProvider)
  375. dragItem.localObject = item
  376. return [dragItem]
  377. } else {
  378. let item = imagesDestination[indexPath.row]
  379. let itemProvider = NSItemProvider(object: item as UIImage)
  380. let dragItem = UIDragItem(itemProvider: itemProvider)
  381. dragItem.localObject = item
  382. return [dragItem]
  383. }
  384. }
  385. func collectionView(_ collectionView: UICollectionView, itemsForAddingTo session: UIDragSession, at indexPath: IndexPath, point: CGPoint) -> [UIDragItem] {
  386. if collectionView == collectionViewSource {
  387. let item = itemsSource[indexPath.row]
  388. let itemProvider = NSItemProvider(object: item as NSString)
  389. let dragItem = UIDragItem(itemProvider: itemProvider)
  390. dragItem.localObject = item
  391. return [dragItem]
  392. } else {
  393. let item = imagesDestination[indexPath.row]
  394. let itemProvider = NSItemProvider(object: item as UIImage)
  395. let dragItem = UIDragItem(itemProvider: itemProvider)
  396. dragItem.localObject = item
  397. return [dragItem]
  398. }
  399. }
  400. func collectionView(_ collectionView: UICollectionView, dragPreviewParametersForItemAt indexPath: IndexPath) -> UIDragPreviewParameters? {
  401. let previewParameters = UIDragPreviewParameters()
  402. if collectionView == collectionViewSource {
  403. previewParameters.visiblePath = UIBezierPath(rect: CGRect(x: 20, y: 20, width: 100, height: 100))
  404. } else {
  405. previewParameters.visiblePath = UIBezierPath(rect: CGRect(x: 20, y: 20, width: 80, height: 80))
  406. }
  407. return previewParameters
  408. }
  409. }
  410. // MARK: - UICollectionViewDropDelegate Methods
  411. extension DragDropViewController : UICollectionViewDropDelegate {
  412. func collectionView(_ collectionView: UICollectionView, canHandle session: UIDropSession) -> Bool {
  413. return true //session.canLoadObjects(ofClass: NSString.self)
  414. }
  415. func collectionView(_ collectionView: UICollectionView, dropSessionDidUpdate session: UIDropSession, withDestinationIndexPath destinationIndexPath: IndexPath?) -> UICollectionViewDropProposal {
  416. if collectionView == collectionViewSource {
  417. if collectionView.hasActiveDrag {
  418. return UICollectionViewDropProposal(operation: .move, intent: .insertAtDestinationIndexPath)
  419. } else {
  420. return UICollectionViewDropProposal(operation: .forbidden)
  421. }
  422. } else {
  423. if collectionView.hasActiveDrag {
  424. return UICollectionViewDropProposal(operation: .move, intent: .insertAtDestinationIndexPath)
  425. } else {
  426. return UICollectionViewDropProposal(operation: .copy, intent: .insertAtDestinationIndexPath)
  427. }
  428. }
  429. }
  430. func collectionView(_ collectionView: UICollectionView, performDropWith coordinator: UICollectionViewDropCoordinator) {
  431. let destinationIndexPath: IndexPath
  432. switch coordinator.proposal.operation {
  433. case .move:
  434. if let indexPath = coordinator.destinationIndexPath {
  435. destinationIndexPath = indexPath
  436. } else {
  437. // Get last index path of table view.
  438. let section = collectionView.numberOfSections - 1
  439. let row = collectionView.numberOfItems(inSection: section)
  440. destinationIndexPath = IndexPath(row: row, section: section)
  441. }
  442. self.reorderItems(coordinator: coordinator, destinationIndexPath: destinationIndexPath, collectionView: collectionView)
  443. break
  444. case .copy:
  445. // Get last index path of table view.
  446. let section = collectionView.numberOfSections - 1
  447. let row = collectionView.numberOfItems(inSection: section)
  448. destinationIndexPath = IndexPath(row: row, section: section)
  449. self.copyItems(coordinator: coordinator, destinationIndexPath: destinationIndexPath, collectionView: collectionView)
  450. break
  451. default:
  452. return
  453. }
  454. }
  455. func collectionView(_ collectionView: UICollectionView, dropSessionDidEnd session: UIDropSession) {
  456. collectionViewDestination.reloadData()
  457. // Save button
  458. if imagesDestination.count == 0 {
  459. save.isEnabled = false
  460. } else {
  461. save.isEnabled = true
  462. }
  463. }
  464. }