@@ -13,7 +13,7 @@ enum NCShareExtensionError: Error {
1313 case cancel, fileUpload, noAccount, noFiles, versionMismatch
1414}
1515
16- class NCShareExtension : UIViewController {
16+ class NCShareExtension : UIViewController , NCEmptyDataSetDelegate {
1717 @IBOutlet weak var collectionView : UICollectionView !
1818 @IBOutlet weak var tableView : UITableView !
1919 @IBOutlet weak var cancelButton : UIBarButtonItem !
@@ -43,9 +43,13 @@ class NCShareExtension: UIViewController {
4343 let heightCommandView : CGFloat = 170
4444 var autoUploadFileName = " "
4545 var autoUploadDirectory = " "
46+ let refreshControl = UIRefreshControl ( )
4647 var progress : CGFloat = 0
4748 var counterUploaded : Int = 0
49+ var uploadErrors : [ tableMetadata ] = [ ]
4850 var uploadMetadata : [ tableMetadata ] = [ ]
51+ var uploadStarted = false
52+ let hud = NCHud ( )
4953 let utilityFileSystem = NCUtilityFileSystem ( )
5054 let utility = NCUtility ( )
5155 let global = NCGlobal . shared
@@ -54,6 +58,20 @@ class NCShareExtension: UIViewController {
5458 var banner : LucidBanner ?
5559 var sceneIdentifier : String = UUID ( ) . uuidString
5660
61+ let database = NCManageDatabase . shared
62+ var account : String = " "
63+ var session : NCSession . Session {
64+ if !account. isEmpty,
65+ let tableAccount = self . database. getTableAccount ( account: account) {
66+ return NCSession . Session ( account: tableAccount. account, urlBase: tableAccount. urlBase, user: tableAccount. user, userId: tableAccount. userId)
67+ } else if let activeTableAccount = self . database. getActiveTableAccount ( ) {
68+ self . account = activeTableAccount. account
69+ return NCSession . Session ( account: activeTableAccount. account, urlBase: activeTableAccount. urlBase, user: activeTableAccount. user, userId: activeTableAccount. userId)
70+ } else {
71+ return NCSession . Session ( account: " " , urlBase: " " , user: " " , userId: " " )
72+ }
73+ }
74+
5775 // MARK: - View Life Cycle
5876
5977 override func viewDidLoad( ) {
@@ -96,6 +114,21 @@ class NCShareExtension: UIViewController {
96114
97115 nkLog ( start: " Start Share session " + versionNextcloudiOS)
98116
117+ // LOG
118+ let levelLog = NCKeychain ( ) . logLevel
119+ //
120+ // NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
121+ // NextcloudKit.shared.nkCommonInstance.pathLog = utilityFileSystem.directoryGroup
122+ // NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start Share session with level \(levelLog) " + versionNextcloudiOS)
123+ NKLogFileManager . shared. logLevel = NKLogLevel ( rawValue: levelLog) ?? . normal
124+ NKLogFileManager . shared. logDirectory = URL ( fileURLWithPath: utilityFileSystem. directoryGroup)
125+ NextcloudKit . shared. nkCommonInstance. writeLog ( " [INFO] Start Share session with level \( levelLog) " + versionNextcloudiOS)
126+
127+ // hud.indicatorView = JGProgressHUDRingIndicatorView()
128+ // if let indicatorView = hud.indicatorView as? JGProgressHUDRingIndicatorView {
129+ // indicatorView.ringWidth = 1.5
130+ // indicatorView.ringColor = NCBrandColor.shared.brandElement
131+ // }
99132 NCBrandColor . shared. createUserColors ( )
100133
101134 registerForTraitChanges ( [ UITraitUserInterfaceStyle . self] ) { ( self : Self, _) in
@@ -154,6 +187,8 @@ class NCShareExtension: UIViewController {
154187 }
155188 }
156189
190+ accountRequestChangeAccount ( account: account, controller: nil )
191+
157192 guard let inputItems = extensionContext? . inputItems as? [ NSExtensionItem ] else {
158193 cancel ( with: . noFiles)
159194 return
@@ -201,6 +236,21 @@ class NCShareExtension: UIViewController {
201236 tableView. visibleCells. forEach { $0. setNeedsLayout ( ) }
202237 }
203238
239+ // MARK: - Empty
240+
241+ func emptyDataSetView( _ view: NCEmptyView ) {
242+
243+ if self . dataSourceTask? . state == . running {
244+ view. emptyImage. image = UIImage ( named: " networkInProgress " ) ? . image ( color: . gray, size: UIScreen . main. bounds. width)
245+ view. emptyTitle. text = NSLocalizedString ( " _request_in_progress_ " , comment: " " )
246+ view. emptyDescription. text = " "
247+ } else {
248+ view. emptyImage. image = UIImage ( named: " folder_nmcloud " )
249+ view. emptyTitle. text = NSLocalizedString ( " _files_no_folders_ " , comment: " " )
250+ view. emptyDescription. text = " "
251+ }
252+ }
253+
204254 // MARK: -
205255
206256 func cancel( with error: NCShareExtensionError ? = nil ) {
@@ -517,6 +567,16 @@ extension NCShareExtension {
517567 }
518568}
519569
570+ extension NCShareExtension : uploadE2EEDelegate {
571+ func start( ) {
572+ self . hud. progress ( 0 )
573+ }
574+
575+ func uploadE2EEProgress( _ totalBytesExpected: Int64 , _ totalBytes: Int64 , _ fractionCompleted: Double ) {
576+ self . hud. progress ( fractionCompleted)
577+ }
578+ }
579+
520580extension NCShareExtension : NCPasscodeDelegate {
521581 func passcodeReset( _ passcodeViewController: TOPasscodeViewController ) {
522582 DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.1 ) {
0 commit comments