CCCreateCloud.swift 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. //
  2. // CCCreateCloud.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 09/01/17.
  6. // Copyright © 2017 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  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 Foundation
  24. // MARK: - CreateMenuAdd
  25. class CreateMenuAdd: NSObject {
  26. let fontButton = [NSFontAttributeName:UIFont(name: "HelveticaNeue", size: 14)!, NSForegroundColorAttributeName:UIColor(colorLiteralRed: 65.0/255.0, green: 64.0/255.0, blue: 66.0/255.0, alpha: 1.0)]
  27. let fontEncrypted = [NSFontAttributeName:UIFont(name: "HelveticaNeue", size: 14)!, NSForegroundColorAttributeName:UIColor(colorLiteralRed: 241.0/255.0, green: 90.0/255.0, blue: 34.0/255.0, alpha: 1.0)]
  28. let fontCancel = [NSFontAttributeName:UIFont(name: "HelveticaNeue", size: 16)!, NSForegroundColorAttributeName:UIColor(colorLiteralRed: 0.0/255.0, green: 130.0/255.0, blue: 201.0/255.0, alpha: 1.0)]
  29. let fontDisable = [NSFontAttributeName:UIFont(name: "HelveticaNeue", size: 12)!, NSForegroundColorAttributeName:UIColor(colorLiteralRed: 65.0/255.0, green: 64.0/255.0, blue: 66.0/255.0, alpha: 1.0)]
  30. let colorLightGray = UIColor(colorLiteralRed: 250.0/255.0, green: 250.0/255.0, blue: 250.0/255.0, alpha: 1)
  31. func createMenuPlain(view : UIView) {
  32. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  33. let actionSheet = AHKActionSheet.init(view: view, title: nil)!
  34. actionSheet.animationDuration = 0.2
  35. actionSheet.automaticallyTintButtonImages = 0
  36. actionSheet.blurRadius = 0.0
  37. actionSheet.blurTintColor = UIColor(white: 0.0, alpha: 0.50)
  38. actionSheet.buttonHeight = 50.0
  39. actionSheet.cancelButtonHeight = 50.0
  40. actionSheet.separatorHeight = 5.0
  41. actionSheet.separatorColor = UIColor(colorLiteralRed: 153.0/255.0, green: 153.0/255.0, blue: 153.0/255.0, alpha: 0.2)
  42. actionSheet.buttonTextAttributes = fontButton
  43. actionSheet.encryptedButtonTextAttributes = fontEncrypted
  44. actionSheet.cancelButtonTextAttributes = fontCancel
  45. actionSheet.disableButtonTextAttributes = fontDisable
  46. actionSheet.cancelButtonTitle = NSLocalizedString("_cancel_", comment: "")
  47. actionSheet.addButton(withTitle: NSLocalizedString("_create_folder_", comment: ""), image: UIImage(named: "createFolderNextcloud"), backgroundColor: UIColor.white, height: 50.0 ,type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
  48. appDelegate.activeMain.returnCreate(Int(k_returnCreateFolderPlain))
  49. })
  50. actionSheet.addButton(withTitle: NSLocalizedString("_upload_photos_videos_", comment: ""), image: UIImage(named: "uploadPhotoNextcloud"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
  51. appDelegate.activeMain.returnCreate(Int(k_returnCreateFotoVideoPlain))
  52. })
  53. actionSheet.addButton(withTitle: NSLocalizedString("_upload_file_", comment: ""), image: UIImage(named: "uploadFileNextcloud"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
  54. appDelegate.activeMain.returnCreate(Int(k_returnCreateFilePlain))
  55. })
  56. if appDelegate.isCryptoCloudMode {
  57. actionSheet.addButton(withTitle: NSLocalizedString("_upload_encrypted_mode", comment: ""), image: UIImage(named: "actionSheetLock"), backgroundColor: colorLightGray, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  58. self.createMenuEncrypted(view: view)
  59. })
  60. }
  61. actionSheet.show()
  62. CCUtility.setCreateMenuEncrypted(false)
  63. }
  64. func createMenuEncrypted(view : UIView) {
  65. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  66. let actionSheet = AHKActionSheet.init(view: view, title: nil)!
  67. actionSheet.animationDuration = 0.2
  68. actionSheet.blurRadius = 0.0
  69. actionSheet.blurTintColor = UIColor(white: 0.0, alpha: 0.50)
  70. actionSheet.buttonHeight = 50.0
  71. actionSheet.cancelButtonHeight = 50.0
  72. actionSheet.separatorHeight = 5.0
  73. actionSheet.separatorColor = UIColor(colorLiteralRed: 153.0/255.0, green: 153.0/255.0, blue: 153.0/255.0, alpha: 0.2)
  74. actionSheet.buttonTextAttributes = fontButton
  75. actionSheet.encryptedButtonTextAttributes = fontEncrypted
  76. actionSheet.cancelButtonTextAttributes = fontCancel
  77. actionSheet.disableButtonTextAttributes = fontDisable
  78. actionSheet.cancelButtonTitle = NSLocalizedString("_cancel_", comment: "")
  79. actionSheet.addButton(withTitle: NSLocalizedString("_create_folder_", comment: ""), image: UIImage(named: "foldercrypto"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  80. appDelegate.activeMain.returnCreate(Int(k_returnCreateFolderEncrypted))
  81. })
  82. actionSheet.addButton(withTitle: NSLocalizedString("_upload_photos_videos_", comment: ""), image: UIImage(named: "photocrypto"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  83. appDelegate.activeMain.returnCreate(Int(k_returnCreateFotoVideoEncrypted))
  84. })
  85. actionSheet.addButton(withTitle: NSLocalizedString("_upload_file_", comment: ""), image: UIImage(named: "importCloudCrypto"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  86. appDelegate.activeMain.returnCreate(Int(k_returnCreateFileEncrypted))
  87. })
  88. actionSheet.addButton(withTitle: NSLocalizedString("_upload_template_", comment: ""), image: UIImage(named: "template"), backgroundColor: colorLightGray, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  89. self.createMenuTemplate(view: view)
  90. })
  91. actionSheet.addButton(withTitle: NSLocalizedString("_upload_plain_mode", comment: ""), image: UIImage(named: "uploadPlainModeNextcloud"), backgroundColor: colorLightGray, height: 50.0, type: AHKActionSheetButtonType.default, handler: {(AHKActionSheet) -> Void in
  92. self.createMenuPlain(view: view)
  93. })
  94. actionSheet.show()
  95. CCUtility.setCreateMenuEncrypted(true)
  96. }
  97. func createMenuTemplate(view : UIView) {
  98. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  99. let actionSheet = AHKActionSheet.init(view: view, title: nil)!
  100. actionSheet.animationDuration = 0.2
  101. actionSheet.blurRadius = 0.0
  102. actionSheet.blurTintColor = UIColor(white: 0.0, alpha: 0.50)
  103. actionSheet.buttonHeight = 50.0
  104. actionSheet.cancelButtonHeight = 50.0
  105. actionSheet.separatorHeight = 5.0
  106. actionSheet.separatorColor = UIColor(colorLiteralRed: 153.0/255.0, green: 153.0/255.0, blue: 153.0/255.0, alpha: 0.2)
  107. actionSheet.buttonTextAttributes = fontButton
  108. actionSheet.encryptedButtonTextAttributes = fontEncrypted
  109. actionSheet.cancelButtonTextAttributes = fontCancel
  110. actionSheet.disableButtonTextAttributes = fontDisable
  111. actionSheet.cancelButtonTitle = NSLocalizedString("_cancel_", comment: "")
  112. actionSheet.addButton(withTitle: NSLocalizedString("_add_notes_", comment: ""), image: UIImage(named: "note"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  113. appDelegate.activeMain.returnCreate(Int(k_returnNote))
  114. })
  115. actionSheet.addButton(withTitle: NSLocalizedString("_add_web_account_", comment: ""), image: UIImage(named: "baseurl"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  116. appDelegate.activeMain.returnCreate(Int(k_returnAccountWeb))
  117. })
  118. actionSheet.addButton(withTitle: "", image: nil, backgroundColor: UIColor(colorLiteralRed: 250.0/255.0, green: 250.0/255.0, blue: 250.0/255.0, alpha: 1), height: 10.0, type: AHKActionSheetButtonType.disabled, handler: {(AHKActionSheet) -> Void in
  119. print("disable")
  120. })
  121. actionSheet.addButton(withTitle: NSLocalizedString("_add_credit_card_", comment: ""), image: UIImage(named: "cartadicredito"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  122. appDelegate.activeMain.returnCreate(Int(k_returnCartaDiCredito))
  123. })
  124. actionSheet.addButton(withTitle: NSLocalizedString("_add_atm_", comment: ""), image: UIImage(named: "bancomat"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  125. appDelegate.activeMain.returnCreate(Int(k_returnBancomat))
  126. })
  127. actionSheet.addButton(withTitle: NSLocalizedString("_add_bank_account_", comment: ""), image: UIImage(named: "contocorrente"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  128. appDelegate.activeMain.returnCreate(Int(k_returnContoCorrente))
  129. })
  130. actionSheet.addButton(withTitle: "", image: nil, backgroundColor: UIColor(colorLiteralRed: 250.0/255.0, green: 250.0/255.0, blue: 250.0/255.0, alpha: 1), height: 10.0, type: AHKActionSheetButtonType.disabled, handler: {(AHKActionSheet) -> Void in
  131. print("disable")
  132. })
  133. actionSheet.addButton(withTitle: NSLocalizedString("_add_driving_license_", comment: ""), image: UIImage(named: "patenteguida"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  134. appDelegate.activeMain.returnCreate(Int(k_returnPatenteGuida))
  135. })
  136. actionSheet.addButton(withTitle: NSLocalizedString("_add_id_card_", comment: ""), image: UIImage(named: "cartaidentita"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  137. appDelegate.activeMain.returnCreate(Int(k_returnCartaIdentita))
  138. })
  139. actionSheet.addButton(withTitle: NSLocalizedString("_add_passport_", comment: ""), image: UIImage(named: "passaporto"), backgroundColor: UIColor.white, height: 50.0, type: AHKActionSheetButtonType.encrypted, handler: {(AHKActionSheet) -> Void in
  140. appDelegate.activeMain.returnCreate(Int(k_returnPassaporto))
  141. })
  142. actionSheet.show()
  143. }
  144. }
  145. // MARK: - CreateFormUploadAssets
  146. class CreateFormUploadAssets: XLFormViewController, CCMoveDelegate {
  147. var serverUrl : String = ""
  148. var titleServerUrl : String?
  149. var assets: NSMutableArray = []
  150. var cryptated : Bool = false
  151. var session : String = ""
  152. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  153. let sectionColor: UIColor = UIColor(colorLiteralRed: 239.0/255.0, green: 239.0/255.0, blue: 244.0/255.0, alpha: 1)
  154. convenience init(_ titleServerUrl : String?, serverUrl : String, assets : NSMutableArray, cryptated : Bool, session : String) {
  155. self.init()
  156. if titleServerUrl == nil || titleServerUrl?.isEmpty == true {
  157. self.titleServerUrl = "/"
  158. } else {
  159. self.titleServerUrl = titleServerUrl
  160. }
  161. self.serverUrl = serverUrl
  162. self.assets = assets
  163. self.cryptated = cryptated
  164. self.session = session
  165. self.initializeForm()
  166. }
  167. //MARK: XLFormDescriptorDelegate
  168. func initializeForm() {
  169. let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor
  170. form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow
  171. var section : XLFormSectionDescriptor
  172. var row : XLFormRowDescriptor
  173. // Section: Destination Folder
  174. section = XLFormSectionDescriptor.formSection()
  175. form.addFormSection(section)
  176. row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: self.titleServerUrl)
  177. row.cellConfig.setObject(UIImage(named: image_settingsManagePhotos)!, forKey: "imageView.image" as NSCopying)
  178. row.action.formSelector = #selector(changeDestinationFolder(_:))
  179. section.addFormRow(row)
  180. // Section: Folder Photo
  181. section = XLFormSectionDescriptor.formSection()
  182. form.addFormSection(section)
  183. row = XLFormRowDescriptor(tag: "useFolderPhoto", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_photo_camera_", comment: ""))
  184. row.value = 0
  185. section.addFormRow(row)
  186. row = XLFormRowDescriptor(tag: "useSubFolder", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_upload_camera_create_subfolder_", comment: ""))
  187. row.hidden = "$\("useFolderPhoto") == 0"
  188. if CCCoreData.getCameraUploadCreateSubfolderActiveAccount(appDelegate.activeAccount) == true {
  189. row.value = 1
  190. } else {
  191. row.value = 0
  192. }
  193. section.addFormRow(row)
  194. // Section: Rename File Name
  195. section = XLFormSectionDescriptor.formSection()
  196. form.addFormSection(section)
  197. row = XLFormRowDescriptor(tag: "maskFileName", rowType: XLFormRowDescriptorTypeAccount, title: NSLocalizedString("_filename_", comment: ""))
  198. let fileNameMask : String = CCUtility.getFileNameMask(k_keyFileNameMask)
  199. if fileNameMask.characters.count > 0 {
  200. row.value = fileNameMask
  201. }
  202. section.addFormRow(row)
  203. // Section: Preview File Name
  204. //section = XLFormSectionDescriptor.formSection()
  205. //form.addFormSection(section)
  206. row = XLFormRowDescriptor(tag: "previewFileName", rowType: XLFormRowDescriptorTypeTextView, title: "")
  207. row.height = 180
  208. row.cellConfig.setObject(sectionColor, forKey: "backgroundColor" as NSCopying)
  209. row.cellConfig.setObject(sectionColor, forKey: "textView.backgroundColor" as NSCopying)
  210. //row.cellConfig.setObject(10, forKey: "textView.layer.borderWidth" as NSCopying)
  211. row.disabled = true
  212. section.addFormRow(row)
  213. self.form = form
  214. }
  215. override func formRowDescriptorValueHasChanged(_ formRow: XLFormRowDescriptor!, oldValue: Any!, newValue: Any!) {
  216. super.formRowDescriptorValueHasChanged(formRow, oldValue: oldValue, newValue: newValue)
  217. if formRow.tag == "useFolderPhoto" {
  218. if (formRow.value! as AnyObject).boolValue == true {
  219. let buttonDestinationFolder : XLFormRowDescriptor = self.form.formRow(withTag: "ButtonDestinationFolder")!
  220. buttonDestinationFolder.hidden = true
  221. } else{
  222. let buttonDestinationFolder : XLFormRowDescriptor = self.form.formRow(withTag: "ButtonDestinationFolder")!
  223. buttonDestinationFolder.hidden = false
  224. }
  225. }
  226. else if formRow.tag == "useSubFolder" {
  227. if (formRow.value! as AnyObject).boolValue == true {
  228. } else{
  229. }
  230. }
  231. else if formRow.tag == "maskFileName" {
  232. let fileName : String? = formRow.value as? String
  233. self.form.delegate = nil
  234. if fileName != nil {
  235. formRow.value = CCUtility.removeForbiddenCharacters(fileName, hasServerForbiddenCharactersSupport: appDelegate.hasServerForbiddenCharactersSupport)
  236. }
  237. self.form.delegate = self
  238. let previewFileName : XLFormRowDescriptor = self.form.formRow(withTag: "previewFileName")!
  239. previewFileName.value = self.previewFileName(valueRename: formRow.value as? String)
  240. // reload cell
  241. if fileName != nil {
  242. if newValue as! String != formRow.value as! String {
  243. self.reloadFormRow(formRow)
  244. appDelegate.messageNotification("_info_", description: "_forbidden_characters_", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.info)
  245. }
  246. }
  247. self.reloadFormRow(previewFileName)
  248. }
  249. }
  250. // MARK: - View Life Cycle
  251. override func viewDidLoad() {
  252. super.viewDidLoad()
  253. let cancelButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: UIBarButtonItemStyle.plain, target: self, action: #selector(cancel))
  254. let saveButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_save_", comment: ""), style: UIBarButtonItemStyle.plain, target: self, action: #selector(save))
  255. self.navigationItem.leftBarButtonItem = cancelButton
  256. self.navigationItem.rightBarButtonItem = saveButton
  257. self.tableView.separatorStyle = UITableViewCellSeparatorStyle.none
  258. //self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
  259. self.reloadForm()
  260. }
  261. func reloadForm() {
  262. self.form.delegate = nil
  263. let buttonDestinationFolder : XLFormRowDescriptor = self.form.formRow(withTag: "ButtonDestinationFolder")!
  264. buttonDestinationFolder.title = self.titleServerUrl
  265. let maskFileName : XLFormRowDescriptor = self.form.formRow(withTag: "maskFileName")!
  266. let previewFileName : XLFormRowDescriptor = self.form.formRow(withTag: "previewFileName")!
  267. previewFileName.value = self.previewFileName(valueRename: maskFileName.value as? String)
  268. self.tableView.reloadData()
  269. self.form.delegate = self
  270. }
  271. //MARK: TableView
  272. override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
  273. switch section {
  274. case 0:
  275. let buttonDestinationFolder : XLFormRowDescriptor = self.form.formRow(withTag: "ButtonDestinationFolder")!
  276. if buttonDestinationFolder.isHidden() {
  277. return ""
  278. } else {
  279. return " " + NSLocalizedString("_destination_folder_", comment: "")
  280. }
  281. case 1:
  282. return " " + NSLocalizedString("_use_folder_photos_", comment: "")
  283. case 2:
  284. return " " + NSLocalizedString("_rename_filename_", comment: "")
  285. case 3:
  286. return NSLocalizedString("_preview_filename_", comment: "")
  287. default:
  288. return ""
  289. }
  290. }
  291. override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
  292. switch section {
  293. /*
  294. case 2:
  295. let buttonDestinationFolder : XLFormRowDescriptor = self.form.formRow(withTag: "maskFileName")!
  296. let text = self.writePreviewFileName(buttonDestinationFolder)
  297. return text
  298. */
  299. default:
  300. return ""
  301. }
  302. }
  303. // MARK: - Action
  304. func moveServerUrl(to serverUrlTo: String!, title: String!, selectedMetadatas: [Any]!) {
  305. self.serverUrl = serverUrlTo
  306. if title == nil {
  307. self.titleServerUrl = "/"
  308. } else {
  309. self.titleServerUrl = title
  310. }
  311. self.reloadForm()
  312. }
  313. func save() {
  314. self.dismiss(animated: true, completion: {
  315. let useFolderPhotoRow : XLFormRowDescriptor = self.form.formRow(withTag: "useFolderPhoto")!
  316. let useSubFolderRow : XLFormRowDescriptor = self.form.formRow(withTag: "useSubFolder")!
  317. var useSubFolder : Bool = false
  318. if (useFolderPhotoRow.value! as AnyObject).boolValue == true {
  319. self.serverUrl = CCCoreData.getCameraUploadFolderNamePathActiveAccount(self.appDelegate.activeAccount, activeUrl: self.appDelegate.activeUrl)
  320. useSubFolder = (useSubFolderRow.value! as AnyObject).boolValue
  321. }
  322. self.appDelegate.activeMain.uploadFileAsset(self.assets, serverUrl: self.serverUrl, cryptated: self.cryptated, useSubFolder: useSubFolder, session: self.session)
  323. })
  324. }
  325. func cancel() {
  326. self.dismiss(animated: true, completion: nil)
  327. }
  328. // MARK: - Utility
  329. func previewFileName(valueRename : String?) -> String {
  330. var returnString : String = ""
  331. if valueRename != nil {
  332. let valueRenameTrimming = valueRename!.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
  333. if valueRenameTrimming.characters.count > 0 {
  334. self.form.delegate = nil
  335. CCUtility.setFileNameMask(valueRenameTrimming, key: k_keyFileNameMask)
  336. self.form.delegate = self
  337. returnString = CCUtility.createFileName(from: assets[0] as! PHAsset, key: k_keyFileNameMask)
  338. } else {
  339. CCUtility.setFileNameMask("", key: k_keyFileNameMask)
  340. returnString = CCUtility.createFileName(from: assets[0] as! PHAsset, key: nil)
  341. }
  342. } else {
  343. CCUtility.setFileNameMask("", key: k_keyFileNameMask)
  344. returnString = CCUtility.createFileName(from: assets[0] as! PHAsset, key: nil)
  345. }
  346. return NSLocalizedString("_preview_filename_", comment: "") + ":" + "\n\n" + returnString
  347. }
  348. func changeDestinationFolder(_ sender: XLFormRowDescriptor) {
  349. self.deselectFormRow(sender)
  350. let storyboard : UIStoryboard = UIStoryboard(name: "CCMove", bundle: nil)
  351. let navigationController = storyboard.instantiateViewController(withIdentifier: "CCMove") as! UINavigationController
  352. let viewController : CCMove = navigationController.topViewController as! CCMove
  353. viewController.delegate = self;
  354. viewController.tintColor = UIColor.init(colorLiteralRed: 0.0/255.0, green: 130.0/255.0, blue: 201.0/255.0, alpha: 1.0) // COLOR_BRAND
  355. viewController.barTintColor = UIColor.init(colorLiteralRed: 248.0/255.0, green: 248.0/255.0, blue: 248.0/255.0, alpha: 1.0) // COLOR_BAR;
  356. viewController.tintColorTitle = UIColor.init(colorLiteralRed: 65.0/255.0, green: 64.0/255.0, blue: 66.0/255.0, alpha: 1.0) // COLOR_GRAY;
  357. viewController.move.title = NSLocalizedString("_select_", comment: "");
  358. viewController.networkingOperationQueue = appDelegate.netQueue
  359. navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
  360. self.present(navigationController, animated: true, completion: nil)
  361. }
  362. }