Marino Faggiana 8 жил өмнө
parent
commit
1fec4b4acd

+ 37 - 17
Picker/DocumentPickerViewController.swift

@@ -113,6 +113,26 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
         readFolder()
     }
     
+    // MARK: - Overridden Instance Methods
+    override func prepareForPresentation(in mode: UIDocumentPickerMode) {
+        
+        switch mode {
+        case .exportToService:
+            //Show confirmation button
+            print("Document Picker Mode : exportToService")
+        case .moveToService:
+            //Show confirmation button
+            print("Document Picker Mode : moveToService")
+        case .open:
+            //Show file list
+            print("Document Picker Mode : open")
+        case .import:
+            //Show file list
+            print("Document Picker Mode : import")
+        }
+    }
+
+    
     //  MARK: - Read folder
     
     func readFolder() {
@@ -240,30 +260,30 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
         
         switch selector {
             
-            case selectorLoadFileView :
+        case selectorLoadFileView :
                 
-                do {
-                    
-                    try FileManager.default.moveItem(atPath: "\(directoryUser!)/\(fileID!)", toPath: "\(directoryUser!)/\(metadata!.fileNamePrint!)")
+            do {
+                
+                try FileManager.default.moveItem(atPath: "\(directoryUser!)/\(fileID!)", toPath: "\(directoryUser!)/\(metadata!.fileNamePrint!)")
                     
-                } catch let error as NSError {
+            } catch let error as NSError {
         
-                    print(error)
-                }
-                
-                let url = URL(string: "file://\(directoryUser!)/\(metadata!.fileNamePrint!)".addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)!)
-                self.dismissGrantingAccess(to: url)
+                print(error)
+            }
                 
-                break
+            let url = URL(string: "file://\(directoryUser!)/\(metadata!.fileNamePrint!)".addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)!)
+            self.dismissGrantingAccess(to: url)
             
-            case selectorLoadPlist :
+        case selectorLoadPlist :
             
-                CCCoreData.downloadFilePlist(metadata, activeAccount: activeAccount, activeUrl: activeUrl, typeCloud: typeCloud, directoryUser: directoryUser)
-                tableView.reloadData()
+            CCCoreData.downloadFilePlist(metadata, activeAccount: activeAccount, activeUrl: activeUrl, typeCloud: typeCloud, directoryUser: directoryUser)
+            tableView.reloadData()
+            
+        default :
+            
+            print("selector : \(selector!)")
+            tableView.reloadData()
             
-            default :
-
-                break
         }
     }
  

+ 15 - 1
PickerFileProvider/FileProvider.swift

@@ -5,6 +5,21 @@
 //  Created by Marino Faggiana on 27/12/16.
 //  Copyright © 2016 TWS. All rights reserved.
 //
+//  Author Marino Faggiana <m.faggiana@twsweb.it>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
 
 import UIKit
 
@@ -62,7 +77,6 @@ class FileProvider: NSFileProviderExtension {
         completionHandler?(nil);
     }
     
-    
     override func itemChanged(at url: URL) {
         // Called at some point after the file has changed; the provider may then trigger an upload